Skip to content

Instantly share code, notes, and snippets.

stephband stephband

Block or report user

Report or block stephband

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
@stephband
stephband / tweet-promoters.csv
Created Feb 13, 2018
A list of twitter accounts that promote tweets. You can import them to your blocklist at https://twitter.com/settings/blocked, choose "Advanced options".
View tweet-promoters.csv
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
948185325142024192
141671778
1595919655
859375579
1310776698
3017785207
628899279
888323120
4802917600
308660195
@stephband
stephband / overload-by-type.js
Last active Aug 29, 2015
Overload a function according to the types of arguments passed in
View overload-by-type.js
// Overload a function according to the types of arguments passed in:
//
// var fn = overloadByTypes({
// 'object': function(object) {},
// 'string number': function(string, number) {},
// 'default': function() {}
// });
//
// Returns the result of the called function. To return this to create
// a chainable method, for example, pass in true as a second argument:
View viterbi.js
// Viterbi algorithm for finding hidden relationships
function Viterbi(data) {
var V = [{}];
var path = {};
// Initialize base cases (t == 0)
for(var i=0;i<data.states.length;i++) {
var state = data.states[i];
V[0][state] = data.start_probability[state] * data.emission_probability[state][data.observations[0]];
path[state] = [state];
@stephband
stephband / jQuery.support.continuousScrollEvents.js
Last active Apr 9, 2016
Feature detect devices that send continuous scroll events. Typically fails on iOS, which only sends scroll events after a scroll gesture has come to rest.
View jQuery.support.continuousScrollEvents.js
(function(jQuery) {
var win = jQuery(window);
var sampleLength = 20;
var maxInterval = 250;
var avgInterval = 35;
var timeStamps = [];
function diff(n, i, array) {
return array[i + 1] - n;
}
@stephband
stephband / slideshow.js
Created Aug 6, 2012
Automatic slides cycling for Bolt
View slideshow.js
(function(jQuery, undefined){
// Cycle news slides
jQuery(document).ready(function(){
var slides = jQuery('.header_slide'),
length = slides.length,
i = slides.index(slides.filter('.active')[0]),
durationShort = 8000,
durationLong = 48000,
timer, fn;
@stephband
stephband / rAF.js
Created May 25, 2012 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
View rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
@stephband
stephband / jQuery.addEasing
Created Dec 12, 2011
Add easing functions to jQuery based on the CSS spec for transition timing functions.
View jQuery.addEasing
// jQuery.addEasing(string)
//
// Interprets and adds easing functions to jQuery.easing
// according to the CSS spec for transition timing functions.
//
// e.g.
// jQuery.addEasing('cubic-bezier(0.4, 0.2, 0.66, 1)');
(function(jQuery, undefined){
View gist:955477
.whatever {
-webkit-box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
-moz-box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
-o-box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
}
You can’t perform that action at this time.