Skip to content

Instantly share code, notes, and snippets.

View asimihsan's full-sized avatar

Asim Ihsan asimihsan

View GitHub Profile
# file: /home/ubuntu/.aws_keys
export AWS_ACCESS_KEY_ID=XXXXXXXXX
export AWS_ACCOUNT_ID=1111111111
export AWS_SECRET_ACCESS_KEY=fFjerT235Fj
# subsequently modify /home/ubuntu/.bash_profile and "dot this in" by using:
# . /home/ubuntu/.aws_keys
@asimihsan
asimihsan / haproxyd
Created April 20, 2011 12:06
/etc/init.d/haproxyd
#!/usr/bin/env bash
# haproxyd
# Script to start|stop|restart haproxy from /etc/init.d/
# By Gubatron.
HAPROXY_CONFIG_PATH=/home/ubuntu/canvas/src/loadbalancer/haproxy.conf
HAPROXY_DAEMON=/usr/local/sbin/haproxy
test -x $HAPROXY_DAEMON || exit 0
@asimihsan
asimihsan / gist:938983
Created April 23, 2011 21:12
Erlang on AWS - part 3
We couldn’t find that file to show.
@asimihsan
asimihsan / google-reader-subscriptions.xml
Created May 13, 2011 08:59
Google Reader Subscriptions
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Asymptote subscriptions in Google Reader</title>
</head>
<body>
<outline text="24in60.com" title="24in60.com" type="rss"
xmlUrl="http://www.24in60.com/feed" htmlUrl="http://www.24in60.com"/>
<outline title="android" text="android">
<outline text="Android Developers Blog"
@asimihsan
asimihsan / .vimrc
Created January 9, 2012 10:53
My .vimrc (#1)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer: amix the lucky stiff
" http://amix.dk - amix@amix.dk
"
" Version: 3.6 - 25/08/10 14:40:30
"
" Blog_post:
" http://amix.dk/blog/post/19486#The-ultimate-vim-configuration-vimrc
" Syntax_highlighted:
" http://amix.dk/vim/vimrc.html
@asimihsan
asimihsan / gist:2266588
Created March 31, 2012 16:35
python retry decorator
import pymongo.errors
# Retry decorator with exponential backoff
def retry(tries=5, delay=0.1, backoff=2):
"""Retries a function or method until it returns True.
delay sets the initial delay in seconds, and backoff sets the factor by which
the delay should lengthen after each failure. backoff must be greater than 1,
or else it isn't really a backoff. tries must be at least 0, and delay
greater than 0.
@asimihsan
asimihsan / spark.patch
Created May 17, 2012 08:31
Disable Spark automatic scroll on activity
Index: src/java/org/jivesoftware/spark/ui/ChatArea.java
===================================================================
--- src/java/org/jivesoftware/spark/ui/ChatArea.java (revision 13060)
+++ src/java/org/jivesoftware/spark/ui/ChatArea.java (working copy)
@@ -298,7 +298,7 @@
final Document doc = getDocument();
styles.removeAttribute("link");
doc.insertString(doc.getLength(), text, styles);
- setCaretPosition(doc.getLength());
+ //setCaretPosition(doc.getLength());
@asimihsan
asimihsan / markdown_extras.py
Created July 5, 2012 09:04
markdown2 wrapper to get table of contents and pygments CSS
import os
import sys
import markdown2
from pygments.formatters import HtmlFormatter
def main():
# ------------------------------------------------------------------------
# Parse and validate inputs.
# ------------------------------------------------------------------------
input_filepath = sys.argv[1]
@asimihsan
asimihsan / bira-date.zsh-theme
Created March 30, 2013 15:38
ZSH "bira" theme with ISO 8601 date in prompt
# ~/.oh-my-zsh/themes/bira-date.zsh-theme
# ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
local rvm_ruby=''
if which rvm-prompt &> /dev/null; then
rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
@asimihsan
asimihsan / list_vs_dict.py
Last active December 15, 2015 14:49
Benchmarking the use of dictionaries vs. lists.
#!/usr/bin/env python
# Some example results on my machine:
# ─[2013-03-30 16:19:13] ai@Mill ~/Programming/python
# ╰─$ ./list_vs_dict.py
# build_list vs. build_dict: '-9.68'%
# access_list vs. access_dict: '-59.29'%
# ╭─[2013-03-30 16:20:10] ai@Mill ~/Programming/python
# ╰─$ ./list_vs_dict.py
# build_list vs. build_dict: '-18.42'%