Skip to content

Instantly share code, notes, and snippets.

View artursapek's full-sized avatar

Artur Sapek artursapek

View GitHub Profile
func (daemon *Daemon) Run() {
defer func() {
if r:= recover(); r != nil {
fmt.Printf("RECOVER daemon=%s\n", daemon.Slug)
fmt.Println(r)
statsd.Increment(fmt.Sprintf("daemon.recover.%s", daemon.Slug))
}
// Schedule next run
time.Sleep(daemon.UpdateFrequency) // (2 seconds)
go daemon.Run()
@artursapek
artursapek / deps.sh
Last active August 29, 2015 14:00
Convert .mov files to GIFs easily
brew install ffmpeg
brew install imagemagick
brew install libtool --universal
brew link libtool
function gbr {
echo `git name-rev --name-only HEAD`
}
# when on master:
# > gbr
# master
function dp {
bundle exec cap -s revision=`gbr` $1 deploy
@artursapek
artursapek / mov2gif
Last active August 29, 2015 14:17
mov2gif
#!/bin/bash
# mov2giv in out width
# mov2gif video_file_in.mov gif_file_out.gif 300
tmp_dir=/tmp/frames_$(date +%s)
mkdir $tmp_dir
if [ -z "$3" ]
then
size=600
git log --pretty="format:%an ~ %s" | grep "shit\|fuck\|asshole\|damn" | cut -d "~" -f 1 | sort | uniq -c | sort -n -r
@artursapek
artursapek / keybase.md
Last active August 29, 2015 14:25
keybase.md

Keybase proof

I hereby claim:

  • I am artursapek on github.
  • I am artur (https://keybase.io/artur) on keybase.
  • I have a public key whose fingerprint is 1948 D3DF 273B 51B3 A2B3 3745 2E63 8758 C05F 376F

To claim this, I am signing this object:

@artursapek
artursapek / scrape_comet.py
Created October 17, 2011 06:12
comet_scrape
from BeautifulSoup import BeautifulSoup
from mechanize import Browser
def CometScrape(date):
br = Browser()
entry = None
br.open('http://www.comettavern.com/shows.php')
br.select_form(nr=0)
form = br.form
month = ['January', 'Feburary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][int(date[0:2]) - 1]
@artursapek
artursapek / gist:1708801
Created January 31, 2012 04:25
earliestTime(x)
def earliestTime(x):
conv = {}
for t in x:
a, b = t[:t.find('m')-1].split(':') if ':' in t else (t[:t.find('m')-1], 0)
conv[(int(a) * 60) + int(b) - (720 if 'am' in t else 0)] = t
return conv[min(conv.keys())].strip()
@artursapek
artursapek / looseSearch.py
Created February 17, 2012 23:17
A tolerant search function
import re
class finder():
# I got these dicts from someone on Stackoverflow. They translate common letters to visually similar unicode keys.
# This will let us match an N with a tilde to a regular N, for example
global unicode_to_text_Matches
unicode_to_text_Matches = { 161: '!', 192: 'A', 193: 'A', 194: 'A', 195: 'A', 196: 'A', 197: 'A', 198: 'Ae', 199: 'C', 200: 'E', 201: 'E', 202: 'E', 203: 'E', 204: 'I', 205: 'I',
206: 'I', 207: 'I', 208: 'Th', 209: 'N', 210: 'O', 211: 'O', 212: 'O', 213: 'O', 214: 'O', 216: 'O', 217: 'U', 218: 'U', 219: 'U', 220: 'U', 221: 'Y', 222: 'th', 223: 'ss', 224: 'a',
225: 'a', 226: 'a', 227: 'a', 228: 'a', 229: 'a', 230: 'ae', 231: 'c', 232: 'e', 233: 'e', 234: 'e', 235: 'e', 236: 'i', 237: 'i', 238: 'i', 239: 'i', 240: 'th', 241: 'n', 242: 'o',
@artursapek
artursapek / vmarker.js
Created February 22, 2012 20:03
this is an object library I wrote that creates interactive markers that represent venues on a map
// bandscape vmarker library written by Artur Sapek
// puts a venue's custom marker on the map and makes it interact with the Hub
vmarker = function(args){
for (var a in args){
this[a] = args[a];
}
this.draw(this.x, this.y, this.name);
}
vmarker.prototype.draw = function(x, y, name){