
via __doc__
Pages tagged as ‘ruby’
Rails Motivation
You’re hired. D’oh, you’re not!
Someone gave me a link to one of DHH’s old blog posts where he was referring to Mac OS X as best operating system for developers. And what made me wonder a few words later was this:
While I can certainly understand the reasons why some people go with Linux, I have run all but dry of understanding for programmers that willfully pick Windows as their platform of choice. I know a few that are still stuck in the rut for various reasons — none of them desire.
And furthermore
I would have a hard time imagining hiring a programmer who was still on Windows for 37signals. If you don’t care enough about your tools to get the best, your burden of proof just got a lot heavier.
That’s ridiculous. It might be true that more and more hackers buy themselves apple notebooks and obviously I’m one of them, but I would never consider Mac OS X being the best developer platform. Being in the linux community for not so long and a pupil until two months ago I had to work with Windows for a long time. And I would never say that Windows is a bad operating system or that you cannot develop good applications on a windows machine. In fact the only reason why I don’t use Windows is the bad terminal and the missing apt-get. In one of the comments on the linked page DHH states that “I’m primarily charging the lack of passion for your tools, which seems to be what a great many developers still left on Windows are citing at least in part for staying. ‘…covers both needs just fine’, ‘Windows simply because we are able to quite easily’.”.
Except of rhythmbox and some other GNOME applications I used on a daily basis I can get all of my developer tools for a windows box too. It’s just more work. And god I know that there are many people using Vim on Windows. Even better, if we’re talking about good tools, there is an awful lot of good tools only available for windows. For example there is Visual Studio. You won’t find an IDE that can compete with it, although Eclipse is certainly on a good way. Still, there are tools you cannot get on Linux and Mac OS X. The only tool I can think of DHH could have had in mind is “TextMate”…
And I can tell you what’s the problem with TextMate: It’s just a normal editor. I admit that everytime I watched a something screencast TextMate in it, I wanted to use that cool thing. But then again, now where I have a TextMate license it’s just a normal editor. And not even the best I fear. I’m used to Vim and over the last years I configured it to such a high level that everytime I use a different editor I’m just less productive. So in general, that’s not my sort of tool. Though, obviously it would stop me from getting hired by somethingsignals.
So what does people think Mac OS X is the best operating system? There are things solved very well on OS X. dmg and bundles is something that looks really nice. I think Linux is definitively missing something like that. ALso the Design of all the apple products and especially of their user interface is gorgeous.
But then again whenever I see a apple user interface I wished the font rendering was powered by libfreetype which gives me the possibility to configure my font rendering in the way I like my fonts to be displayed. I’m used to the fact that I’m the only person interested in the font rendering but that’s one of the things I just hate about OS X. The only thing you can configure regarding font rendering is the threshold for non antialiased fonts (And the strength of the hinting which doesn’t make things that better). And text is the thing I look at most of the time. Whenever I complained about that in the last few weeks people pointed me to articles that showed off that apple decides to render the fonts like they would appear on the paper and that this approach is better. Well, TextMate is better too, isn’t it? But I can use Vim instead of TextMate. I cannot get OS X to render fonts like I want them to be rendered.
The next problem you have with OS X is that it’s darn expensive. OS X as such might be a darn lot cheaper than Windows. But every single piece of software consts. Tired of mud mousing? Pay 30 bucks. Tired of Finder? Pay 30 bucks. Chaotic window manager feeling? Pay 15 bucks. Want to have more than one QuickTime window? Pay 30 bucks. Virtual Desktops? Wait for Leopard or pay 30 bucks. Different themes for your OS X? 20 bucks. Those are problems you don’t have on Windows (because of tons of freeware) or Linux (because of tons of open source software).
And still, I’m not that unhappy with my Macbook because there are good aspects too. Though. I hate it when people praise OS X as the best developer platform or find amusing or bad accuses for problems you have on OS X. Apple is not a religious group or enlightened or whatever. They make mistakes too, not less than any other software company. Just that you have to pay more for them. So please. Don’t let the decision of hiring depend on the operating system a developer users. They might have good reasons for doing so. And not everybody has the same idea of aesthetics.
Fun with Ruby Syntax
Smilies:
smilies = :-? /:-/ :-D
That’s nonsense code, smilies just gets /:-/ assigned. Fun nevertheless. Why that works? The first thing is a symbol literal, then there is a ternary operator, first result expression is a regular expression literal, the second is the negative version of the “D” constant. Because the symbol is true the second return expression is never evaluated and nobody complains about the missing constant D.
Ruby XMLRPC Vulnerability
Looks like the Ruby XMLRPC implementation still has a vulnerability:
#!/usr/bin/env ruby
require 'xmlrpc/server'
class TestHandler
def foo
42
end
end
if __FILE__ == $0
srv = XMLRPC::Server.new(5000)
srv.add_handler('test', TestHandler.new)
srv.serve
end
Connecting to it with the python shell now does this:
>>> from xmlrpclib import ServerProxy
>>> p = ServerProxy("http://localhost:5000/")
>>> p.test.send('foo')
42
>>> p.test.send('`', 'echo "Shit"')
'Shit\n'
And something tells me there is no way to avoid this problem, so better just not use add_handler with a class. Explicit is better than implicit.
Update after some googeling i found someone that discovered the same: Ruby, Python, and an XML-RPC Server Arbitrary Shell Command Execution Flaw.
CVS Version of Vim-Ruby
The new CVS Version of the vim ruby support rocks the house:

Special thanks to Tim Pope for fixing some of the bugs i found that quickly.
You can find it here: vim-ruby.rubyforge.org.
Just Another Ruby Hacker
class<<self;define_method(%_>6E9@50>:DD:?8_.tr(%_0-f_,%_\_-t_)){|*_|@_\
=_};end;(Just another Ruby hacker!);(_,@_=@_;$><<_<<%_ _)while@_;$><<$/
Looks like another testcase for pygments, but it’s my new signature for the german ruby forum :D
This is Ruby
def method_missing*_;@_=_;end
Is this Ruby? Yes it is.
It's really rockin'.
Ruby is cool :D
puts@_.join(' ').gsub(/s(it|d)/i,'!')
Output:
Is this Ruby? Yes!! Ruby is cool!
syck vs syck
$ time python -c "import syck; syck.load(file('yaml').read())"
real 0m2.255s
user 0m1.572s
sys 0m0.088s
$ time ruby -ryaml -e "YAML.load(File.open('yaml'))"
real 0m9.455s
user 0m7.984s
sys 0m0.080s
Mutable Hash Keys
Caveat. Mutable hash keys in ruby obviously behave different than you would expect:
>> foo = [1, 2, 3]
[1, 2, 3]
>> bar = {foo => 42}
{[1, 2, 3]=>42}
>> foo << 4
[1, 2, 3, 4]
>> bar[foo]
nil
Update: there is Hash#rehash.