Skip to content

Instantly share code, notes, and snippets.

View phillipalexander's full-sized avatar

Phillip Alexander phillipalexander

  • Galvanize
  • San Francisco
View GitHub Profile
pairs = ( obj ) ->
arr = []
for own key, val of obj when key isnt "id"
arr.push "#{ key }=#{ val}"
arr.join ","
makeORMClass = ( table ) ->
# CoffeeScript syntactic sugar for class creation.
class Model
/* REPO UNWATCHER
*
* This unwatches any repo that you don't specify.
* It must be run from the console while you are at https://github.com/watching
*
* *No need to edit any code - the instructions will prompt you to list out the repos you'd like to keep watching!*
*/
var repo;
var repos = [];
@phillipalexander
phillipalexander / keybase.md
Created February 4, 2015 05:04
keybase.md

Keybase proof

I hereby claim:

  • I am phillipalexander on github.
  • I am phillipalexander (https://keybase.io/phillipalexander) on keybase.
  • I have a public key whose fingerprint is FFDF 0A1B B1A8 605F EE6E 0A84 C53B 3118 05B8 2DCF

To claim this, I am signing this object:

@phillipalexander
phillipalexander / InspectorA.js
Created July 19, 2013 00:52
X-Ray Spectacles For Your JavaScript Objects
var xRay = function (obj, key, spaces) {
var i,
k,
keyTypeStr,
xrayResult,
indent;
key = key || "";
spaces = spaces || 1;
indent = "";
@phillipalexander
phillipalexander / defineProperty.js
Created July 22, 2013 01:19
Javascript Object.definePropery() method
var o = {}; // Creates a new object
// Example of an object property added with defineProperty with a data property descriptor
Object.defineProperty(o, "a", {value : 37,
writable : true,
enumerable : true,
configurable : true});
// 'a' property exists in the o object and its value is 37
// Example of an object property added with defineProperty with an accessor property descriptor
@phillipalexander
phillipalexander / d3.phylogram.js
Created July 26, 2013 18:55 — forked from kueda/d3.phylogram.js
Demonstration of two common tree visualizations using [d3](http://mbostock.github.com/d3) and [newick.js](https://github.com/jasondavies/newick.js). I hadn't found any examples of these kinds of right-angle trees so I figured I'd share. Input data is a Newick-formatted guide tree from a clustalw multiple sequence alignment on some cytochrome b s…
/*
d3.phylogram.js
Wrapper around a d3-based phylogram (tree where branch lengths are scaled)
Also includes a radial dendrogram visualization (branch lengths not scaled)
along with some helper methods for building angled-branch trees.
d3.phylogram.build(selector, nodes, options)
Creates a phylogram.
Arguments:
selector: selector of an element that will contain the SVG
{
"name": "flare",
"children": [
{
"name": "analytics",
"children": [
{
"name": "cluster",
"children": [
{"name": "AgglomerativeCluster", "size": 3938},
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
/*
Grep.js
Author : Nic da Costa ( @nic_daCosta )
Created : 2012/11/14
Version : 0.2
(c) Nic da Costa
License : MIT, GPL licenses
Overview:
Basic function that searches / filters any object or function and returns matched properties.
@phillipalexander
phillipalexander / InjectLib.coffee
Created August 8, 2013 19:39
inject a JS library into the current webpage
injectLib = do ->
scriptSrc = prompt('Source to inject')
head = document.getElementsByTagName('head')
body = document.getElementsByTagName('body')
target = if head? then head else body
scriptEl = document.createElement('script')
scriptEl.src = scriptSrc
target[0].appendChild(scriptEl)
console.log("injected: #{scriptSrc}")