Programming ≈ Fun

OLAP for the Masses

| Comments

In the small database that contains about one million records the need for some reporting arose. Since the system will work for at least 5 more years I was reluctant to just “winging it with recapitulation tables and some SQL” approach.

The green pastures of OLAP have lured me long enough. My hopes where high, and my knowledge non existing. This is a tale of a man vs. the elements.

Let It Be

| Comments

Lately pet peeve of mine is how to make small methods look more elegant. One idea was to use “indentation” for implicit end of small methods. Big problem with this is that this is only a wish. I was forced to just cram the method to one line and curse the destiny. For a while I was torn. I loved cramming small methods and hated the impact on readability it had.

Couple of days ago it came to my attention that you can use define_method to get a job done. If we start with this:

1
2
3
def stupid?
  @pretty ? "NO" : "YES"
end

Why Reddit Is Not Worth It?

This article will sum up my experiences with reddit and why I think it is not worth it to bother with. It all started this summer. Somebody has putted me on a HN and I went front page.

7k visitors was more that my tender brain could comprehend :)
I didn’t know it right away but in hindsight that put a “link-aggregate” bug in my brain. I am a long time occasional reddit reader. I know you are not exactly supposed to put you own stuff up there, but hey it’s not like it is really spamming. There is down vote button on the article so if it’s a dumb one it will get buried in 5 minutes. No harm done. Right?

It’s easy to say ‘don’t put your own stuff’. BUT when you have zero readers (like me) it’s easier said than done.

Ruby Oddities

Over the course of time I’ve noticed three peculiar Ruby behaviours. I am not saying these things are good or bad. They are a bit odd/unexpected, mostly neat and always good to know.

I Would Love to See This in Ruby

| Comments

I like small methods. Small methods make comments unnecessary and allow me to describe algorithms in a way I will understand in couple of months when bug strikes. They allow me to develop domain and talk about domain in the code. There is just one thing bothering me:

The excessive presence of end keyword.
This is particularly bothersome for small methods.

Refactoring Exercise

I’ve just read an excellent article about refactoring rcat in Rubies in the Rough. If you are not subscribed you should be… I couldn’t resist to take a swing at it and refactor Display class since thats where most of the action is happening. In one line rcat is supposed to behave as Unix cat command for some basic cases.

Geek…No More!

Majority of people I know of that are great with computers tend to be not so great at sports. In tender years of their youth they are usually picked up the last for all sorts of sports activities. I believe this actually helps their computer skills as they get to spend more time with computer. After all everybody likes doing what he is good at. I’ve noticed couple of distinct phases.

Grokking the Ruby Blocks in 10 Minutes

I am assuming you are intrigued about Ruby blocks. My assumption is that you are aware that they exist but unsure of what they are or how to use them. From my experience main obstacle in understanding them is introduction of multiple concepts all at once. You need to understand closures and procs to understand blocks. Also Ruby mix-up with lambda vs. proc debate is not helpful either. There are some great posts about the subject. For example Understanding Ruby Blocks Procs and Lambdas.

Nightmare at 20,000 Feet
Nightmare at 20,000 Feet via Wikipedia

I am going to bluntly ignore the details and just give the 20,000 feet look at it.

Block in Ruby is just another type of variable.

Memorize the Concepts Not the APIs

| Comments

I was always ashamed of not being able to bang out code without looking at the documentation. One example was file opening/handling in .NET 1.1. I remember not being able to do it even if my life would depend on it. Later on I’ve read that Microsoft made the study about APIs usability. One of the APIs that missed the mark was the IO.

The main complaint was that you need way too many lines of code for basic scenarios.
The other complaint was that you need the knowledge of rather abstract (from the usage point of view) inheritance tree. That was a bit of relief. I stopped feeling as such an imposter that was getting payed for doing nothing. Still I regarded this as my flaw and was always irritated when unable to do simple stuff because I forgot API details.

Similarly, after finding out about Ruby I was amazed that alpha geeks figured it out five years before me. When I think about it more carefully, it would not be logical any other way. I speculate that they were able to position Ruby as a Smalltalk derivate that has some Perl syntax sugar and some Lisp functional goodness. That enabled them to label/recognize the whole technology relatively fast and easy.

Breaking the Rules

| Comments

Yesterday I’ve subscribed to Rubies in the Rough from James Edward Gray II and read his article “Doing it Wrong”.

In his article he questions (along with some other rules) the rule of never using regular expression for xml parsing.

As it turned out it was a fortunate move since six dollars and one day latter I came across .xml that needed to be parsed.

I have a confession to make: I’ve always hated xml parsers. This particular .xml did not even use xml strengths; data inside was all messed up:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Exchage rates list</title>
<link>http://*******</link><description>Excange rates list 12/13/2011</description><item>
      <guid isPermaLink="false">code: 978</guid>
      <title>EMU (EUR)</title>
      <description>
          Unit: 1<br />
          Buying: 1.95583  <br />
          Medium: 1.95583  <br />
          Selling: 1.95583 <br />
      </description>

  </item>   <item>
      <guid isPermaLink="false">code: 36</guid>
      <title>Australia (AUD)</title>
      <description>
          Unit: 1<br />
          Buying: 1.488813<br />
      ...