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
include ActionView::Helpers # If you want to test from a Rails console | |
number_to_currency(12.34, :locale => :en) # => "$12.34" | |
number_to_currency(12.34, :locale => :ja) # => "12円" | |
number_to_currency(12.34, :locale => 'en-GB') # => "£12.34" |
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
set -g default-terminal "xterm-256color" # More colors | |
set-option -g xterm-keys on # Work more nicely with odd key combos (emacs) | |
set -g base-index 1 # Tabs start at '1', not '0' | |
set -s escape-time 0 # Faster activation | |
# Bind <C-q> to leader | |
# Make sure to update status-right to include your leader! | |
unbind C-b | |
set -g prefix C-q | |
bind-key q send-prefix |
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
#Include this method in your application_controller.rb | |
def self.expose(*variable_names) | |
variable_names.each do |variable_name| | |
define_method((variable_name.to_s+"=").to_sym) do |value| | |
@exposed ||= Hash.new | |
@exposed[variable_name]= value | |
end | |
private (variable_name.to_s+"=").to_sym | |
define_method(variable_name) do |
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
brew install riak | |
edit /usr/local/Cellar/riak/<riak version>/libexec/etc/app.config | |
change | |
{storage_backend, riak_kv_bitcask_backend}, | |
to | |
{storage_backend, riak_kv_eleveldb_backend}, | |
ulimit -n 1024 | |
riak start |
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
include Ripple::Document | |
property :custom_key, String | |
key_on :custom_key | |
before_save :set_key | |
def set_key | |
self[:custom_key] ||= "#{self.created_at.utc.to_s(:key)}-#{SecureRandom.hex(8)}" | |
self[:custom_key] | |
end | |
private :set_key |
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
module Ripple | |
module Document | |
module DynamicFinders | |
class << self | |
def included(base) | |
base.module_eval do | |
extend DynamicFindersClassMethods | |
end | |
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
class FasterCSV | |
def <<(row) | |
# make sure headers have been assigned | |
if header_row? and [Array, String].include? @use_headers.class | |
parse_headers # won't read data for Array or String | |
self << @headers if @write_headers | |
end | |
# Handle FasterCSV::Row objects and Hashes | |
row = case row |
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
namespace :b2b2dot0 do | |
namespace :magento do | |
desc "Imports some stuff from one place to another" | |
task :import_stuff => :environment do | |
benchmark = Benchmark.measure do | |
# The import stuff here | |
SomeStuff.import do |stuff| | |
stuff.do_something_more | |
end | |
end.real |
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 log(string) | |
string.split(/\n/).each do |line| | |
puts "[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] #{line}" | |
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
Riak::MapReduce.new(Ripple.client). | |
add(@bucket_to_filter, | |
[ | |
[:tokenize, "-", 1], #Note: 1 based index | |
[:between, start_time.to_s(:key), end_time.to_s(:key)] | |
]) |