Out of the box

Personal rants

How I became a computer programmer – Part I

with one comment

1. The real motivation

Inspired by a friend who said – I control what the computer does – I started learning Pascal back in the 90′s, when I was fourteen. I wanted this power too, and that sentence pushed me hard.
Along with a ~20 pages tutorial, I grabbed two 3½-inch floppy disks from him, containing a version of Turbo Pascal.

Getting home, I anxiously installed and ran it. A blue screen which seemed like a text editor was presented. After exploring it for few minutes with no idea on how to begin, I started reading the tutorial. It seemed difficult at first, as it had a bunch of acronyms and names I had never read or heard before. But I was very keen to explore it and learn how to control that wonderful machine. I wondered what powers it could give me.

2. Baby steps

I started by transcribing a simple example to sum 2 natural numbers and print the result. It took me time to figure out what was going on there. I changed the numeric values and the text being printed, and when I saw it being executed by the computer, I got completely fascinated. Yes, that little thing planted a seed on my soul. It also made me wish to write my own calculator, so I read the whole tutorial, not once or twice, but many times. While most pages didn’t make any sense to me, I started to understand what a type and a variable were, and how to use them.

I had open a gate to a completely new world and I was walking thru and exploring things I had never seen before. I felt magnificently well. It really blown my mind!

3. The big decision

In the first day I past many hours sat in front of my computer typing code, reading, and trying new things. That became my priority in life, and at this point everything else was just secondary.
After few weeks on this very same routine, the most important decision of my life was taken. I had become a computer programmer.

4. Obsession

At the time I was in the first year of secondary school, and I already knew what to do next. It led me to lose much of my interest on things not related to computers, and this had a direct impact on my grades. Most importantly, it was a negative impact.

I was frustrated because I never had been such a bad student, so I made a deal with myself. My grades would dictate how much time I could spend in front of a computer, forcing me to pay more attention to classes. That was a damn good deal!

The first year was about to end, and I was mastering chemistry, and doing good at others. My math was only satisfactory, mostly because I didn’t like the teacher and his way of explaining things. And I tell you that because I always loved math and chemistry.

My grades shown me that programming had become an obsession. That drove me to self-punishment, which in many ways presented itself as a positive thing.

5. Finding the gold mine

I programmed many things during the first weeks. Most, or all of them, were just useless for real life, but taught me lots of new stuff. That is, I was practicing and learning. Took me months to figure out what a record was, and I was beginning some interaction with files and directories.

I had very limited access to internet, and most syntax and commands I learned were from few random tutorials. It was proving quite difficult to make any progress at this stage, so I started questioning myself how else I could learn, and how other people learned it. It couldn’t be that hard.

Finally, I found an answer. In fact, the best answer I could have got – the help menu. I didn’t know how to read it though, because its syntax seemed complicated to me. But it was there, and it had thousands of entries. I found a gold mine, literally.

Took me days or maybe weeks to fully understand how to read it, but the feeling was that I could make big progresses.

Written by jweyrich

September 13, 2010 at 7:50 pm

Posted in Programming

Minify and Concatenate JavaScript plus CSS files

leave a comment »

Yesterday I wrote this little Makefile to minify and concatenate multiple JavaScript and CSS files. It depends on the YUI Compressor JAR. :-)

Since the browser can open at most 5 concurrent connections to the same host, and I had a web application depending on 20+ of these files, the first request was taking too long.

The only solution I saw was minifying and concatenating them to serve only 2 files (1 JS + 1 CSS). And that’s what I did.

Here’s how it works:

$ make
[css] static/css/first.css
[css] static/css/second.css
[css] static/css/third.css
[css] static/css/and_so_on.css
[tag] @import url("static/css/all.css");
[js] static/js/first.js
[js] static/js/second.js
[js] static/js/third.js
[js] static/js/and_so_on.js
[tag] <script type="text/javascript" src="static/js/all.js"></script>
Done.

Simple huh?
Now, replace those bunch of includes, and be happy!

Written by jweyrich

July 31, 2010 at 7:33 pm

Posted in Web

String based extension for LINQ’s OrderBy & ThenBy methods

leave a comment »

Recently I had to add ordering support to an application using the column names as strings, but the LINQ API accepts only Lambda expressions.
And to worsen my case, I needed it to work with IEnumerable, plus nested properties, so I decided to write this extension to fulfill these needs.

Normally you’d write:

list.OrderBy(p => p.Name);
list.OrderBy(p => p.Member.SubMember).ThenBy(p => p.AnotherMember);

Now, you can write:

list.OrderBy("Name");
list.OrderBy("Member.SubMember").ThenBy("AnotherMember");

It ended up being more friendly, and I hope it makes your life easier as well.

Written by jweyrich

October 25, 2009 at 2:24 am

Posted in C#, Programming

D-Link 500G Authentication Bypass

leave a comment »

This morning, while I was testing a bug related to HTTP authentication in Google Chrome, I found an authentication bypass on D-Link 500G.

The original advisory is here.

Written by jweyrich

August 24, 2009 at 1:55 pm

Posted in Hacking, Network, Security

Problem with Parallels Desktop 4 and Ubuntu 9.04 (Jaunty)

leave a comment »

UPDATE 2009.09.06: Parallels Tools is fully working on Ubuntu 9.04 since 2009.09.01, according to this article.

Today I wrote some RTTI (Run-Time Type Information) tests. After compiling it with Apple’s gcc on Mac, I decided to check how this would go with GNU’s gcc on Linux.
I ran my virtual machine, Ubuntu 9.04 (Jaunty), installed on Parallels Desktop 4.0 (for Mac), and tried to copy’n'paste my source code. I noticed it didn’t work, then I figured out Parallels Tools was missing. At this point, I tried to install it, without success. Checking the generated log at /var/log/parallels-tools-install.log, I found the following messages:

Installation of kernel modules was finished successfully
Start installation of user space modules
X Server: xorg, v1.5.0
Install X modules from directory: .1.6
System X modules are placed in /usr/lib/xorg/modules
Error: there is no X modules for this version of X server
Error: failed to install user space applications and drivers

In short, it says the Parallels Tools couldn’t find the necessary modules for Xorg 1.6.0. So I went to the Parallels website and searched for it. Without success again.
What I found instead, was a forum thread relating this exact problem, started in Apr 17, 2009. I read all the pages quickly, and got surprised it isn’t fixed until now. Let’s count… Aug 22 (today) – Apr 17 = ~4 months.
In addition, there’s a KB article about Parallels Desktop 4 and Ubuntu 9.04 support, showing the last review date as Jul, 22 2009.
But when it’s going to be fixed? No timeline, and no progress updates. Concluding, no idea!
Those customers are very frustrated/disappointed, and many are migrating to VMware Fusion or VirtualBox, declaring it isn’t the first time this kind of problem happens.

A temporary fix would be downgrading Xorg to a prior version, but it is totally unacceptable for me.

Written by jweyrich

August 23, 2009 at 3:30 am

Posted in Linux/Unix, MacOSX

Follow

Get every new post delivered to your Inbox.