Skip to content

Instantly share code, notes, and snippets.

View kachok's full-sized avatar

Dmitry Kachaev kachok

View GitHub Profile
@kachok
kachok / listing.py
Created July 29, 2011 17:11
Quick and dirty way to get 1.usa.gov click archive
import urllib
import re
import time
data = urllib.urlopen('http://bitly.measuredvoice.com/bitly_archive/?C=M;O=D').read()
#print data
#datafiles name pattern - usagov_bitly_data2011-07-29-1311919454
@kachok
kachok / gist:1376975
Created November 18, 2011 16:35 — forked from defnull/gist:1224387
Deploy a Bottle app on Heroku
mkdir heroku
cd heroku/
virtualenv --no-site-packages env
source env/bin/activate
pip install bottle gevent
pip freeze > requirements.txt
cat >app.py <<EOF
import bottle
import os
@kachok
kachok / gist:1674638
Created January 25, 2012 04:03
Stats on bikes "hidden" moves in CaBi data
# "hidden" move - bike move started in bike station, different from the one where bike was actually left in previous trip
# 0 ['Duration', 'Start date', 'End date', 'Start station', 'End station', 'Bike#', 'Member Type']
# 1 ['0h 7min. 48sec.', '12/31/2011 23:55', '1/1/2012 0:03', '18th & M St NW (31221)', '10th & U St NW (31111)', 'W01319', 'Registered']
f=open ("2011-1st-quarter.csv")
tracking={}
member_types={}
total=0
@kachok
kachok / turk.js
Created March 20, 2012 20:08 — forked from longouyang/turk.js
Small helper file for doing external HITs on Mechanical Turk
var turk = {};
(function() {
var param = function(url, name ) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( url );
return ( results == null ) ? "" : results[1];
}
@kachok
kachok / survey.html
Created March 21, 2012 01:15
HTML+JS for embedding Language Survey into MTurk questions
<!--
HTML+JS for embedding Language Survey into MTurk questions
Licensed under MIT/CC BY-SA 3.0 license
Use: replace FOREIGN with the name of foreign language
Requires JQuery library loaded in HEAD:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
@kachok
kachok / gitignore.py
Created April 14, 2012 16:00
python .gitignore
*.pyc
.project
.pydevproject
.settings/
build/
ISC License (ISC)
Copyright (c) 4-digit year, Company or Person's Name
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
The MIT License (MIT)
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION W
@kachok
kachok / tweets_es_pickleit.py
Created May 29, 2012 15:55
pickling of words from spanish tweets
import codecs
import pickle
file = "/Users/dkachaev/repos/hltcoe/tweets-es/data/oov.vocab"
out = codecs.open(file, "r", "utf-8")
vocab={}
@kachok
kachok / gist:3396898
Created August 19, 2012 18:22
Dictionaries dump
create table dictionary_dump_20120504 as
select l.prefix, v.id, v.word, vhr.translation, a.worker_id, p.quality, p.total
from voc_hits_results vhr, languages l, vocabulary v, assignments a, voc_hits_workers_performance p
where
a.id=vhr.assignment_id and
p.id=a.worker_id and p.language_id=l.id and
vhr.is_control=1 and vhr.quality=1
and v.id=vhr.word_id
and v.language_id=l.id