Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import time
import json
import urllib
import re
def lambda_handler(event, context):
lastHourDateTime = int(time.time()) - 3600
@canburak
canburak / com.agendaless.supervisord.plist
Last active August 29, 2015 14:02
Daemons for a developer on Mac OS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- Do not restart when you intentinally shutdown supervisord -->
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>

Keybase proof

I hereby claim:

  • I am canburak on github.
  • I am canburak (https://keybase.io/canburak) on keybase.
  • I have a public key whose fingerprint is F7F8 9AC8 1CCB C7C1 7A54 38F5 E1F2 0A23 12D2 2CBE

To claim this, I am signing this object:

#!/bin/bash
#set -vx
SOURCE="...@s....gridserver.com:/home/.../"
# Where all the history of files are stored
DESTINATION_PARENT="/.../mediatemple/"
# Where will be the latest backup will be stored, relative to
# DESTINATION_PARENT. Note that ISO-8601 is used for the ability to remove old
@canburak
canburak / toIpad.sh
Created January 20, 2014 09:43
I use this to move videos to iTunes. The staps are: (1) Get the video (2) Add the subtitle to the folder (optional) (3) Run the script below, path to the video as first parameter (If there is a subtitle, it adds it to the resulting file.) (3) use http://identify2.arrmihardies.com/ to add metadata to the video. Get the tool from http://handbrake.…
#!/bin/bash
#set -vx
outputdir="/Users/can/Desktop/iPad/"
input="$1"
mkdir "${outputdir}" 2> /dev/null || true
basename="$(basename "${input}")"
dirname="$(dirname "${input}")"
noext="${basename%.*}"
def merge_lists(l1, l2):
# If any of the lists are epty, return the other list
if not l1: return l2
if not l2: return l1
if l1[0] <= l2[0]:
# Prepend the smaller item to the merged version of the rest
return [l1[0]] + merge_lists(l1[1:], l2)
else:
return merge_lists(l2, l1)
@canburak
canburak / tg.py
Created May 7, 2013 11:03
Background mask with opencv
import cv2
bgs = cv2.BackgroundSubtractorMOG(99, 1, 0.5, 99)
capture = cv2.VideoCapture("VIDEO_2013-04-13_14-59-22.avi")
#cv2.namedWindow("input")
a = 0
while(True):
f, img = capture.read()
@canburak
canburak / ga.py
Last active February 13, 2021 23:26
blog post: Push data to Google Analytics with Python: https://medium.com/p/pushing-data-to-google-analytics-with-python-80eb9691d61f
"""
Simple proof of concept code to push data to Google Analytics.
Related blog post:
* https://medium.com/python-programming-language/80eb9691d61f
"""
from random import randint
from urllib import urlencode
from urllib2 import urlopen
from urlparse import urlunparse
@canburak
canburak / middleware.py
Created January 8, 2012 13:23
blog post: Automatically decorating all views of a django project
def process_view(self, request, view_func, view_args, view_kwargs):
if not hasattr(settings, "VIEW_AUTHENTICATORS"): return None
mauths = settings.VIEW_AUTHENTICATORS.keys()
module = view_func.__module__
# Trying to find if any authenticator is defined for this module
module_matches = [mauth for mauth in mauths if module.startswith(mauth)]
# if there is no match, bail out
if not module_matches: return None