I know the answer (it's 42)

A blog on coding, .NET, .NET Compact Framework and life in general....

December, 2007

Posts
  • I know the answer (it's 42)

    Choose your company name well

    • 2 Comments
    Picture 057

    Sometime back Hutch phone in India got bought over by the international phone giant vodafone. They re-branded Hutch in India to Vodafone.

    Now when I call up home and the phone is busy I get a recorded message in Bengali which means "The Vodafone number you're trying to call is busy". All that is good but the problem is that vodafone in Bengali exactly means foolish phone. So I just hang up and wait for the foolish-phone to get free.

     

    Cross posted here...

  • I know the answer (it's 42)

    Bar Charts on the console

    • 1 Comments
    Golconda fort arches

    I work on the UI action recorder and it has a strict performance requirement. The tool dumps the time it takes to record each action in it's log and that is compared against the maximum allowed value (otherwise the system will seem sluggish). To do this obviously we need fancy charts, as everyone likes them, other than of course the alpha-geeks :).

    However, I like the console chart. Way back my mom used to work on Main-frames that ran COBOL on them and dumped out business data on paper at the end of the day. These reports had these printed bar charts.

    I wrote a small ruby script to dump these charts on the console. The output looks like

    D:\MyStuff\Code\Ruby>perf c:\logs\Recorder_20071118_144855.843.log
    c:/logs/Recorder_20071118_144855.843.log ===============================>
      640 ********************************************************************************
        0 *
      109 *************
        0 *
       46 *****
        0 *
    
    

    Serves the same purpose as their fancier counterpart but manages to look uber geeky.

    >> Cross-posted here...

  • I know the answer (it's 42)

    Fun Windows Home Server site

    • 1 Comments
    2006_1101_200024

    Windows Home Server team has a nice light-hearted site up at http://www.stayathomeserver.com/. All of it was funny, until I reached the page http://www.stayathomeserver.com/book.aspx. It says "daddy wants to give mommy a special gift.... So he buys a stay-at-home server".  That's not funny, "Wife Acceptance Factor" would be reflecting nitrogen freezing point for a home server.

    You can sneak one in, understate the price and show all the image streaming to kinda buy acceptance, but a gift, no way :)

  • I know the answer (it's 42)

    Support for range in programming languages

    • 5 Comments

    DSCF2530

    The .NET platform and the languages on top of it have limited or no support for range of values. Data ranges are one of the most common data-types and somehow it's not there. Funnily most programmers do not even seem to miss it (unless of course if you have used Ruby).

    How would you specify a valid range of age and validate user data against it? If you know the maximum and minimum values, at max you'd define a MaxAge and MinAge consts and strew the code with if(age < MinAge|| age >MaxAge). Or maybe you'll define a class to encapsulate this and add a IsValid method.

    However, in Ruby, Range is a standard DataType like say string. To do the above processing you'd do

    age = 1..120
    
    print age.include?(50)
    print age.include?(130)


    print age === (50) # more easier way to do include? test using the === operator

    So intuitively you create a range using start..stop.

    Creating a range of data is also very simple. Say you want to generate the column numbers for an excel sheet, you'd do the following

    column = 'A'..'ZZ'
    
    column.to_a # creates an array of all the values
    
    column.each {|v| puts "#{v}\n"}
    

    Similarly ranges can be easily created for any class by implementing some special methods. On ruby the support of Range is in the compiler and makes the code very easy to develop and intuitive.

    >>Cross posted here

Page 1 of 1 (4 items)