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
class Modul # "module" is a keyword in ruby | |
attr_accessor :name, :size | |
def initialize(name, size=1) | |
@name = name | |
@size = size | |
end | |
def inspect | |
"#{name}(#{size})" | |
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
foo = %w{demo coda dome doom mode} | |
foo.each do |w| | |
if foo[0].bytes.sort == w.bytes.sort | |
puts w | |
end | |
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
// /Library/Widgets/World Clock.wdgt/WorldClock.js | |
{city:'Sakhalin', offset:660, timezone:'Asia/Vladivostok', id:"2119441"} | |
// /Library/Widgets/World Clock.wdgt/English.lproj/localizedStrings.js | |
localizedCityNames['Sakhalin'] = 'Sakhalin'; |
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
# /etc/ssh_config | |
ServerAliveInterval 100 |
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 fib n, dict = [] | |
if n < 2 | |
dict[0] = 1 | |
else | |
dict[n-1] = ( dict[n-2] || fib(n-1, dict).last ) + ( dict[n-3] || fib(n-2, dict).last ) | |
end | |
dict | |
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
# Move dock to the corner | |
defaults write com.apple.Dock pinning 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
1. Copy and paste this to Terminal.app: | |
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\ | |
LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local\ | |
-domain system -domain user | |
2. Relaunch Finder (Cmd+Option+Click on Finder icon and then Relaunch) |
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
class Activity < ActiveRecord::Base | |
# Activity#result is a boolean | |
end | |
# Let's say | |
Activity.all.pluck(:result) # => [false, true, false, false, false, true] | |
# How can I calculate the number of the false results before that true one? |
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
- http://tools.ietf.org/html/rfc2616#section-13 | |
- http://tomayko.com/writings/things-caches-do | |
- http://www.mnot.net/cache_docs/ |
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 'active_record' | |
require 'yaml' | |
require 'mysql' | |
require 'logger' | |
task :default => :migrate | |
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x" | |
task :migrate => :environment do | |
ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil ) |
OlderNewer