Soya pizza

When you made 3L of soy milk, you’d have plenty of soy pulp leftover. I needed a way to use it, so here is the pizza.

I made pizza dough with the pulp with oyster mushroom, onion, asparagus, and bamboo shoots over the tomato sauce, which I made for preservation using only lime juice, onion, and garlic as flavorings. Drizzles of Olive oil, fifteen minutes at 250°C oven, crispy thin crust, the toppings still juicy.

That 3 liter of milk was only my second batch, first one I made about 1L. Since then, I’ve been frying some fritters. Still has a whole box of pulp, and have not even used up the pulp from first batch.

I know people eat pizza like this for whatever reason they have, primarily for so called health food, but I really just want to eat all the pulp without dumping it.

Off to fry some more fritters…

parameterize, Parameter Objects, Scheme SRFI 39 in Python

parameterize (GitHub) is a Python implementation of Scheme SRFI 39, Parameter objects by Marc Feeley, drafted in 2002 and 2003, finalized in 2006:

This SRFI defines parameter objects, the procedure make-parameter to create parameter objects and the parameterize special form to dynamically bind parameter objects. In the dynamic environment, each parameter object is bound to a cell containing the value of the parameter. When a procedure is called the called procedure inherits the dynamic environment from the caller. The parameterize special form allows the binding of a parameter object to be changed for the dynamic extent of its body.

Frankly, I don’t understand everything in SRFI 39 since I can’t code in Scheme and know absolutely nothing about the language, but the explanation of parameterize might be clearer:

[…], parameter objects hold a single value. They are meant to be declared as global variables, so that the values they contain can be accessed anywhere. […] context manager, parameterize(), […] Any changes to the parameter that happen within this code block can’t escape it, and can’t affect other threads of execution.

[…] halfway between global variables and local variables. They’re access[i]ble from anywhere, and modifiable from anywhere, but modifications are always contained completely within their parameterize() block.

If still not, the following example code from README might:

import parameterize
import sys

# create our parameter and proxy object
stdoutp = parameterize.Parameter(sys.stdout)
sys.stdout = stdoutp.proxy()

with open('output.txt', 'w') as f:
    with stdoutp.parameterize(f):

What this code does is, it redirects the sys.stdout to the file and it does not interrupt with other threads if any who are also print() out data, they use the real sys.stdout other than the redirected destination.

To create a parameter object, or use its APIs:

po = parameterize.Parameter(default, converter)


# equivalent to

with po.parameterize(v) as ctx:

The created parameter object has set and get methods for manipulate the value that is contained by this object. A parameterize method is used to produce a context manager as seen in the example above. proxy method is used to track any changes made to the value.

parameterize is written by Aaron Griffith under the MIT License, currently version 0.1 (2014-04-22), for both Python 2 and 3.


xpermutations (GitHub) is a library for making permutations or combinations.

>>> from xpermutations import xcombinations, xuniqueCombinations, xselections, xpermutations
>>> from itertools import combinations, combinations_with_replacement, permutations, product
>>> " ".join("".join(x) for x in xcombinations("1234", 2))
'12 13 14 21 23 24 31 32 34 41 42 43'
>>> " ".join("".join(x) for x in xuniqueCombinations("1234", 2))
'12 13 14 23 24 34'
>>> " ".join("".join(x) for x in combinations("1234", 2))
'12 13 14 23 24 34'
>>> " ".join("".join(x) for x in xselections("1234", 2))
'11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44'
>>> " ".join("".join(x) for x in product("1234", repeat=2))
'11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44'
>>> " ".join("".join(x) for x in xpermutations("123"))
'123 132 213 231 312 321'
>>> " ".join("".join(x) for x in permutations("123"))
'123 132 213 231 312 321'

It’s based on a ActiveState recipe from 2003 by Ulrich Hoffmann, most of these can be easily done by the itertools, which was added in Python 2.3. The recipe “uses Python 2.2 generators to create appropriate generator objects, that can be use for example as ranges in for loops.” I am guessing itertools might have used code from the recipe.

Blackskirt, relative weekday or date lookups

Blackskirt (GitHub) is a Python library for finding out dates like the date of nth Wednesday in April, 1999.

For example, this Thanksgiving is going to be on 2014-11-27:

>>> from blackskirt import (
...     WEEKDAY_SUN,)
>>> from blackskirt.ops import (
...     mondayise, next_weekday, prev_weekday,
...     nearest_weekday, nth_weekday, last_weekday,
...     next_date, prev_date, nearest_date,)
>>> nth_weekday(year=2014,
...             month=11,
...             n=4,
...             weekday=WEEKDAY_THU)

The query is asking the fourth Friday in November, 2014. And the Black Friday and Cyber Monday will be on 2014-11-28 and 2014-12-01, respectively:

>>> next_weekday(year=2014,
...              month=11,
...              day=27,
...              weekday=WEEKDAY_FRI)
>>> next_weekday(year=2014,
...              month=11,
...              day=27,
...              weekday=WEEKDAY_MON)

It has other functions such as mondayise, nearest_weekday, last_weekday, prev_date, and next_date for other querying. It only answers with one format, YYYY-MM-DD, simple and not ambiguous at all.

It’s written by James Nah under the LGPLv3, currently version 0.1.1 (2014-04-15), it runs on both Python 2 and 3.