Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jbowles's full-sized avatar
💭
working on it...

josh bowles jbowles

💭
working on it...
View GitHub Profile
@jbowles
jbowles / horizon_first_draft.md
Created November 23, 2012 14:54
Horizon First Draft

Horizon

Transactional system that defines a set of primitive and composable concepts. It is inspired by Finite State Grammars.

ABSTRACT

Finite State Transactional Grammar. I don't know if I made up this term, so I won't claim to have invented this, but I'm running with it. What is sketched here is a transactional system inspired by finite state machines, finite state grammars, rule engines, map-reduce algorithms, functional programming (namely Clojure and LISP), business intelligence, and the rubygem Hero.

Hub

@jbowles
jbowles / bad_config.ru
Created September 6, 2012 16:58
Bad web server file example for learntoprogram course at One on One
require File.join(File.dirname(__FILE__), 'lib','new_class.rb')
has_many :hadoop_logs
def self.twitter_creds
tconfig_file = Rails.root.join 'config', 'twitter_oauth.yml'
NimbleTwitter.twitter_config(NimbleTwitter.dev_twitter("#{tconfig_file}"))
end
def self.json_encoder
Yajl::Encoder.new
@jbowles
jbowles / config.ru
Created September 6, 2012 16:27
New app server with a class for leartoprogram course at One on One
require File.join(File.dirname(__FILE__), 'lib','new_class.rb')
nc = NewClass
tell_me = NewClass.tell_me_something
rs = nc.randomize_select
app = Proc.new do |env|
response = []
response << 200
response << { 'Content-Type' => 'text/plain'}
response << ["Here is our class: #{nc}.\n Here is our method call from the class: #{tell_me}.\n And check this out: #{rs}"]
@jbowles
jbowles / new_class.rb
Created September 6, 2012 16:27
NewClass for the learntoprogram course at One on One
class NewClass
def self.tell_me_something
"whatup!"
end
def self.randomize_select
list = [
"one",
"two",
"three"
]
@jbowles
jbowles / consumer_loop-kakfa.rb
Created August 25, 2012 03:29
Simple looped consumer for Kafka ruby gem
require 'kafka'
consumer = Kafka::Consumer.new
consumer.loop do |message|
puts "received"
message.each do |m|
#puts "Payload: #{m.payload}, Magic: #{m.magic}, Checksum: #{m.checksum}"
puts m.payload
end
end
@jbowles
jbowles / multi_batch_producer-kafka.rb
Created August 25, 2012 03:27
Batch methods for testing kafka producer with ruby gem
require 'kafka'
def batch(m1, m2, m3)
producer = Kafka::Producer.new
producer.batch do |msgs|
puts "batching multi-message..."
msgs << Kafka::Message.new("#{m1} ONE")
msgs << Kafka::Message.new("#{m2} TWO")
msgs << Kafka::Message.new("#{m3} THREE")
end
@jbowles
jbowles / digger.rb
Created June 19, 2012 20:21
Goldmine collections in MongoDb
# Use case for goldmine:
# the pivoting functionality of Goldmine#dig allows you to easily mine data
# from Mongo collections
require 'goldmine'
require 'mongo'
require 'yajl'
class Digger
# Convenience for connecting to MongoDB database instance on localhost
@jbowles
jbowles / node_centos_install
Created June 12, 2012 17:20
Install Node.js on CentOS
# this is a work in progress!!
######################################################
# I'm on a CentOS dev VM provided by my company #
######################################################
#uname -a
#Linux ------- 2.6.18-128.el5 ----- x86_64 x86_64 x86_64 GNU/Linux
# OR
#cat /proc/version
#Linux version 2.6.18-128.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)) ----
@jbowles
jbowles / jambda.js
Created May 28, 2012 17:20
trying to get node lambdas/anons down
var first = function(){return 'first';},
second = function(){return 'second';},
func_one = function(someFunction, someValue){someFunction(someValue);},
func_two = function(anotherFunction, anotherValue){anotherFunction(anotherValue);};
function say(word) {console.log(word);}
function speak(anotherWord) {console.log(anotherWord);}
/*
* run the two functions above
@jbowles
jbowles / lamba.rb
Created May 28, 2012 16:52
basic ruby lambda call
def func_one
func_one = lambda do
puts "lambda_one"
end
#func_one.call
end
def func_two
func_two = lambda do
puts "lambda_two"
end