Skip to content

Instantly share code, notes, and snippets.

View hamsolodev's full-sized avatar

hamsolo.dev hamsolodev

View GitHub Profile
Python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.exit()
$
Jan 16 12:05:06 beardy upsmon[16391]: UPS smartups@localhost on battery
Jan 16 12:05:56 beardy upsmon[16391]: UPS smartups@localhost on line power
Jan 16 14:02:27 beardy upsmon[8713]: UPS SmartUPS@localhost on battery
Jan 16 14:02:52 beardy upsmon[8713]: UPS SmartUPS@localhost on line power
Jan 16 14:18:49 beardy upsmon[8713]: UPS SmartUPS@localhost on battery
Jan 16 14:18:54 beardy upsmon[8713]: UPS SmartUPS@localhost on line power
Jan 16 14:21:14 beardy upsmon[8713]: UPS SmartUPS@localhost on battery
Jan 16 14:21:24 beardy upsmon[8713]: UPS SmartUPS@localhost on line power
Jan 16 14:55:53 beardy upsmon[8713]: UPS SmartUPS@localhost on battery
Jan 16 14:55:58 beardy upsmon[8713]: UPS SmartUPS@localhost on line power
Helps a bit with verifying things are being cached properly and retrieved from cache by requests.
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
set resp.http.X-Cache-Hits = obj.hits;
} else {
set resp.http.X-Cache = "MISS";
}
def hello(**kwargs):
print ','.join(kwargs)
import datetime
from collections import deque
from functools import wraps
from django.core.cache import cache
def timed_task(f):
@wraps(f)
def wrapper(*args, **kwargs):
"""Simple decorator to cache previous 10 execution times
if request.method == "POST":
email_form = SendAnEmail(request.POST, prefix='emailform')
if email_form.is_valid():
connection = DjangoBrokerConnection()
publisher = Publisher(connection=connection,
exchange="sendemail",
routing_key="sendemail_emails")
publisher.send(email_form.cleaned_data.get('email_address'))
publisher.close()
connection.close()
import struct
from Crypto.Cipher import AES
def pkcspad(s, block_size=AES.block_size):
"""PKCS#5/#7 padding - return string the right length for a block cipher.
# the output of pkcspad is 8 bit so use an md5 digest here in the
# doctests to check output.
>>> from hashlib import md5
@hamsolodev
hamsolodev / .emacs
Created March 9, 2011 09:42
only start the emacs server if it's not already running, and set up
(if (file-exists-p
(concat (getenv "TMPDIR") "emacs"
(number-to-string
(user-real-uid)) "/server"))
nil (server-start))
@hamsolodev
hamsolodev / app.coffee
Created April 24, 2011 02:24
basic Express starter app in CoffeeScript
express = require 'express'
app = module.exports = express.createServer()
app.configure ->
app.set 'views', __dirname + '/views'
app.set 'view engine', 'jade'
app.use express.bodyParser()
app.use express.methodOverride()
app.use app.router
@hamsolodev
hamsolodev / .zshrc
Created July 1, 2011 01:43
why is my RHS zsh prompt always the literal string "${vcs_info_msg_0_}"?
autoload -Uz vcs_info
autoload -U colors && colors
my_prompt_setup() {
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:git:*' check-for-changes true
precmd() {
vcs_info
}
PROMPT="%{$fg[blue]%}(%{$reset_color%}%{$fg[red]%}%m%{$reset_color%}%{$fg[yellow]%}:%{$reset_color%}%{$fg[green]%}%1d%{$reset_color%}%{$fg[blue]%})%{$reset_color%}%# "
RPROMPT='${vcs_info_msg_0_}'