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
>> Date.current.beginning_of_day == Time.local(2013, 7, 25, 0, 0, 0) | |
Date.current.beginning_of_day == Time.local(2013, 7, 25, 0, 0, 0) | |
=> true | |
>> Date.current.end_of_day == Time.local(2013, 7, 25, 23, 59, 59) | |
Date.current.end_of_day == Time.local(2013, 7, 25, 23, 59, 59) | |
=> false |
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
When trying to deploy with capistrano: | |
executing "cd /path/to/app/releases/20130723160825 && cat .ruby-version && ruby -v && which bundle" | |
servers: ["x.x.x.x"] | |
[x.x.x.x] executing command | |
** [out :: x.x.x.x] ruby-1.9.3-p448 | |
** [out :: x.x.x.x] ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux] | |
** [out :: x.x.x.x] /usr/local/rvm/bin/bundle | |
command finished in 519ms | |
* executing "cd /path/to/app/releases/20130723160825 && bundle install --gemfile /path/to/app/releases/20130723160825/Gemfile --path /path/to/app/shared/bundle --deployment --binstubs --without development test" | |
servers: ["x.x.x.x"] |
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
<%= f.date_select :valid_until, | |
:use_month_names => (1..12).map { |m| sprintf('%02d', m.to_s) }, | |
:order => [:month, :year] %> |
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
Clemens is a freelancer with lots of experience in all things Ruby/Rails and the web in general. When not hacking on code, you'll probably find him working on his culinary skills, reading books about programming and health/fitness/nutrition or pretending to work on his PhD thesis in Marketing. |
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
de: | |
i18n: | |
transliterate: | |
rule: | |
À: A | |
Á: A | |
Â: A | |
Ã: A | |
Å: A | |
Ä: Ae |
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 Article | |
define_index do | |
indexes title | |
indexes abstract | |
indexes content | |
end | |
end | |
Article.search("foo", :fields => [:title, :abstract]) |
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 NewsPost < ActiveRecord::Base | |
self.table_name = 'newsposts' # old schema; model was called Newspost | |
has_many :picture_assignments, :as => :owner | |
has_many :pictures, :through => :picture_assignments | |
end | |
NewsPost.first.pictures | |
# generated SQL: | |
# SELECT `pictures`.* |
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
r = Redis.new(options) | |
# classic: | |
r.set('foo', 'bar') | |
r.get('foo') | |
r.sadd('baz', 1) | |
# etc. | |
# this could be cool: | |
k1 = r.key('foo') |
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
# download test.jpg from http://www.railway.at/test/test.jpg | |
# then run the following command | |
cp test.jpg test1.jpg && time mogrify -rotate "90<" -resize "2000x1500" test1.jpg | |
# if GraphicsMagick is installed, this would also be helpful: | |
cp test.jpg test1.jpg && time gm mogrify -rotate "90<" -resize "2000x1500" test1.jpg | |
# Be careful not to repeatedly run mogrify on the same file because it replaces the file | |
# so from the second time on it would be faster because the file is smaller. | |
# This is why the commands above work on copies rather than the original. |
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
# values in this case: | |
# - columns: 4 | |
# - rows: 3 | |
# - dimensions: an array containing two numbers (potentially floats due to mm to pixels conversion) | |
# - picture_paths: an array of already cropped pictures | |
# - target_path: the target path (obviously) | |
`montage -tile #{columns}x#{rows} -geometry #{dimensions.join('x')}+0+0 #{picture_paths.join(' ')} #{target_path}` |