2013-12-14

JavaScript syntax soup: 「p in o」

another episode of syntax soup. In JavaScript, you have p in o and for (var p in o) {…}. The first looks the same as part of the second, but have completely different semantics.

Soup. Soup. Soup. It's All Soup.

2013-12-12

Stereographic Projection & mobius transformation

Stereographic Projection & mobius transformation。 If you want to understand Einstein's theory of relativity, you must understand mobius transformation. To understand mobius transformation, you must first understand Riemann sphere, complex numbers, geometric inversion.

stereographic projection by Henry Segerman 2013-12-12
stereographic projection by Henry Segerman

赤平投影和莫比乌斯变换。如果你想了解爱因斯坦的理论,你必须明白莫比乌斯转型。要了解莫比乌斯变换,必须先了解黎曼球,复数,几何反转。

see http://xahlee.info/math/stereographic_projection_physical_model.html

wikipedia controversies

wikipedia is not without controversies in its reliability. However, in general, if you are a learned man, and read it frequently, you basically know by heart which parts is not trustworthy.

when you are a learned man (as in, you have several degrees, or is a scholar, and often minimally knowledgeable in diverse fields from sciences to humanity, such as philosopher), you can basically tell when you read something that came across as funny, wikipedia or not. Because, you know what you know and what you don't know, and you have good experience of seeing questionable writing.

And, if you do use wikipedia a lot, you also know which type of article, or part of the writing style, is red ink.

gratuitous links:

2013-12-10

Python: Example of Using Sets

Python: Example of Using Sets

# -*- coding: utf-8 -*-
# python

# utility to show the difference of JavaScript's encodeURI and encodeURIComponent functions

# 2013-12-09

digits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}

letters_upper = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}

letters_lower = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}

printable_ascii = digits.union(letters_upper, letters_lower,
{'!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/' , ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~' })

encodeURIComponent_not_encoded_ascii_chars = digits.union(letters_upper, letters_lower, {"""-""", """_""", """.""", """!""", """~""", """*""", """'""", """(""", """)"""})

encodeURIComponent_encoded_ascii_chars = printable_ascii - encodeURIComponent_not_encoded_ascii_chars

encodeURI_not_encoded_ascii_chars  =  digits.union(letters_upper, letters_lower,
{"""-""", """_""", """.""", """!""", """~""", """*""", """'""", """(""", """)""", """;""", """,""", """/""", """?""", """:""", """@""", """&""", """=""", """+""", """$""", """#"""})

encodeURI_encoded_ascii_chars = printable_ascii - encodeURI_not_encoded_ascii_chars

print encodeURI_encoded_ascii_chars

see JavaScript Encode URL, Escape String