How Your Brain Decides Without You

“We form our beliefs based on what comes to us from the world through the window of perception, but then those beliefs act like a lens, focusing on what they want to see. In a New York University psychology laboratory earlier this year, a group of subjects watched a 45-second video clip of a violent struggle between a police officer and an unarmed civilian.3 It was ambiguous as to whether the officer, in trying to handcuff the person resisting arrest, behaved improperly. Before seeing the video, the subjects were asked to express how much identification they felt with police officers as a group. The subjects, whose eye movements were being discretely monitored, were then asked to assign culpability. Not surprisingly, people who identified less strongly with police were more likely to call for stronger punishment. But that was only for people who often looked at the police officer during the video. For those who did not look as much at the officer, their punishment decision was the same whether they identified with police or not…”

http://nautil.us/issue/19/illusions/how-your-brain-decides-without-you

lua-lru, LRU cache in Lua

“LRU cache is implemented using a doubly linked list and a hash map. Hash Map maps a key to a corresponding tuple. Doubly Linked List is used to store list of tuples (value, previous, next, key, size_in_bytes). key is needed in a tuple to be able to remove an element from the hash map. Field size_in_bytes is optional and is used if sizes in bytes are counted (and constrained) as well as the number of elements…”

https://github.com/starius/lua-lru

Python List Comprehensions: Explained Visually

“Sometimes a programming design pattern becomes common enough to warrant its own special syntax. Python’s list comprehensions are a prime example of such a syntactic sugar.

List comprehensions in Python are great, but mastering them can be tricky because they don’t solve a new problem: they just provide a new syntax to solve an existing problem.

Let’s learn what list comprehensions are and how to identify when to use them…”

http://treyhunner.com/2015/12/python-list-comprehensions-now-in-color/

Faking the TCP handshake

“The TCP handshake works like this, with A being the client that is connecting to B:

A: Hi B, I’m A, send number 5.
B: Hi A, I’m B, 5, send number 3.
A: Hi B, I’m A, 3, send number 6. I’d like example.net.
B: Hi A, I’m B, 6, send number 4. Here comes the data: …

After this, A can send data to B and B can send data to A. For each byte of data they send to each other, their numbers increase. This is to keep track of whether all data has been received by the other party, to ensure reliable transmission…”

http://lgms.nl/blog-2