ProgFu

programming tips & tricks

Feb 26

The journey to NoSQL

Disclaimer: I’ve never used a NoSQL database before for a real project. I’ve heard about them, and I tried some little things, such as using a MongoDB (MongoHQ) as a hash-in-the-sky storage, I used Redis as a cache for a while before going back to memcached and that’s basically my whole NoSQL experience.

However as I’ve been recently discovering, there’s a lot more to NoSQL than just the hash-in-the-sky.

In the following series of articles, I will write about my journey from NoSQL noob to hopefully a somewhat proficient user. These won’t be very in depth and explanatory articles, but more of a this is my learning experience and how my point of view changes over time.

Read More


Feb 9

Should we write specs for validations?

When I was starting with TDD in Rails, I had times when I wasn’t really sure what to test for. Some of the apps were so simple that there wasn’t really that much to test, but I wanted to practice. I wanted to keep writing code.

I had this inner conflict about testing validations. At least for me, validations were kind of like getters and setters in their complexity. You don’t generally write a test case for a getter unless it has some additional logic inside.

Read More


Feb 3

Why am I never using PrestaShop again, ever!

For some reason, I thought that widely used opensource projects will have clean and easily maintainable code, but I was wrong.

I’ve been using PrestaShop for over a year now, generally for clients who just wanted a cheap e-commerce and didn’t really care how it gets done. At the time I needed to do this for the first time, I asked around among my friends who have some e-commerce sites, and almost everyone pointed me to PrestaShop, so I didn’t really ask questions and went with it.

Read More


Feb 1

theconfusedtraceur asked: What theme are you using? It looks really nice. (Found your blog through Pinboard's top bookmarks)

The theme is called Easy Reader v1.2, but I’ve customized it quite a bit, especially typography.

It still isn’t final, I have plans to improve it quite a bit over the course of the next week, so stay tuned for some awesome changes :)


Jan 31

A story of me becoming not-totally-noob VIM user

This article is a followup to the initial story of editors, this time focusing on VIM. It will also be a multi-part series because there’s just too much ground to cover

As almost every cool kid trying to be a hacker in high school, I learned VIM basics when toying with Linux on my desktop machine. Working isn’t the correct word, because I wasn’t really doing anything serious. I felt totally badass for being able to compile a kernel from source and actually make the machine boot up after that.

Read More


Jan 30

It is time to Get Things Done!

I’ve spent a long time trying to pick and set up a perfect system for my task management. Ever since I read the GTD book by David Allen, I’ve been switching from one tool to another, trying to make everything just perfect.

For a long time, I’ve been the kind of guy who tries to get the most features out of everything. I always installed all the available plugins, had every single extension there was in the browser and just tried to whore up as many features as I could into my workflow.

Read More


Jan 24

Enough abstraction, it’s time for Arduino

update: this article was originaly posted on my wordpress blog on 10th November, but since I’m unable to set a publish date on tumblr, and I felt it would be a shame to just leave it there, I’m republishing it here.

Over the past few years, I’ve been moving up in the levels of abstractions in programming languages, from AVR Assembler all the way up to enterprise Java and Ruby on Rails. Right now I’m at the point where I can work with a database without even knowing whether it’s MySQL, Postgre or SQLite.

Read More


The story of TextMate, VIM and SublimeText

I always preferred heavyweight IDE to do most of the stuff. I tried many IDEs for Ruby, even purchased two upgrades for RubyMine, but it never felt right. I wanted to do the same things that IntelliJ can do to Java, all those beautiful hardcore refactorings. But those just don’t exist for Ruby.

I used my IDE to do source control and I didn’t really understand the command line tools. I knew how to invoke Rails generators from the IDE, but I wasn’t really confident doing the same from the command line.

Read More


Oct 3

WordPress query_posts with pagination

This is probably the first issue I stumbled upon ever since I started working with WordPress; which is surprising because I really expected hacking in PHP templates to be much harder and error prone (but more on that in following articles).

The issue comes up when you want to display posts based on some specific criteria, for example listing the most recent posts from all but one category. There’s an amazing query_posts().

When I first realized that I need to display only something and not everything on the main page, I got a little angry, because I expected I will have to code all the stuff myself, but WordPress surprisingly offered a very easy solution.

Specifically, I needed to exclude a category #5, and all that needs to be done is call query_posts() right before the main loop.

 <?php query_posts('cat=-5&posts_per_page=3') ?>

 <?php if (have_posts()) : ?>
 <?php while (have_posts()) : the_post(); ?>
    // blah blah usual stuff

Note the cat=-5, which says I want everything EXCEPT for the category #5.

Now there are two downsides of doing this. First, the query will persist even if you have multiple loops, so you need to reset it back by calling wp_reset_query() after the main loop, which isn’t such a big deal.

Another thing that stops working though is the use of next_posts_link() and previous_posts_link(), because once you call query_posts() WordPress won’t automatically apply the page parameter; you will have to pass it manually.

 <?php query_posts('cat=-5&posts_per_page=3&paged=' . get_query_var('paged') ); ?>

Yes it is very simple, but also very easy to forget. The bottom line is every time you call query_posts(), be sure to check your pagination.


Sep 18

Back from the Dead

It’s been a while since my last article. I’ve been neglecting this blog, but that’s about to change now. I’m going to try to write regularly and at least post some progress on my current projects and learning new languages along the way.

Specifically, I’m trying to learn Scala, which is a language that I always considered interesting, but never really got into it because I thought Ruby is the only thing I need. It turned out that you should never be 100% sure of anything, because there will always be times when it’s not true, and that’s the case of Ruby. I’m going to get more into this in the following articles.

Another thing that I’m getting into a little bit is ActionScript 3. The dreaded Flash has finally caught my attention, so I’m probably going to write something on the ugly and messy ActionScript too.

Last but not least, I’ve finally got to work with WordPress. Not just as a user, but theme development in particular. I’ve been afraid of this for a long time, but since everyone on the web is using it, I should at least have some knowledge to be able to manage my pet projects a little bit better.

I might even get a little bit into plugin development, but I’m not sure about that, since PHP is something I’d like to avoid in the future.

So much for an introduction, see you at the next article!