Esteban Pastorino

Simple File Uploads with Backbone.js

Backbone.js is great for doing single page apps or to tidy up some messy javascript code. But there are a few things that are a bit tricky to do, like uploading files. Sure, some browsers support uploading files via XHR, but some others don’t (I’m looking at you IE). There are a few workarounds for this situation. Here’s a quick explanation on how I achieved file uploads in backbone in a recent project.

Rails Security Pitfalls

Another article for SitePoint. This one’s about some security issues and considerations on Rails. A few important things to have in mind. Go take a look!

Quick Ruby Tip: || vs or

Quick heads up on operator precedence:

If you want to assign a value to a variable depending on a boolean, use || not or.

|| takes precendence over =. or does not.

Example:

or operator
1
2
a = false or true
puts a # => false
|| operator
1
2
a = false || true
puts a # => true

I got stuck a few minutes today until I realized where the error was.

Hope this helps and you don’t fall in the same trap :)

Fixing a CPU-consuming logrotate

Last week I noticed one CI server was taking a huge amount of time to finish a test suite. It was supposed to run a few minutes, but was taking hours instead. A few months before, when the server was just set up, it ran in a few minutes as expected. Here’s how it was diagnosed and fixed.