#!/bin/bash -e
function usage {
cat <<EOM
Usage: $(basename "$0") [OPTION]...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# requirement: python-mysqldb | |
import MySQLdb as dbapi | |
import sys | |
import csv | |
QUERY = 'SELECT * FROM mydb.people;' | |
db = dbapi.connect(host='localhost', user='root', passwd='password', db='dbname') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# steps taken verbatim from: | |
# http://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html#install_docker | |
# | |
sudo yum update -y | |
sudo yum install -y docker | |
sudo service docker start | |
sudo usermod -a -G docker ec2-user | |
# log out and log in to pickup the added group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib2 import urlopen | |
code = urlopen("http://example.com/").code | |
if (code / 100 >= 4): | |
print "Nothing there." | |
# via http://stackoverflow.com/questions/1966086/how-can-i-determine-if-anything-at-the-given-url-does-exist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def sigmoid(x): | |
return 1.0 / (1 + np.exp(-float(x))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def tuple_to_dict(t): | |
return dict([t]) | |
def get_first(d): | |
t = sorted(d.items())[0] | |
return tuple_to_dic(t) | |
def combine_to_dict(keys, values): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
best simi is: 0.97 | |
**** other image compare to base_center_vector **** | |
[('610703da-0eeb-42f7-99a8-f01634379847.jpg', 0.95584446), | |
('7156d573-8db5-4ab4-ab0f-cf9cb1d9aaba.jpg', 0.9364199), | |
('1b0f9271-d199-4585-99f6-b474856f94fa.jpg', 0.74257964), | |
('28c1dd5e-65ac-4b8b-887e-0ade5492da22.jpg', 0.71596545), | |
('3a53ad92-3f77-47cc-926f-3f8af1537c0d.jpg', 0.6548833), | |
('3a1c4638-762a-4ae4-b00c-dc5c71b9eb89.jpg', 0.6441053), | |
('2ea2b9a8-2fbd-495b-95d0-26781efd059a.jpg', 0.63781774), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 20131214 | |
# switch to the relevant keg directory | |
cd /usr/local/Library/Taps/homebrew-science | |
brew versions opencv | |
# look for the version you want, eg: | |
# 2.4.5 git checkout ae74fe9 opencv.rb | |
# checkout the version you want | |
git checkout ae74fe9 opencv.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/tasks/db.rake | |
namespace :db do | |
desc "Dumps the database to db/APP_NAME.dump" | |
task :dump => :environment do | |
cmd = nil | |
with_config do |app, host, db, user| | |
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
end | |
puts cmd |