Skip to content

Instantly share code, notes, and snippets.

View njh's full-sized avatar

Nicholas Humfrey njh

View GitHub Profile
@creationix
creationix / chatServer.js
Created November 19, 2010 20:47
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@omsai
omsai / gist:2363047
Created April 11, 2012 22:01
Arduino UNO pulse counter
/*
Arduino UNO reads rising edge trigger pulses on pin 2 and displays counter on
Sparkfun SerLCD LCD-10097
Photo of setup: http://ompldr.org/vZGNlbA/photo.JPG
Pariksheet <p.nanda@andor.com> Mar 2012
*/
@njh
njh / mqtt-eventsource.rb
Created April 14, 2012 14:09
Subscribe to MQTT messages in browser using HTML5 Server-Sent Events
#!/usr/bin/env ruby
require 'rubygems'
require 'eventmachine'
require 'em-mqtt'
require 'sinatra/base'
require 'thin'
class WebApp < Sinatra::Base
@njh
njh / _README.md
Last active October 5, 2019 12:06
Shell script to create a WebID certificate using OpenSSL
# /usr/bin/notify-site-is-down.rb
require "rubygems"
require "twilio-ruby"
account_sid = ENV["TWILIO_ACCOUNT_SID"]
auth_token = ENV["TWILIO_AUTH_TOKEN"]
@client = Twilio::REST::Client.new account_sid, auth_token
@jpmens
jpmens / builder.sh
Created June 5, 2013 17:45
Build Mosquitto 1.2 on OSX Lion
# Build OpenSSL 1.0.1e (or whichever)
$ ./Configure darwin64-x86_64-cc --prefix=/usr/local/stow/openssl-1.0.1e/
$ make install
# Obtain and build Mosquitto
$ hg clone https://bitbucket.org/oojah/mosquitto
$ hg up -r 1.2
@willurd
willurd / web-servers.md
Last active July 26, 2024 13:45
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@jpmens
jpmens / mosquitto-dns-srv.diff
Created November 13, 2013 07:48
Add support for DNS SRV records to Mosquitto's mosquitto.py Code placed in the public domain, by Jan-Piet Mens, November 2013
--- mosquitto.py.orig 2013-11-12 11:41:17.000000000 +0100
+++ mosquitto.py 2013-11-13 08:44:31.000000000 +0100
@@ -45,6 +45,11 @@
import sys
import threading
import time
+HAVE_DNS = True
+try:
+ import dns.resolver
+except ImportError:
@wholmgren
wholmgren / use-bbdiff
Last active July 8, 2024 03:04
set git difftool to bbdiff
git config --global diff.tool bbdiff
git config --global difftool.bbdiff.cmd 'bbdiff --wait --resume "$LOCAL" "$REMOTE"'
git config --global difftool.prompt false
git config --global merge.tool bbdiff
git config --global mergetool.bbdiff.cmd 'bbdiff --wait --resume "$LOCAL" "$REMOTE"'
Double check ~/.gitconfig
@PurpleBooth
PurpleBooth / README-Template.md
Last active July 27, 2024 07:37
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites