Skip to content

Instantly share code, notes, and snippets.

#include <Servo.h>
#include <SPI.h>
#include <Ethernet.h>
#include <PusherClient.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
PusherClient client;
int ledPin = 13; // LED connected to digital pin 13
@ffaerber
ffaerber / filelist_to_hash.rb
Created April 22, 2012 15:48
filelist to hash
require "awesome_print"
require 'json'
list = [
"compass-config.rb",
"config.yaml",
"content/00_home/00_index.md",
"content/00_home/01_work.md",
"content/01_additional services/00_index.md",
"content/01_additional services/01_writing labs.md",
@ffaerber
ffaerber / Prioritize.rb
Created August 27, 2013 14:45
Prioritize things
positions = %w(
reset_password_mail
registration_mail
welcome_mail
newsletter
)
class Prioritize
def initialize(positions)
positions.each do |position|
1234136
1234149
1234162
1234175
1234188
1234201
1234214
1234227
1234239
1234252
"result" : [
{
"_id" : {
"year" : 2014,
"month" : 3,
"day" : 11,
"hour" : 23
},
"wh" : 1247628
},
{
"result" : [
{
"_id" : 22,
"wh" : 1246489
},
{
"_id" : 23,
"wh" : 1247302
},
{ "_id" : ObjectId( "53203555666661072f9f0500" ),
"meter_id" : 1,
"timestamp" : Date( 1394668740000 ),
"wh" : 1247628 }
db.measurements.aggregate([
{ "$match" : { "timestamp": { "$gte": ISODate('2014-03-12 00:00:00'), "$lt": ISODate('2014-03-12 23:59:59') } } },
{ "$project": {
"wh": 1,
"hourly": { "$hour": "$timestamp" }
}},
{ "$sort": { "hourly": 1 } },
{ "$group": {
"_id": "$hourly",
"firstReading": { "$first": "$wh" },
> db.measurements.find()
{ "_id" : ObjectId("53203553666661072f000000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:00:00Z"), "wh" : 1234136 }
{ "_id" : ObjectId("53203553666661072f010000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:01:00Z"), "wh" : 1234149 }
{ "_id" : ObjectId("53203553666661072f020000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:02:00Z"), "wh" : 1234162 }
{ "_id" : ObjectId("53203553666661072f030000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:03:00Z"), "wh" : 1234175 }
{ "_id" : ObjectId("53203553666661072f040000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:04:00Z"), "wh" : 1234188 }
{ "_id" : ObjectId("53203553666661072f050000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:05:00Z"), "wh" : 1234201 }
{ "_id" : ObjectId("53203553666661072f060000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:06:00Z"), "wh" : 1234214 }
{ "_id" : ObjectId("53203553666661072f070000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:07
@ffaerber
ffaerber / rubybuilt.rb
Created July 3, 2014 08:17
ruby build chef
include_recipe 'ruby_build'
file "/etc/gemrc" do
content <<-EOS
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
EOS
owner "root"
mode 0644