Skip to content

Instantly share code, notes, and snippets.

James Padolsey padolsey

Block or report user

Report or block padolsey

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 ArrayMemberAccessFilter.js
/**
* I reckon computed member access in JS, i.e. ...[...],
* could be a tonne more powerful. This is an example of that.
* ===========================================================
* This is a filthy hack. Probably don't use it...
* ===========================================================
* It sets up a proxy that'll catch member access to arrays.
* Upon member-access, toString will be natively called and
* intercepted; the intercepted value will be used within our
* proxy to return a filtered version of the array.
View number_proxy_range.js
Number.prototype.to = function*(n) {
let finish = n.valueOf();
let start = this.valueOf();
let finishLessThan = start >= finish;
for (
let i = start;
finishLessThan ? i >= finish: i <= finish;
i += finishLessThan ? -1 : +1
) yield i;
};
View keybase.md

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:

View duino-lcd-play.js
'use strict'
const five = require('johnny-five');
const board = new five.Board();
board.on('ready', () => {
console.log('Ready');
let lcd = new five.LCD({
View assertions.js
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'),
View fuzzysearch.js
// 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 (.*):
View TheThing.js
TheThing.SOME_CONSTANT = 1;
TheThing.SOME_OTHER_CONSTANT = 1;
function TheThing() {
}
TheThing.prototype = { /* ... */ };
View yql_grab.js
// 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('&');
View git_helpers.sh
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 |
View english.js
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 ')
You can’t perform that action at this time.