Skip to content

Instantly share code, notes, and snippets.

@podlech
podlech / iterators.py
Created June 12, 2018 03:56
iterators.py
from functools import reduce
arr = [1, 2, 3]
map1 = map((lambda x: (print("inside map1: %s" % (x + 1)) or x + 1)), arr)
map2 = map((lambda x: (print("inside map2: %s" % (x + 2)) or x + 2)), map1)
print("sum: " + str(reduce((lambda x, y: x + y), map2, 0)))
print(sorted(map2)) # gives [] since iterator has been consumed
"""
@podlech
podlech / yosemite_ruby_libv8_therubyracer.sh
Last active November 1, 2016 11:02
OS X Yosemite ruby (1.9.3p484) libv8 (3.11.8.17) therubyracer (0.11.4)
brew install homebrew/dupes/apple-gcc42
rbenv install 1.9.3-p484
rbenv global 1.9.3-p484
git clone https://github.com/cowboyd/libv8.git
cd libv8
git checkout 3.11
export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2
bundle install