Mistři v programování na #hovnokod

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,

#Napiste pseudokod, ktery invertuje radky, napr. "abc" -> "cba"

"abc".split("").reverse.join("").to_pseudocode

Anonymous,

Vskutku. Uh...

# converts some times to integers (errr, floats in strings, uh)
[:Application_Delay, :Handling_Time].each do |f|
  value = row[f]
  next if not value
  matches = value.match(/^(\d\d?):(\d\d?):(\d\d?)$/)

  if not matches
    row[f] = nil
    STDOUT.write('X')
    next
  else
    value = matches[1].to_i * 60 * 60 + matches[2].to_i * 60 + matches[3].to_i
    value = value.to_f.to_s
    value.gsub! '.', ','
    row[f] = value
  end
end

Anonymous,