News for hackers. Stuff that matters.

Amnon

Re:Vimroom on Saturday October 08, 2011 @03:25PM (#3088707)
What I do is split the window vertically (C-w v), and resize the left window so that the text in the right window is centered on the screen.
Actually, 10. doesn't necessarily repeat the last command 10 times, it just runs it again with an argument of 10. For example ">>10." will indent the current line and then indent it and the following 9 lines.

I still haven't found an easy way to indent a line N times without pressing ">" 2N times...

Re:Introducing a new data structure, streams, in Javascript on Sunday September 11, 2011 @03:12PM (#2984515)
The advantage of "streams" is that it can be used to elegantly define infinite sequences recursively.

For example, you can define powers of two as:

   var powersOf2 = new Stream(1, function() {
     return powersOf2.scale(2);
   });
(untested) which means that the sequence of powers of 2 begins with 1 follows with the the same sequence scaled by 2!

The implementation in the linked article however seems to be flawed, since it doesn't store the node's tail after computing it. This means that to get each element of the sequence you have to compute all the elements before it (even though you already did in order to get to that element).

This works not only for numbers but for other infinite sequences such as expressions in a language. I recommend the book Higher Order Perl if you're interested in this.

Re:Nastiest Python list comprehension ever on Friday February 25, 2011 @05:09PM (#2263984)
Of course Python doesn't automatically ensure good code. But the Python code in your example is readable -- pretty match as readable as it gets, considering the constraints I mentioned.
Re:Nastiest Python list comprehension ever on Friday February 25, 2011 @02:32PM (#2263469)
shells were specifically made to operate with external programs (the Unix way) while Python is a more general programming language, so naturally it will be more verbose for this kind of task.

Of course the first syntax breaks when one of the arguments has a space or any other meta-character in it.

Re:Mental hashing for paper address books (with Python) on Sunday January 09, 2011 @10:43AM (#2085610)
Did anyone notice the mailing list? It's one dedicated to the author. Interesting alternative for a blog.
Re:Google’s decreasingly useful, spam-filled web search on Thursday January 06, 2011 @07:25AM (#2075007)
Yes! Something changed in the search algorithm recently, for the worse. I search for X and get Y. Is this documented anywhere?

(I didn't know that a "+" prefix can fix this. Thanks for the info.)

It will also be the slowest only 1/3 of the time, so in fact this isn't an explanation why "the other lines" seem to be faster.
Re:"Whale Fail" - Google Books' Error Page on Tuesday December 07, 2010 @05:12AM (#1978591)
Not if you don't know what the Fail Whale is.
Re:"Whale Fail" - Google Books' Error Page on Monday December 06, 2010 @04:50PM (#1976962)
Turns out the page is a reference to a certain Fail Whale -- http://www.whatisfailwhale.info/.

The thing that's bothering me about the fail whale -- all the strings that hold the whale are curved. Is this physically possible? (Assuming the birds can hold the whale in the air). Shouldn't at least one of the strings be a straight line?

Re:Two Envelopes Problem on Saturday August 07, 2010 @10:52AM (#1583634)
Statement 1 isn't true. If you have 10$ in the envelope, and it's the smaller envelope, you gain 10$. But if it's the larger envelope you don't lose 10$. The fallacy is that "x" refers to different things in each case.

Statement 2 is true but it isn't relevant, since you don't know the posterior probability given y. If the envelope contains the smaller amount of money then there is no way you can lose -- it's not a 50-50 chance.

Actually I wasn't talking about the monetary value. It's not an investment scheme but a way to keep souvenirs for the future.

(Apparently the people at HN tend to think of everything as a business opportunity ;) )

Re:So, What Does "HREF" Stand For, Anyway? on Friday August 06, 2010 @09:15AM (#1580912)
Interesting. The glossary at http://www.w3.org/MarkUp/html-spec/html-spec_2.html#GLOSS19 defines hyperlink as

"a relationship between two anchors, called the head and the tail. The link goes from the tail to the head. The head and tail are also known as destination and source, respectively."

So what we have is "Anchor Head REFerence" when we should simply have "Link DESTination". Think about it when you next design a world changing markup language.

Re:Ghost of WWII: 1940's meticulously overlaid on modern day on Tuesday August 03, 2010 @04:27AM (#1570505)
> Everything in the world has a U-shaped value curve.

On this point, a good thing to do is to keep some of the ubiquitous everyday things when you want to throw them away. Especially outdated technology like, say, old mobile phones. In 50 years they will become a rarity.

Re:Tupper's Self-Referential Formula on Monday August 02, 2010 @09:57AM (#1567647)
Yes, it's a little disappointing. It's like saying the Unix cat is a self referential program since it can be used to display its own source code.
Re:Hacker News User Base Changed? on Tuesday July 27, 2010 @11:46AM (#1551576)
This should be mentioned in every discussion about HN's negative aspects: click your login at the top of the screen and change noprocast to yes. Next time you'll visit HN, you'll see a "Get back to work!" message and hopefully you'll go do something more productive.
Re:Hacker News User Base Changed? on Tuesday July 27, 2010 @11:39AM (#1551551)
What's with the periodicity of the graph? It looks like users who have signed at the beginning of the year -- any year -- are more likely to comment? Or more likely, much more people sign at the beginning of the year. Strange, in any case.
Re:Ask HN: Food hacks for eating well? on Sunday July 25, 2010 @11:00AM (#1545632)
> The end result is that people always tell me I am too skinny even though I eat a lot.

Umm... Doesn't being too skinny mean you're not eating well? (I'm asking because I'm in the same situation).

Re:"Uh-oh. I didn't know conversation had rules." on Wednesday July 21, 2010 @05:19AM (#1534728)
I wasn't explicit enough about the fact that the article originally attributed the term to Grice, and then an anonymous editor changed it to this scholar who isn't mentioned anywhere else on the Web.

Also, in many cases the hypothesis that Wikipedia is correct isn't /very/ likely.

Re:"Uh-oh. I didn't know conversation had rules." on Tuesday July 20, 2010 @03:40PM (#1533219)
I wanted to write about how linguistics should be handled by linguists not philosophers, so I checked the citations. I noticed that Wikipedia says implicature was coined by Patrick McBride which, according to Wikipedia is "a retired American soccer midfielder". Turns out the article was edited some time ago by an anonymous user. I guess not enough people visited it to notice.
Re:Nigerian Internet use increasing on Sunday July 18, 2010 @12:44PM (#1526088)
I suppose you're right. It was the rich man's bias, thinking that you don't need money to be happy. (That word again). Also, I didn't realize that you were speaking more generally.

Of course the lack of internet access is also related to other things (e.g. food shortage) that I didn't refer to.

Re:Google JavaScript style guidelines on Sunday July 18, 2010 @09:30AM (#1525734)
The "tips and tricks" section is interesting. I didn't know that iterating over node lists can take O(n^2). Also the Closure Compiler was new to me.
> So, how about if we could compile JavaScript into native code?

Isn't that what all modern JavaScript engines do? If so, how are the results for the experiment so good? My guess is that he didn't take the compilation time into account in his own method.

Re:Nigerian Internet use increasing on Sunday July 18, 2010 @09:16AM (#1525711)
You assume that Internet access makes you happier. I'm not sure. At least they are spared a lot of distractions :)
Re:Ask HN: What would alien code look like? on Monday July 12, 2010 @05:07AM (#1507276)
Imagine humans in prehistoric times thinking about making contact with aliens: "Will their spearheads be made of stone or a more advanced material?" If aliens will come we'll see that the questions you ask here are irrelevant, as the terms programs and programming languages will not apply to their technology -- it will be something completely different.

Admittedly, programming has mathematical foundations (algorithms) so it has a good change to still be relevant.

If they do have programs, then the according to the Church-Turing thesis the programs could be translated to human code, but not necessarily in a clear way.

Re:Tell PG: A bug in HN? on Sunday July 11, 2010 @10:48AM (#1505533)
I tried to click it and nothing happened.

Oh, the link is clickable!

Re:The Least Surprised (Ruby comic by _why) on Sunday July 11, 2010 @10:46AM (#1505528)
Also, it proves that his name can be spelled without the underscore.
Re:Did Americans in 1776 have British accents? on Sunday July 04, 2010 @05:33PM (#1486429)
Oh, so that's what A Nation of Shoplifters means! Funny. (It's a song by Carter USM).
Re:Ask HN: What were your naivetés in your twenties? on Wednesday June 30, 2010 @08:53AM (#1474660)
How did you skip 4 years?

Older »