Skip to content

Instantly share code, notes, and snippets.

View benbuckman's full-sized avatar

Ben Buckman benbuckman

View GitHub Profile
@benbuckman
benbuckman / test-getters.js
Created December 5, 2012 22:43
JS getter example
function Client(){
this.subClient = new SubClient();
};
function SubClient(){
this.numConnections = 0;
this.status = 'OK';
};
// getting error,
// TypeError: Invalid property. A property cannot both have accessors and be writable or have a value, #<Object>
@benbuckman
benbuckman / test-refs.js
Created December 4, 2012 18:13
Testing JS references
// is it possible to hold a reference to a wrapper's object,
// such that the reference automatically updates when the object updates?
// (rather than staying with the original object)?
var assert = require('assert');
function Wrapper(){
this.client = null;
};
@benbuckman
benbuckman / magicdictionary.coffee
Created November 30, 2012 21:07
Magic Dictionary algo
dict = ['hello', 'kitty', 'farm']
isWordInDict = (word)->
(dict.indexOf(word) > -1)
findAllWords = (str)->
words = []
for startInd in [0..(str.length - 1)]
for endInd in [(startInd + 1)..str.length]
@benbuckman
benbuckman / seq-test.js
Created December 11, 2011 05:15
Understanding node-seq (control flow library for node.js)
### OUTPUT ###
vars at end: { firstVar: 'A', secondVar: 'B', thirdVar: 'C' }
in A
vars: {}
in B
vars: {}
timer done in A
in C
vars: {}
@benbuckman
benbuckman / drupal-syslog-parser.js
Created November 29, 2011 17:56
node.js script to parse Drupal logs in linux syslog (and find distinct 404'd URLs)
// drupal log parser w/ node.js
// takes a filtered syslog file
// run as node `drupal-syslog-parser.js LOGPATH`
// [install dependencies (lazy,underscore) first with `npm install ___`]
var lazy = require('lazy')
, fs = require('fs')
, path = require('path')
, _ = require('underscore');
<?php
/**
* Implementation of hook_drush_command().
*/
function MODULE_drush_command() {
$items = array();
$items['resync-content-taxonomy'] = array(
'description' => "Re-sync content_taxonomy from term_node",
);
return $items;
@benbuckman
benbuckman / flickr-slideshow-code-generator.html
Created August 27, 2014 05:49
Flickr slideshow code generator
<!doctype html>
<!--
Flickr slideshow code generator.
Created by Ben Buckman, August 2014. Open source under MIT license.
-->
<html>
<head>
<title>Flickr Slideshow Generator</title>
<script>