Ruby gives you two basic ways to organize your program so that you can run different parts of it ``at the same time.'' You can split up cooperating tasks within the program, using multiple threads, or you can split up tasks between different programs, using multiple processes. Let's look at each in turn. Multithreading Often the simplest way to do two things at once is by using Ruby threads .
If you were a Unix shell fan, I bed that the “grep” command would be in your top-used list. But as for the Ruby programming, are you still prefer “grep” to the other methods come with the “Enumerable” module? Do you know in most of the situation, using “grep” is more handy and powerful than the commonly used “map” or “select” methods?
So yesterday we saw how to setup and run ruby scripts as executables from the command line. While this is pretty rad, it definitely has its limitations. For one, it’s not very portable and secondly it just isn’t very flexible or powerful. If we stuck with this approach we’d need to write our own semantic versioning, we’d have to setup a way to make sure that all of our required 3rd party gems get installed properly… really it’ll just be a big mess if we try to hand-roll it.
Rake is a tool for controlling builds. In this part of the Rake tutorial, we see how to organize the Rake actions to apply to many similar tasks. In the RakeTutorialIntroduction, we talked about the basics of specifying dependencies and associating actions to build the files.
For journalists and researchers, being able to web-scrape is perhaps one of the most compelling reasons to learn programming. Agencies and organizations don't always release their information in nicely-formatted databases. Learning to web scrape allows you to gather, in an automated fashion, freely available data in virtually any kind of online format. It's also one of the best ways to practice programming because the end goal is clear: either you have the data or you don't. And there's little harm to be done, provided your program scrapes at a reasonable rate. This chapter introduces the strategy of web scraping with a very non-technical overview of how websites work.
By Ilya Grigorik on February 04, 2007 I often find myself trying to automate content extraction from a saved HTML file or a remote server. I've tried a number of approaches over the years, but the dynamic duo of Hpricot and Firebug blew me away - this is by far the fastest way to get what you want without compromising flexibility. Hpricot is an extremely powerful ruby-based HTML parser, and Firebug is arguably the best on-the-fly development add-on for Firefox. Now, I said it will take you about 60 seconds.
A method in Ruby is a set of expressions that returns a value. With methods, one can organize their code into subroutines that can be easily invoked from other areas of their program. Other languages sometimes refer to this as a function . A method may be defined as a part of a class or separately. [ edit ] Method Calls
Installing Ruby 1.9.3 on Ubuntu 12.04 Precise Pengolin (without RVM) 02 May, 2012 The new Ubuntu release has just rolled around and with it a slew of new packages. Personally, I'm tracking the development of Ruby quite closely but the default Ruby on Ubuntu ist still the 1.8 series which I can't recommend. Ruby 1.9 has some performance improvements and 1.9.3 in particular a lot of them compared to 1.9.2.
Ruby Version Manager which is known as RVM generally is a best software out there to manage multiple Ruby versions on a single PC. I myself have installed RVM a few times in different machines. But, whenever I needed to install RVM I had to visit a few sites that list all the necessary steps to set it up with Ruby, Rails.
Posted by sood on Thursday, January 20th, 2011 in Programming - Ruby/Rails Welcome to Part I of how to SSH to a Linux, Windows, etc. server using Ruby. This post will give you a complete code example to get you up and running right away!
Posted by sood on Thursday, January 20th, 2011 in Programming - Ruby/Rails Welcome to Part II of how to SSH to a server using Ruby. In Part I of this article, we gave you a simple example of how to SSH to a server and run a command. The hostname, username, password, and the command to execute were hardcoded in the example. In this article, we will expand on the first example by allowing you to specify the server connection information and the command to execute as command-line parameters. This will allow you to use the same script to connect to a variety of servers and execute any command without modifying the script over and over.
Before you can do anything with Net::SSH, you need to require the net/ssh module: Requiring Net::SSH [ruby] Once you have required the net/ssh module, you can begin an SSH session by calling Net::SSH.start .
3.1. What are Channels? The SSH protocol requires that requests for services on a remote machine be made over channels . A single SSH connection may contain multiple channels, all run simultaneously over that connection. Each channel, in turn, represents the processing of a single service.
This tutorial will walk you through the basics of setting up and using Capistrano. It will not introduce you to the deployment system that is bundled with Capistrano, but will instead focus on the more general areas of executing Capistrano and writing your own recipes. It will be primarily of interest to those wanting to use Capistrano in non-deployment domains, and to those who just wish to become more familiar with Capistrano itself. Installation
by Johan Lundahl - Dynamic languages , Tips & Tricks New to Capistrano? Read my previous and more introductory blog post on Capistrano - Remote builds with Capistrano . Are you using Capistrano and are confused why the user environment, the PATH for example, is different from when you log on to your server via SSH? Perhaps you have failed to use RVM or other user specific applications when running your Capistrano scripts?