Skip to content

Instantly share code, notes, and snippets.

View gbishop's full-sized avatar

Gary Bishop gbishop

View GitHub Profile
@pmuellr
pmuellr / run-when-changed.py
Created November 23, 2009 06:16
run-when-changed.py
#!/usr/bin/env python
#-----------------------------------------------------------------------------
# The MIT License
#
# Copyright (c) 2009, 2010 Patrick Mueller
#
# 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
@mathiasbynens
mathiasbynens / jquery.insertAtCaret.js
Created March 9, 2010 11:13
jQuery insertAtCaret plugin
// I found this somewhere on the intertubes, and optimized it
$.fn.insertAtCaret = function(myValue) {
return this.each(function() {
var me = this;
if (document.selection) { // IE
me.focus();
sel = document.selection.createRange();
sel.text = myValue;
me.focus();
} else if (me.selectionStart || me.selectionStart == '0') { // Real browsers
# monkey patch the python json module to handle undefined
import json
json.decoder._CONSTANTS['undefined'] = None
json.scanner.pattern('(-?Infinity|NaN|true|false|null|undefined)')(json.decoder.JSONConstant)
json.decoder.JSONScanner = json.decoder.Scanner(json.decoder.ANYTHING)
if __name__ == '__main__':
print json.loads('{ "foo": 1, "bar": undefined }')
@weakish
weakish / README.markdown
Last active December 18, 2023 05:58
#Solarized themes (dark and light) for #roxterm.
@atesgoral
atesgoral / LICENSE.txt
Last active January 26, 2017 18:11 — forked from 140bytes/LICENSE.txt
Date formatter that uses human-readable date instance getters instead of cryptic Y/M/D etc. tokens
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Ates Goral <http://magnetiq.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@spicycode
spicycode / tmux.conf
Created September 20, 2011 16:43
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@phpdude
phpdude / nginx.conf
Last active February 28, 2024 04:36
Nginx image filter + caching of results.
location /resize {
alias /tmp/nginx/resize;
set $width 150;
set $height 100;
set $dimens "";
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) {
set $width $1;
set $height $2;
set $image_path $3;
@minrk
minrk / ipnbdoctest.py
Last active September 14, 2023 11:23
simple example script for running and testing notebooks.
#!/usr/bin/env python
"""
simple example script for running and testing notebooks.
Usage: `ipnbdoctest.py foo.ipynb [bar.ipynb [...]]`
Each cell is submitted to the kernel, and the outputs are compared with those stored in the notebook.
"""
# License: Public Domain, but credit is nice (Min RK).
@jkp
jkp / websocketserver.py
Created July 18, 2012 13:28
A simple WebSockets server with no dependencies
import struct
import SocketServer
from base64 import b64encode
from hashlib import sha1
from mimetools import Message
from StringIO import StringIO
class WebSocketsHandler(SocketServer.StreamRequestHandler):
magic = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
@cjanis
cjanis / gist:3910234
Created October 18, 2012 07:01
Resume iOS Web App on last open web page
if (window.navigator.standalone) {
var setLastUrl = function() {
localStorage['lastUrl'] = window.location;
}
if (sessionStorage['init']) {
setLastUrl();
} else {
sessionStorage['init'] = true;
if (localStorage['lastUrl']) {
if (localStorage['lastUrl'] != window.location) {