I hereby claim:
- I am luisalima on github.
- I am luisalima (https://keybase.io/luisalima) on keybase.
- I have a public key ASDJhuwOZQX6RCcbovR-py-NVzwoYeO0El1x2XJD_RTspQo
To claim this, I am signing this object:
# without shoulda... tons of code :-) | |
it "should belong to person" do | |
Model.reflect_on_association(:person).macro.should == :belongs_to | |
end | |
# with shoulda... one-liner! | |
it{should belong_to(:person)} |
# updated from the original @ http://cheat.errtheblog.com/s/rspec_shoulda | |
# just a subset -- models -- is included here. I'll update this, and create cheat sheets for others, as I go along. | |
# I marked the ones I added with NEW and also added the links to the corresponding code, as I think it's useful. | |
# Any comments/corrections are welcome! | |
# ================= Data and Associations ======================= | |
# https://github.com/thoughtbot/shoulda-matchers/tree/master/lib/shoulda/matchers/active_record | |
it { should_not have_db_column(:admin).of_type(:boolean) } |
# == Schema Information | |
# | |
# Table name: Bla | |
# test :boolean | |
class Bla < ActiveRecord::Base | |
attr_accessible :test | |
before_validation :test_present | |
def test_present | |
puts "TEST PRESENT" |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
# swapping two integers, without using a temporary variable | |
a = 5 # 5 | |
b = 7 # 7 | |
a.to_s(2) # "101" | |
b.to_s(2) # "111" | |
a ^= b # a is now "010" | |
b ^= a # b is now "101" | |
a ^= b # a is now "111" |
# left shift operator is the equivalent of multiplying by a power of 2. | |
b = 1 | |
(b << 1).to_s(2) # "10", equivalent to multiplying by 2^1 | |
(b << 4).to_s(2) # "10000", equivalent to multiplying by 2^4 | |
# right shift operator is the equivalent to integer divisin by 2. | |
b = 32 | |
b.to_s(2) # "100000" | |
(b >> 1).to_s(2) # "10000", equivalent to dividing by 2 | |
(b>>3).to_s(2) # "100", equivalent to dividing by 2^3 |
Use `log` from handlebars v3 onwards: | |
http://stackoverflow.com/a/32218903 |
I hereby claim:
To claim this, I am signing this object:
#!/bin/bash | |
export HOSTNAME='***' | |
TOOLS="tmux" | |
COUNTRY="**" | |
SSID="***" | |
function change_hostname { | |
sudo sh -c "echo $HOSTNAME > /etc/hostname" | |
sudo sed -i "s/raspberrypi/$HOSTNAME/g" /etc/hosts |