Skip to content

Instantly share code, notes, and snippets.

Joe Farro tiffon

Block or report user

Report or block tiffon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Note: There are several variations to do the same thing (see # or). The idea
is to choose the best (one or so) of the variations and implement that. I.E.
these are different designs possibilities for the API.
tiffon /
Last active Jan 15, 2017
A somewhat ghetto, but still handy, utility for getting a random user-agent weighted by their general popularity (circa mid-2014). Useful for web-scraping.
import random
rng = random.SystemRandom()
TOTAL = 77.28
def get_agent():
tiffon /
Created Apr 4, 2015
Beautiful Soup 4 code that scrapes a few questions off
#! /usr/bin/env python
import sys
import time
import urllib2
from bs4 import BeautifulSoup
tiffon / gist:8747582
Created Feb 1, 2014
Simulated Annealing algorithm from "Programming Collective Intelligence" by Toby Segaran.
View gist:8747582
public class SimulatedAnnealing
public static final double DEFAULT_TEMPERATURE = 10000;
public static final double DEFAULT_COOL_RATE = 0.95;
static public double[] optimize(double[][] domain, SolutionCost costF, double stepSize)
return optimize(domain, costF, DEFAULT_TEMPERATURE, DEFAULT_COOL_RATE, stepSize);
View gist:5881101
`` 'it' keyword replaces 'this'
`` variable declaration ':='
`` lamda function '-->'
`` within an object literal ':prop = value'
`` loops
`` -----------------------------------------------------------------------------
tiffon / jsToWorker.js
Last active Dec 10, 2015
Create a WebWorker from a javascript function. Optionally, supply environment variables. Derived from this jsFiddle:
View jsToWorker.js
var jsToWorker = (function(win) {
var enabled = !!win.Worker,
blobBuilder = win.BlobBuilder || win.WebKitBlobBuilder || win.MozBlobBuilder,
urlFactory = win.URL || win.webkitURL,
if (!enabled || !urlFactory || (!win.Blob && !blobBuilder)) {
var noop = function(){};
noop.enabled = false;
tiffon / retina.js
Created Dec 20, 2012
Retinajs change to employ localStorage caching of image path results. Original (1st version) downloaded from:
View retina.js
(function() {
var root = (typeof exports == 'undefined' ? window : exports);
var config = {
// Ensure Content-Type is an image before trying to load @2x image
check_mime_type: true
tiffon / Find Results.hidden-tmLanguage
Created Dec 19, 2012
Tricked-out Find in Files... results
View Find Results.hidden-tmLanguage
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<string>Find Results</string>
You can’t perform that action at this time.