Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 RUBY


  Use downcase! with caution in Ruby

Ruby provides ! to change state of some object in place. Hence if you see some functions have ! appended, it means the state of the caller of the function is expected to be changed. This is a very interesting Ruby feature. But sometimes one should be cautious when using this kind of functions because you would get unexpected behavior if using improperly.Let's take an example of String#downcase!. According to the documentation.Downcases the contents of str, returning nil if no changes were made. Note: case replacement is effective only in ASCII region.If there is a String pl...

3,798 0       RUBY EXCLAMATION MARK DOWNCASE


  Stub Mixlib::ShellOut and shell_out in Ruby unit testing

Unit testing is part of software development to ensure the tiny component of a function can work as designed. Different frameworks and tools can be used to run unit testing for different programming languages. In Ruby, one popular unit testing framework is Rspec, or Chefspec if you are writing Chef recipes.While writing Chef recipes, some low level commands(DOS commands or shell commands) need to be executed on the managed resource to perform actions or gather information. For example, listing directory and files on an Unix system using ls command. Mixlib-Shellout can be used to execute o...

9,559 0       RUBY UNIT TESTING RSPEC CHEFSPEC SHELL_OUT


  Ruby net-scp cannot scp multiple files with asterisk(*)

net-ssh/net-scp is a Ruby gem which can be used to scp files between different *nix machines. It's similar to how the *nix scp command. It can be used to scp a file or a directory. However, it seems it has some problem to scp multiple files using pattern *.For example, below script is supposed to download all files from remote directory to local directory:require 'net/scp'host = 'testmachine'login = 'testaccount'password = "testpassword"remote_path = '/tmp/remote_dir/*'Net::SCP.start(host, login, :password => password) do |scp| scp.download(remote_path, '.')endThe...

5,074 7       RUBY NET-SCP ASTERISK MULTIPLE FILES


  Resolve stylesheet_link_tag fails to work in Ruby on Rails

When developing Ruby On Rails application, developers sometimes will see an unexpected behavior where the application cannot be loaded due to "TypeError: Object doesn't support this property or method" when invoking stylesheet_link_tag. The symptom looks like And the Rails log will show something similar to belowThe error occurs because there is some problem finding the correct assets which are located in app/assets. To resolve the issue, you can following below steps.Add gem 'coffee-script-source', '1.8.0' into Gemfile and run bundle install thenRun bundle update coffee-script-sourceRest...

10,099 2       RUBY ON RAILS STYLESHEET_LINK_TAG JAVASCRIPT_INCLUDE_TAG TYPEERROR


  How to Choose the Right Ruby on Rails Hosting Platform

Over the last decade, Ruby on Rails has become an increasingly popular framework for web-based apps. At its beginnings, hosting Rails was a real challenge and required a fair amount of relevant know-how. Nowadays, there are dozens of hosting platforms that provide cheap and accessible services for building and deploying Rails apps.In general, the choice of hosting should be based on your requirements and technical skills – some platforms are much more difficult to handle than others. Here's a selection of some of the most renowned Rails hosting platform s– read on to see how they d...

6,059 0       RUBY ON RAILS RUBY HOSTING


  6 Reasons Why Devs Should Learn Ruby on Rails

Ruby on Rails has during the last ten years become an increasingly popular framework for web app development. The current shaky economy and rapidly changing tech environment requires the art of app building to be faster and more cost-effective. That's why becoming fluent in Rails might be a great way for developers to expand their knowledge, which can land them a number of great jobs or interesting projects, as well as grant access to a thriving community.Let's start with the basics – what exactly is Ruby on Rails? It's a web application framework written in Ruby programming language tha...

6,865 0       ADVANTAGE RUBY ON RAILS


  World of Father of Ruby

"I am Yukihiro Matsumoto, I believe keyboard can change the world" is a video about Father of Ruby -- Yukihiro Matsumoto. This video introduces us a father, a husband rather than a programmer.Yukihiro Matsumoto shared his understanding about programming in this video. Computer is not quite smart, it cannot understand human languages, so if we want computers to complete jobs we assign to them, then we need something both human beings and computers can understand. That's why we have programming languages.Yukihiro Matsumoto loves programming, but he loves his family more. He works at home lo...

11,651 0       YUKIHIRO MATSUMOTO


  Gracefully exiting from console programs in Ruby

Imagine you write a CLI program or a Rake task which loops through some data performing some work on it. You run it and then you remembered something. You’d love to kill the process with ctrl-c, but that will raise an exception somewhere in the loop. What you want is for the iteration to complete and then you want the program to quit.You could handle the Interrupt exception or add some conditions. But how about a cleaner and reusable way?No problem - you can trap signals, which means we can trap the ctrl-c (which is an INT signal). Servers, like unicorn, use signals for graceful restart...

6,354 0       RUBY CONSOLE EXIT COMMAND WINDOW GRACEFUL