Skip to content

Instantly share code, notes, and snippets.

View padolsey's full-sized avatar

James Padolsey padolsey

View GitHub Profile

Keybase proof

I hereby claim:

  • I am padolsey on github.
  • I am padolsey (https://keybase.io/padolsey) on keybase.
  • I have a public key whose fingerprint is F256 45CF 1A20 5360 6A46 A9AD 599B 1D48 053D 0BD2

To claim this, I am signing this object:

'use strict'
const five = require('johnny-five');
const board = new five.Board();
board.on('ready', () => {
console.log('Ready');
let lcd = new five.LCD({
var uk = createFuzzyScorer('United Kingdom');
var us = createFuzzyScorer('United States');
console.log([
uk('United') > uk('uk'),
uk('nited') > uk('ingdom'),
uk('united kingdom') > uk('united kingdo'),
uk('united dom') < uk('united kin'),
uk('knited k') > uk('dom'),
uk('_united_') < uk('united'),
// context: https://twitter.com/codepo8/status/572863924887945216
function fuzzysearch(query, text) {
// Build a regex, then test text against it:
return RegExp(
query
// Escape any special regex characters:
.replace(/[.*+?^${}()|[\]\/\\]/g, '\\$&')
// Any escaped or non-escaped character can be followed by
// any number of other characters (.*):
TheThing.SOME_CONSTANT = 1;
TheThing.SOME_OTHER_CONSTANT = 1;
function TheThing() {
}
TheThing.prototype = { /* ... */ };
@padolsey
padolsey / yql_grab.js
Last active February 21, 2024 11:49
// Scrape/Grab page using YQL via JSONP
function grab(url, cb) {
var fn = '__grabber' + +new Date;
var query = 'select * from html where url="{URL}" and xpath="*"';
var yurl = 'http' + (/^https/.test(location.protocol)?'s':'') + '://query.yahooapis.com/v1/public/yql?';
yurl += [
'callback=' + fn,
'format=xml',
'q=' + encodeURIComponent(query.replace('{URL}', url))
].join('&');
function git_likely_authority() {
# Outputs a ranked list of likely author(itie)s regarding tracked files matching *${1}*
# (Makes it easier to discover who likely knows most about the matched files)
# (Note: Not always indicative if large refactors/renamings have occurred)
# E.g. `git_likely_authority some_pattern_that_matches_a_path`
git ls-files "*${1}*" |
grep -v -E 'node_modules|vendor' | # edit to avoid certain files/dirs
xargs -n1 git blame --line-porcelain |
sed -n 's/^author //p' |
sort -f |
describe(' a tribute ')
.to(' the syntactical hubris of attempting ')
.to(' present logic flows as grammatically coherent ')
.english()
it(' is a foolish attempt ')
.for(' it aids aesthetically but limits functionally ')
.and()
.truly(' misidentifies ')
.a(' difficulty in the understanding of code ')
.foolishly(' attributing understandability of it to its ')
var vic = require('./vic').vic;
var singular = require('./singularValidators');
var DateRange = require('./DateRange');
var Date = require('./Date');
var NativeDate = Date.NativeDate;
// Regexes adaped/used in the regexBuilder (r)
// Flag hard-set to 'i';
var YEAR = /(\d{2,4})/;
@padolsey
padolsey / gist:7990476
Created December 16, 2013 17:08
Get notified when you're attempting jQuery method calls on an empty collection
for (var i in $.fn) (function(method, name) {
// ignore traversal/selection methods
if (typeof method != 'function' || [
'constructor', 'init', 'find', 'add', 'next', 'nextUnil', 'prevUntil',
'parents', 'closest', 'eq', 'filter', 'has', 'first', 'siblings',
'last', 'map', 'not', 'slice', 'addBack', 'andSelf', 'contents', 'prev',
'end', 'not', 'children', 'nextAll', 'prevAll', 'parent', 'parentsUntil'
].indexOf(name) > -1) {
return;
}