Skip to content

Instantly share code, notes, and snippets.

View kirang89's full-sized avatar

Kiran Gangadharan kirang89

View GitHub Profile
nosetests --with-profile --profile-stats-file=nose.prof
python -c "import hotshot.stats ; stats = hotshot.stats.load('nose.prof') ; stats.sort_stats('time', 'calls') ; stats.print_stats(20)"
#
# String.hashCode in Python
#
def java_string_hashcode(s):
h=0
for c in s:
h = (31 * h + ord(c)) & 0xFFFFFFFF
return (h + 0x80000000) & 0xFFFFFFFF - 0x80000000

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@kirang89
kirang89 / xcode.gitignore
Created August 26, 2014 06:42
Gitignore for iOS projects
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
@kirang89
kirang89 / something.py
Last active November 11, 2022 05:10
Creating a mutable ARRAY data type in sqlalchemy
class Something(Base):
__tablename__ = 'yaddayadda'
id = Column(Integer, primary_key=True)
data = Column(MutableList.as_mutable(ARRAY(String(100))))
@kirang89
kirang89 / s3upload.py
Created July 28, 2014 14:55
Uploading a file to Amazon S3 using boto
import cStringIO
from boto.s3.connection import S3Connection
from boto.s3.key import Key
def s3upload(filename, extension, file):
conn = S3Connection('AWS_ACCESS_KEY', 'AWS_SECRET_KEY')
k = Key(conn.get_bucket('<bucket name>'))
k.key = filename
k.set_metadata("Content-Type", file.mimetype)

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@kirang89
kirang89 / white_noise.sh
Created July 19, 2014 17:46
Generating white noise from Terminal in OSX
brew install sox
cat /dev/urandom | sox -traw -r44100 -b16 -e unsigned-integer - -tcoreaudio
@kirang89
kirang89 / openssl_on_osx.md
Created July 15, 2014 11:54
Installing openssl on OSX using Homebrew

First execute the following commands to install openssl on OSX using Homebrew:

brew update
brew install openssl
brew link --force openssl
openssl version -a

If the new version has not been applied successfully, create a symlink to solve the problem. To do that, we need to figure out the location of openssl using