HNHacker News
TopNewBestAskShowJobs

csl

833 karma · joined July 19, 2008

submissionscomments
csl··on The Mandelbrot set in JavaScript
The next step is smooth coloring. I've written a post explaining it here: https://csl.name/post/mandelbrot-rendering/

The js code can be tested on https://csl.name/mandelbrot

csl··on The Busy Beaver Game
FWIW, I implemented some BB code in Python and made some pretty neat plots:

https://github.com/cslarsen/busy-beaver

Of course I cheat by knowing S(n).

csl··on Lessons I wish I had been taught (1996)
> Every mathematician has only a few tricks

Can anyone in the know illuminate this with some examples?

csl··on Lambda expression comparison between C++11, C++14 and C++17
I find that pointlessly pedantic. By the same measure, languages that don't offer bignums don't offer integers. Even Lisps need to implement closures in one way or another, and you may be surprised to see how they actually do it.
csl··on Ask HN: What are examples of GitHub repositories with high code quality?
Well, as long as the functions are short and the name is descriptive, I always use short names when the meaning is clear. For example strlower, you don't need more than `s` as the parameter name. It will probably be short, so using `len` or even just `l` for the string length should be fine for a ~15 line function.

A tip is to look at the function declaration in the header files. There I, at least, use somewhat longer parameter names for descriptive purposes (along with documentation) but usually use short ones in the function bodies.

So, if your functions are short and to the point (low coupling, high cohesion, in Coding Complete parlance), then I consider short parameter and variable names a good style. But it's just one ingredient in good code.

Unless you're looking at competitive programming, I feel the best programmers make clear code with short names.

csl··on Hotpatching a C Function on x86
But that would only be possible from the same process space, right? So only applicable for plugins etc.?

What I'd like to see is hotpatching the function for another process, but I guess that's very hard to do with ASLR. Probably doable with some tricks, though.

Edit: Come to think of it, gdb is able to attach to a running process w/o debug symbols and find function addresses. So in other words, I just need to dig into and grok the gdb source.

csl··on Ask HN: How do you search for an appropriate English word?
I google for "define:word" to check for spelling, but a thesaurus is usually available in the drop down menu. Then I search words with similar meaning to find the word on the tip of my tongue.
csl··on The Most Common Job in Each State 1978-2014
This reminded me of the "Humans need not apply" video, which I strongly recommend, if you haven't already seen it: https://www.youtube.com/watch?v=7Pq-S557XQU

Discussion: https://news.ycombinator.com/item?id=8172461

csl··on Ask HN: New attempt at mobile markup – keep or bail?
And iOS. I often use this feature.
csl··on 23andMe meets FDA standards, adds back wellness reports
Thanks. It's definitely a lot of fun. And, as you can see, some things are not hard at all to detect. In fact, I was surprised how little knowledge you need to be able to flick through genome wide association studies (GWAS) and casually play around with their findings. (It's also fun to see how desperately some GWAS studies seem to try to make sense of the genome --- it's a pretty young field, I guess!)

Of course, you should be pretty careful with interpreting results as a hobbyist (as I am). But probing your genome with a parser, like the one I've made, is a great vehicle for piquing your intellectual curiosity.

csl··on 23andMe meets FDA standards, adds back wellness reports
I've made a 23andMe parser that can report on this. Actually, it covers quite a lot of their health results:

https://github.com/cslarsen/dna-traits

The test for Alzheimers is here: https://github.com/cslarsen/dna-traits/blob/master/py-dnatra... (the algorithm used to be patented, by the way). By closely reading the algorithm, you can probably find out yourself, given that 23andMe still lets you browse your genome.

To see all health reports, run this file on the downloaded genome: https://github.com/cslarsen/dna-traits/blob/master/py-dnatra... (you have to compile the C++ code first)

Actually was playing with the idea of monetizing off this project, but the laws in my country prohibit me from doing so. In fact, just using the program I made is illegal unless its my own genome.

csl··on Goto in Python
Nice. But does it handle extended jumps?

I know this is a problem for at least the Byteplay module.

csl··on How Norway Created Salmon Sushi
As a tourist? Go to the north west: Møre og Romsdal and further up north, Lofoten. If you want to visit the national parks, go east from Møre (the mid parts of Norway). I'm Norwegian, and if you want to see postcard nature, you have to go to the norhern coastal parts. Don't go just to Oslo or Stavanger and think that's all there is (although both are beautiful in their own ways). Go in late July or August. Best wishes!
csl··on PeachPy: Assembly Code Generation in High-Level Python
I wonder if assembler is going to make a come back :).

I'm certainly seeing a lot of cool projects that make assembly more accessible, not to mention a lot of good guides on the web. As for myself, I've recently made Python ctypes bindings for GNU Lightning, which lets you write architecture agnostic RISC assembly, then JIT to native code on x86, ARM, etc. See https://github.com/cslarsen/lyn/

It's pretty light-weight and JITs fast. The point is that it's very fun and addictive to do assembly from a language like Python.

csl··on Ask HN: What do you use for spell checking?
Looks pretty neat, but the demo account is too limited. For instance, it found a problem with my other comment here, but wouldn't tell what (of course, I have to pay up 30 bucks to see what it found).

And, I guess it's web-only, which is a shame, since I wouldn't be able to automatically check my TeX-documents as part of the build process.

csl··on Ask HN: What do you use for spell checking?
Thanks for the kind comment!

I'm Norwegian, and I do consider English as one of my primary languages --- but it's not my native language, so it's easy to write something that doesn't sound right to others, not to mention grammatical problems. For instance, it's been years since I learned about punctuation and comma, and there are differences between Norwegian and English in this regard.

Writing comments online is one thing. It's entirely different when I have to write reports and stuff like that. That's when I'd like to use a good tool to help with grammar and general flow. It's easy to make a mistake when you're writing tens of pages of text that you have to deliver somewhere.

csl··on Call/cc for C programmers (2010)
Exactly! The top-level is actually special in many circumstances.

Some people have suggested removing call/cc from Scheme. I don't know if they want to put delimited continuations in its stead. See http://okmij.org/ftp/continuations/against-callcc.html

csl··on Call/cc for C programmers (2010)
Not by default, but I've seen some schemes offer serialization of continuations, for example http://wiki.call-cc.org/eggref/4/suspension
csl··on Call/cc for C programmers (2010)
It says it's just setjmp/longjmp, but later on expands on that, saying you can jump not only up the stack, but down and sideways too (#1).

I think the best explanation (mentioned in the article) is that you take a copy of the entire call stack, and can then reinstate it whenever you want to.

An even simpler explanation is Guy L. Steele's that it's "gotos with parameters", that is, basically goto, but let's you pass a parameter to the destination:

    (define saved-continuation #f)

    (display (string-append "hello "
                (call/cc (lambda (here)
                  (set! saved-continuation here)
                  "world"))
                "!\n"))
    ; Displays: "hello world!"

    (saved-continuation "everyone")
    ; Displays "hello everyone!"
Running it with guile:

    $ guile cc.scm
    hello world!
    hello everyone!
This code makes `saved-continuation` equivalent to

    (lambda (param)
            (display (string-append "hello " param "!\n"))))
Matt Might has an explanation, too: http://matt.might.net/articles/programming-with-continuation...

Finally, we have delimited continuations, which lets you basically slice off a portion of the current call stack, instead of taking it in its entirety. It's more powerful and lets one create true functions, and implement any other control flow construct.

#1: What's often not mentioned is the fact that you can only jump to code you've already run. So you can't jump straight into somewhere your program has not been, yet.

csl··on Apple Unveils the iPad Pro
Seems the holy grail is a really tough 1ms: https://youtu.be/vOvQCPLkPt4?t=52s

Hard to see from the videos, but I don't really expect anything better than 10ms. At least, we can hope to see incremental improvements in the coming years.

csl··on Paxos Explained from Scratch [pdf]
These guys also made a slide deck for the paper: http://www.ux.uis.no/~meling/papers/PaxosTutorial-Meling-OPO...
csl··on Paxos Explained from Scratch [pdf]
Happy to see my thesis advisor's paper on the HN front page! This paper really helped me when I was implementing a simplified version of Paxos using OpenFlow.

I also remember Hein recommended me to study Paxos before delving into Raft, actually, even though Raft is supposedly easier to get started with.

csl··on Compiling GCC 5 on OS X
I work with reservoir modelling, and it continues to amaze me that everyone coming from non-CS fields seem to have programmed solely in Fortran. Besides, I believe the Intel Fortran compiler is extremely fast. I wouldn't say there's no reason to write new programs in Fortran.
csl··on Ruby-like string interpolation in Python

    Also, if this thing is truly mangling bytecode, it's not portable between
    different python versions [...] seems to be done by interpy_untokenize,
    which boils down to some string mangling
It uses the Python file encoding property ("# coding: foobar") to rewrite the source code, not the bytecode, and they refer to pyxl as an inspiration.

For a good explanation, see https://github.com/dropbox/pyxl

csl··on Ask HN: How do you deal with professional jealousy and getting older?
I'm sympathetic with your feelings. My advice is to focus on yourself instead of comparing yourself with others. I've often found solace in Max Erhmann's "Desiderata" --- http://mwkworks.com/desiderata.html --- which says:

  If you compare yourself with others,
  you may become vain and bitter;
  for always there will be greater and lesser persons than yourself.
  Enjoy your achievements as well as your plans.
I recommend reading the whole thing; it's beautiful and very inspirational. Also, Richard Feynman has a great quote about disregarding what others are doing, which I guess is from "Surely you're joking, Mr. Feynman", but can't find his exact words (can anyone help me out?).

From https://imagineer7.wordpress.com/2013/03/14/the-most-importa...

  Feynman wrote one word, in capitals: DISREGARD on his
  notepad when he read that. This word became his motto.
  That, he said, was the whole point. That was what he had
  forgotten, and why he had been making so little progress.
  The way for thinkers like himself to make a breakthrough
  was to be ignorant of what everybody else was doing and
  make their own interpretations and guesses.
You can't stop time, so you better learn how to deal with getting older. I'm sure you're a great person, just find out what you want to spend your time on and focus on that, and disregard what others are doing. As Max Ehrmann said: "Strive to be happy".
csl··on The Z3 Theorem Prover released under MIT license
I've used model checkers before, but never SMT solvers. Looks really cool!

Anyway, here's a great post on solving a Project Euler problem using Z3/SMT-lib, which may be inspiring for other novices like myself:

http://blogs.teamb.com/craigstuntz/2014/07/07/38818/

csl··on Algorithms Every Programmer Should Know: Reservoir Sampling
> is it a common problem to have, not knowing the set size?

Yes. It could be as simple as receiving values from a Python generator (or equivalent mechanism in your favourite language), where you don't know the number of items beforehand (and querying for the length is either impossible or expensive).

In such a cases, using reservoir sampling is an elegant solution, because you're probably in a situation where you'll be iterating through all values anyway.

csl··on Show HN: Discover your ranking on GitHub
The cool thing is, of course, to find like-minded people locally!

It would be nice to be able to see results by specifying a geographic radius.

csl··on Email Encryption Software Relies on One Guy, Who Is Going Broke
It's a library that talks through the shell. I was kinda disappointed when I learned that. But it may be on purpose, as someone else mentioned.

I've used it while making bindings for it for my Scheme project: https://github.com/cslarsen/mickey-scheme/tree/master/lib/op...

csl··on Email Encryption Software Relies on One Guy, Who Is Going Broke
So I just donated €20 and I invite others to do it as well.

(And they use Stripe for payments, which of course is relevant here on HN. And as a first time user, it was a breeze to donate.)

← PreviousPage 3 of 6Next →