It’s a fact that Ruby on Rails programmers don’t buy books! Really! Ruby and Rails are changing fast. Books getting outdated in just a couple of months. Buying books is just a waste of time and money for nothing. At the time the books come out, Ruby on Rails developers already read blogs/saw screencasts or even get hands dirty committing to the rails core source code. Books are just for students, not for RoR...
We can makes Git’s status, branch, and diff commands much more readable by ading the following to ~/.gitconfig: [color] branch = auto diff = auto status = auto [color “branch”] current = yellow reverse local = yellow remote = green [color “diff”] meta = yellow bold frag = magenta bold old = red bold new = green bold [color “status”] added = yellow changed = green untracked =...
Just wanna share with you guys some of the common ruby array functions that I used every day. 1. Summing elements: This is a fairly common task. We’ll use Ruby’s inject method to sum all the items in the array and then print out the sum: my_array.inject(0){|sum,item| sum + item} 2. Double every item: This is a class of problem where we want to preform an operation on every element of the array. Again, this is fairly simple using Ruby’s map method. Think of performing a “mapping” from the first array to the second based on the function in the block. Keep in mind, this will return a new array and will NOT effect the original array. If we want to do a destructive map (change the initial array) we would use map!. This is a common convention in Ruby: my_array.map{|item| item*2 } 3. Finding all items that meet your criteria: If you want to collect all the values in the array that meet some criteria, we can do this using the (duh) find_all method. Again, this will return an array. The code below finds all items that are multiple’s of three : my_array.find_all{|item| item % 3 == 0 } 4. Combine techniques: Let’s now say we want to find the sume of all elements in our array that are multiples of 3. Ruby to the rescue! This is very simple because we can chain methods together gracefully in Ruby. Check it out: my_array.find_all{|item| item % 3 == 0 }.inject(0){|sum,item| sum + item } 5. Sorting: We can sort items in an array quite easily. Below, I will show...
Rails 3 assumes that everything is NOT html safe (a change of opinion from Rails 2). Now, all strings are html escaped by default: <%= h some_string %> is now the same as <%= some_string %> To unescape the HTML (i.e you already know that the string is OK to render out), you need to mark it as html_safe or use keyword raw : <%= some_string.html_safe %> or <%=raw some_string...
app developer singapore,web designer singapore,web application singapore,web design singapore,app development singapore,web design services singapore,singapore mobile app developer,ios developer singapore,singapore web development,mobile application developer singapore,design agency singapore,developer in singapore,singapore website design,website design singapore,ios app development singapore,mobile apps development singapore,web design company singapore,mobile app developer singapore,android developer singapore,singapore app developer,website developer singapore,graphic designer in singapore,singapore mobile application developer,web development singapore,developers in singapore,mobile application development singapore,singapore web design,web development company singapore,mobile app development singapore,mobile developer singapore,singapore web design services,ruby on rails developer singapore,website designer singapore,mobile game developer singapore,design firms in singapore,website development singapore,mobile apps singapore