Skip to content

Instantly share code, notes, and snippets.

View hiway's full-sized avatar

Harshad Sharma hiway

View GitHub Profile
@mahmoudimus
mahmoudimus / python-monkey-patch-built-ins.py
Created February 4, 2010 22:20
pythonic monkey patching built-in types
# found this from Armin R. on Twitter, what a beautiful gem ;)
import ctypes
from types import DictProxyType, MethodType
# figure out side of _Py_ssize_t
if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
_Py_ssize_t = ctypes.c_int64
else:
_Py_ssize_t = ctypes.c_int
@garyharan
garyharan / _mixins.scss
Created May 5, 2011 15:46
Useful scss mixins (rounded corners, gradients, text-field, button)
@mixin box-shadow($top, $left, $blur, $color, $inset: false) {
@if $inset {
-webkit-box-shadow:inset $top $left $blur $color;
-moz-box-shadow:inset $top $left $blur $color;
box-shadow:inset $top $left $blur $color;
} @else {
-webkit-box-shadow: $top $left $blur $color;
-moz-box-shadow: $top $left $blur $color;
box-shadow: $top $left $blur $color;
}
@jbhannah
jbhannah / dropbox-setup.sh
Created May 23, 2011 03:51
Dropbox setup on a headless Ubuntu Server (http://wp.me/pnbL6-5F)
#!/bin/sh
# Dropbox setup on a headless Ubuntu Server
# Script written by Jesse B. Hannah (http://jbhannah.net) <jesse@jbhannah.net>
# Based on http://wiki.dropbox.com/TipsAndTricks/UbuntuServerInstall
###
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
@gleicon
gleicon / txredns.py
Created July 10, 2011 01:13
Python/Twisted/Redis backed DNS server.
# Python/Twisted/Redis backed DNS server - resolves from NAME to IP addrs
# fallback to google or any other DNS server to resolv domains not present on Redis
# to set a new domain on redis, just issue a SET domain.tld ip_addr
# run with twistd -ny txredns.tac
# gleicon 2011
from twisted.names import dns, server, client, cache
from twisted.application import service, internet
from twisted.internet import defer
from twisted.python import log
@johnboxall
johnboxall / dns.py
Created August 15, 2011 21:57
Twisted DNS server!
# http://notmysock.org/blog/hacks/a-twisted-dns-story.html
# http://blog.inneoin.org/2009/11/i-used-twisted-to-create-dns-server.html
# twistd -y dns.py
import socket
from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor
from twisted.names import dns
from twisted.names import client, server
@pithyless
pithyless / gist:1208841
Created September 10, 2011 21:49
Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

@stefanv
stefanv / sparks.py
Created November 17, 2011 00:25
Command line sparks in Python
#!/usr/bin/python
# coding=utf-8
# Python version of Zach Holman's "spark"
# https://github.com/holman/spark
# by Stefan van der Walt <stefan@sun.ac.za>
"""
USAGE:
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@bennylope
bennylope / LICENSE
Last active August 17, 2023 10:44
Django manage.py file that loads environment variables from a .env file per Honcho/Foreman
Copyright the authors of Honcho and/or Ben Lopatin
Licensed for reuse, modification, and distribution under the terms of the MIT license