Skip to content

Instantly share code, notes, and snippets.

@thom-nic
thom-nic / queue_test.rb
Created February 9, 2012 20:04
AMQP Example
require 'amqp'
AMQP.start 'amqp://localhost' do
puts 'Connected.'
AMQP::Channel.new do |channel, open_ok|
channel.queue "schwartz.test2", :durable => false do |queue, ok|
queue.subscribe do |headers, msg|
puts "Got message: #{msg}"
end
EM.add_periodic_timer 5 do
@thom-nic
thom-nic / example_amqp_spec.rb
Created February 17, 2012 15:28
Testing ruby-amqp and evented-spec with MiniTest
require 'evented-spec'
require 'minitest/autorun'
require "amqp"
class TestConsumer
attr_reader :connection_string, :queue_name,
:connection, :channel, :queue,
:msg_count, :errors
def initialize opts={}
@thom-nic
thom-nic / wifi-dmesg.txt
Created June 6, 2012 18:54
Raspberry Pi wifi adapter dmesg output
Linux version 3.1.9+ (dc4@dc4-arm-01) (gcc version 4.5.1 (Broadcom-2708) ) #52 Tue May 8 23:49:32 BST 2012
CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: BCM2708
Memory policy: ECC disabled, Data cache writeback
On node 0 totalpages: 57344
free_area_init_node: node 0, pgdat c03bb910, node_mem_map c0408000
Normal zone: 448 pages used for memmap
Normal zone: 0 pages reserved
Normal zone: 56896 pages, LIFO batch:15
@thom-nic
thom-nic / dmesg-apple-kbd.txt
Created June 7, 2012 13:47
Raspberry Pi dmesg errors with Apple USB keyboard
71)
hub 1-1.3:1.0: unable to enumerate USB device on port 2
DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK
DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK
DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK
hub 1-1.3:1.0: cannot disable port 2 (err = -71)
usb 1-1.3: USB disconnect, device number 56
@thom-nic
thom-nic / wpa_supplicant-dd.txt
Created June 7, 2012 17:18
wpa_supplicant output
root@raspbian:~# wpa_supplicant -i wlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf -dd
wpa_supplicant v1.0
random: Trying to read entropy from /dev/random
Initializing interface 'wlan0' conf '/etc/wpa_supplicant/wpa_supplicant.conf' driver 'default' ctrl_interface 'N/A' bridge 'N/A'
Configuration file '/etc/wpa_supplicant/wpa_supplicant.conf' -> '/etc/wpa_supplicant/wpa_supplicant.conf'
Reading configuration file '/etc/wpa_supplicant/wpa_supplicant.conf'
ctrl_interface='/var/run/wpa_supplicant'
ctrl_interface_group='0'
ap_scan=2
Line: 16 - start of a new network block
@thom-nic
thom-nic / dmesg.out
Created June 12, 2012 16:53
new dmesg and wpa_supplicant output for raspbian
6.611593] 0x30 0x14 0x01 0x00 0x00 0x0f 0xac 0x04
[ 476.622731] 0x01 0x00 0x00 0x0f 0xac 0x04 0x01 0x00
[ 476.634192] 0x00 0x0f 0xac 0x02 0x00 0x00 0xd4 0xcc
[ 476.645687] =>rtw_wx_set_essid
[ 476.654897] ssid=EW, len=2
[ 476.663757] Set SSID under fw_state=0x00000008
[ 476.674480] <=rtw_wx_set_essid, ret 0
[ 482.689276] wpa_set_auth_algs, AUTH_ALG_OPEN_SYSTEM
[ 482.700379] set_mode = IW_MODE_INFRA
[ 482.710917]
@thom-nic
thom-nic / jasmine.matcher.toBeInstanceOf.js
Last active December 4, 2015 19:29 — forked from heat/jasmine.matcher.toBeInstanceOf.js
Jasmine Matcher instanceof for Jasmine 2.3 & ES6
/* eslint-env jasmine */
beforeEach(function() {
jasmine.addMatchers({
toBeInstanceOf: (util, customEqualityTesters) => {
return {
compare: (actual, expected) => {
const pass = (actual instanceof expected);
return {
pass,
message: `Expected ${actual} to ${pass ? 'not' : ''} be instance of ${expected}`,
@thom-nic
thom-nic / enoc_open_sql.rb
Created March 29, 2013 13:34
Script to load EnerNOC Open data (see http://open.enernoc.com/data) into a relational database. Note that this resulted in a ~500 MB sqlite file for all 100 sites in the 2012 dataset. Once the data is loaded, you can make standard relational queries over the data such as: select r.* from readings r join sites s on r.site_id = s.site_id where s.i…
require 'sqlite3'
require 'csv'
module ENOC
##
# Functions to load EnerNOC Open Data (http://open.enernoc.com/data)
# into a sqlite database for relational access. This sould be easy
# to migrate to Postgres or MariaDB if you want a 'real' database.
#
module Sql
@thom-nic
thom-nic / npm ls tree
Created December 19, 2015 02:54
react dependencies
├── axios@0.7.0
├─┬ babel@5.8.34
│ ├─┬ commander@2.9.0
│ │ └── graceful-readlink@1.0.1
│ ├── convert-source-map@1.1.2
│ ├── fs-readdir-recursive@0.1.2
│ ├─┬ glob@5.0.15
│ │ ├─┬ inflight@1.0.4
│ │ │ └── wrappy@1.0.1
│ │ └── once@1.3.3
@thom-nic
thom-nic / Rakefile
Created August 20, 2013 20:43
Octopress rake tasks for deploying to S3 and pinging sitemaps
# Add this w/ your other imports:
begin
require 'aws/s3'
require 'yaml'
rescue
puts "No S3 upload support!"
end
# and in your config section...
s3_config_file = "amazon_s3.yml" # location of file with S3 access key, private key, bucket name