Skip to content

Instantly share code, notes, and snippets.

still doing homework....

josh bowles jbowles

still doing homework....
Block or report user

Report or block jbowles

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jbowles / multi_batch_producer-kafka.rb
Created Aug 25, 2012
Batch methods for testing kafka producer with ruby gem
View multi_batch_producer-kafka.rb
require 'kafka'
def batch(m1, m2, m3)
producer =
producer.batch do |msgs|
puts "batching multi-message..."
msgs <<"#{m1} ONE")
msgs <<"#{m2} TWO")
msgs <<"#{m3} THREE")
jbowles / consumer_loop-kakfa.rb
Created Aug 25, 2012
Simple looped consumer for Kafka ruby gem
View consumer_loop-kakfa.rb
require 'kafka'
consumer =
consumer.loop do |message|
puts "received"
message.each do |m|
#puts "Payload: #{m.payload}, Magic: #{m.magic}, Checksum: #{m.checksum}"
puts m.payload
jbowles /
Created Sep 6, 2012
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 = 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 / new_class.rb
Created Sep 6, 2012
NewClass for the learntoprogram course at One on One
View new_class.rb
class NewClass
def self.tell_me_something
def self.randomize_select
list = [
jbowles /
Created Sep 6, 2012
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'
def self.json_encoder


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


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.


jbowles /
Created Nov 23, 2012
Horizon TFSG Step, Formula, Hub First Draft
;; Clojure Step
(declare step check-valid base-complete check-user)
(defn one-of [coll]
(if (seq coll)
[(rand-nth coll)]))
(defn step[] (concat (check-valid) (base-complete) (check-user)))
(defn check-valid[] (one-of [0 1]))
jbowles /
Created Nov 23, 2012
Horizon Transaction First Draft

The :hub is the transaction and/or application (more on this later). Each :node is wrapper around a Hero Formula responsible for passing the non-boolean values to the :hub, but it also returns a boolean. Each camel-cased line inside the :node parentheses is a Hero :formula and the values in quotes are the return values of a Formula's :step. Formula.step is the only thing responsible for changing state.

The following is in Clojure but it should be interpretable from a Ruby perspective; it's the relations that matter here not the syntax.

[:hub ;; begin transaction
 ( ;; begin set of Nodes
jbowles /
Created Nov 23, 2012
Horizon Transactional Grammar First Draft
(def simple-grammar
  {:hub [:node-unique-accept :node-unique-check :node-unique-persist]
   :node-unique-accept [:ParseUrl :ParseParams :AcceptBool]
   :node-unique-check [:FormatRead :FormatCheckBool]
   :node-unique-persist [:SaveOrUpdate :PersistBool]
   :ParseUrl #{"http, www,, /blog/seo-glossary-url-definitions/" "http, jbowles," "http, www,, /~mckeeman/cs48/mxcom/doc, FiniteAutomata.pdf" "https, www,, categories/state_machines.html"}
   :ParseParams #{"program address city state zip" "fname lname school program address city state zip" "fname lname school state zip" "fname lname city state zip"}
   :AcceptBool #{"0" "1"} ;;[] (one-of [0 1])
   :FormatRead #{"UTF8" "other stuff"}
jbowles / example_nlp_with_treat.rb
Created Feb 22, 2013
A quick look at what can be done with treat
View example_nlp_with_treat.rb
require 'treat'
include Treat::Core::DSL
doc1 = document('')
doc2 = document('')
[d1,d2].apply(:chunk, :segment, :tokenize)
#Check it!
You can’t perform that action at this time.