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(pbstream). | |
| -export([load/1, keys/0, bucket/0, map/3, pb_link/0, pb_link/2]). | |
| -define(QUERY, [{map, {modfun, riak_kv_mapreduce, map_object_value}, <<"filter_notfound">>, true}]). | |
| load(HowMany) -> | |
| lists:foreach(fun(Index) -> | |
| BIndex = list_to_binary(integer_to_list(Index)), | |
| RObj = riakc_obj:new(<<"examples">>, <<"key",BIndex/binary>>, <<"Value ",BIndex/binary>>), |
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 'ripple/associations/proxy' | |
| require 'ripple/associations/one' | |
| module Ripple | |
| module Associations | |
| class OneKeyProxy < Proxy | |
| include One | |
| def replace(doc) | |
| @reflection.verify_type!(doc, owner) |
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 'riak/client/http_backend' | |
| require 'riak/failed_request' | |
| module Riak | |
| class Client | |
| # Uses the Ruby standard library Net::HTTP to connect to Riak. | |
| # Conforms to the Riak::Client::HTTPBackend interface. | |
| class NetHTTPTimeoutBackend < HTTPBackend | |
| def self.configured? | |
| begin |
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 'riak' | |
| class RiakCache | |
| def initialize | |
| @client = Riak::Client.new(:pb_port => 8081, :protocol => :pbc) | |
| @bucket = @client.bucket("riakcache") | |
| end | |
| def read(key) |
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
| it "returns the list of possible industries for this account" do | |
| fake_industries = ['Deforester', 'Sludge Distillery'] # Captain Planet hates these | |
| @cavs_api.stub(:industries).and_return(fake_industries) | |
| estimator.industries.should eq(fake_industries) | |
| 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
| require 'mkmf' | |
| have_header('ruby.h') or missing('ruby.h') | |
| dir_config("ivar") | |
| create_makefile("ivar") |
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
| # spec/dummy/config/application.rb | |
| ENV['BUNDLE_GEMFILE'] = File.expand_path('../../../../Gemfile', __FILE__) | |
| require 'rubygems' | |
| require 'bundler' | |
| Bundler.setup | |
| $:.unshift File.expand_path('../../../../lib', __FILE__) |
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
| # Set Apple Terminal.app resume directory (OS X Lion feature) | |
| if [[ $TERM_PROGRAM == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]] { | |
| # function must be named chpwd so when new tab is opened it will go to the | |
| # current working directory | |
| function chpwd { | |
| local SEARCH=' ' | |
| local REPLACE='%20' | |
| local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}" | |
| printf '\e]7;%s\a' "$PWD_URL" | |
| } |
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
| # after pasting the class in speaker.rb into irb, run the following, | |
| # edit to your liking... | |
| @speaker = Speaker.new | |
| # other voices can be found at | |
| # http://www.gabrielserafini.com/blog/2008/08/19/mac-os-x-voices-for-using-with-the-say-command/ | |
| @speaker.voice = 'Kathy' | |
| @speaker.what = %[what should i say here?] |
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
| # per sean cribb's suggestion some time ago | |
| User.new.becomes(Super::User) # thanks Rails :) | |
| # below not needed, for reference | |
| User = Class.new(ActiveRecord::Base) | |
| class Super::User < ::User | |
| def self.wrap(user) |