Browsing articles tagged with " ruby"
Nov
10
2011

Writing a Script to Validate HTML/CSS of a Webpage in Ruby

In this post, I am going to write HTML and CSS Validators in Ruby and PHP. W3C HTML and CSS Validators basically check the validity of the URL supplied to it. It is always a good idea to write completely valid HTML and CSS for several reasons. The W3C HTML Validator checks the markup validity of Web Documents in HTML, XHTML, etc. while the W3C CSS Validator does the same for Web Documents in CSS. These validators [...]

Nov
6
2011

Get Bitcoin Market Rate

Bitcoin is a decentralized digital currency that can be used to make payments to anyone and anywhere in the world. Many institutions and organizations these days have started to accept payments in bitcoins. Even many freelancers these days accept payments in bitcoins! From Wikipedia – Bitcoin is a decentralized, peer-to-peer network that tracks and verifies transactions. Satoshi Nakamoto created Bitcoin in 2009 and described his work in a self-published paper. The term Bitcoin is also used to refer to the digital currency implementation [...]

Nov
3
2011

Quick Tip: Installing Ruby Gems in the user’s Home Directory

Note: The Operating System in use is Ubuntu Linux (11.04) My Gem Environment – After spending quite sometime to find the correct way to install my ruby gems in the HOME directory instead of the system-wide directory (/usr/local/lib/ruby/gems/1.9.1) , i found that the solution was indeed quite simple – You can even put “gem: –user-install” in your ~/.gemrc for rubygems to do that automatically on `gem install`. The problem was that, `gem install gem_name` would [...]

Jun
14
2011

For Loops in Ruby

There is no C++/Java/PHP type for loop in Ruby like this – for( init, while-condition, increment ) { // code here } So i just tried to write one in Ruby for fun, here is the code – So whats going on ? 1. First of all, the loop method in Ruby accepts a block and loops over it until a break is encountered. 2. ->{x < 5} and ->{x += 1} are basically shorter [...]

Jun
6
2011

PHP Urlencode equivalent in Ruby

If you are finding a way to encode urls in ruby then here is a quick tip – Short Answer: You could use the URI class or the CGI class. We have CGI.escape and URI.escape, but they have some slight differences. I have tried to show the differences in IRB as follows – So i hope you can see the difference now and can choose the one you need. Cheers!

Jun
2
2011

Find where a method is defined in Ruby

There are times when you might be working on a codebase with other people and spot a method which you do not know about. You may want to locate the source of that method to learn and understand more about its functionality. So, Here is a quick tip on how to find where a method is defined or located. I was working on a project where i found this piece of code – var = [...]

May
28
2011

Install Ruby 1.9.2 on Ubuntu

As you all know Ruby is one of the most popular programming language on the web. It is recommended to install ruby 1.9.2 instead of 1.8.x I tried to install ruby from the package manager on Ubuntu, but ruby 1.9.2 is not there in the repo. So, I am going to show you how to install ruby 1.9.2 on Ubuntu Step 1 – Fire up the terminal and execute these few commands – Step 2 [...]