Modules are useful for highly specialized code that can be injected into other classes for fun and profit or for creating Namespaces. An interesting approach is to use modules as an alternative to classical inheritance (without its the usual trade-offs) : the core idea is to share an abstracted role that can be inclu ...
⁂
On Ruby modules and concerns
⁂
On semantic Ruby block constructs
I was cruising around my Github notifications and I found an interesting open issue created by Jim Weirich : “The Semantic Rule for { } VS do/end” in the Ruby style guide repository .
>The semantic rule says use { }
for blocks where the primary purpose of the block is t ...
⁂
On Ruby 2.0 memory usage, Unicorn and Heroku
On UNIX-like operating systems (e.g. Linux) there's the concept of process forking via the fork()
system call. When one calls fork from a parent-process it will spawn a new child-process - that is a copy of its parent, then both processes return from fork. The child-process has an exact copy of the parent's memory in ...
⁂
Improve Rails performance by adding a few gems
Working with Rails for some time you start nitpicking on how to improve it. This is a first in the series of articles regarding on how to improve (even marginally) Rails's performance.
I'll focus on a bunch of gems that speed up, in some cases considerably, small parts of Rails, like the html escaping, the String#bla ...
⁂
Is Rubinius 2.2.3 production ready ?
Ruby 2.1 was released this Christmas, great news everyone! It sports a better GC (RGenGC - gerational GC), hierarchical method caching, some small syntax changes and non-experimental rafinements. All in all one can expect 5% to 15% performance increase which is quite awesome.
As I was reading the comments in the hack ...
⁂
Chunked transfer encoding in Rails (streaming)
Anyone that has written a little PHP knows what the flush()
family of functions do. The ideal usage scenario for using chunked transfer[0] is when we have something costly to render e.g. the first three most recent articles on a blog. Why ? one might ask.
Is rather simple: in a normal request where the server respo ...
⁂
Ruby 2.2.0 Preview 1 quick Rails benchmarks
Great news everyone! Ruby 2.2 preview 1 has been released ! I'm really curios about the Incremental GC and Symbol GC so let's run some quick Rails benchmarks o ...
⁂
Shedding some light into UUID version 4 in Ruby and Rails
Ruby's standard library and Rails's PostgreSQL adapter use by default version 4 UUIDs. This can be changed in Rails migrations via:
default: 'uuid_generate_v1()'
param whereas Ruby's stdlib only supports version 4.
Another interesting difference is in the implementations:
In the Ruby's s ...
⁂
Using RVM for quite some time? You should clean it up a bit
I can't even remember the last time I ran rvm implode
, I'd reckon I've been using RVM for about three years.
Sure: I always update it via rvm get stable
but I never really clean up old Rubys or gems, I only run bundle clean --force
in each repository from time to time since I don't always use bundle exec
.
...
⁂
Programming archaeology: PHP's dollar sigil
I started out with Java as my professional language and before I discovered Ruby, PHP was my main programming language of choice for new projects. This was probably six to seven years ago or more. I had some pretty good times with CodeIgniter [0] and various libraries like HHMVC [1].
In any case, I digress - even ba ...
⁂
The perils of writing request specs using concurrent-ruby under the JVM
When I write an API, though I'm not a hard core TDD practitioner, I do like writing specs - especially requests specs that test the whole stack.
Adding them into an API is fast and yields quite good results compared to an app with an UI where you have to use chrome-cli or phantomjs just to get near of that level but ...
⁂
Interesting links - Is logging a "code smell" ?
I was reading this article it raises quite an unexpected question - "Can we consider logging as a code smell"?
Clearly - the answer is more nuanced than that and whilst I do enjoy the event bus
approach from the article - that seems like overkill for m ...
⁂
Ruby meets LISP: Unveiling alien tech at Friendly.rb's lightning talk
Recently at the Friendly.rb conference in Romania, I explored an experimental blend of Ruby and LISP, particularly through Clojure. This journey was more about embracing the spirit of experimentation intrinsic to Ruby, rather than direct comparison.
A big shoutout to [Jakob](https://twitter. ...
⁂
Moving from iTerm2 to Kitty for simplicity and performance
I love iTerm2, but it can be sluggish sometimes on my old late 2016 MacBook Pro. Plus, many of its features I never use. I had tried Alacritty before, but making it look and act like iTerm2 was a no-go. This time, I tried Kitty, and within two hours of work, it looked and behaved just like my iTerm2 configuration. This ...