Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
import mock | |
def returnList(items): | |
def func(): | |
for item in items: | |
yield item | |
yield mock.DEFAULT | |
generator = func() |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
(10/30/2016) I am not sure when and how this gist gained quite a few stars... But as stated in the v1.13 change log (from 06/16/2015): some content may be outdated, and I am not going to fix them. Moreover, having learned much myself, I do not necessarily agree with every point made in this document from 2.5 years ago. Therefore, please take views from this document with a grain of salt, and do further research as you see fit.
This document was initally written for a friend of mine, Jiawen Li, so it might reflect some personal tastes here and there. For instance, some discussions are geared towards Windows, though *nix is obviously superior. For another example, when I say "you seem to love Sublime Text a lot," I'm certainly not expecting most people to love Sublime (in fact I never used it for more than three minutes in a row).
This document is written in Markdown. The Markdown rendering engine on GitHub Gist is somewhat limited a
// 4 spaces to 2 spaces | |
%s;^\(\s\+\);\=repeat(' ', len(submatch(0))/2);g | |
// Tab to 2 spaces | |
:%s/\t/ /g |
#! /bin/zsh | |
TIME=$1 | |
FNAME=$2 | |
# if [[ $# != 3]] then; | |
# echo "USAGE: $0 time_interval filename" | |
# exit 2 | |
# fi | |
if [[ -f $FNAME ]]; then |
A simple Python raytracer that supports spheres with configurable "material" properties (base color and a bunch of
light coefficients). To generate a raytraced image of the pre-defined scene, run: python raytracer.py
and open
image.ppm
with a PPM-compatible viewer (eog
works fine on Linux):
I found the following resources extremely helpful: