Skip to content

Instantly share code, notes, and snippets.

View morenoh149's full-sized avatar
💭
Working from 🛰

Harry Moreno morenoh149

💭
Working from 🛰
View GitHub Profile
@unbracketed
unbracketed / gist:228457
Created November 7, 2009 01:45
Django virtualenv postactivate hook
#I usually drop something like this into my virtualenv's postactivate for some
#quick and handy shortcuts to common Django commands.
#This way dropping in to do some work on any arbitrary project is as easy as:
# 1. workon <project name>
# 2. djr
cd /path/to/site/root
#Django command shortcuts
alias dj='python manage.py'
@banksean
banksean / mersenne-twister.js
Created February 10, 2010 16:24
a Mersenne Twister implementation in javascript. Makes up for Math.random() not letting you specify a seed value.
/*
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
so it's better encapsulated. Now you can have multiple random number generators
and they won't stomp all over eachother's state.
If you want to use this as a substitute for Math.random(), use the random()
method like so:
var m = new MersenneTwister();
@rkumar
rkumar / itunes.sh
Created August 1, 2010 09:23
control iTunes from command line
#!/bin/bash
#
####################################
# iTunes Command Line Control v1.0
# written by David Schlosnagle
# created 2001.11.08
# edit 2010.06.01 rahul kumar
####################################
showHelp () {
@jimeh
jimeh / com.rabbitmq.rabbitmq-server.plist
Created March 24, 2011 10:47
Mac OS X launchctl plist for Homebrew-based RabbitMQ installations. Place in: ~/Library/LaunchAgents
<?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>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.rabbitmq.rabbitmq-server</string>
<key>Program</key>
<string>/usr/local/sbin/rabbitmq-server</string>
@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@amoilanen
amoilanen / string_search.js
Created August 2, 2011 19:13
Rabin-Karp Algorithm for Searching Strings Implemented in JavaScript
function simpleSearch(text, str) {
var matches = [];
for (var i = 0; i <= text.length; i++) {
if (matchesAtIndex(i, text, str)) {
matches.push(i);
}
}
return matches;
}
@jboner
jboner / latency.txt
Last active April 26, 2024 03:40
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@cjolly
cjolly / pg.sh
Last active July 25, 2022 20:16
Use homebrew to upgrade to postgres on OSX
newpg=9.6.1 # set to new PG version number
oldpg=`pg_config --version | cut -d' ' -f2`
# PG 96. upgrades the readline to v7, which breaks anything linked against readline v6, like ruby via ruby-build.
# I *think* this should prevent it from installing v7. But if weird shit happens with various rubies,
# you'll have to reinstall them.
brew pin readline
# Stop current Postgres server
brew services stop postgresql
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 25, 2024 06:23
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@terryjray
terryjray / gist:3296171
Created August 8, 2012 15:55
Enabling hstore for new postgresql 9.1 and rails 3 install on ubuntu 12.04
RAILS_ENV=production rake db:setup
# produces the error below.....hmmm.....it's a no-worky
psql:/yourprojectpath/yourproject/db/structure.sql:29: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory
# hstore postgresql extension needs to be installed, so....
sudo apt-get install postgresql-contrib
# now your extension should be available to enable so log in with psql
psql -d yourproject_production -U yourdbuser -W