Skip to content

Instantly share code, notes, and snippets.

View calston's full-sized avatar

Colin Alston calston

View GitHub Profile
colin@cas1:~$ curl -v https://www.fnb.co.za
* About to connect() to www.fnb.co.za port 443 (#0)
* Trying 196.11.125.149... Connection timed out
def thingsAndStuff():
# Do many things
pass
reactor.callWhenRunning(thingsAndStuff)
reactor.run()
@calston
calston / gist:9320470
Created March 3, 2014 08:06
Riak S3 backup
#!/bin/bash
bucket="ChangeMe"
if [ -e "/usr/bin/s3cmd" ]; then
s3cmd="/usr/bin/s3cmd"
else
s3cmd="/usr/local/bin/s3cmd"
fi
>>> w = lambda i: base64.b64encode(struct.pack('<d', i).strip('\x00')).strip('=')
>>> [w(i) for i in range(10)]
['', '8D8', 'QA', 'CEA', 'EEA', 'FEA', 'GEA', 'HEA', 'IEA', 'IkA']
>>> [w(i) for i in range(1000,1010)]
['QI9A', 'SI9A', 'UI9A', 'WI9A', 'YI9A', 'aI9A', 'cI9A', 'eI9A', 'gI9A', 'iI9A']
@calston
calston / gist:8710552
Created January 30, 2014 15:07
Send an email
#!/usr/bin/python
import sys, os, time
import smtplib
from email.MIMEText import MIMEText
from email.MIMEMultipart import MIMEMultipart
from email.MIMEImage import MIMEImage
C:\Users\colin>python
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> open('//cas1/colin/.screenrc').read()
'vbell off\ntermcapinfo xterm|xterms|xs|rxvt ti@:te@\n\ntermcap facit|vt100|xterm LP:G0\nterminfo facit|vt100|xterm LP:G0\n\nhardstatus alwayslastline "%{b kw}%H %{r}%1` %{w}| %{y}%d.%m.%Y %{w}| %{-b kw}%u %-Lw%{= rW}%50> %n%f %t %{-}%+Lw%<"\n'
>>> a = bucket.new('a', data={'a':1})
>>> b = bucket.new('a', data={'b':1})
>>> a.store()
<riak.riak_object.RiakObject object at 0x155c3d0>
>>> b.store()
<riak.riak_object.RiakObject object at 0x155c8d0>
>>> bucket.get('a').data
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/colin/semita/frontend/ve/local/lib/python2.7/site-packages/riak/riak_object.py", line 45, in _getter
root@kraken:/# pip install --upgrade pip
Downloading/unpacking pip
Downloading pip-1.5.tar.gz (898Kb): 898Kb downloaded
Running setup.py egg_info for package pip
warning: no files found matching 'pip/cacert.pem'
warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.rst' found under directory 'docs/_build'
no previously-included directories found matching 'docs/_build/_sources'
Installing collected packages: pip
# stats: dump at 1387274503
stats: users 0 21
stats: session 0 0 0 9197.701904296875 43.4970703125 1162.7733880202904 1199
stats: users_count 0 1199
stats: finish_users_count 0 1199
stats: request 0 0 0 524.969970703125 4.169921875 64.43933685786332 2398
stats: page 0 0 0 524.969970703125 4.169921875 64.43933685786332 2398
stats: connect 0 0 0 490.672119140625 1.74609375 67.35115139080743 1199
stats: 302 0 1199
stats: 200 0 1199
MultipleObjectsReturned: get() returned more than one GeneralPreferences -- it returned 2! Lookup parameters were {}
ERROR 2013-12-09 14:59:28,156 base 18128 140388145288960 Internal Server Error: /logo/
Traceback (most recent call last):
File "/var/praekelt/eggs/Django-1.4.1-py2.7.egg/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/var/praekelt/eggs/Django-1.4.1-py2.7.egg/django/views/generic/simple.py", line 26, in direct_to_template
c = RequestContext(request, dictionary)
File "/var/praekelt/eggs/Django-1.4.1-py2.7.egg/django/template/context.py", line 176, in __init__
self.update(processor(request))
File "/var/praekelt/eggs/jmbo_foundry-1.1.21-py2.7.egg/foundry/context_processors.py", line 13, in foundry