Found it the hard way.
Improper/misleading:
true or true ? "yes" : "no" => true
the above is basically the same as this:
true or (true ? "yes" : "no") => true
The proper way:
true || true ? "yes" : "no" => "yes"
Found it the hard way.
Improper/misleading:
true or true ? "yes" : "no" => true
the above is basically the same as this:
true or (true ? "yes" : "no") => true
The proper way:
true || true ? "yes" : "no" => "yes"
Uh... pretty terrible and silly. Classic zombie movies are the way to go. This is not.
0.3This movie is actually quite bad, but it has Arnie in it! Guess that makes it a must see, even though he sure looks like a "grandpa" rather than a super-hero saving the world.
0.3Czarny czwartek. Janek Wisniewski padl (2011)
2013-05-20 23:22Very important film, showing dark pages from the Poland's history under the communist regime.
0.3Very important movie for Polish hip-hop, showing the story of one of the most famous lead rappers of all time in Poland. Really well made (as far as Polish movies are concerned).
0.3The Hobbit: There and Back Again (2012)
2013-05-10 23:39Wow... It certainly does live up to the expectations set by the original LOTR trilogy. Cant' wait to see the other two parts!
0.3Seems like it’s not so straightforward. Here’s the excerpt from my config/deploy.rb:
require "bundler/capistrano" set :bundle_dir, "" # install into "system" gems set :bundle_flags, "--quiet" # no verbose output set :bundle_without, [] # bundle all gems (even dev & test)
Maybe someone finds it helpful.
I did the recommended upgrade of my current p180 to the new p290 using rvm:
$ rvm upgrade ruby-1.9.2-p180 ruby-1.9.2-p290
First annoyance – moving gems from one gemset to the new one took over 40 minutes. Have really no idea why.
But after it was done, whenever I tried to run ‘gem’ or ‘rake’ or ‘bundle’ I got:
Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/guard-0.8.1.gemspec]: invalid date format in specification: "2011-09-29 00:00:00.000000000Z" Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/json-1.6.1.gemspec]: invalid date format in specification: "2011-09-18 0 0:00:00.000000000Z" Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/heroku-2.8.4.gemspec]: invalid date format in specification: "2011-09-23 00:00:00.000000000Z" Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/guard-0.8.4.gemspec]: invalid date format in specification: "2011-10-03 00:00:00.000000000Z" Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/multi_xml-0.4.0.gemspec]: invalid date format in specification: "2011-09 -06 00:00:00.000000000Z" Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/heroku-2.8.1.gemspec]: invalid date format in specification: "2011-09-21 00:00:00.000000000Z" Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/metrical-0.0.7.gemspec]: invalid date format in specification: "2011-09- 11 00:00:00.000000000Z" ... and so on...
The above is another manifestation of the YAML engine switch from Syck to Psych and all of the incompatibilities it has brought. The problem is that now you have to reinstall all of your gems, because all installed gems have wrong gemspec specification. D’oh.
I fixed it by running:
$ rvm gemset empty
And then bundling in each project…
$ bundle
Completely bad code follows, beware.
Silent error in Ruby 1.8.7:
x = [:a, :b] => [:a, :b] x.slice!(:a) => nil x => [:a, :b]
Explicit error (resulting in a failing test) in Ruby 1.9.2:
x = [:a, :b] => [:a, :b] x.slice!(:a) TypeError: can't convert Symbol into Integer
Just yet another incompatibility, but for the better!
You write specs for your javascript, right? If not, you really should.
jasmine-headless-webkit really helps with that. guard-jasmine-headless-webkit makes it all even more enjoyable, although there’s one caveat – it’s not so easy to set it all up.
There is a great guide for that, but it lacks some important details on running guard-jasmine-headless-webkit without graphical interface (X server).
Assuming you already have Xvfb installed, execute this command to run Xvfb in the background:
Xvfb :0 -screen 0 1024x768x24 > /dev/null 2>&1 &
And then you need to setup the DISPLAY shell variable in order for guard-jasmine-headless-webkit to automatically connect to our virtual frame buffer. Here’s the excerpt from my .bash_profile (it first checks if there is Xvfb running on display :0 and only then sets the DISPLAY variable):
xdpyinfo -display :0 &>/dev/null && export DISPLAY=:0
I needed to output a Hash as a nested HTML structure. Googling didn’t find any satisfactory results, so I decided to roll my own. UL/LI tags seemed like the best choice. It was a nice exercise in recursion.
The result is a function, which outputs a nicely indented HTML. Note, however, that it’s a very basic solution. It doesn’t cope well with anything other than Strings and Numbers (unless your objects support a nice to_s method).
# Prints nested Hash as a nested <ul> and <li> tags
# - keys are wrapped in <strong> tags
# - values are wrapped in <span> tags
def HashToHTML(hash, opts = {})
return if !hash.is_a?(Hash)
indent_level = opts.fetch(:indent_level) { 0 }
out = " " * indent_level + "<ul>\n"
hash.each do |key, value|
out += " " * (indent_level + 2) + "<li><strong>#{key}:</strong>"
if value.is_a?(Hash)
out += "\n" + HashToHTML(value, :indent_level => indent_level + 2) + " " * (indent_level + 2) + "</li>\n"
else
out += " <span>#{value}</span></li>\n"
end
end
out += " " * indent_level + "</ul>\n"
end
Who knows, maybe someone somewhere finds it useful.
Update: much more concise solution by Piotr Szotkowski.
It was a small but important patch to the i18n gem‘s pluralization rules for the Polish language.
Really made my day. Thanks Krzysztof!
{}.fetch(:a) { 0 }
=> 0
I think it’s really beautiful. Oh, and it’s Ruby, btw.
Update: this is even better:
{}.fetch(:a) { {} }
=> {}
This is simply amazing:
$ g pull Already up-to-date. $ g co edge Switched to branch 'edge' == AddFileTypeToSong: migrating ============================================== -- add_column(:songs, :file_type, :string) -> 0.0048s == AddFileTypeToSong: migrated (0.1380s) ===================================== $ g rebase master Current branch edge is up to date. $ g co master Switched to branch 'master' == AddFileTypeToSong: reverting ============================================== -- remove_column(:songs, :file_type) -> 0.1674s == AddFileTypeToSong: reverted (0.1679s) =========================
Oh, and it will bundle automatically for you as well, so don’t hesitate and hookup your Rails project!
Back at the day I used to recommend dual core processors to my friends precisely becase of one reason:
Since there are not that many applications at the moment utilizing the power of two cores, the best use case for them is this: when your application hangs up it sometimes eats up to 100% of your CPU and you you cannot even move your mouse or click anywhere simply because there is not enough processing power left. Now with two cores, when your application hangs up like that, you still have that second core sitting idle in the background and you can quickly bring up task manager and kill the misbehaving app.
Nowadays, when by far the most used and abused application is the web browser, and when each tab is its own process, from time to time I see all of my cores – two, to be exact – being fully utilized up to a point that typing or switching to another application becomes almost impossible. Even mouse movement becomes shattered (and I’m on a Core 2 Duo 2.53GHz). I feel like being back at the single core times. Four cores might behave a little better, but maybe eight is the target to reach? I’m worried that the browser will just eat them up, no matter how many you’ll have.
Applications utilizing multiple cores are actually very appreciated, it’s just too bad, that this model has some drawbacks.