In Ruby 1.9, instance_eval calls the block the with receiver as the first argument: In Ruby 1.8, receiver.instance_eval(&block) calls block.call() In Ruby 1.9, receiver.instance_eval(&block) calls...
...block.call(receiver) This will blow up in your face in Ruby 1.9, where a lambda crashes when it is called with a different number of arguments: wrong number of arguments...
...cast strings into their respective types like this: Note.columns_hash['user_id'].type_cast('123') # => 123 Note.columns_hash['deleted'].type_cast('1') # => true Note.columns_hash['deleted'].type_cast('0') # => false
...Button Sound”; the “Power Save Audio” entry is usually grayed out, so this is 1 beep less than from above.) Right Down Tick Do it this way or your colleagues...
...will stand at your desk after the 12th beep, ready to smack you...
...s the default for switching input languages (i.e. keyboard layouts). If you use only 1 language/layout, you will not notice except for the key not working.
...ibus-setup (e.g. from a terminal). This will open a GUI dialog. In the 1st tab you should see "Next Input Method" followed by " space". Click the "..." button on the...
If you get a message like this: Jan 21 13:42:38 foobar syslogd: /var/log/authlog : no such file or directory But you are sure the file exists and it have...
...the correct permissions: # example for Solaris 9 -rw-r--r-- 1 root sys 8,0K 21. Jan 13:51 /var/log/authlog Then you perhaps have a trailing whitespace after /var/log/authlog in...
...with each option explained. About Hello, This site contains 29761 parsed manpages from sections 1 and 8 found in Ubuntu's manpage repository. A lot of heuristics were used to...
...will open an debugging IRB right away, like this: require File.dirname(__FILE__) + '/../config/boot' (rdb:1) _ Enter c to continue and reach your actual debugger call. Then, debug away.
...can feed it to block-taking methods by prefixing it with &: printer = method(:puts) [1, 2, 3].each(&printer) # will print one line per number
stats = {} ObjectSpace.each_object {|o| stats[o.class].nil? ? stats[o.class] = 0 : stats[o.class] += 1 }; stats => {String=>192038, Array=>67690, Time=>2667, Gem::Specification=>2665, Regexp=>491, Gem::Requirement=>16323...
Make sure the daemon is running. Error: Process /usr/lib/sflphone/sflphoned exited with status 1 This mean the last process didn't shut down properly and let a PID file...
...If you've shut sflphone down some seconds ago, you just have to wait 10 seconds and don't have to remove the pid file manually...
...and no special hardware. On our production frontend machines, SSL/TLS accounts for less than 1% of the CPU load, less than 10KB of memory per connection and less than...
Follow the instructions here. PRs at makandra/rubocop-config are welcome. Also check the issue tracker. RubyMine Since version 2017-1 RubyMine...
From Ubuntu 17, rbenv fails to install Ruby below 2.4 because of a mismatching OpenSSL dependency: it needs libssl1.0-dev for the installation process, but recent Ubuntus come with libssl-dev...
...instead of the current upstream version (which is 7). Install Ruby like this: # Ruby 1.8.7 apt install libssl1.0-dev # This will remove libssl-dev CONFIGURE_OPTS="--with-readline-dir=/usr/include/readline --with...
...With a block, it counts the number of elements yielding a truthy value. ary = [1, 2, 4, 2] ary.count #=> 4 ary.count(2) #=> 2 ary.count { |x| x...
The following snippet will convert a string with wildcards to a appropriate regexp, i.e. parse_wildcards("foobar") # => /\Afoo.bar\z/
execute "SET @pos := 0;" update " UPDATE pages SET position = ( SELECT @pos := @pos + 1 ) ORDER BY updated_at DESC...
...due to a conflict, for example), you may want to know the current commit. [1]\ Luckily, there is lots of useful stuff in the .git directory. Commit hash that you...
...Handy when you want to look at that branch's state of the file. [1] While git shows the commit when stopping at conflicts, for example, that information may have...
When your block takes an argument that should have an default, only in Ruby 1.9 you can say: block = lambda do |message, options = {}| # ... end If you are on Ruby 1.8.6...
...or 1.8.7 you must resort to the following workaround: block = lambda do |*args| message = args[0] options = args[1] || {}
...to a variable and further want to use it. Example: irb(main):001:0> 1 + 2 => 3 irb(main):002:0> _ => 3 irb(main):003:0> a...
...and many more you'll need when reading weird code. Regex $~ (last MatchData) $1 $2 $3 $4 (match groups from the last pattern match) $& (last matched string) $+ (last match...
...weekdays (Monday to Friday) between to given dates, try this: require 'date' a = Date.parse "11.04.2014" b = Date.parse "31.12.2014" (a..b).count {|date| (1..5).include?(date.wday...
...invert the pattern. @include texture(green, 34, 0); // color, texture-number, 0=inverted or 1=normal If you have ever done this manually you know how much pain this can...
...list all branches matching your query as input options for git checkout greckout ar 1) ar/cache-api-keys-1098 2) ar/add-categories-object-to-tv-show-1382...
...Import the icon-font by adding a file icon_font.sass: $icon-prefix: '-' @import "generated/icon_font_icons" $size: 1em * $line-height-base // only works with bootstrap .icon // adjust some styles display: inline-block
height: 1em font-size: $size -moz-osx-font-smoothing: grayscale -webkit-font-smoothing: antialiased text-rendering: auto font-style: normal font-weight: normal line-height: 1 // We can not...