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
# To show hot code uploading, we first need to build a simple phoenix project so we can see it happen in real time. | |
# Start by making a new phoenix project | |
$ mix phoenix.new hotcode | |
# Go into the directory | |
$ cd hotcode | |
# Add exrm dependency to mix.exs file | |
{:exrm, "~> 1.0.3"} |
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
Show hidden characters
{ | |
"disallowSpaceAfterKeywords": [ | |
"if", | |
"for", | |
"while", | |
"switch", | |
"catch" | |
], | |
"requireCurlyBraces": [ | |
"if", |
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
:cd ~/code/ | |
:set wildmenu | |
:colorscheme slate | |
:set tabstop=2 | |
:set shiftwidth=2 | |
:set expandtab | |
:set incsearch |
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
rake aborted! | |
uninitialized constant SomeModel |
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
raise variable.to_yaml |
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 ranges(sequence) | |
return sequence.to_s if sequence.is_a? Numeric | |
sequence.inject([]) { |result, n| | |
if result.empty? | |
result << n | |
elsif result.last.is_a?(Numeric) && (result.last - n).abs == 1 | |
result[-1] = [result.last, n] | |
result | |
elsif result.last[1] - result.last[0] == n - result.last[1] |
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
require 'benchmark' | |
require 'test/unit' | |
def morse_to_eng(morse) | |
a = " ET_IA_NM____SU_RW____DK_GO#{'_'*13}HV_F_____L__PJ#{'_'*13}BX_CY____ZQ" | |
morse.gsub(/[.-]/, '.' => 1, '-' => 2).gsub(/\d+ ?| /) { |l| a[l.to_i(3)] } | |
end | |
class TestMorseToEng < Test::Unit::TestCase | |
def test_simple |
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
people.index_by(&:login) | |
=> { "nextangle" => <Person ...>, "chade-" => <Person ...>, ...} | |
people.index_by { |person| "#{person.first_name} #{person.last_name}" } | |
=> { "Chade- Fowlersburg-e" => <Person ...>, "David Heinemeier Hansson" => <Person ...>, ...} |
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
%w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase } | |
# => {'foo' => 'FOO', 'bar' => 'BAR'} |
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
user = FactoryGirl.create(:user) | |
user.confirm! # necessary if your users have been marked as :confirmable | |
login_as user, scope: :user |
NewerOlder