Problems with Ruby on FreeBSD
The people following me on twitter already know I had problems with Ruby on a FreeBSD 6.3 system yesterday.
It seems that the default ruby 1.8 from the ports system has a big problem with recursion. The recursion level cant go nearly as deep as it can on other operating systems.
And if the limit is reached the ruby process crashes with a signal 4 (a SIGILL) instead of raising a SystemStackError as it is supposed to be.
So if you see your ruby processes (and this includes your mongrels) die without any reason on FreeBSD 6 you know what is wrong.
Posted in Ruby, Daily annoyances, Software, Hardware and the Mac | no comments |
Object#methods: Looking at the difference
When I play around with a new API or library in Ruby, I usually use IRB, the interactive Ruby shell, to do so. Creating an Object, writing a mini-Class or somthing like that, just to get a feel for the object.
Often I use Object#methods to look at the interface of an object. The annoying part is, that you alway see plenty of methods intorduced by the base class (Object), wich every Object has.
So I added a method to Object, thorough monkey patching it:
[code lang="ruby"] class Object def methodswithoutdefault (self.methods - Object.new.methods) end end [/code]
and put that into my .irbrc file.
So now someobject. methodswithout_default gives me an array of all non-Object-inherited methods of that objcet :-)
Posted in Ruby | no comments |
You will never miss Perl when using Ruby
This is valid Ruby syntax
?{*?{%?{-?{**?{+?{||?{|?{&?{&&
?}|?}**?}-?}%?}&&?}+?}*?}||?}&
?[&?[||?[|?[-?[%?[&&?[**?[+?[*
?]|?]*?]&&?]||?]**?]%?]-?]&?]+
?;&?;-?;%?;+?;*?;||?;**?;&&?;|
?:*?:&&?:&?:||?:**?:+?:|?:%?:-
?'-?'&&?'+?'|?'||?'%?'&?'*?'**
?"%?"+?"&?"*?"-?"||?"**?"&&?"|
?/||?/|?/&?/-?/+?/&&?/*?/**?/%
??-??&??&&??||??%??|??*??**??+
?.*?.&?.%?.-?.+?.|?.&&?.||?.**
?,&&?,-?,||?,%?,**?,+?,|?,&?,*
?<-?<+?<&&?<%?<||?<|?<&?<*?<**
?>**?>+?>|?>%?>||?>*?>&&?>-?>&
?=**?=|?=*?=&&?=%?=+?=-?=||?=&
?-&&?-&?-+?--?-%?-|?-**?-||?-*
?+*?+%?+||?+|?+&&?+-?++?+**?+&
?_|?_+?_%?_&&?_||?_&?_*?_-?_**
?)%?)*?)&?)&&?)-?)|?)||?)+?)**
?(%?(+?(-?(**?(*?(|?(&&?(||?(&
?*&&?*+?*-?**?***?*|?*%?*||?*&
?&|?&-?&&?&&&?&%?&||?&+?&**?&*
?^%?^&?^||?^*?^+?^-?^&&?^**?^|
?%*?%+?%**?%||?%%?%&?%-?%&&?%|
?$%?$|?$*?$-?$**?$&&?$&?$||?$+
?#&&?#**?#*?#+?#-?#&?#||?#%?#|
?@+?@%?@&&?@&?@|?@-?@*?@**?@||
?!&&?!||?!&?!**?!*?!%?!|?!+?!-
?~|?~&&?~&?~-?~||?~**?~%?~+?~*
?`&?`||?`**?`*?`%?`&&?`|?`+?`-
?||?|+?|-?|**?|||?|&?|%?|*?|&&
??
it evaluates to
[code lang="ruby"] -114374367934617190099880295228066276746218078451850229775887975052369504785666896446606568365201542169649974727730628842345343196581134895919942820874449837212099476648958359023796078549041949007807220625356526926729664064846685758382803707100766740220839144 [/code]
BTW: The ruby syntax colorer does not like this blob ;-)
Posted in Ruby, Notes to myself (and the rest of the world) | no comments |
Bratwurst for Everyone
This year I'm attending the RailsConf Europe in Berlin.
Of course I attended Bratwurst on Rails, the pre-conference get together inspired by last years Pizza on Rails in London.
I have to say it was pretty cool, I met a bunch of cool people and so I'm looking forward to attending keynote by Dave Thomas in about an hour.
I'm posting all the pictures I took on my new picture gallery, so have a look.
Posted in Ruby | no comments |
Men are from MARS
"Boys are from LAMP, men are from MARS"
MARS is MySQL + Apache + Rails + Solaris and it's manly.
Posted in Ruby, Fun | no comments |
Ruby just rocks
These days I often get reminded why I love ruby so much.
Easy things are easy, complex things are possible and it works just the way you think it will – most of the time at least.
An example: How to shuffle any array (the numbers of 1 to 10 in this example)
[code lang="ruby"] (1..10).sort{|a,b| rand(3)-1 } [/code]
Updated:
kev of the guys at gluttonous had the same idea a some month back. From the comments and a Usenet discussion from December 2005 about the same code snipplet I learned that
[code lang="ruby"] (1..10).sort_by {rand} [/code]
is 4x to 5x times faster and at least as elegant.
the really optimized
[code lang="ruby"] def shuffle3 h = Hash.new self.each { |v| h[rand(1000000000)] = v } h.keys.sort.collect { |k| h[k] } end [/code]
seems to be even faster, but only by a knifes edge.
Posted in Ruby, Art and Beauty | no comments |
Railgun
After several attempts, wich failed, I finally managed to upgrade this blog to the latest bleedin' edge Typo svn version.
I just had to remeber
- That there is something like
rake migrate- wich is a wonderfull invention to migrate your database - And that I have to check my own typo template - wich renders this wonderfull layout - aginst the latest bleedin' edge azure default template - maybe they changed something that breaks your blog.
So now I'll be rememberd
Posted in Ruby, Daily annoyances, Software, Hardware and the Mac | no comments |