Skip to content

Instantly share code, notes, and snippets.

@apackeer
apackeer / gist:3796932
Created September 27, 2012 22:52 — forked from kennethreitz/gist:3788842
Top 20 Downloaded Projects on PyPI
Top 20 Downloaded Projects on PyPI
==================================
#1 lxml ........ 4890886 downloads
#2 setuptools .. 4243069 downloads
#3 distribute .. 3880163 downloads
#4 zc.buildout . 3090694 downloads
#5 pip ......... 2695166 downloads
#6 boto ........ 2463436 downloads
#7 simplejson .. 2364527 downloads
@apackeer
apackeer / gist:3796936
Created September 27, 2012 22:52
xmltodict
#!/usr/bin/env python
import xml.parsers.expat
class ParsingInterrupted(Exception): pass
class DictSAXHandler:
def __init__(self,
item_depth=0,
xml_attribs=True,
item_callback=lambda *args: True,
@apackeer
apackeer / gist:3806095
Created September 30, 2012 06:56
Flatten a list
def flatten(list_):
nested = True
while nested:
iter_ = False
temp = []
for element in list_:
if isinstance(element, list):
temp.extend(element)
iter_ = True
else:
@apackeer
apackeer / gist:3806099
Created September 30, 2012 06:57
Remove Duplicates from an array
def remDuplicates(arr):
returnme = []
for i in arr:
if not i in returnme:
returnme.append(i)
return returnme
# Example:
# remDuplicates(["test", "test1", "test2", "test", "test2"]) -> ["test", "test1", "test2"]
@apackeer
apackeer / gist:3806106
Created September 30, 2012 06:59
paramiko example
from paramiko import SSHClient
client = SSHClient()
client.load_system_host_keys()
client.connect('192.168.137.101', username='admin', password='admin')
stdin, stdout, stderr = client.exec_command('list')
for line in stdout:
print '... ' + line.strip('\n')
@apackeer
apackeer / zsh.md
Created October 1, 2012 07:08 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu

Getting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh

and then you change your shell to zsh

chsh -s `which zsh`

and then restart

@apackeer
apackeer / osx_lion_rail_setup.md
Created October 2, 2012 20:14 — forked from jpantuso/osx_lion_rail_setup.md
Setup OS X 10.7 w/ homebrew, oh-my-zsh, rvm, rails, and MySQL

Setup new Mac with OSX Mountain Lion from scratch

First things first, run a software update...

Install xcode 4

App store http://itunes.apple.com/us/app/xcode/id448457090?mt=12) The download/install takes awhile so start it first. When it finishes downloading you will still need to run it to complete installation.

Install Command Line Tools for Xcode

Downloads for Apple Developers

@apackeer
apackeer / gist:3825451
Created October 3, 2012 06:49
Convert CIDR mask to dotted decimal
from socket import inet_ntoa
from struct import pack
bits = 0
mask = 25
for i in xrange(32 - mask,32):
bits |= (1 << i)
dotted_decimal = inet_ntoa(pack('>I', bits))
@apackeer
apackeer / README.md
Created October 16, 2012 20:57 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@apackeer
apackeer / gist:3922942
Created October 20, 2012 10:42
Devstack Install
Had problems with stack.sh stuffing up with pip.
so my full install sequence is now....
install Ubuntu 11.10 server
sudo apt-get update
sudo apt-get dist-upgrade
sudo init 6
sudo apt-get install git
git clone git://github.com/cloudbuilders/devstack.git