HNHacker News
TopNewBestAskShowJobs

prakashk

939 karma · joined April 5, 2010

submissionscomments
prakashk··on Automate the Boring Stuff with Python
Hi Al, I looked for a way to send feedback on the site, but couldn't find anything. So, posting it here. On the menu of chapters (displayed when you click on the floating menu button on every page), the sorting is broken; lexical order instead of numerical order is being used.

Thanks for writing this book and making it available under the Creative Commons License.

prakashk··on CSV Challenge
In addition to the explanation by a1369209993's explanation (https://news.ycombinator.com/item?id=9438730):

    * <> reads from file(s) specified as command-line arguments (data.json in this case)
    * Option -0777 tells Perl to slurp the whole file
    * Option -MJSON loads the JSON module
prakashk··on CSV Challenge
Perl (assuming the data is downloaded):

    perl -0777 -MJSON -le '
        print for "name,creditcard\n",
                  map {"$_->{name},$_->{creditcard}\n"}
                  grep {$_->{creditcard}}
                  @{JSON->new->decode(<>)}
    ' data.json > 20150425.csv
prakashk··on Stop using tail -f (mostly)
This is not a replacement for searching for a specific string in `less` which highlights the matches, and eliminates the need for scanning the text manually which is harder and prone to missing information.
prakashk··on Data munging in Perl 6 vs. Perl 5
It does return the values as expected. See my other reply: https://news.ycombinator.com/item?id=8730798
prakashk··on Data munging in Perl 6 vs. Perl 5
> $glob2 = glob(".c"); # returns the second match of "" and stores it in $glob2

Not true.

    $ touch 1 2 3 4.c 5.c 6.c 7 8
    $ ls
    1  2  3  4.c  5.c  6.c  7  8
    $ perl -E '
         @globvals = glob("*");
         say "globvals = @globvals";
         $glob1 = glob("*");
         $glob2 = glob("*.c");
         say "glob1 = $glob1\nglob2 = $glob2"
      '
    globvals = 1 2 3 4.c 5.c 6.c 7 8
    glob1 = 1
    glob2 = 4.c
As you can see, the third call to glob returns the expected value.

Here's how glob is documented in the perlfunc document[1].

    glob    In list context, returns a (possibly empty) list of filename
            expansions on the value of EXPR such as the standard Unix shell
            /bin/csh would do. In scalar context, glob iterates through such
            filename expansions, returning undef when the list is exhausted.
[1]: http://perldoc.perl.org/functions/glob.html
prakashk··on Data munging in Perl 6 vs. Perl 5
Context is a pretty important, pervasive concept in Perl. So much so that chromatic discusses it in the very first chapter[1] of his Modern Perl book[2].

    [1]: http://modernperlbooks.com/books/modern_perl_2014/01-perl-philosophy.html#Q29udGV4dA
    [2]: This very accessible, and free, book (updated very recently for 2014) is a must-read for any Perl developer.
prakashk··on What Was Said at the Uber Dinner
An up-front and prominent disclosure could also color my perception in the author's favor, and I'd be more inclined to give higher credence to author's arguments.
prakashk··on Hints for writing Unix tools
The main problem here is that a change that should have been done as part of an individual's customization was made to a shared configuration file.
prakashk··on ISRO Mars Orbiter Mission: Spacecraft successfully enters Martian Orbit
Thanks for the recommendations.

While searching for these, I found what appears to be a pretty comprehensive list of books on Indian space program here: http://forum.nasaspaceflight.com/index.php?topic=33814.0

prakashk··on Unbiased Randomization with the Fisher-Yates Shuffle
List::Util [1], part of Perl 5 standard library, offers shuffle function which implements Fisher-Yates [2].

[1]: https://metacpan.org/pod/List::Util#values-shuffle-values [2]: http://www.perlmonks.org/?node_id=1869

prakashk··on EtherCalc: Open-source web spreadsheet
audreyt was also the principal contributor to pugs [1], a Perl 6 implementation written in Haskell (partly).

[1]: https://github.com/perl6/Pugs.hs

prakashk··on A Gentle Introduction to Monad Transformers – or, Values as Exceptions
See "The Marvels of Monads" (http://blogs.msdn.com/b/wesdyer/archive/2008/01/11/the-marve...), where the author talks about controlling complexity using composition, and how monads aid in accomplishing it.

It's all in C#.

prakashk··on Strapfork – Easy Custom Bootstrap
Aside: this is the first HN post I have come across in a long time, that has more comments than points!
prakashk··on Flappy Bird in Swift
Apple is the new Microsoft.
prakashk··on India's pro-business Modi storms to historic election win
> If you are going to hold someone to a standard, then hold EVERYONE to that standard.

True. However, the question is, does it need to be stated explicitly every time someone gets criticized, or asked to be held accountable for something.

> You can't just hold someone to an arbitrary standard just because you don't like them.

I don't think that was happening here. Modi wasn't being held to an "arbitrary standard" because he wasn't "liked". His actions were the point of discussion here.

prakashk··on Ack is a grep-like tool, optimised for programmers
> I think this website was going to be some ironic trash-talking about grep.

Andy Lester, the primary author of ack, is one of the nicest guys I know of. You wouldn't see any trash-talking on that site. He even changed the name of the site from "better than grep" to "beyond grep" [1].

In fact, he gives props to similar tools like ag and others [2].

[1] https://news.ycombinator.com/item?id=5578304 [2] http://beyondgrep.com/more-tools/

prakashk··on The next version of DuckDuckGo
The "What is this?" link below Cloud Save buttons doesn't respond (Firefox 30.0a2 on Ubuntu 12.04). Right-click and Open Link in a New Tab results in a "403 Forbidden".
prakashk··on TLS/SSL implementation in Haskell
http://www.ubuntuask.com/q/answers-haskell-platform-on-13-04...
prakashk··on A brief introduction to Haskell, and why it matters
I recently learned about the `interact` function in Haskell, which makes it easy to write programs reading from standard input and write to standard output, just like many of the Unix tools.

For example, if you want to print the id and name of each user from a file in the /etc/passwd format:

    -- display all users: ids and names from /etc/passwd

    import Data.List.Split (splitOn)

    eachLine :: (String -> String) -> (String -> String)
    eachLine f = unlines . map f . lines

    showUser :: String -> String
    showUser line = fields !! 0 ++ "\t" ++ fields !! 4
                    where fields = splitOn ":" line

    main = interact (eachLine showUser)
This can be run, like (assuming the program is saved in list-users.hs):

    $ runhaskell list-users.hs < /etc/passwd
I am very new to Haskell, and I am sure there are other, perhaps better ways to do this.
prakashk··on You Don't Want to Think Like a Programmer
Your last example could be aligned a little bit differently to make it easier to visually parse:

    var                        firstVar = "one";
    var                       secondVar = "two";
    var                        thirdVar = "three";
    var       thisVarHasAReallyLongName = "four";
    var thisIsAnotherVarWithALongerName = "five";
prakashk··on Indian School Girl Creates Washing Machine That Runs Without Electricity
> it's a bit misleading to suggest she's created a washing machine that "runs without electricity"

I don't think it's misleading at all.

If electricity and electric cars were available and commonplace in Fred Flintstone's era, and he designed a car that used no electricity, then he could and should be credited for designing a car that "ran without electricity".

Now, if someone said this machine ran without energy, that would me not only misleading, but a lie.

> At this stage of mankind's industrialization, it's disingenuous to look at a human powered machine as an improvement over an electricity powered one.

That's a legitimate point, and one that is worth discussing about.

prakashk··on Perfectly centered break of a perfectly aligned pool ball rack
> I think he is confused.

You don't mean that the GP (taliesinb) is confused, do you?. He works for Wolfram Research, developing Mathematica.

prakashk··on Interactive SICP
> this beautiful PDF version: https://github.com/sarabander/sicp-pdf/blob/master/sicp.pdf

This is the direct link to the pdf file: https://github.com/sarabander/sicp-pdf/raw/master/sicp.pdf

prakashk··on Faker is a Python package that generates fake data for you
> Aren't they all kind of inspired by the original Perl implementation?

The original Perl implementation is Data::Faker (https://metacpan.org/pod/Data::Faker). The earliest version available on CPAN appears to be from 2005.

prakashk··on Code != computer science
> Of course if this was Perl it would be even worse.

Sigh. Sadly, it has become fashionable to bring up Perl only to ridicule it even when there is absolutely no context or need.

Take a look at this implementation [1] of doubly linked list in Perl. Tell me how that is worse [2].

Now, I will go back to my corner to being productive using Perl or whatever language I need.

[1] https://metacpan.org/source/LEONT/List-DoubleLinked-0.003/li...

[2] Of course, I have no way of knowing if it is an exact or even close translation of your code, but it does implement doubly linked lists.

prakashk··on Clojure vs. Scala
I am not as fluent in Scala as I am in Perl, but I do like both. Perhaps, I am an exception.
prakashk··on The Mathematical Hacker (2012)
> "What is mathematics?"

Are you referring to the book authored by Richard Courant (http://www.amazon.com/dp/0195105192)?

prakashk··on This Google ad has moved people to tears across India and Pakistan
Here's the story of Saroo Munshi Khan finding his home/family 26 years after he lost them with the help of Google Earth:

http://googleblog.blogspot.com/2013/10/a-long-way-home-with-...

He wrote a book about his experience: "A Long Way Home" (http://www.penguin.com.au/products/9780670077045/long-way-ho...)

prakashk··on Indian generics and AIDS
> It's those 50-60 odd corrupt assholes on the top ...

Are you saying that corruption exists only among this limited group of individuals?

← PreviousPage 2 of 7Next →