Skip to content

Instantly share code, notes, and snippets.

View benbuckman's full-sized avatar

Ben Buckman benbuckman

View GitHub Profile
@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>
<?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 / 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');
@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 / 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 / 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 / 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 / results-docusign-sentinel.log
Last active December 16, 2015 17:19
Testing/understanding various node.js redis-sentinel implementations
Using test hash test-sentinel-662038
sentinel client [no role] [no port] got 'end' { '0': undefined, '1': undefined, '2': undefined, '3': undefined }
sentinel client [no role] [no port] got 'connect' {}
sentinel client master 5379 got 'ready' {}
---- knock 1 ----
1 Set? true
1 check integrity: all good
---- knock 2 ----
2 Set? true
2 check integrity: all good
@benbuckman
benbuckman / 1--messed-up-scope.coffee
Last active December 21, 2015 04:39
Surprising scoping confusion with coffeescript constructors
_ = require 'lodash'
class CrazyParentView
events:
'mousedown .thing': ->
class CrazyChildView extends CrazyParentView
constructor: ->
@benbuckman
benbuckman / 1-process-uncaughtException.js
Last active December 22, 2015 11:19
Catching uncaught exceptions with node v0.10.13
// this catches the error (good) but still crashes (bad)
// was process.uncaughtException already deprecated?
// (shouldn't have been yet - http://nodejs.org/api/process.html#process_event_uncaughtexception)
process.on('uncaughtException', function(error) {
return console.error("CAUGHT uncaughtException", error);
});
throw new Error("A big error!");