This file contains hidden or 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 'faye/websocket' | |
| # Configuration: | |
| # | |
| # With rackup | |
| # map '/notifier' do | |
| # run Notifier.new | |
| # end | |
| # | |
| # With Rails, add this to config/routes.rb |
This file contains hidden or 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
| # PassiveRecord disables all of the mutable behaviors of a class that behaves like an ActiveRecord::Base | |
| module PassiveRecord | |
| module Base | |
| extend ActiveSupport::Concern | |
| module InstanceMethods | |
| def passive_record_benign_method(*args, &block) | |
| return false | |
| end | |
| end |
This file contains hidden or 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
| $ du -sh .git | |
| 260K .git |
This file contains hidden or 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
| # Bulk API design | |
| # | |
| # resources :posts | |
| class PostsController < ApplicationController | |
| before_filter :separate_bulk_ids | |
| # GET /posts/1 | |
| # params[:id] => 1 | |
| # params[:ids] => [ 1 ] |
This file contains hidden or 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
| module Enscoped | |
| def self.included(base) | |
| base.extend(ClassMethods) | |
| end | |
| module ClassMethods | |
| # Create one named scope from many named scopes. | |
| # |
This file contains hidden or 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
| # Playing with Thrift, Hbase, and Ruby (I created a table and added some values using Hbase shell earlier) | |
| irb > transport = Thrift::BufferedTransport.new(Thrift::Socket.new('localhost',9090)) | |
| => #<Thrift::BufferedTransport:0x10196c678 @transport=#<Thrift::Socket:0x10196c6a0 @timeout=nil, @port=9090, @handle=nil, @host="localhost", @desc="localhost:9090">, @index=0, @rbuf="", @wbuf=""> | |
| irb > transport.open | |
| => #<Socket:0x10196a030> | |
| irb > protocol = Thrift::BinaryProtocol.new(transport) | |
| => #<Thrift::BinaryProtocol:0x101964c98 @strict_read=true, @trans=#<Thrift::BufferedTransport:0x10196c678 @transport=#<Thrift::Socket:0x10196c6a0 @timeout=nil, @port=9090, @handle=#<Socket:0x10196a030>, @host="localhost", @desc="localhost:9090">, @index=0, @rbuf="", @wbuf="">, @strict_write=true> | |
| irb > client = Apache::Hadoop::Hbase::Thrift::Hbase::Client.new(protocol) | |
| => #<Apache::Hadoop::Hbase::Thrift::Hbase::Client:0x10195d448 @seqid=0, @oprot=#<Thrift::BinaryProtocol:0x101964c98 @strict_read=true, @trans=#<Thrift::Bu |
This file contains hidden or 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 gitget(uri) | |
| # We look for very specific links within the page like: | |
| # <a href="/raw/383785/5bcefcae03bbc40d6ce40591d93f278585e47950/example.rb">raw</a> | |
| raw_uri_pattern = /\<a href="(.+)"\>raw\<\/a\>/ | |
| begin | |
| # Load the referenced gist | |
| gist_html = open(uri).read | |
This file contains hidden or 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 localhost | |
| reverse_lookup "127.0.0.1" | |
| end |
This file contains hidden or 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
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: mongodb | |
| # Required-Start: $all | |
| # Required-Stop: $all | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: starts the mongodb data-store | |
| # Description: starts mongodb using start-stop-daemon |
This file contains hidden or 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 'rubygems' | |
| require 'active_support' | |
| class Foo | |
| def talk(arg) | |
| puts "talking about '#{arg}'" | |
| end | |
| end | |
| class Bar |