Skip to content

Instantly share code, notes, and snippets.

@atiw003
atiw003 / virtualenv-auto-activate.sh
Created April 23, 2012 10:40 — forked from robbles/virtualenv-auto-activate.sh
virtualenv-auto-activate with support for zsh and virtualenvwrapper
#!/bin/bash
# virtualenv-auto-activate.sh
#
# Installation:
# Add this line to your .bashrc or .bash-profile:
#
# source /path/to/virtualenv-auto-activate.sh
#
# Go to your project folder, run "virtualenv .venv", so your project folder
# has a .venv folder at the top level, next to your version control directory.
@atiw003
atiw003 / tree.md
Created April 24, 2012 10:56 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@atiw003
atiw003 / forticlientsslvpn
Created April 25, 2012 07:18
For forticlientsslvpn
abhi@Laptop:~/forticlientsslvpn$ ls -l
total 2392
-rwxr-xr-x 1 abhi abhi 2442292 2009-03-10 09:35 forticlientsslvpn
drwxr-xr-x 2 abhi abhi 4096 2012-04-25 16:57 helper
abhi@Laptop:~/forticlientsslvpn$ cd helper/
abhi@Laptop:~/forticlientsslvpn/helper$ ls -l
total 2140
-rwxr-xr-x 1 abhi abhi 902 2009-03-10 09:35 cleanup.linux.sh
-rw-r--r-- 1 abhi abhi 11 2009-03-10 09:35 config
@atiw003
atiw003 / wordpress_importer.rb
Created May 20, 2012 06:59 — forked from Oneiroi/wordpress_importer.rb
Import a WordPress database and generate markdown files for Jekyll
# based on the import script by icebreaker, which is based on mojombo's
# https://github.com/mojombo/jekyll/blob/master/lib/jekyll/migrators/wordpress.rb
# https://gist.github.com/303570
# edited to rewrite image URLs to use my CloudFront URL
require 'rubygems'
require 'sequel'
require 'fileutils'
require 'yaml'
@atiw003
atiw003 / wp-xml-octopress-import.rb
Created May 20, 2012 07:04 — forked from tnmt/wp-xml-octopress-import.rb
Import XML of Wordpress to Octopress
# -*- coding: utf-8 -*-
require 'fileutils'
require 'date'
require 'yaml'
require 'uri'
require 'rexml/document'
include REXML
doc = Document.new File.new(ARGV[0])
@atiw003
atiw003 / deps.pp
Created May 20, 2012 13:39 — forked from rcrowley/deps.pp
Deploying Django with Puppet
stage { "pre": before => Stage["main"] }
class python {
package {
"build-essential": ensure => latest;
"python": ensure => "2.6.6-2ubuntu1";
"python-dev": ensure => "2.6.6-2ubuntu1";
"python-setuptools": ensure => "latest";
}
exec { "easy_install pip":
path => "/usr/local/bin:/usr/bin:/bin",
@atiw003
atiw003 / ses_test.py
Created May 24, 2012 09:48 — forked from batok/ses_test.py
A test of ses "AWS" service from python using boot
"""
do ...
pip install boto, turbomail
echo "just a test" > README.txt
... first
"""
import sys
from boto import connect_ses
FROM = "[email protected]"
TO = "[email protected]"
@atiw003
atiw003 / postfix-config-aws-ses.txt
Created May 29, 2012 10:48 — forked from zapnap/postfix-config-aws-ses.txt
postfix config for AWS-SES
# /etc/postfix/main.cf
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
@atiw003
atiw003 / latency.txt
Created June 1, 2012 08:18 — forked from jboner/latency.txt
Latency numbers every programmer should know
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
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 1 MB sequentially from memory 250,000 ns 0.25 ms
Round trip within same datacenter 500,000 ns 0.5 ms
Read 1 MB sequentially from SSD 1,000,000 ns 1 ms 4X memory
@atiw003
atiw003 / yaml_ordered_dict.py
Created June 9, 2012 09:46 — forked from enaeseth/yaml_ordered_dict.py
Load YAML mappings as ordered dictionaries
import yaml
import yaml.constructor
try:
# included in standard lib from Python 2.7
from collections import OrderedDict
except ImportError:
# try importing the backported drop-in replacement
# it's available on PyPI
from ordereddict import OrderedDict