Skip to content

Instantly share code, notes, and snippets.

View vanstee's full-sized avatar
💭
🛠

Patrick Van Stee vanstee

💭
🛠
View GitHub Profile
require 'blather/client'
setup 'hello@highgroove.com', '******', 'talk.google.com'
message :chat?, :body do |m|
write_to_stream "I am a robot!"
end
class EventsController < AdminController
def index
@days_with_events = Events.all.map(&:to_days).flatten.uniq
end
end
class Event < ActiveRecord::Base
def to_days
(started_at.to_date..ended_at.to_date).to_a
end
....
requirements = scoped_requirements_for_index_or_export.page(page).per(params[:per_page]).all
requirements.map(&:id) #apparently makes this work....
logger.debug "DEBUG: Requirement: #{@requirement.id}"
logger.debug "DEBUG: Last Requirement: #{requirements.last.id}"
if requirements.last.id == @requirement.id and requirements.num_pages != page
....
require 'rubygems'
require 'bundler'
Bundler.require
Ripple.client = Riak::Client.new(:host => "#{HOST}")
class Stat
include Ripple::Document
property :message, String
end
// Format for Stat objects (in json)
{
"token": "cbbae92d897f244cf65104a574fb60afdf000ddb",
"timestamp": 1316134227,
"v": 2,
"employee_range": "Enterprise",
"company_size": "Enterprise",
"revenue_range": "Over $5B",
"ip": 219025168,
# Input - Lunch Records
# { "date": "10-25-2011", "tasty": true, "food": "pizza", "restaurant": "Antico Pizza" }
# { "date": "10-24-2011", "tasty": true, "food": "tacos", "restaurant": "Taqueria del Sol" }
# { "date": "10-23-2011", "tasty": false, "food": "wings", "restaurant": "Wing Nuts" }
# { "date": "10-22-2011", "tasty": true, "food": "sandwiches", "restaurant": "Super Pan" }
# { "date": "10-22-2011", "tasty": true, "food": "pizza", "restaurant": "Fellini's Pizza" }
class TastyMapper < Wukong::Streamer::LineStreamer
def process(line)
lunch = JSON.parse(line)
grouped_sessions = self.values.map do |token, requests|
requests_by_time = requests.sort_by { |r| r[:timestamp] }
previous_timestamp = nil
sessions_by_time = requests_in_order.chunk do |r|
r[:timestamp] != previous_timestamp
end.map(&:last)
sessions_by_user = sessions_by_time.map do |requests|
requests.group_by { |r| r[:user_agent] }.values
require 'formula'
class Thrift < Formula
homepage 'http://incubator.apache.org/thrift/'
head 'http://svn.apache.org/repos/asf/incubator/thrift/trunk'
url 'http://archive.apache.org/dist/incubator/thrift/0.5.0-incubating/thrift-0.5.0.tar.gz'
md5 '14c97adefb4efc209285f63b4c7f51f2'
depends_on 'boost'
@vanstee
vanstee / env.sample.js
Created December 29, 2011 21:32 — forked from jmreidy/env.sample.js
Pivotal to Sprintly importer
module.exports = {
pivotal: {
TOKEN: 'TOKEN'
PID: 'PID',
},
sprintly: {
USER: "USER_EMAIL",
ID: 'PRODUCT_ID',
KEY: 'API_KEY'
},
message :chat? do |message|
say message.from, "Oh hai!"
end