Saturday, 12 February 2011
Friday, 11 February 2011
Omnipotence biscuits
A coworker who also appreciates trying strange Chinese foods stopped by my desk and showed me a biscuit he'd found on the snacks table in the cafeteria. Being a glutton, I had to have one too. These are a slightly sweet, heavy and solid block. I quite liked them and headed back to have another.
Six biscuits are vacuum packed into the foil bag. I like foil vacuum packed bags, it gives me the confidence in a fresh product.
The biscuits up close.
I didn't enjoy eating these the second time, and ended up throwing them away. Sensations of salt and recycled cardboard occupied my thoughts as I ate them. In a way, they remind me of the bumper bars that Cookie Time do back in New Zealand - now I could go for some of those.
Posted by Richard at 10:56 pm 2 comments
Randomly drying fish
I was walking along a street in an area in or near Jing'an, munching on jian bing, when I passed these on the side of the footpath. Several large sides of fish hung out to dry.
Posted by Richard at 10:32 pm 0 comments
Thursday, 10 February 2011
Work lunch buffet 2
Another lunch I remembered to photograph. The soup was nice and flavourful, the cucumber dish was light and tasty, and the meat which I think was duck was also pretty tasty.
Posted by Richard at 10:31 pm 0 comments
Wednesday, 9 February 2011
Cheds
Many years ago these biscuits appeared on the shelves in New Zealand. Covered in strong cheddar cheese, they stood out from the rest of the mealy offerings on the shelf. Look at the biscuits on the box, and their savoury looking coating.
Of course eventually time passes and some suit makes an easy decision to cheapen the production process, and you get what you see in this next photo.
Now with a light and innocuously coloured coating that provides a minimum of flavour, Cheds are a pale shadow of the biscuit they used to be. Of course, there are plenty worse biscuits out there, and compared to them Cheds are still an option that at least have some flavour. But they're no longer a treat to eat.
Posted by Richard at 10:46 pm 0 comments
Tuesday, 8 February 2011
Sphinx and htmlhelp
I remember when I went to do a release of Stackless Python and as usual I went to make a futile attempt at building the documentation, and found that the documentation generation I could never get to work on Windows had been replaced. I still find the new Python documentation generation, based on sphinx, to be inspirational. Being able to go make checkout and have sphinx and its dependencies fetched, and then to be able to go make htmlhelp or just make html and to have the respective format of documentation generated with minimal extra work.. it is just a pleasure. However, there are some little bits and pieces I would like to note related to the generation of the htmlhelp format documents.
HTML Help Workshop
In order to generate the .chm files, you need to have the HTML Help Workshop installed. I don't know how this is done with just sphinx, but when you are generating the Python documentation the make script takes care of assuming the presence of a default installation location.
if "%HTMLHELP%" EQU "" set HTMLHELP=%ProgramFiles%\HTML Help Workshop\hhc.exe64 bit Windows users like myself will find that %ProgramFiles% actually resolves to C:\Program Files\ which is all well and good, but HTML Help Workshop is a 32 bit program and therefore it gets installed to C:\Program Files (x86)\. You can replace that line with the following lines.
REM Find the 32 bit Program Files directory. set PFA=%ProgramFiles% if not "%ProgramFiles(x86)%" == "" set PFA=%ProgramFiles(x86)% REM Set defaults for non-existent environment variables. if "%HTMLHELP%" EQU "" set HTMLHELP=%PFA%\HTML Help Workshop\hhc.exe
Compilation failed while compiling index.html
I adapted the make.bat script that comes in the Python Doc directory to build documentation for my own project. But when I tried to run HTML Help Workshop on the .hhp file that sphinx generated, it exited claiming "Compilation failed while compiling index.html". This is a file that sphinx tells hhc.exe to use, but where does it come from? Beats me, I tried searching but in the end went back to where the Python generation gets its version. It does the following.
- Adding a
templates_path = [ "templates" ]
statement to the conf.py file. - Adding a
html_additional_pages = { "index": "index.html", }
statement to the conf.py file. - Making a templates directory in the same directory as the conf.py file.
- Put a blank file named index.html in the templates directory.
Posted by Richard at 11:42 pm 0 comments
Labels: programming, python
Work lunch buffet
A spoonful of rice, a spoonful of each of the other dishes and a bowl of soup. This was pretty tasty. Some days the cooked vegetable dishes taste like random inedible garden plants, but not this day.
Posted by Richard at 10:24 pm 0 comments
Monday, 7 February 2011
Deep fried breadsticks
These yóutiáo (油条) or deep fried breadsticks, were on the bakery table at the local supermarket. Normally these sticks are a light appealing golden colour, and have the texture of pastry - that is if I have not confused two similar products. The Jiānbing (煎饼) vendors that make the pancake sandwich versions sometimes have them and use them in place of the crispy wafers, as filling. Anyway, these were heavy and dark in colour. I expect it was because they were low quality, as most of their in-house cooked goods seem to be. The impression I get is that they tend to use their left over meats and vegetables and in general other low quality ingredients to make them.
Quarter of a kilogram for these two sticks, there's a lot of grease here. The first character yóu (油) unsurprisingly means oily :-)
Inside, they look bready. Maybe these are different from the lighter sticks that I have had in the past.
Too salty and too greasy. I need to stay away from their in-house cooked goods table.
Posted by Richard at 10:32 pm 0 comments
Paris Baguette snack selection
I'd just finished meeting a friend, and decided to stop in at Paris Baguette and buy a range of their interesting looking snacks. Many stores in China contain bags within bags within bags.
I've had the donuts here before, but this time I was just grabbing one rather than picking wisely. This one was particularly hard looking and dark coloured. That was a bad sign, and experience of eating it was heavy on grease and light on flavour.
This was a like a large flat muffin. The flavour was good, being a combination of blueberry and coconut. Unfortunately, it was also too greasy. Whatever it was cooked in had been overly greased and the parts of the muffin that touched it were again overly crispy and greasy.
I like a dense cake, so this isn't the first time I have bought this. But unfortunately it lacks any flavour. Hopefully I'll remember not to buy this again.
I like the look of many of the things that Paris Baguette sell, but I don't enjoy eating them.
Posted by Richard at 10:14 pm 0 comments
Python packaging pain
Being in China with a wireless internet connection that drops in and out, I want to be able to just download and install software with the minimum amount of complication and fuss, if I need to. Tonight I wanted to download sphinx so that I could generate some documentation. First step was googling "sphinx" and seeing what the website had to say.
I've used easy_install in the past. I don't remember much about it, but I remember it both errored and installed things in ways I didn't quite understand. After a bit of searching, I concluded that it didn't seem to come with Python 2.7, so I decided to go with the second option and downloaded sphinx from the Python Package Index.
More egg things and source code. I don't understand those egg things and using them without being prepared to spend several hours working around non-working packaging systems is just not worth it. At least, that's what my past experience with them has led me to believe. So I went with the source code, in the hope I could just extract it and use it. After downloading the file, I consulted the README file:
Use ``setup.py``::So the only option is to engage the "magic" packaging systems, whether I want to or not.
python setup.py build
sudo python setup.py install
D:\Sphinx-1.0.7>c:\Python27\python.exe setup.py buildThe "magic" is in progress.
---------------------------------------------------------------------------
This script requires setuptools version 0.6c9 to run (even to display
help). I will attempt to download it for you (from
http://pypi.python.org/packages/2.7/s/setuptools/), but
you may need to enable firewall access for this script first.
I will start the download in 15 seconds.
(Note: if this machine does not have network access, please obtain the file
http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c9-py2.7.egg
and place it in this directory before rerunning this script.)
---------------------------------------------------------------------------
Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c9-py2.7.egg
Traceback (most recent call last):Well, that's my "once every couple of years" encounter with Python packaging over and done with. I think I'll go back to easier and more straightforward solutions that involve just using source code directly. Sure, I could look into this and try and sort it out for myself, or google to see if someone else has encountered it. But I've been down this rabbit hole before, with almost exactly the same problem with the packaging system several years ago. Fortunately, I can just abandon this hoop jumping and copy this source code from the SVN exports that the Python documentation building process does (since I build it for Stackless Python), and adapt the script that comes with it.
File "setup.py", line 6, in
ez_setup.use_setuptools()
File "D:\Sphinx-1.0.7\ez_setup.py", line 95, in use_
setuptools
return do_download()
File "D:\Sphinx-1.0.7\ez_setup.py", line 89, in do_d
ownload
egg = download_setuptools(version, download_base, to_dir, download_delay)
File "D:\Sphinx-1.0.7\ez_setup.py", line 150, in dow
nload_setuptools
src = urllib2.urlopen(url)
File "c:\Python27\lib\urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "c:\Python27\lib\urllib2.py", line 398, in open
response = meth(req, response)
File "c:\Python27\lib\urllib2.py", line 511, in http_response
'http', request, response, code, msg, hdrs)
File "c:\Python27\lib\urllib2.py", line 436, in error
return self._call_chain(*args)
File "c:\Python27\lib\urllib2.py", line 370, in _call_chain
result = func(*args)
File "c:\Python27\lib\urllib2.py", line 519, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found
Posted by Richard at 2:54 am 15 comments
Labels: programming, python
Sunday, 6 February 2011
Onion compressed biscuits
I've walked past these before, and after having tried the similarly packaged "omniscient" or something similarly named biscuit, I decided to buy these and try them.
They taste like.. a solid lump of heavy biscuit-like matter, with almost no flavour and an undertone of maybe a hint of onion that most likely does not exist, but is most likely pure projection on my part due to the name of the biscuit.
The texture of emergency rations, the flavour of recycled cardboard.. I note what I eat on this blog to remind me of what to buy or not, but I don't expect I will need to revisit this post to remember not to buy these again. Are there people that actually like these things?
Posted by Richard at 10:08 pm 1 comments
Better article support
There are too many interesting things to work on, and too little time to do them in. I use this as justification for why I haven't worked on the Christmas requests from a user of my MUD framework until now.
Anyway, the task at hand is allowing use of articles in the commands they give, and displaying more correct messages in response to those commands by using articles in them. This transcript shows the current user experience.
> lookAs it shows, articles are treated as unrecognised adjectives in user commands. And when a sentence is constructed to describe an action (like the successful taking of pants), the lack of an article leaves it looking clunky.
A room
This is a room.
It contains: brown pants, green pants, chest, you.
Exits: south
> take pants
Which pants?
> take the pants
You cannot find any the pants.
> take brown pants
You take brown pants.
It has been years since I last thought about how to do this sort of thing. I seem to recall some complex series of rules where a bystander and the actor see different things. The actor would see a description qualified by "the" when it is the only object which matches the command they gave, and qualified by "a" or "an" when it is one of two or more objects which match the command they gave. Meanwhile the bystander would always see "a" or "an". Or something like that. Thinking about it a little, I decided I would rather go with something simpler and worry about complexities later on. So taking a simpler approach when dealing with single objects, the actor would alway sees "the" and the bystander always see "a".
X takes an apple.Or in Python..
You take the apple.
# If the object is a body, use their short description directly. text = self._object.shortDescription if isinstance(self._object, Body): return text # If the viewer is the actor, use the description with "the" article. if self._viewer is self._actor: return "the "+ text # If the viewer is not the actor, use the description with "a"/"an" article. if text[0] in ("a", "e", "i", "o", "u"): return "an "+ text return "a "+ textLooking at the simplistic "vowel as a first character" check, I can obviously find some standard list of special cases to ensure as much correctness as possible. I also seem to recall some script on MudBytes that someone ran which located special cases of words, although maybe that wasn't related to articles. I can look into that at some later time.
Anyway, moving on.. the parser already supports stripping adjectives from a command and identifying the name of the object being referred to. Adding the articles to the list of these standard grammatical adjectives (determiners) does the trick.
articleDeterminers = set([ "a", "an", "the" ]) determiners = distributiveDeterminers | cardinalNumberDeterminers | articleDeterminersAnd then the stripping ensures they are not factored into identifying the referred objects.
words = [ s.strip().lower() for s in string.split(" ") ] noun = words.pop() allAdjectives = set(words) adjectives = allAdjectives.difference(determiners)Now I have basic article support. Hmm. It is rather basic. But now that I can see articles in object descriptions in game output, I can see that I should be using the same point of view based logic in all description generation. For instance, displaying the room contents in a 'look' command.
Posted by Richard at 7:39 pm 0 comments
Labels: game programming, mud