Mistři v programování na #hovnokod

paranoia gem

  # Please do not use this method in production.
  # Pretty please.
  def self.I_AM_THE_DESTROYER!
    # TODO: actually implement spelling error fixes
    puts %Q{
      Sharon: "There should be a method called I_AM_THE_DESTROYER!"
      Ryan:   "What should this method do?"
      Sharon: "It should fix all the spelling errors on the page!"
}
  end

Anonymous,

Ruby je krasny jazyk `{"childKey"=>"childValue"}`

p ({ "parentKey" => { "childKey" => "childValue" } }).first.last

Anonymous,

invalid date (12 + 1) Date.today.month.class => Fixnum

end_date = Date.today
end_date.change(day: 1, month: end_date.month + 1)

Anonymous,

Rekvalifikace z Pascalu na Ruby

sFileName=ARGV[0]                                # jmeno souboru z prikazoveho radku
sFileName=FILE_NAME \
     if(sFileName.nil?())                        # popr. neni-li zadano

#
### nacteni dat, vytvoreni asociativniho pole
#
nTotalValid=0                                    # pocet platnych polozek
nTotalInput=0                                    # pocet vstupnich polozek
hList=Hash.new(0)                                # vychozi hodnota ~0
oInputFile=File.open(sFileName)
until(oInputFile.eof?())
     sS=oInputFile.readline().chomp!()
# popr. doplnit vynechani 'prazdnych radek'
     nTotalInput+=1
     aResults=sS.split(MAIL_SEPARATOR)
     next \
          if(aResults.length()<2)                # tzn. (zjevne) neni platna E-adresa
     nTotalValid+=1
     sKey=aResults[1].downcase()                 # prevod kvuli vylouceni 'falesnych' duplicit
     hList[sKey]+=1                              # predpoklada nastaveni vychozi hodnoty
end
oInputFile.close()

#
### histogram dle cetnosti
#
aList=hList.keys().sort!() \
     {|sA,sB|
     nResult=hList[sB]<=>hList[sA]               # (sestupne) setrideni (klicu) podle hodnot
     (nResult==0)?(sA<=>sB):nResult              # a v pripade shody dotrideni podle klicu
	 }


Anonymous,


Anonymous,