Pretty logging
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"| # Title is an active record model | |
| titles = Title.all.each { |title| title.some_attribute = Random.new_seed }.sort_by { |title| title.some_attribute } |
| # SELECT * | |
| # FROM people | |
| # WHERE name = 'francais' collate utf8_bin; | |
| # | |
| # This is the active record equivalent of MySQL query above. | |
| Person.where("name = :name collate utf8_bin", name: "francis") |
| Week.where{ matches_count.eq 0 } | |
| # Week Load (1.0ms) SELECT "weeks".* FROM "weeks" | |
| # => #<ActiveRecord::QueryMethods::WhereChain:0x007fee87784fd8 @scope=#<ActiveRecord::Relation [#<Week id: 6, created_at: "2015-07-24 09:39:24", updated_at: "2015-07-24 09:39:24", matches_count: 2>, #<Week id: 1, created_at: "2015-07-24 09:39:24", updated_at: "2015-07-24 09:39:24", matches_count: 2>, #<Week id: 5, created_at: "2015-07-24 09:39:24", updated_at: "2015-07-24 09:39:24", matches_count: 2>, #<Week id: 3, created_at: "2015-07-24 09:39:24", updated_at: "2015-07-24 09:39:24", matches_count: 2>, #<Week id: 4, created_at: "2015-07-24 09:39:24", updated_at: "2015-07-24 09:39:24", matches_count: 2>, #<Week id: 2, created_at: "2015-07-24 09:39:24", updated_at: "2015-07-24 09:39:24", matches_count: 2>]>> |
| # thanks to tanaydin < github.com/tanaydin > | |
| # set locales for system | |
| export LANGUAGE="en_US:en" | |
| export LC_ALL="en_US.UTF-8" | |
| sudo locale-gen en.UTF-8 | |
| sudo dpkg-reconfigure locales | |
| echo "LANGUAGE=\"en_US:en\"" | sudo tee --append /etc/default/locale | |
| echo "LC_ALL=\"en_US.UTF-8\"" | sudo tee --append /etc/default/locale |
| class User < ActiveRecord::Base | |
| validates_confirmation_of :password, message: "custom message." | |
| # ... | |
| end |
| mysqladmin variables | grep socket |
| # You can your favorite code editor. | |
| # I love sublime :) | |
| subl `ls db/migrate/*.rb | tail -n 1` |
| "hello world".upcase | |
| # => "HELLO WORLD" | |
| nil.upcase | |
| # NoMethodError: undefined method `upcase' for nil:NilClass | |
| # "gem install activesupport" if it is not installed | |
| require 'active_support/core_ext/object/blank' | |
| nil.presence && nil.upcase |
Pretty logging
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"Collection of frontend web development tools & documents