Archive

Archive for December, 2015

2015 in review

December 31, 2015 Leave a comment

The WordPress.com stats helper monkeys prepared a 2015 annual report for this blog.

Here's an excerpt:

The Louvre Museum has 8.5 million visitors per year. This blog was viewed about 200,000 times in 2015. If it were an exhibit at the Louvre Museum, it would take about 9 days for that many people to see it.

Click here to see the complete report.

Advertisements
Categories: python Tags: ,

[nodejs] increase memory limit

December 22, 2015 Leave a comment

Problem
Your Node.js program terminates with a “process out of memory” error. How to increase the memory limit?

Solution
Launch your program with the following switch:

node --max-old-space-size=8192 mem_eater.js

This way you give 8 GB RAM to your process.

More tips here.

Categories: nodejs Tags: ,

generate all subsets of a set

December 17, 2015 1 comment

Problem

Having a set, generate all its possible subsets. This time I had a list, but the problem is the same.

Solution

I found the answer here.

from itertools import chain, combinations

def all_subsets(ss):
    return chain(*map(lambda x: combinations(ss, x), range(0, len(ss)+1)))

for subset in all_subsets([1, 2, 3, 4]):
      print(subset)

Output:

()
(1,)
(2,)
(3,)
(4,)
(1, 2)
(1, 3)
(1, 4)
(2, 3)
(2, 4)
(3, 4)
(1, 2, 3)
(1, 2, 4)
(1, 3, 4)
(2, 3, 4)
(1, 2, 3, 4)
Categories: python Tags: , , ,

Advent of Code

December 8, 2015 Leave a comment

Let’s prepare for the advent with some coding challenges: http://adventofcode.com/ .

Categories: python Tags: ,

Mr. Robot

December 1, 2015 Leave a comment

I started to watch the TV show Mr. Robot. It’s a very cool techno thriller that displays hacking scenes quite realistically.

But what does it have to do with this blog? Well, in episode “eps1.3_da3m0ns.mp4” I saw the following image:

mr_robot

Check out the source code on the left side :)

Links

Update (20151202):

I found another Python script in the show (in episode 5):

mr_robot_2

Categories: python Tags: , ,