# Infection

Infection is a sandbox contagion simulator I recently started working on. It is an entertaining game that anyone with a basic understanding of JavaScript should be able to hack.

A simple set of rules and values govern how an infection spreads in a square board of 400 tiles. In the future, different challenges should be made available.

It is hosted at GitHub and released under the MIT license.

You can find an online version of the project here.

# Python: Use Generators to Save Memory

Even though this feature is not new at all, very few seem to use generators as much as they should. Generators may help one write programs that require less memory to run when compared to their list comprehension analogous.

Let me use a trivial example to demonstrate the difference. Real-world examples may involve more complicated number crunching but will have a very similar structure and also present the same improvements.

Problem: determine the sum of the first ten thousand perfect squares

## Solution using list comprehension

sum([n ** n for n in range(10 ** 4)])


## Solution using a generator

sum((n ** n for n in range(10 ** 4)))


In this case, refactoring is very simple, but usually you would have the list comprehension result assigned to a variable and used later on. It’s up to the developer to spot scenarios where a list comprehension may be replaced by a generator.

The list, in its entirety, takes 79.28 MiB on my machine, whilst the bigger value produced by the generator takes only 17.33 KiB. As you would expect, the results are identical.

## Determining the size of a list in memory

If you don’t know about it yet, there is a nice tool called pympler that allows you to measure the memory size of collections. See the snippet below.

from pympler.asizeof import asizeof

print(asizeof(list_of_perfect_squares))  # 84 134 440 -> 79.28 MiB


# Photo: an Image Manipulation Library

This is an announcement of a Java image manipulation library I created.

It is released under BSD 2-Clause and can be found here. The main reason for creating it was that there was not an open source Directional Cubic Convolution Interpolation implementation out there in Java.

According to Wikipedia,

An article from 2013 compared the four algorithms above, and found that DCCI had the best scores in PSNR and SSIM on a series of test images.

There is also a dedicated page for this library here.

A Maven artifact is on its way. If you have any suggestions or requests, send me an email or create a new issue.

# Setting up a Fetch-Only Remote

It may happen that you have a remote to which you have push rights but will never want to push. If you are afraid of pushing your changes to it by accident or just want to play it safe, this command may be of assistance:

git remote set-url upstream --push disallowed


This makes the push url of the upstream remote (use whatever name your remote has) an invalid address that will prevent accidental pushes.

# What CS Majors Should Know

This post is a collection of highlights from this fantastic article about what every computer science major should know by Matt Might.

# Portfolio over Resume

A resume says nothing of a programmer’s ability.

Every computer science major should build a portfolio.

# Communication

Modern computer scientists must practice persuasively and clearly communicating their ideas to non-programmers.

# Unix

Given the prevalence of Unix systems, computer scientists today should be fluent in basic Unix.

# Programming Languages

While it is important to teach languages relevant to employers, it is equally important that students learn how to teach themselves new languages.

The best way to learn how to learn programming languages is to learn multiple programming languages and programming paradigms.

# Mathematics

Computer scientists must be fluent in formal mathematical notation, and in reasoning rigorously about the basic discrete structures: sets, tuples, sequences, functions and power sets.

# User Experience

Programmers too often write software for other programmers, or worse, for themselves.

User interface design (or more broadly, user experience design) might be the most underappreciated aspect of computer science.

# Databases

It’s useful to understand the fundamental data structures and algorithms that power a database engine, since programmers often enough reimplement a database system within a larger software system.

# There is more

There is much more than this on the original post. It is also supposedly an alive post, so you should definitely check it out from time to time. There is also some really nice stuff about which languages the author thinks provide a reasonable mixture of paradigms and practical applications that I did not quote because it is fairly long.