Profile cover photo
Profile photo
Simon Lindgren
Simon's posts

Write yourself a Quine for fun (and profit?)!

This is a fairly well known puzzle. The point is to write a program that prints the source code of itself to the terminal when run, without reading and printing the source file itself.

On linux a good way to test the program is this (assuming C code, replace as required for other languages):
$ gcc quine.c
$ ./a.out > quine2.c
$ diff -u quine.c quine2.c

If the last command prints nothing, it works :)

Now, make the program as short as possible. My best for C is a 105 byte source file. Can you do better? No cheating!

A word of advice: This can easily be googled, especielly now that you know it's called a quine. However, doing that will spoil the satisfaction of solving it, because when you read a solution you pretty much can't unlearn it (and the core concept of most solutions is pretty simple).

Computer Science warning: This would be considered a programming system implementation detail for most real programming tasks. It is likely a little off-topic for this group. Still, I'll give the topic a shot.

I want to discuss garbage collectors :)
There are a couple of classes of collectors that I find relevant for the discussion/that I know of:
1. Mark and Sweep. Simple, stops all threads and looks at all the memory each time collection is necessary. For instance the Boehm GC.
2. Generational GC. Stops all threads in the program, splits the memory into generations to optimize according to the hypothesis that most objects die young. Examples: The JVM CMS collector, Mono SGen, V8 (I think), future version of Firefox.
3. Concurrent GC. Allows the program to run concurrently with the garbage collector. Many collectors are a little concurrent, but the only example I know of a completely concurrent GC is Azul Systems C4.

Some potential discussion directions:
 * What are current research directions for GCs?
 * What type of GC do you think will be common in the future?'
   * My opinion is that concurrent GC will be the future. Do you agree, and when will we get there?
 * Will we get production GCs that integrate with the OS (for instance to minimize the impact of swapping, I've seen a paper about this before)?

Just chat away about how different VMs/runtime solves these things and other interesting observations you may have made :)

Workplace/Tooling question:

In your experience, do software companies generally buy the best possible tools? That means that if you code in java, do you use IntelliJ or are you stuck with Eclipse (debatable probably, but I consider eclipse inferior). If C#/F#, which edition of visual studio? Do the company shell out for addons and more tools like Resharper, dotTrace, JRebel, JProfiler, etc?

And what are the signs of companies that do/don't invest in good tooling?

I ask from my own perspective as a soon to be CS Masters graduate.

EDIT: I'm not trying to evaluate companies here... I want to get a feel for what is "typical" in the industry.

Post has attachment
First comment is negative, and then the rest of the thread keeps backing systemd as a great piece of software, calling the first comment baseless. You must be doing something right! :)

traceroute -m 60

That is all.

Post has shared content
It works, bitches.

Post has shared content
Laglig censur?
Press Release #PPUK BPI Legal action - BPI Legal action The proxy server the Pirate Party UK initially provided in solidarity with other parties in Europe, but later as an anti-censorship resource for UK users, has now been been removed. Loz Kaye made the following statement: Elected members of the party's National Executive Committee, along with the head of IT, received letters from lawyers acting for British Phonographic Industry (BPI), threatening them personally wit...

Post has shared content
... och till slut får vi ett bra DRM-system :)
I bought a digital video download today that required a video player from Leaping Brain. As usual, the proprietary player wasn't great and to transfer it to my iPhone I'd need another proprietary player. Ugh. But I browsed around and found that the video had been downloaded into a hidden directory as a bunch of .mov files. Great, except none of the files would play.

It turned out the actual player, launched from their compiled app, was a Python wrapper around some VLC libraries. Nothing funny going on, as far as I could tell, but when I tried to launch the player directly, nothing happened. The compiled app was modifying the .mov files right before they were loaded into the player, and then reverting the file on disk. According to

 "We apply our BrainTrust™ proprietary video encryption to your movies before we upload them to our servers. If someone ever was able to gain access to your content, the files would be useless and unplayable, because they are stored in a scrambled, encrypted format. Once downloaded to the user’s hard drive, the files are still encrypted and only readable via the MOD Machine Player by a legitimate owner. We are not aware of a better DRM scheme than ours. Where Windows Media DRM is easily crackable, and doesn’t run on Macs, BrainTrust™ works great on Windows 8, Vista, Windows XP and Mac, and is virtually uncrackable."

Virtually uncrackable? Well, since they load the file from a Python script, it's easy to make a copy of the "decrypted" file before it's reverted. Having done so, I was curious to see the encryption scheme. By comparing the binary files, I discovered the "proprietary video encryption" algorithm: for the first 15kB, each 1kB block has its initial bytes xor'd with the string "RANDOM_STRING". That's the "scrambled, encrypted format" that leaves these files "useless and unplayable".

Post has shared content
Ska det gå till på det här viset? Sprid. If the retailer, in this case Amazon, thinks you’re a crook, they will throw you out and take away everything that you bought.

edit: Tips om hur man tar bort DRM från Amazon Kindle-böcker:
Wait while more posts are being loaded