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
# put variable to alias | |
#put it out of quote | |
!sh -c 'git rebase -i HEAD~'$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
#If we have following code in model: | |
composed_of :temperature, :mapping => %w(celsius) | |
#Then our composition class can be this: | |
class Temperature | |
def initialize(celsius) | |
@celsius = celsius | |
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
render "shared/header", { :headline => "Welcome", :person => person } | |
# shared/header | |
<% if local_assigns.has_key? :headline %> | |
Headline: <%= headline %> | |
<% 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
# for with index | |
for value, index in list | |
console.log value, index | |
#jQuery each | |
$.each data, (i, line) -> |
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
# check if column exist | |
ActiveRecord::Base.connection.column_exists?(:table_name, :column_name) |
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
# it looks to `schema_migrations` table and check what migrations was already run | |
# after merge your code with migration if your migration has name e.g. 2015000000 | |
# and it used some old column name that already renamed in new migrations, this | |
# migration will crash | |
# file: 2015000000_old_migration | |
class OldMigration < ActiveRecord::Migration | |
def up | |
# trow Error, that column car_id doesn't exist |
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
h2[id="tagline" | |
class="small tagline"] = page_tagline |
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
# :includes delegates to :eager_loading or :preload | |
# :eager_loading - one big query | |
# :preload - few small queries | |
# get only polish adresses then preload all | |
User.joins(:addresses).where("addresses.country = ?", "Poland").preload(:addresses) | |
# SELECT "users".* FROM "users" | |
# INNER JOIN "addresses" ON "addresses"."user_id" = "users"."id" | |
# WHERE (addresses.country = 'Poland') |
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
# check if variables is set | |
if [[ $1 ]]; then | |
echo 'variable is set!' | |
else | |
echo 'ERROR: variable is not set!' | |
fi |
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
mkdir /ftpmount | |
# first install curlftpfs if it doesn't exist | |
curlftpfs -o allow_other user_name:password@ftpserver /ftpmount | |
# mount it permanently | |
# go to /etc/fstab and add command above | |
# it will be added automatically | |
# umount | |
umount /ftpmount |