Skip to content

Instantly share code, notes, and snippets.

View sente's full-sized avatar

Stuart Powers sente

View GitHub Profile
import codecs
def unicode_safe_127(ss, debug=False):
"""safely handle strings with have ordinal values greater than 127
by escaping each value as appropriate.
if debug=True, log each conversion to stderr
"""
mys = ss
tos=[]
for i,s in enumerate(mys):
@sente
sente / jquery oneliner
Created September 15, 2011 13:09 — forked from RichardBronosky/jquery oneliner
This is the shortest line of code for getting jquery into a js console (Chrome, Safari, Firefox, etc.)
($=document.createElement('script')).src='http://j.mp/jqueryjs';(document.getElementsByTagName('head')[0]).appendChild($)
@sente
sente / gist:1442351
Created December 7, 2011 10:43
Awesome Python libs
@sente
sente / array.extensions.md
Created July 26, 2012 06:52 — forked from hemanth/array.extensions.md
Array.from and Array.of
@sente
sente / angryorigin.py
Created July 26, 2012 06:55 — forked from hemanth/angryorigin.py
Angry Origin - because cross origin requests are for wimps
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from SocketServer import ThreadingMixIn
import threading
import requests
class Handler(BaseHTTPRequestHandler):
def __init__(self, request, client_address, server):
print "Init!"
self.protocol_version = 'HTTP/1.1'
BaseHTTPRequestHandler.__init__(self, request, client_address, server) #http://www.mlsite.net/blog/?p=80
@sente
sente / gist:3180654
Created July 26, 2012 06:59 — forked from hemanth/gist:3002180
Awesome Python libs

New Machine

Here's what I do after I do a fresh install of Lion. Things are sorta grouped by type.

General Config

  1. Run Software Update
  2. Start downloading Xcode
  3. Disable auto-bright and turn brightness all the way up
  4. Enable mouse right click
@sente
sente / chunk.js
Created July 26, 2012 07:05 — forked from roidrage/chunk.js
chunk.js
function chunk(a, s){
for(var x, i = 0, c = -1, l = a.length, n = []; i < l; i++)
(x = i % s) ? n[c][x] = a[i] : n[++c] = [a[i]];
return n;
}
function(key, values, rereduce) {
Array.prototype.unique = function() {
var a = [];
var l = this.length;
for(var i=0; i<l; i++) {
for(var j=i+1; j<l; j++) {
// If this[i] is found later in the array
if (this[i] === this[j])
j = ++i;
}