Skip to content

Instantly share code, notes, and snippets.

View hamsolodev's full-sized avatar

hamsolo.dev hamsolodev

View GitHub Profile
Copyright (c) 1992-2011 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 8.2-RELEASE #0: Fri Feb 18 02:24:46 UTC 2011
root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Intel(R) Celeron(R) CPU 420 @ 1.60GHz (1596.01-MHz 686-class CPU)
Origin = "GenuineIntel" Id = 0x10661 Family = 6 Model = 16 Stepping = 1
Features=0xafebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,PBE>
@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_}'
@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 / .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))
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
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 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
def hello(**kwargs):
print ','.join(kwargs)
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";
}
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