Rescue from MultiJson::DecodeError in Ruby on Rails
If you are developing an API with Rails you need to rescue from the errors produced by a bad formatted JSON. In order to do that I use a middleware file placed in app/middleware named ParamsParserRescue.rb.
I’d like to share some sites with programming challenges, also known as programming puzzles. I find them very useful to learn a new language, much more than reading a lot of books. Actually, I usually read one book for beginners of the language and after that I go to one of the following sites and start to code. My favourite is /r/dailyprogrammer. /r/DailyProgrammer. Subreddit with three challenges every week or so (easy, intermediate and hard).
Creating a great RESTful API
REST is a style of software architecture, often used in web. The design of Rails, for instance, is based a lot on REST. The idea behind this architecture is to have very similar interfaces to access all the resources in your system.
Recently I had to create 2 APIs in 3 months so I had to learn all I could in a very short time. I’d like to share some conclusions but giving the fact that to develop an API people usually say you need 10 years of experience take them with caution.
Subversion and files with @
If you have worked with Subversion and iOS you are probably aware of this problem. Whenever you are going to do something with a file that has an at sign in its name you can’t. For instance imagine you’ve just added a file for retina and try to add it to the repository (XCode can do this too): $ svn add email@example.com The message from Subversion will be: Skipped firstname.lastname@example.org That’s because Subversion uses the @ for other purposes.
Naming of predicate methods
A predicate method is tipically one that should return a boolean value (true or false). These methods are useful in a lot of scenarios, like when you have an class with a boolean attribute.
Too short routines?
I think as developers we tend to create complexity if we don’t think carefully about every line of code we are typing. Systems tend to be complex and managing that complexity is one of the main task we have. Routines are great, they are one of the best ways to encapsulate algorithms and make your code more readable. Sometimes we think routines are too short, but actually the usually are too long.
An important lesson from Objective-C
I’ve started to develop applications for iOS about 3 months ago and there were a lot of things new for me in that environment (there are a lot yet) and Objective-C wasn’t an exception.
Subversion: remove all the deleted files from a repository
In order to remove all the files from the repository after they have been deleted from disk you have a couple of options.
Return at the beginning of functions
I had a little doubt about when to do the return if you have a big if, something like the following function:
Origin of HTML radio buttons
The radio buttons in HTML come in handy when the user should select only one option in a form.