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
CSV_DATA = <<~TEXT | |
invoice_id,invoice_number | |
48010,10172 | |
48086,10262 | |
48106,10320 | |
48107,10275 | |
48165,10438 | |
48193,10393 | |
48194,10447 | |
48218,10477 |
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 Avia::Kiwi | |
class CallbacksProcessService | |
UndefinedStatusError = Class.new(StandardError) | |
attr_reader :params, :order | |
def initialize(params) | |
@params = params | |
@order = Avia::Kiwi::Order.find_by!(kiwi_bid: params[:bid]) |
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
Scripting Guake | |
Another great thing about Guake is that it is scriptable. I work on projects where I need 10 or more tabs to start everything up. That is just a click / command away with a simple Guake script. Here's an example that I'm using for a project: | |
#!/bin/sh | |
# open project notes | |
guake -e "cd ~/Dropbox/projects/project1" -r notes; | |
guake -e "vim" |
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
Here is another possible solution, using the resolve attribute of the $stateProvider or the $routeProvider. Example with $stateProvider: | |
.config(["$stateProvider", function ($stateProvider) { | |
$stateProvider | |
.state("forbidden", { | |
/* ... */ | |
}) |
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
All: | |
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Newname'; GIT_AUTHOR_EMAIL='new@email'; GIT_COMMITTER_NAME='Newname'; GIT_COMMITTER_EMAIL='new@email';" HEAD | |
Last: | |
git commit --amend --author "New Author Name <email@address.com>" |
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 ClearbitManager | |
PROSPECTOR_COUNT = 20 | |
COLLEGE_RECRUITER_TITLES = [ | |
'university recruiter', | |
'university relations', | |
'campus recruiter', | |
'college recruiter', | |
'head of graduate recruitment', |
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
path = ARGV[0] | |
ext = ["mp3"].join(",") | |
Dir.chdir(path) do | |
files = Dir.glob("*.{#{ext}}").shuffle! | |
files.each_with_index do |name, i| | |
i += 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
>> require "benchmark" | |
>> require "set" | |
>> array = ["a", -3.14, 0, []] | |
>> set = array.to_set | |
>> Benchmark.bm do |bench| | |
>> bench.report("array:") do | |
>> 1000.times { array.include? -3.14 } | |
>> 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 "responds with JSON" do | |
my_model = stub_model(MyModel,:save=>true) | |
MyModel.stub(:new).with({'these' => 'params'}) { my_model } | |
post :create, :my_model => {'these' => 'params'}, :format => :json | |
response.body.should == my_model.to_json | |
end |