Skip to content

Instantly share code, notes, and snippets.

@epall
epall / keybase.md
Created September 26, 2014 01:36
keybase.md

Keybase proof

I hereby claim:

  • I am epall on github.
  • I am epall (https://keybase.io/epall) on keybase.
  • I have a public key whose fingerprint is 4C49 3AA1 0D5F A617 7AE5 9F46 2D24 89BE 5627 5190

To claim this, I am signing this object:

const NIMBITS_EMAIL = "eric@electricimp.com"
// we recommend creating an access key specifically for the point(s) you want
// to write to, instead of using your account secret
const NIMBITS_ACCESS_KEY = "9cb960d95161235a"
const NIMBITS_POINT = "demo1"
function nimbits_submit(value) {
local body = http.urlencode({
point=NIMBITS_POINT,
page <- @"
<html>
<body>
<form method=""POST"">
<input type=""submit"" value=""Up"" name=""action"">
<input type=""submit"" value=""Down"" name=""action"">
</form>
</body>
</html>
"
@epall
epall / emma.js
Created November 14, 2012 14:52
Post tweets with a hashtag to an Electric Imp "Emma" board
var twitter = require('node-twitter')
, util = require('util')
, https = require('https')
var twitterClient = new twitter.SearchClient({
consumer_key: '__YOUR_TWITTER_CONSUMER_KEY__',
consumer_secret: '__YOUR_TWITTER_CONSUMER_SECRET__'
});
var lastTweet;
@epall
epall / server.js
Created November 8, 2012 20:24
graceful restart
var net = require('net')
var child_process = require('child_process')
var number = process.argv.length > 2 ? parseInt(process.argv[2], 10) : 0;
function listen(server) {
server.on('connection', function(socket) {
socket.write('hi from #'+number+'\n');
});
@epall
epall / using_async.js
Created October 23, 2012 15:35
example of JavaScript "coroutines" in practice
var async = require('async');
async.waterfall([
Foo.create.bind(Foo, fooId, false),
function(foo, cb) {
Bar.create(barId, '0000000000000001', false, null, utils.randomID(12), cb);
},
function(result, cb) {
Baz.create('baz_'+utils.randomID(4), true, 1, 'hello, world', cb);
},
@epall
epall / hannah-motiondetect.nut
Created October 15, 2012 18:31
Vibration sensor using accelerometer on Hannah
// Vibration sensor using accelerometer on Hannah
//I2C Addresses
const i2c_ioexp = 0x7C;
const i2c_temp = 0x98;
const i2c_als = 0xE8;
const i2c_accel = 0x38;
//----------------------------------------
//-- Configure I2C
@epall
epall / jenkins.plist
Created October 4, 2012 22:25
Jenkins slave launch agent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>jenkins</string>
<key>ProgramArguments</key>
<array>
--------------------
have_library: checking for PQconnectdb() in -lpq... -------------------- no
"gcc -o conftest -I/opt/chef/embedded/include/ruby-1.9.1/x86_64-linux -I/opt/chef/embedded/include/ruby-1.9.1/ruby/backward -I/opt/chef/embedded/include/ruby-1.9.1 -I. -I/opt/chef/embedded/include -I/usr/include/postgresql -L/opt/chef/embedded/lib -I/opt/chef/embedded/include -fPIC conftest.c -L. -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L/usr/lib/x86_64-linux-gnu -Wl,-R/usr/lib/x86_64-linux-gnu -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L. -Wl,-rpath /opt/chef/embedded/lib -L/opt/chef/embedded/lib -I/opt/chef/embedded/include -rdynamic -Wl,-export-dynamic -L/usr/lib -Wl,-R -Wl,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -lruby-static -lpq -lpthread -lrt -ldl -lcrypt -lm -lc"
/usr/lib/libpq.so: undefined reference to `SSL_CTX_use_certificate_chain_file@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_write@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference
epall@Everett$ ruby --1.9 -e 'require "mail"'
RegexpError: /.../n has a non escaped non ASCII character in non ASCII-8BIT script
Patterns at /Users/epall/.rvm/gems/jruby-head/gems/mail-2.3.0/lib/mail/patterns.rb:31
Mail at /Users/epall/.rvm/gems/jruby-head/gems/mail-2.3.0/lib/mail/patterns.rb:3
(root) at /Users/epall/.rvm/gems/jruby-head/gems/mail-2.3.0/lib/mail/patterns.rb:2
require at org/jruby/RubyKernel.java:970
require at /Users/epall/.rvm/rubies/jruby-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36
Mail at /Users/epall/.rvm/gems/jruby-head/gems/mail-2.3.0/lib/mail/patterns.rb:45
(root) at /Users/epall/.rvm/gems/jruby-head/gems/mail-2.3.0/lib/mail.rb:2
require at org/jruby/RubyKernel.java:970