This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from hashlib import sha512 | |
import hmac | |
import string | |
# random key, generated with os.urandom(20) | |
secret_key = 'y6!n\xe1\x15\x96\x8c\xe8VX:\xa7\ta\xe6c\xf9\x04+' | |
# charset to use in tripcode | |
charset = string.ascii_letters + string.digits + '$#!@%&*' | |
# tripcode length | |
length = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from markdown2 import Markdown | |
patched = Markdown._get_pygments_lexer | |
def patch_get_pygments_lexer(self, lexer_name): | |
if lexer_name != "python": | |
return patched(self, lexer_name) | |
from pygments.lexers import PythonLexer | |
from pygments.token import Name, Keyword | |
from pygments.filter import Filter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
description "fig service runner" | |
start on filesystem and started docker | |
stop on runlevel [!2345] | |
respawn | |
chdir /wherever/your/fig/file/is | |
script | |
# Wait for docker to finish starting up first. | |
FILE=/var/run/docker.sock | |
while [ ! -e $FILE ] ; do | |
inotifywait -t 2 -e create $(dirname $FILE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Call Descriptor | |
~~~~~~~~~~~~~~~ | |
Allows you to dynamically modify an instance's __call__ value. | |
You may be asking, why not just use an attribute on the object | |
instead of this magical descriptor? | |
Good fucking question... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PENDING = 0; | |
const FULFILLED = 1; | |
const REJECTED = 2; | |
function PromiseState(component, stateKey, initial) { | |
this.component = component; | |
this.stateKey = stateKey; | |
var self = this; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var StateCacheMixin = function(key) { | |
if (!Modernizr.sessionstorage) { | |
return {}; | |
} | |
return { | |
componentWillMount: function() { | |
var prevState = sessionStorage.getItem(key); | |
if (prevState === null) return; | |
try { | |
prevState = JSON.parse(prevState); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM */ | |
// Wrapper around the selectize jQuery plugin. | |
module.exports = React.createClass({ | |
getDefaultProps: function() { | |
return { | |
// HTML attrs | |
disabled: false, | |
multiple: false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mixin for components that bind to keyboard events using Mousetrap. | |
// Use this.bind like you would Mousetrap.bind. | |
function nop(){} | |
module.exports = { | |
bind: function(keys, callback, action) { | |
this._mousetrapBindings.push([keys, action]); | |
Mousetrap.bind(keys, callback.bind(this), action); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* For limiting concurrency, Javascript style. | |
* | |
* Created for a document viewer; basically a number of thumbnails and | |
* a full image of the current page. "Changing the page" entailed | |
* changing the src of the full image, and the expectation was for that | |
* page to load. However, the thumbnails would saturate the browser's | |
* download limit, so the page wouldn't change until _all_ of the | |
* thumbnails had finished downloading. With 300+ page documents and |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function History(initialState) { | |
this.reset(initialState); | |
} | |
History.prototype = { | |
reset: function(initialState) { | |
this.history = [initialState]; | |
this.pointer = 0; | |
this.tail = 0; |
OlderNewer