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
To change two vertically split windows to horizonally split | |
^Wt^WK | |
Horizontally to vertically: | |
^Wt^WH | |
where ^W means "hit Ctrl-W". Explanations: | |
^Wt makes the first (topleft) window current | |
^WK moves the current window to full-width at the very top |
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
# Ruby's `retry` with steroids: | |
# | |
# - retry up to 5 times without waiting between them and retrying after any exception | |
# | |
# retry_upto(5) do ... end | |
# | |
# - retry up to 5 times, waiting 2 seconds between retries and retrying after any exception | |
# | |
# retry_upto(5, :wait => 2) do ... 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
# Ruby's `retry` with steroids: | |
# | |
# - retry up to 5 times without waiting between them and retrying after any exception | |
# | |
# retry_upto(5) do ... end | |
# | |
# - retry up to 5 times, waiting 2 seconds between retries and retrying after any exception | |
# | |
# retry_upto(5, :wait => 2) do ... 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
# When searching, you need to provide a latitude and longitude | |
# in the query so that | |
# these variables are accessible on the server. | |
Restaurant.search_tank("tasty", | |
:var0 => 47.689948, | |
:var1 => -122.363684, | |
# And we'll return all results sorted by distance | |
:function => 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
class Product < ActiveRecord::Base | |
include Tanker | |
tankit 'my_index' do | |
indexes :name | |
indexes :description | |
end | |
after_save :update_tank_indexes | |
after_destroy :delete_tank_indexes |
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
#make a new branch that tracks remote branche | |
git branch --set-upstream foo upstream/foo | |
#list the files modified on the last 10 commits and filter only spec files | |
git diff --name-only HEAD~10 | egrep _spec\.rb | |
#difference between the state of the file from 3 commits in the past | |
git diff HEAD~3 -- app/views/topics/merges/_new.html.haml | |
#run specs modified on the last 10 commits |
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 notify | |
@user = User.find(params[:id]) | |
if @user.is_expert? | |
@topic.experts << @user | |
end | |
@user.notify_about_topic!(@topic) | |
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
it 'should notify user and add to leader board if user is an expert' do | |
user = mock_model(User, :is_expert? => true) | |
topic = mock_model(Topic, :id => 1) | |
collection = mock('col') | |
collection.should_receive(:<<).with(user) | |
topic.should_receive(:experts).and_return(collection) | |
user.should_receive(:notify_about_topic!).with(topic) | |
User.should_receive(:find).with(1).and_return(user) | |
Topic.should_receive(:find).with(1).and_return(topic) | |
post :notify, :topic_id => topic.id, :id => 1, :format => 'js' |
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 Processors | |
class ImagesProcessor | |
def initialize(queue, image_cache_options = {}) | |
@queue = queue || {} | |
@image_cache = Processors::ImageCache.new(image_cache_options) | |
@logger = CSV_PROCESSOR_LOG | |
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
#!/usr/bin/env ruby | |
## Taken from: http://snippets.dzone.com/posts/show/4935 | |
# | |
# Usage: | |
# a = AmazonS3Asset.new | |
# a.copy_over_bucket("myapp_production", "myapp_production") | |
require 'aws/s3' | |
require 'mechanize' | |
require 'logger' |