Skip to content

Instantly share code, notes, and snippets.

Jon de la Motte jondlm

Block or report user

Report or block jondlm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jondlm
jondlm / logger.js
Last active Aug 29, 2015
A flexible console logger for Node.js complete with log levels and color
View logger.js
// Logging levels:
//
// INFO
// WARN
// ERROR
// FATAL
//
// Usage:
// var log = require('./logger.js');
//
@jondlm
jondlm / q.js
Created Sep 22, 2014
Node style callbacks to q promises
View q.js
var Q = require('q');
var assert = require('assert');
// Node style callback
function echo(thing, callback) {
callback(null, thing + thing);
}
//
// Test code
@jondlm
jondlm / centos_shellshock_patch.yml
Created Sep 26, 2014
ShellShock fix Ansible playbook for CentOS
View centos_shellshock_patch.yml
- hosts: all
gather_facts: false
sudo: true
tasks:
- name: check for shellshock bash vulnerability
shell: executable=/bin/bash env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
register: test_vuln
- name: update bash from yum if vulnerable
yum: name=bash
@jondlm
jondlm / sinon_example.js
Last active Aug 29, 2015
Mocha, Chai, and Sinon Example
View sinon_example.js
// `npm install -g mocha`
// `npm install chai sinon`
// Run with `mocha sinon_example.js`
var assert = require('chai').assert;
var sinon = require('sinon');
var clock = sinon.useFakeTimers();
// Sample function, this would normally be where you `require` your modules
var slow = function(cb) {
@jondlm
jondlm / ssh_agent_tmux.md
Created Oct 30, 2014
SSH agent with tmux
View ssh_agent_tmux.md

Create a file called ~/.ssh/save_ssh_agent.sh on your remote box and make it executable:

#!/bin/sh
SSHVARS="SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION DISPLAY"

for var in ${SSHVARS} ; do
  echo "export $var=\"$(eval echo '$'$var)\""
done 1>$HOME/.ssh/latest_ssh_agent.sh
  1. ssh into your box using ssh agent forwarding.
@jondlm
jondlm / trees.js
Created Nov 5, 2014
Javascript Trees
View trees.js
var util = require('util');
function TreeNode(data) {
this.data = data;
this.children = [];
}
TreeNode.prototype.isLeaf = function() {
return this.children.length === 0;
};
@jondlm
jondlm / index.js
Last active Aug 29, 2015
virtual dom example requirebin
View index.js
var h = require('virtual-dom/h');
var diff = require('virtual-dom/diff');
var patch = require('virtual-dom/patch');
var createElement = require('virtual-dom/create-element');
// Create a deterministic function that declares what the DOM should look like
// Model data in, vtree out
function render(user) {
return h('div#bro', {}, [
h('div', {}, 'First name: ' + user.firstName),
@jondlm
jondlm / index.js
Last active Aug 29, 2015
[requirebin] virtual dom example
View index.js
var h = require('virtual-dom/h');
var diff = require('virtual-dom/diff');
var patch = require('virtual-dom/patch');
var createElement = require('virtual-dom/create-element');
// Create a deterministic function that declares what the DOM should look like
// Model data in, vtree out
function render(user) {
return h('div#bro', {}, [
h('div', {}, 'First name: ' + user.firstName),
@jondlm
jondlm / index.js
Created Dec 3, 2014
rx error handling
View index.js
var Rx = require('rx');
var $ = require('jquery');
function searchWikipedia (term) {
return $.ajax({
url: 'http://en.wikipedia.org/w/api.php',
dataType: 'jsonp',
data: {
action: 'opensearch',
format: 'json',
@jondlm
jondlm / index.js
Last active Aug 29, 2015
virtual-dom drag and drop
View index.js
var Rx = require('rx');
// Create draggable element, nothing fancy going on here
var box = document.createElement('div');
box.style.width = box.style.height = '100px';
box.style.backgroundColor = 'grey';
box.style.position = 'absolute';
box.innerText = 'Drag me';
document.body.appendChild(box);
You can’t perform that action at this time.