This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using the Unicode Names package: http://www.rust-ci.org/huonw/unicode_names/doc/unicode_names/#cargo-enabled | |
//require macros... | |
// in Cargo.toml looks like this: | |
// [dependencies.unicode_names_macros] | |
// git = "https://github.com/huonw/unicode_names" | |
#![feature(phase)] | |
#[phase(plugin)] extern crate unicode_names_macros; |