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

 RUBY


  Learning Ruby and Ruby vs Lisp

The company I work for has a lot of legacy Ruby code, and as Ruby has become kind of a mainstream language, I decided to get a book about it and learn how it works. As my learning resource, I chose The Ruby Programming language by David Flanagan and Yukihiro Matsumoto as that receives great customer reviews, covers Ruby 1.8.7 and 1.9 and is authoritative because the language creator is one of the authors. The book makes a good read in general. There are plenty of code examples, but not too much to obscure the prose. What I found first interesting, later annoyi...

6,526 1       OOP RUBY DIFFERENCE FEATURE FUNCTIONAL LISP


  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,397 0       RUBY CONSOLE EXIT COMMAND WINDOW GRACEFUL


  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,083 0       RUBY ON RAILS RUBY HOSTING


  Resolve SystemStackError issue when resolving IP address in Ruby

In Ruby, Resolv is the default DNS resolution implementation. It can be used to resolve IP address of a hostname. To use it, one just needs to require 'resolv' in the code. But sometimes, a user would want to check /etc/hosts first or some other mechanisms to resolve an IP address. In this case, one can require 'resolv-replace' and then replace the default DNS resolvers with customized DNS resolvers.For example, using resolv-replace, one would writerequire 'resolv-replace'Resolv::DefaultResolver.replace_resolvers([Resolv::Hosts.new, Resolv::DNS.new])Resolv.getaddress 'some-site.com'In this cas...

5,420 0       RUBY RUBY ON RAILS NETWORK


  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,112 7       RUBY NET-SCP ASTERISK MULTIPLE FILES


  How to check which Ohai plugin hangs in chef client run

Ohai plugins are very important components in chef client which aims to provide resource management automation on a server. The data discovered by Ohai plugins are describing the current state of the server and they will be used to maintain the server in a desired state. Each Ohai plugin discovers a specific pierce of information about the server such as cpu, memory, middleware etc.However, there are rare occasions(well I am a bit optimistic here) someone may find that the chef client run is hanging and it hangs at Ohai plugin discovery stage. Given every server has its own unique co...

4,955 0       HOW TO CHEF-CLIENT OHAI UPTIME HANG


  Ruby WinRM undefined method `split' for nil:NilClass

WinRM service is a service provided by Windows to enable remote access a Windows system. It is similar to what SSH is for *nix. And it is frequently used in applications which want to automate process or accessing remote Windows system and perform actions on them. Ruby also provided the WinRM gem which is an implementation of the WinRM service. When using WinRM gem, one may often want to use :negotiate as the transport protocol for authentication. This transport will negotiate using different security mechanisms depends on the setting. These mechanisms include Kerberos, NTLM, Basic e...

4,428 0       RUBY WINRM INIT_AUTH PROXY


  Handle NXDomain error when resolving IP address in Ruby DNS resolver

In another post, we covered how to resolve SystemStackError when resolving IP address in Ruby. In this post, we would cover another common issue where a NXDomain error is returned when resolving an IP address. The NXDomain error means that the queried domain name does not exist in the DNS.In Ruby, DNS resolver library will use /etc/resolv.conf by default get the name servers to resolve the domain name. There are multiple DNS name servers can be specified in /etc/resolv.conf with below format.nameserver nameserver nameserver ...By default, only the top MAXNS name servers(3 in Linux by...

4,267 0       RUBY RUBY ON RAILS NETWORK DNS NXDOMAIN