February 2013
1 post
When a cow laughs, does milk come out her nose?
– http://www.quotegarden.com/ (via cowees)
January 2013
1 post
2 tags
How to find a model by any attribute in Ember.js
One of the common things people ask about Ember Data is how to find a single record by it’s attribute. This is because the current revision (11) only offers three methods of fetching records
App.User.find(1) // returns a single user record
App.User.find({ username: "wycats" }) // returns a ManyArray
App.User.findQuery({ username: "wycats" }) // same as the above
If you want to search for...
September 2012
4 posts
4 tags
Make your Rails development faster with Ruby-perf...
Nothing is perfect and even a great framework like Ruby on Rails has its weak parts, and one of those is speed.
But I am not talking about speed in production where you can scale up to 50 instances in your cloud service and nobody really cares. I am talking about development speed. When your application starts growing and you start adding gems, it starts to take really long to start up, be it...
2 tags
What is a Monad - first look
Disclaimer: I have no idea what a Monad actually is, I just want to share my current point of view.
Monad is a context in which you execute something.
Monad is a container.
Monad is a method of encapsulation.
Monad is a way to hide the God object.
Monad is nothing special, you can define it yourself.
Monad is something newbies are afraid of.
Monad is not the only thing you will be afraid...
Be sensible about your projects - shameless self...
I’ve recently founded a Ruby startup Sensible.io with a couple of my colleagues. Our goal is to create and deliver great applications and make our customers happy.
So far we’ve worked on couple of large projects, and a lot of small ones. We all have many years of experience with Ruby on Rails.
But that’s not all, we are also fluent in JavaScript, including Node.JS and...
2 tags
Functional programming (Haskell) - prelude
It’s been a while since my last post, but I hope to get back to regular writing, so here it starts.
I’ve been trying to get into functional programming for a while, almost a year now, but without any major success. I’ve given a try to Scala, Clojure, even a little bit of Erlang, but nothing really caught me for long enough to trully learn it.
But this changed when Chris...
May 2012
1 post
2 tags
Implementing an autoincrement counter in...
In one of the recent articles we implemented an autoincrement counter function using closures in JavaScript. Here’s the source code:
var counter = (function() {
var count = 0;
return function() {
return ++count;
}
})();
Today I was playing around in CoffeeScript, and I basically needed the same functionality. The first idea that came to my mind was this is impossible,...
March 2012
7 posts
1 tag
Git Coding Guidelines
This article is less of an article and more of a list of guidelines for proper git workflow. Let’s dive right in.
master branch is ALWAYS ALWAYS ALWAYS deployable, never work directly on master
Development code should be on dev branch and then merged into master once fully tested, that way master awlays stays deployable
Every time you start a new task, create a branch from dev and then...
1 tag
Two line solution to drop all data from CouchDB
Today was my first day when I actually had to use CouchDB on a real project. The problem I stumbled upon while developing is that there is no way to just drop all that data in a databse from the beautiful web interface that CouchDB has.
After about 15 minutes of fiddling around with the _deleted attribute, I came to a dead simple solution.
namespace :couch do
desc "Delete and create...
Common sense is the collection of prejudices acquired by age eighteen
– Albert Einstein
1 tag
Private JavaScript variables with the Module...
In the previous article, we’ve talked about closures which are the building stone for anything even remotely complex in JavaScript. This time, we’ll take a look at private variables.
JavaScript itself doesn’t have the concept of a private or public variable, everything is public. But there’s a way around this. Let’s take a look at our previous example
var...
1 tag
Notebook: a few vim shortcuts →
groenewege:
gf : edit the file whose name is under or after the cursor
gd : when the cursor is on a local variable or function, this command will jump to its declaration
’ ‘ (two single quotes) : return to the line where the cursor was before the latest jump
gi : return to insert mode where you inserted text the last time
CTRL-o : move to previous position you...
3 tags
ZSH + VIM + RVM
I’ve recently switched to ZSH from Bash which was all in all a great decision, but there are some consequences.
One thing I stumbled upon today, is that Vim and MacVim don’t load the ~/.zshrc by default, which means if you’re using RVM it won’t work.
However they do load ~/.zshenv, so you can easily get around this by sourcing your .zshrc from within the .zshenv
$ cat...
2 tags
What is a Closure and the JavaScript module...
In this article, we’ll take a look at closures in JavaScript, and how can we use them to our advantage to write a better code.
Let’s start off with an example
var counter = function() {
return ++count;
}
We want this function to be able to count the number of visitors on our site. How would we do this in the dumbest way possible? By introducing a global variable (not global...
February 2012
6 posts
1 tag
You can't change the history - the story of Git
Working with Git can be scary, especially once you get into the more advanced commands, such as reset, rebase and merge. Even little things like deleting branches can cause fear of losing some data.
Not so long ago, when I had to do something a little bit destructive (rebasing), I always backed up my whole repository in order to be able to undo any possible damage.
But what I learned...
3 tags
Why I prefer request specs over cucumber
I’ve always liked the idea of doing BDD, and especially Cucubmer, as it just makes everything super clear. Writing scenarios feels so natural, especially when you’re not sure about the project, writing down specific steps of the scenario can help you figure out what is actually going to happen.
The problem is, at least for me, when I have to implement the steps. In an ideal case, I...
1 tag
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...
3 tags
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...
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...
theconfusedtraceur asked: What theme are you using? It looks really nice. (Found your blog through Pinboard's top bookmarks)
January 2012
4 posts
2 tags
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...
4 tags
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...
1 tag
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...
4 tags
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....
October 2011
1 post
2 tags
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....
September 2011
1 post
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...
June 2011
1 post
Join the community on smallZOOM
It’s been a while since my last article, but here I am with something new. I’d like to show you one of my not so recent projects, that never got much exposure.
The idea behind this project is, that when you want to create a service or just a simple website, it’s important to get some feedback, so you know what to improve.
That’s where smallZOOM comes in. By posting your...
February 2011
2 posts
2 tags
Deferred Objects in jQuery 1.5 - AJAX
The latest version of our beloved jQuery introduced a couple of new features, one of which is called Deffered Objects. Now what is that exactly?
We often need to introduce some sort of a callback mechanism in JavaScript, where a function is invoked once a task is done. The most popular usecase would be AJAX.
If you wanted to create a AJAX request and then work with the response (prior to...
2 tags
Stash it with Git!
How often do you change something and one minute later it breaks
and you want to go back to the working version to debug it or just
run it again to see how it works.
But what do you do with all those changes you already made? Since
something isn’t working, you probably haven’t commited anything
to the repository yet.
Hide it in your Secret Stash
You can actually go back without...
January 2011
2 posts
3 tags
Your Code is Not Self Documenting
There is this movement that people should try to write
a self documenting code. Such code doesn’t require any
comments, because it is obvious what it does. While that
might be true, it’s not the whole truth.
Imagine the following code
def backup
backup_database()
backup_repositories()
backup_emails()
push_backups_to_s3()
end
At a first glance, it is obvious what the...
Redcar: It's Time for a Ruby Editor →
December 2010
4 posts
5 tags
Sinatra and SQLite on 64MB RAM
This article is a direct followup of Ruby on 64MB RAM.
If you didn’t read it, please do it now.
No MySQL
Since we’re running on very low resources, we need to think carefuly about every
process we want to run on our server.
First database that comes to mind is MySQL. We could probably squeeze it somewhere
in the remaining 40MB RAM, but is that really worth it? Our...
1 tag
Once again back on tumblr
I’ve moved my blogs multiple times in the past few years, always
expecting things to improve.
At first I started with WordPress, then somebody told me about tumblr,
so I moved everything to tumblr. Then I found out I can’t run any
server side scripts on tumblr, so I moved back to WordPress and yet again
installed every possible plugin you can imagine.
WordPress Plugins? Nothx
I...
3 tags
Ruby on 64MB RAM
This week I got my hands on 64MB RAM and very little CPU VPS. At first I thought it’s useless since there’s no way I can do anything with this, even the smallest Rails app barely runs on 256MB with nginx and MySQL.
But what about Sinatra? Could we run a small database driven application on such a tiny server? Let’s give it a try!
Let’s try to do this from the...
3 tags
Walk the Path to Ruby Enlightenment
As Ruby is gaining popularity, many new people come to learn it. Even though there are numerous numbers of books for the topics, many programmers prefer to learn by example.
Not everyone has the time to buy a thick book full of examples and just start reading it. Then you have to rewrite the examples from the book to try them yourself, which is pain in sometimes pain in the ass, as books contain...
May 2010
1 post
If you want to make a difference in the world, the single most important thing...
February 2010
6 posts
The Rails Upgrade Handbook is now available
omgbloglol:
The eBook I previously mentioned is now available! It’s only $12 at http://railsupgradehandbook.com.
Inside you’ll find…
Almost 120 pages of upgrade information
A step-by-step guide to upgrading your app to Rails 3
High-level discussion of what’s new in Rails 3
Practical tips on using Rails 3’s new features to improve your code
Real case studies of upgrading apps and...
1 tag
Instapaper - A simple tool to save web pages for... →
After some time of searching how to convert articles on the web to my Kindle, Instapaper saved the day. Compiling 20 articles into one bundle and sending it via whispernet is really nifty.
2 tags
Testing helps undrestanding the code
Do you often find yourself working on a project, where you don’t have any idea
what’s going on? Sometimes it is project you wrote several months ago, or you
were given a project after someone else and you have to finish it. It takes
time to learn how things work
Testing eliminates false assumptions
If you are learning new stuff, you naturally make some assumptions.
However, when you...
1 tag
11 tips for better code
There are several reasons why you should write clean and readable code. Most importantly, every code is written once, but read many times over and over. When you come back to your code next day, you have to read it. When you show your code to someone else, he has to read it. Thus by spending little more time with writing, you save A LOT of time when reading it again.
Lets see some of the...
2 tags
Traveling Back in Time With Source Control
Everyone makes mistakes, sometimes we wish to go back in time and fix things we’ve done wrong. Unfortunately that is not possible in real life. In the world of programming, you can go back and forth and change anything you want. To make this possible, you need a version control system (VCS).
There are many different VCSs out there, most of which you will never use, but they generally fall...
2 tags
Testing is waste of time, I know that my code...
Even though there are literally hundreds of books and articles about Test Driven Development, there are still lots of people that are untouched by the power of testing.
There are severals reasons why you might not want to write tests:
It takes too much time.
It is not worth it.
I’m too lazy.
I don’t know how to do it.
I know my code works because I ran it once and it worked.
...