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
View Trace_Analysis_00_filter_groupby.py
"""
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.
"""
"""
Filtering
"""
@tiffon
tiffon / agents.py
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.
View agents.py
import random
rng = random.SystemRandom()
TOTAL = 77.28
USER_AGENTS = None
def get_agent():
"""
@tiffon
tiffon / stackoverflow.py
Created Apr 4, 2015
Beautiful Soup 4 code that scrapes a few questions off stackoverflow.com
View stackoverflow.py
#! /usr/bin/env python
import sys
import time
import urllib2
from bs4 import BeautifulSoup
HOMEPAGE_URL = 'http://stackoverflow.com/'
TAG_PAGE_URL = 'http://stackoverflow.com/questions/tagged/web-scraping?sort=newest&pageSize=10'
@tiffon
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
tiffon / jsToWorker.js
Last active Dec 10, 2015
Create a WebWorker from a javascript function. Optionally, supply environment variables. Derived from this jsFiddle: http://jsfiddle.net/YUKSu/7/
View jsToWorker.js
var jsToWorker = (function(win) {
var enabled = !!win.Worker,
blobBuilder = win.BlobBuilder || win.WebKitBlobBuilder || win.MozBlobBuilder,
urlFactory = win.URL || win.webkitURL,
stringToBlobUrl;
if (!enabled || !urlFactory || (!win.Blob && !blobBuilder)) {
var noop = function(){};
noop.enabled = false;
@tiffon
tiffon / retina.js
Created Dec 20, 2012
Retinajs change to employ localStorage caching of image path results. Original (1st version) downloaded from: https://raw.github.com/imulus/retinajs/5671145d8a8adf3d72b6b62d8927799f8dd97863/src/retina.js
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
// https://github.com/imulus/retinajs/pull/45)
check_mime_type: true
};
@tiffon
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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Find Results</string>
<key>patterns</key>
<array>
<dict>
You can’t perform that action at this time.