Skip to content

Instantly share code, notes, and snippets.

@sriki77
sriki77 / car.io
Created November 13, 2011 12:04
Io Day 1
#!/usr/bin/env io
Vehicle := Object clone
Vehicle desc := "Moving Object"
Car := Vehicle clone
Car drive := method ("Vrooom..." println)
ferrari := Car clone
Car drive
Car slotNames println
@sriki77
sriki77 / csv.rb
Created November 12, 2011 12:37
Ruby Day 3
module ActsAsCsv
def self.included(base)
base.extend ClassMethods
base.act_as_csv
end
module ClassMethods
def act_as_csv
include InstanceMethods
Print array 4 elements each time
[*(1..16)].each { |v| v%4==0? p(v) : print("#{v},")}
@sriki77
sriki77 / Ruby_Day_1.rb
Created November 2, 2011 12:36
Ruby Day 1
#1. Print Hello World
puts "Hello World."
#2. Index of "Ruby"
puts "Hello Ruby".index("Ruby")
#3. Name 10 times
puts "Srikanth#{$/}" * 10
DateFormat indiaDtFmt = new SimpleDateFormat("dd/MM/yyyy HH'h'mm");
DateFormat gmtDtFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
indiaDtFmt.setTimeZone(TimeZone.getTimeZone("Asia/Calcutta"));
gmtDtFmt.setTimeZone(TimeZone.getTimeZone("GMT"));
Date worldWarIIDate = indiaDtFmt.parse("02/02/1944 06h30");
Date nonWorldWarIIDate = indiaDtFmt.parse("02/02/2006 06h30");
System.err.println(gmtDtFmt.format(worldWarIIDate) +" GMT");