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
# mongo_template.rb
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/prototype.js"
@jbowles
jbowles / monkey_patcher.rb
Created November 29, 2011 21:57 — forked from hopsoft/monkey_patcher.rb
Monkey Patcher
MONKEY_PATCHES = {}
module MonkeyPatcher
begin
errors = []
port = Mongo::Connection::DEFAULT_PORT
begin
db_conn = Mongo::Connection.new('host', port).db('db')
db_error = Mongo::Connection.new('host', port).db('db')
@jbowles
jbowles / string_build_rebuild.py
Created May 7, 2012 01:03
(Re)Build String to MultiValue Hash
#!/usr/bin/env python
def builder(string1,string2):
return string1 + ' ' + string2
def insert(string_list):
return [char +'-' for char in string_list]
def joiner(string_list):
return ''.join(x for x in string_list)
@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
@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 / 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 / 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 / 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 / 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 / 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"
]