Skip to content

Instantly share code, notes, and snippets.

View sidwood's full-sized avatar
🇮🇱

Sid Wood sidwood

🇮🇱
  • Expana
  • London, UK
View GitHub Profile
# This should be triggered through a cron job at 6:15 PM on week days.
# Example cron: 15 18 * * 1,2,3,4,5 cd ~/code/jury_duty && ~/.rbenv/shims/ruby call.rb >> ~/code/jury_duty/call-log.txt 2>&1
# It uses Twilio to make a call based on TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, and TWILIO_PHONE.
# It calls the JURY_PHONE, transcribes it, looks for JURER_NUMBER and texts the result to PERSONAL_PHONE.
require "rubygems"
require "bundler/setup"
Bundler.require(:default)
Dotenv.load
@khanov
khanov / Binary Tree Printer.swift
Last active July 14, 2021 02:17
Binary Tree ASCII Printer
import Foundation
// Ideally Node should be a struct.
// However Swift doesn't allow recursive value types at the moment.
class Node {
var left, right: Node?
var value: String
init(value: String = "") {
@sidwood
sidwood / selenium.sh
Created September 1, 2014 10:45
A selenium server management script for node.js projects. Dug this relic up and updated line #7 so that it can act as a replacement for protractor's currently broken `webdriver-manager update`. Just pop this in your ./bin folder, make it executable, and run `./bin/selenium.sh install`. Jobs a good’un.
#!/usr/bin/env bash
#
# Constants
#
# DOWNLOAD_PATH=vendor/selenium
DOWNLOAD_PATH=node_modules/protractor/selenium
CD_VERSION=2.10
@sidwood
sidwood / products.test.js
Created July 2, 2014 09:46
Hapi plugin test that illustrates plugins containing route definitions with array values for the method will fail when the plugin is registered to more than one server instance.
// plugins/products-api/test/products.test.js
'use strict';
var Lab = require('lab');
var Hapi = require('hapi');
var productsApi = require('../index');
var dataStore = require('../../store');
@branneman
branneman / better-nodejs-require-paths.md
Last active June 29, 2024 16:00
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@sidwood
sidwood / matchers.js
Created June 7, 2013 16:55
An example of asserting that a test double is implementing it's role/interface correctly in AngularJS test suites suing Jasmine. http://www.meetup.com/AngularJS-London/events/106468592/
// client/test/support/matchers.js
beforeEach(function() {
this.addMatchers({
toRespondTo: function(method) {
return void 0 !== this.actual[method];
}
});
});
@domenic
domenic / README.md
Created March 29, 2012 16:01
Cross-platform git hooks for Node.js

Here's how this works:

  • Include a git_hooks/ directory in your project, with these two files (plus other hooks if you want, written in a similar style).
  • Add "npm" to your devDependencies in package.json, so that the pre-commit hook can do its magic.
  • Add test and lint scripts to your package.json, e.g.
    "scripts": {
        "test": "mocha",
 "lint": "jshint ./lib --show-non-errors"
@cpatni
cpatni / app.rb
Created November 21, 2011 22:39
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE