Skip to content

Instantly share code, notes, and snippets.

@jperler
jperler / blowfish.txt
Created September 23, 2024 00:08
Blowfish
Ticket #3224
@jperler
jperler / interval.js
Created February 17, 2015 18:10
Simulates a setInterval call which calls different functions at each interval.
var Interval = function(interval) {
this.interval = interval;
this.calls = 0;
this.funcs = [];
};
Interval.prototype.push = function(func, context) {
this.funcs.push(func.bind(context || window));
};
@jperler
jperler / chunk.js
Last active December 8, 2017 01:05
Array chunking function for Underscore.js. Usage: _.chunks([1,2,3,4,5,6,7], 2) => [[1,2],[2,3],[4,5],[5,6],[7]]
_.mixin({
chunks: function(arr, size) {
var len = arr.length,
chunk_len = Math.ceil(len/size),
chunks = [];
for (var i = 0; i < chunk_len; i++) {
chunks.push(arr.slice(i*size, (i+1)*size));
}
return chunks;
}
@jperler
jperler / Image.py
Created October 12, 2012 14:39
PIL Wrapper
import socket
import urllib2, uuid, os
from PIL import Image, ImageChops, ImageOps
import simplejson as json
from settings import MEDIA_ROOT
from studio.misc import PhotoSize
"""
Dependencies: PIL