Setting PATH for Apache on OSX
March 30th, 2012 § Leave a Comment
I use virtualenv to manage my Python development environment and use the latest MacPorts Python. Recently I had to work on some CGI Python scripts. Out of the box, Apache web server runs in the default OSX environment, so the CGI scripts run with the system Python and can’t use any of the Python packages installed using virtualenv. The Apache SetEnv directive allows you to set environment variables, such as PYTHONPATH, but changes to the PATH environment variable are ignored.
To change the PATH for Apache, with OSX Lion, edit /System/Library/LaunchDaemons/org.apache.httpd.plist and after the first <dict> tag add the following, where <string> contains the PATH that you want.
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/local/bin:/opt/local/sbin:/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
Then restart Apache. This CGI-script will let you see the CGI enviroment variables (not for production environments!).
#!/usr/bin/env python
import os
print "Content-Type:text/plain" print ""
for param in os.environ.keys():
print "%20s %s" % (param,os.environ[param])
Notable Reads – SOPA, PIPA, ACTA, TPP Edition
February 2nd, 2012 § Leave a Comment
A lot has been written, recently, about SOPA, PIPA, ACTA and TPPA. Here’s a selection:
- SOPA and PIPA would create a consumption-only internet – Clay Shirky. http://www.guardian.co.uk/commentisfree/cifamerica/2012/jan/18/sopa-pipa-consumption-only-internet
- “Don’t wait for the time machine, because we’re never going to invent something that returns you to 1965 when copying was hard and you could treat the customer’s convenience with contempt.” http://radar.oreilly.com/2012/01/the-presidents-challenge.html
- Fred Wilson in SOPA/PIPA http://www.avc.com/a_vc/2012/01/a-post-pipa-post.html
- Chris Keall of the NBR http://www.nbr.co.nz/opinion/sites-offer-excuses-excuses-sopa-blackout-looms
- http://radar.oreilly.com/2012/01/the-presidents-challenge.html
- “This isn’t about one bill. This isn’t about one issue. This is about an entire process.” http://www.techdirt.com/articles/20120116/14480017423/sopapipa-how-far-weve-come-how-far-we-need-to-go.shtml
- “SOPA is at death’s door, but other threats to a free and open Internet remain live in Congress” http://www.theatlantic.com/technology/archive/2012/01/internet-rejoices-sopa-is-at-deaths-door/251517/
- “Not copyright Pirates but Disillusioned Potential Customers” http://internetnz.net.nz/news/blog/2012/Not-Pirates-Disillusioned-Potential-Customers
- “If you thought SOPA and PIPA were bad, then ACTA is your worst nightmare.” FAQ on how ACTA would affect you: http://www.zdnet.com/blog/london/how-acta-would-affect-you-faq/2773
- SOPA & PIPA: threats to our national interests http://internetnz.net.nz/news/blog/2012/SOPA-PIPA-threats-our-national-interests
- How the MPAA thinks. http://www.mpaa.org/resources/c4c3712a-7b9f-4be8-bd70-25527d5dfad8.pdf
- Pando Daily: Copyright Theft Is Bad, When It Happens To People We Like http://pandodaily.com/2012/01/28/angry-nerds-copyright-theft-is-bad-when-it-happens-to-people-we-like/
- Megaupload raid: the US govt just proved it has all the power it needs to fight piracy without SOPA and PIPA http://www.theatlanticwire.com/technology/2012/01/anonymous-megaupload-revenge-shows-copyright-compromise-isnt-possible/47640/
If you don’t like the back-room dealing, lobbying and secret negotiations for this legislation and these trade agreements, then remember the supporters are commercial entities. Don’t give them your money. Encourage others to do the same. Here’s the list of SOPA supporters to start with: https://sites.google.com/site/boycottsopasponsors/home/list-of-supporters-and-sponsors
Remember too, that the people who appropriate copyright material without authorisation or distribute it on the Internet are contributing to the problem. The music and film industries may seem like dinosaurs with a terrible business model, but they are often matched by the freeloaders who exhibit a tremendous sense of entitlement and a poor understanding of what copyright is. There’s plenty of blame to go around. Bad legislation and complaining about losses accruing on works you don’t actually sell is not ok, but neither is wholesale ripping off other people’s work.
Notable Reads
January 1st, 2012 § Leave a Comment
- The Molotov Party. Frank Rick of New York Magazine, explains the GOP.
- New York Times on understanding Mitt Romney.
- Joseph Stiglitz on the US economy.
- Ayn Rand and her influence on US society.
- Glenn Greenwald on Christopher Hitchens.
- In the Independent: What price the new democracy? Goldman Sachs conquers Europe.
- The Surveillance Catalog - where governments get their snooping tools.
- Neil deGrasse Tyson Lists 8 (Free) Books Every Intelligent Person Should Read.
- Sir Ken Robinson on Creative Education.
- New Zealand and Charter Schools.
- Clive Thompson on Why Kids Can’t Search.
- People out of touch with nature and Climate Change - Sir David Attenborough.
- Google, Chrome and the importance of Firefox.
- A case study in the muddle that is Android software updates.
- When Criminals Become Data Scientists.
- Internet surveillance, censorship, and avenues of resistance with anonymity - Jacob Appelbaum (scroll down).
- Jan Chipchase, It’s your Face, Not Ours.
- The Social Graph is Neither.
- Why The New York Times Isn’t Using Facebook’s ‘Frictionless Sharing’.
WNDR3700 meets DD-WRT
January 1st, 2012 § Leave a Comment
Many wireless access points have a “convenience” setup feature called WPS. Unfortunately WPS introduces a security weakness that allows an attacker to recover the WPA/WPA2 passphrase in a few hours[1, 2].
I have a Netgear WNDR3700 dual-band wireless access point, which includes the WPS feature. Prompted by the disclosures, mentioned above, I had a closer look at how WPS worked on the Netgear AP. WPS seems to be permanently enabled. The AP has an option to allow the router to disable WPS for a time, if there are too many connections attempts. This seemed like an unnecessary risk, so I decided to change the firmware to something without this vulnerability: dd-wrt.
The installation process has a reputation of being quite touchy and prone to bricking the router. Installation is set out on the WNDR3700 wiki page. Currently you need to install build r16785 on the router, then once the installation is complete and the NVRAM rebuilt, use the dd-wrt web admin interface to upgrade the firmware to a more recent version. I used webflash build r17201. I also tried a more recent build, r18024, but the 5GHz radio didn’t work properly. If you brick the router, use the recovery procedure here.
Finally, to ensure the clients can connect at the full 300Mbps, you need to configure the wireless settings from the advice in the Atheros wiki page.
Christmas Mince Pies
November 28th, 2011 § Leave a Comment
The fruit mixture is the key to a good Christmas mince pie. Here’s our recipe:
- 900 g currants
- 300 g raisins
- 300 g dark brown sugar
- 225 g mixed crystallised peel
- 2 lemons, zest and juice
- 2 t cinnamon
- 2 t ground cloves
- 2 t all spice
- 1 t nutmeg
- 1 t ginger
- ¼ c brandy
Roughly chop the currants and raisins. Grinding the spices gives better flavour than pre-ground spices. Lemon juice balances the sweetness, so check the flavour. Should be quite sharp as well as sweet. Ideally the mince should be stored in sterilised jars for a few weeks before use.
We use mini-muffin tins and frozen commercial short pastry. Assemble and cook at 180C until golden. About 20 mins.
Notable Reads
November 28th, 2011 § Leave a Comment
Notable reads:
Big Biometric Database – what could possibly go wrong?
http://www.fastcompany.com/1790444/the-downside-of-biometrics-9-million-israelis-records-hacked
What would Socrates Say? Technology and Learning.
http://www.ascd.org/publications/educational-leadership/sept09/vol67/num01/What-Would-Socrates-Say%C2%A2.aspx
Why Science Museums are Failing Adults
http://boingboing.net/2011/09/23/science-museums-are-failing-grown-ups.html
Neal Stephenson, Innovation Starvation
http://www.worldpolicy.org/journal/fall2011/innovation-starvation
Stephen Fry on Steve Jobs
http://www.stephenfry.com/2011/10/06/steve-jobs/single-page/
http://www.bbc.co.uk/news/14664694
Stephen Wolfrom remembers Steve Jobs
http://blog.stephenwolfram.com/2011/10/steve-jobs-a-few-memories/
David Frum, Why I am a Republican
http://www.frumforum.com/why-i-am-a-republican
MapToaster Topo/NZ v5.6
September 27th, 2011 § Leave a Comment
Shipping party! A new version of our MapToaster Topo/NZ topo maps of NZ is going out the door.
Notable Reads
September 25th, 2011 § Leave a Comment
This week’s notable reads.
“The arrogance of Web evangelists is staggering.” Joe Hewitt on the Web as a platform.
Christopher Hitchens on the death penalty.
Costs of poverty – Canada’s experiment.
Reflections of a former GOP operative.
“The net is a waste of time” William Gibson
Don Norman “”Google doesn’t understand people,” he said. “Have you ever spoken to a Google support person on the phone? They don’t have them. Sure, they’ll direct you to their blogs — where you’ll be lucky if you can find the answer you’re looking for — or they’ll let you give feedback. But do they ever give you feedback on your feedback?”
Evgeny Morozov – the Internet and political repression.
Lion and WiFi
August 27th, 2011 § Leave a Comment
Notable Reads
August 21st, 2011 § Leave a Comment
Marc Andreesson on the disruptive nature of software. Argument to a degree undermined by some of the examples not being real businesses
John Young writes on, US Education Secretary, Arne Duncan’s epiphany.
12 Nasa Blueprints – selected engineering drawings for the US space program.
In the Financial Times: ”A failure of economic strategy and leadership lies behind the near simultaneous collapse of market confidence in the eurozone and US economies.” Tripped up by globalisation.
Data is hard. In the Guardian, headlines that spring from faulty analysis.
Interview with Gorbachev.
“The companies who we appear loyal to are those that best help us define, refine, and express who WE are. “Your customer wont take a bullet for you – Kathy Sierra.
OSX Lion and PostgreSQL
August 7th, 2011 § Leave a Comment
After upgrading to OSX Lion, one of the few things that was broken was PostgreSQL. Apple have replaced MySQL with PostgreSQL in their server product and the upgrade on a standard Mac includes the Postgres client library. It seems the that upgrade deletes the postgres user and replaces it with a _postgres user. If you look at the Postgres files, they longer have their user and the server no longer starts.
(default)magellan:desktop jdm$ sudo ls -l /usr/local/pgsql/data -rw------- 1 103 postgres 4 9 Nov 2009 PG_VERSION drwx------ 15 103 postgres 510 14 May 15:02 base drwx------ 45 103 postgres 1530 22 Jul 14:19 global drwx------ 3 103 postgres 102 9 Nov 2009 pg_clog etc...
Happily, this is easily fixed. First update the UserName setting in /Library/LaunchDaemons/org.postgresql.postgres.plist to _postgres. Then change the ownership of the affected files
sudo chown -R _postgres:_postgres /usr/local/pgsql/data sudo chown -R _postgres:admin /usr/local/pgsql/var
Then delete the postgres group as it’s no longer needed
sudo dscl . -delete /Groups/postgres
Finally start the server
sudo launchctl unload /Library/LaunchDaemons/org.postgresql.postgres.plist sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist
Notable reads
August 5th, 2011 § Leave a Comment
Notable reads from the last few days:
Minority rules: Scientists discover tipping point for the spread of ideas
‘The Objective of Education Is Learning, Not Teaching’
Tarte Tatin
July 26th, 2011 § Leave a Comment
Some foods are greater then the sum of the parts. Tarte tatin is such a food.
You need an oven-proof heavy-bottomed frypan. For two to four people, I use a 160 mm cast iron omlette pan. Add 70g sugar, 35g unsalted butter and a generous squeeze of lemon. Cook over a medium heat, stirring constantly, until the sauce just begins to colour. If the sauce caramalises too much at this point, the final sauce will be dark and too strongly flavoured.
Peel, core and slice two apples. Arrange the slices in the pan, packing firmly. Cook over a medium heat. The apples will release juice into the sauce. Continue cooking until the sauce darkens and thickens.
Now place a circle on puff pastry on top of the apples. Cut a vent in the centre of the pastry to let steam out as it cooks.
Cook in the oven at 200C until the pastry is nicely coloured. Remove from the oven and allow to cool for a couple of minutes. Cover the pan with a plate and invert. If you don’t let it cool enough the sauce will run out on the bench when you turn it over. If you let it cool too long, the apples will stick to the pan.
Finally allow the tarte to cool some more before serving. Cream or ice cream are optional. Can be served warm or cold.
Mail Reading Software
July 20th, 2011 § Leave a Comment
Prompted by Lance Wiggs’ post on which email clients were most popular I had a look at the stats for three newsletters, run from Campaign Monitor, that I have access to. The first set of figures is for a newsletter sent by a Christchurch business to its customers. The second two are from a social development NGO. The recipients for all three newsletters are largely in New Zealand.
The dominance of Outlook no doubt reflects its position as the the default mail client for Windows, especially in businesses. Yahoo! Mail’s popularity is probably the result of Yahoo’s relationship with the large New Zealand ISP, Xtra.
These results reported by Campaign Monitor are a bit muddled – a mixture of ISP and mail client data. Yahoo, GMail and Hotmail should be aggregated as “Web-based client”.
| Outlook | 49.6% |
| Web-based | 15.6% |
| Apple Mail | 8.8% |
| iOS | 8.6% |
| Others | 17.4% |
Thermograph
June 17th, 2011 § Leave a Comment
Writeup and source code for simple Arduino-based thermograph posted on our Chaos blog.
Christchurch CDB Visualised in Data
May 26th, 2011 § Leave a Comment
Since the Feb 22nd earthquake, the centre of Christchurch has been cordoned off, empty and without power. This image shows the quiescent CDB, visualised using WiFi packets as a proxy for human activity.
And for comparison, here’s the same area visualised with data from my iPhone WiFi geo-location database, from before Feb 22. The data and the collection methods are different, but you get the idea.
Arduino GLCD font for KS0108 LCD’s
May 19th, 2011 § Leave a Comment
Have added a repo to github with two fonts for use with the Arduino GLCD library. The repo is at https://github.com/johnmccombs/calfonts . Add the *.h files to the fonts folder in the GLCD library folder.
Apple and Location Tracking
April 21st, 2011 § Leave a Comment
There’s been a lot of controversy around a blog post on O’Reilly Radar that claims Apple is recording user’s location data, for unknown purposes. I pulled the data from my phone and mapped six months of it.
The red points are from the cellphone table and the blue dots are from the WiFi table. The first thing I noticed is that the data look nothing like my regular spatial pattern, see below. These maps are not the same scale and time period, but you get the general idea. Look for the empty park in the centre of the top map and in the centre, near the top of the bottom map. The map below was recorded with a real GPS.
Here’s another map from a trip to Auckland. My actual location was Auckland Airport, upper-left, where I scampered from the domestic terminal to an international connection. Note the points all over South Auckland.
The timestamps in the database are curious. There are typically dozens or hundreds of records all with the same timestamp. There are a few unique timestamps per day, but there are many days with no data.
So what is this data? While the names of the database fields suggest that this data is a recording of the phone’s position, the authors of the blog post offer no evidence that this is actually the case.
The map from my phone has thousands of WiFi points at locations that I haven’t been near to and the gross pattern of recorded points doesn’t match my travel especially well. Your phone might be able to connect with distant cell towers, and I guess it’s possible that the phone has seen brief scraps of data from all these access points.
I’m wondering if this database is something else. Perhaps it’s a cache of data from a geolocation webservice that the phone can use to determine its position? If it is tracking my location, the positions are wildly inaccurate. You certainly couldn’t determine where I live or work from the data.
Update: Looks like this data is the devices radio logs and geolocation data.
Update: turns out Android phones keep this type of data too.
Update: Apple speaks.
From a privacy point of view, it’s not great that this file is lying around unencrypted. But in terms of disclosing your location, it’s not doing much better than “I was in Christchurch”. My online calendar and emails would be a much more accurate source of this information.
Perhaps the most striking part of this story is the hysterical storm that has swept across the news and social media. Come on, these things are location enabled devices. What did you expect?
Garmin GPSMAP 62s Review
February 15th, 2011 § Leave a Comment
Just added a review of the Garmin GPSMAP 62s to the MapToaster website.
















