For the whole of May, I will blog about weird things in Ruby over at Idiosyncratic Ruby – Don’t miss it!
Long time readers of this blog will remember that I used to tweak GNOME’s gedit editor a lot. However, I ditched it for Sublime Text and I am not looking back. Here are some of the things I like about Sublime:
- Offers a good out-of-the-box experience, including an amazing “fuzzy search” tool (ctrl+p)
- It works on ubuntu without any problems
- Fast (enough)
- Multiple cursors!
- Once you have installed Package Control: An integrated extension repository
- Encourages you to write your own extensions
- Looks good
There are many implementations of password managers/safes out there. But lots of them are black boxes, either because they are not open source, or because they have to much features and it gets complicated to understand the source (which is most likely not written in a happy programming language). You don’t know, what really happens with your passwords. So…
Do it yourself!
Do it with Ruby!
Do it in less than 250 lines ;)
One useful (and funny) feature of Ruby is the
Symbol#to_proc method that lets you write concise code like this:
%w|1 2 3 4|.map(&:to_i). Almost everyone who knows this feature loves it ;). However, the use cases are pretty limited, because in most cases you need to pass parameters!
This article is written for people with experience in programming in general, but who are new to Ruby.
A German version is published in the offline magazine #2, a magazine by some students of TU Dresden.
The intention is to demonstrate some features of Ruby and show, what is so great about Ruby:
A clean syntax combined with the possibility to adapt the language to given requirements flexibly.
At my last entry, a question arose about what is the most efficient way to convert integers between the bases 2 and 10: either using built-in ruby methods (and even do lightweight string-operations) or calculating it manually. I had to find out ;). So I have written a little benchmark program, which does the conversion in three different ways:
- using built-in to_i-magic
- calculating it by hand
- using sprintf
It stops the time each method needs to get the fastest. The result might be surprising. [Update: improved the custom methods]