Posted: April 20th, 2011 | Author: Dax | Filed under: Ruby | No Comments »
Here’s a short snippet of how to grab a domain’s nameserver info using Ruby.
require 'resolv'
a = []
dns = Resolv::DNS.new
dns.getresources("google.com", Resolv::DNS::Resource::IN::NS).collect {|n| a << n.name.to_s }
puts a
Posted: April 20th, 2011 | Author: Dax | Filed under: Ruby | No Comments »
This tutorial shows how you can read and write csv files in Ruby. I’m going to use a plugin called FasterCSV.
To install FasterCSV, type in your terminal:
sudo apt-get install fastercsv
In your ruby code:
require 'rubygems'
require 'faster_csv'
# Reading csv file
FasterCSV.foreach(csv_file, :quote_char => '"', :col_sep => ',', :row_sep => :auto) do |row|
puts row[0] # Output first cell
end
# Writing data into a csv file
FasterCSV.open("report.csv", "w") do |csv|
csv << ['Bulls','62','20']
csv << ['Spurs','61','21']
end
There are also other alternatives for parsing and writing csv files in Ruby. You can use CSV, CSVScan and CCSV
Posted: February 13th, 2010 | Author: Dax | Filed under: Personal | 1 Comment »
My wife and I just got back from the clinic today. She took an ultrasound and we found out we are going to have a baby girl! My first born is a baby girl! Everything is right where it should be…I hope and pray she’ll come out healthy. I’m so happy today
Posted: February 9th, 2010 | Author: Dax | Filed under: Javascript, PHP | No Comments »
If you are developing an CakePHP application where ajax is mostly used. It is advisable that you set the following session configurations inside your core.php.
Configure::write('Session.timeout', '86400'); // expires in 30 days
Configure::write('Security.level', 'medium');
If your application calls more than one ajax request at the same time, it is recommended that you set your ajax requests to synchronous to prevent session regeneration id errors.
Posted: February 9th, 2010 | Author: Dax | Filed under: Javascript | Tags: jQuery | No Comments »
This tutorial illustrates how to check if a plugin exists or if plugin has been already loaded usingĀ jQuery. This is particularly useful if you are writing your jQuery code that depends on that plugin.
if(jQuery().plugin_name) {
// plugin exists
} else {
// plugin not loaded
}