Skip to content

Instantly share code, notes, and snippets.

View cwallenpoole's full-sized avatar

Christopher Allen-Poole cwallenpoole

View GitHub Profile
function flatten(input){
const out = [];
function recurse(a){
// This captures all iterators, not just arrays.
if(a[Symbol.iterator]) {
for(let v of a){
recurse(v);
}
}
/*
Example:
var val = createInstances([0,1,2,4,...<set of ascending integers>]);
Instructions, each time user stalls, give the new "bug report"
1. val.total is giving me NaN!
* If a candidate sees the typo (but not that total isn't set), point out that the bug is still there.
* If the user sees the reason it's NaN, then ask whether the other properties are being set correctly
2. It's not always adding listeners to the right items
/*
createInstances(<array of integers>)
ItemFinder.find(<int representing ID of item from list>)
returns the item which is found or null
item.needsUpdate returns something "truthy" or "falsy" (can be 1,true, "cat", null, NaN, undefined, false, etc.)
og.notifications.getNotifier() returns a notifier object. It has at least one method "transmit":
notifier.transmit({
#!/usr/bin/env php
<?php
/*
* This file can be run as a shell script. It connects to a project's
* MySQL DB. If you are in a directory with a WordPress install, it
* will use `wp db cli`, if in Drupal it will use `drush sqlc`, if in
* Laravel it will parse the `.env` file and use the default connection
* names there.
*/
@cwallenpoole
cwallenpoole / RSS.py
Created July 9, 2011 16:34 — forked from mnot/RSS.py
RSS.py: work with RSS channels as data structures
#!/usr/bin/env python
"""
RSS.py
Classes for working with RSS channels as arbitrary data structures.
Requires Python 2.2 or newer and PyXML 0.7.1 or newer.
ChannelBase - Base class for RSS Channels.
CollectionChannel - RSS Channel modeled as a URI-per-entry