Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Buckman benbuckman

View GitHub Profile
View flickr-slideshow-code-generator.html
<!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>
View Drupal - Re-Sync Content Taxonomy.php
<?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 Nov 29, 2011
node.js script to parse Drupal logs in linux syslog (and find distinct 404'd URLs)
View drupal-syslog-parser.js
// 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 Dec 11, 2011
Understanding node-seq (control flow library for node.js)
View seq-test.js
### OUTPUT ###
vars at end: { firstVar: 'A', secondVar: 'B', thirdVar: 'C' }
in A
vars: {}
in B
vars: {}
timer done in A
in C
vars: {}
View magicdictionary.coffee
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 Dec 4, 2012
Testing JS references
View test-refs.js
// 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;
};
View test-getters.js
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 Dec 16, 2015
Testing/understanding various node.js redis-sentinel implementations
View results-docusign-sentinel.log
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 Dec 21, 2015
Surprising scoping confusion with coffeescript constructors
View 1--messed-up-scope.coffee
_ = require 'lodash'
class CrazyParentView
events:
'mousedown .thing': ->
class CrazyChildView extends CrazyParentView
constructor: ->
@benbuckman
benbuckman / 1-process-uncaughtException.js
Last active Dec 22, 2015
Catching uncaught exceptions with node v0.10.13
View 1-process-uncaughtException.js
// 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!");