Skip to content

Instantly share code, notes, and snippets.

@tahnok
tahnok / example.rb
Created June 5, 2012 19:38
Default hash behaviour
> a = Hash.new([])
=> {}
> a[:one]
=> []
> a[:one] << "item"
=> ["item"]
> a[:one]
=> ["item"]
> a => {} #WAT???
@tahnok
tahnok / gist:3232168
Created August 2, 2012 01:11
Dashboard demo
int potPin1 = 0; // select the input pin for the potentiometer
int potPin2 = 1; // select the input pin for the potentiometer
int potPin3 = 2; // select the input pin for the potentiometer
int val1 = 0; // variable to store the value coming from the sensor
int val2 = 0; // variable to store the value coming from the sensor
int val3 = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
@tahnok
tahnok / gist:3232179
Created August 2, 2012 01:11
Dashboard demo 2: electric boogaloo
require 'serialport'
require 'faraday'
require 'json'
sp = SerialPort.new("/dev/tty.usbmodemfa131", 9600, 8, 1, SerialPort::NONE)
def post(widget, value)
Faraday.post("http://192.168.10.75:3000/widgets/#{widget}") do |req|
req.headers['Content-Type'] = 'application/json'
req.body = {auth_token: '60b3d4dd2194e29fa045736e76995cf6', value: value.to_i}.to_json.to_s
@tahnok
tahnok / gist:3315290
Created August 10, 2012 16:12
xorg.conf for rotate mk802
Section "Device"
Identifier "Card0"
Driver "fbdev"
Option "Rotate" "CW"
EndSection

Dashing!

A handsome dashboard framework solution

Introduction

Dashing is a framework for building web-based dashboards.

Features:

<h1 data-bind="title"></h1>
<h3 data-bind="text"></h3>
class Dashing.SweetWidget extends Dashing.Widget
constructor: ->
super
@set('attr', 'wooo')
onData: (data) ->
super
@set('cool_thing', data.massage.split(',')[2]
$text_value-color: #fff;
$text_title-color: lighten($widget-text-color, 30%);
.widget-text {
.title {color: $text_title-color;}
.p { color: $text_value-color;}
}
# :first_in sets how long it takes before the job is first run. In this case, it is run immediately
SCHEDULER.every '1m', :first_in => 0 do |job|
send_event('widget_id', {text: "I am #{%w(happy sad hungry).sample}"})
end
curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "value": 100 }' http://localhost:3000/widgets/synergy