Some Bits: Nelson's log

21 posts in December 2014

git pull: merge vs rebase

In my previous post I jumped through some hoops to do a “git fetch; git rebase” instead of a “git pull” so that I ended up without a merge commit in my timeline. (See explanation here). Those two commands are very manual, what else can we do?

One simple option is to do git pull --rebase, which rebases instead of merges.  However that can apparently cause problems depending on what’s in your local repo. I have no idea what rebase does if there would be a merge conflict.

The git up user-contributed command is another solution. I think at its heart it’s a wrapper for fetch + rebase, but it has some other smarts in it. No idea if it can cause problems.

This StackExchange answer has a much more thorough investigation. He recommends doing a git update followed by git merge --ff-only. I guess fast forwards are “safe”; using this flag prevents git from automatically creating a merge commit if it can’t fast forward. There’s a lot more detail there, worth a close read.

I’m going to follow the StackExchange recommendation of setting git config --global pull.ff only and see where that gets me. I think it’s entirely safe; if I do a pull the worst that will happen is I’m on my own to do a manual merge. I may still keep using that git up Ruby command, too.

And now my rant. Fuck git. It’s insane to me that you have to do this kind of contortion. The default obvious tool should be the right one. I hate the neckbeardy attitude you read in most git discussions where the Superior Nerd gets to say “actually, it’s complicated because it needs to be blah blah”. That’s crap; it’s complicated because git has a bad UI and a bit too many exposed sharp corners for civilian use. (I particularly like the StackExchange guy’s observation “Note that the purpose of Git is to make it easy to share and consume the evolution of a codebase, not to precisely record history exactly as it unfolded.”) Git is amazing in many ways and has enabled a lot of things, but I sure wish a more humane alternative were the popular one.

GitHub collaboration notes

After my whining about pull requests Mike gave me commit access to the repo. Here’s some quick notes on some simple git stuff he helped me do. The setup is we both started working in on separate projects. He made a private branch, made a bunch of changes, then pushed them to the ditch-node branch. Meanwhile I had made my own pyconform branch off of ditch-node before his changes and wanted to bring mine in with his. We could have just merged, but Mike asked me to rebase so that my changes came after his to keep the history tidy. That was easy because there were no conflicts. Here’s how it went.

# Push my pyconform branch up to GitHub
  506  git push -u origin pyconform

# Fetch Mike's changes in ditch-node
  507  git fetch origin ditch-node

# In my pyconform banch, rebase with the changes in ditch-node.
# This happened automatically without extra work on my part, no conflicts
# No commit necessary.
  510  git rebase origin/ditch-node

# Try to push my newly altered pyconform branch to GitHub
  513  git push
# That didn't work because we've altered history and Git is confused.
# So now we have to force the push to rewrite GitHub's version of things
  514  git push -f origin pyconform

# At this point my pyconform branch is done and looks as if I'd forked it off
# of Mike's changed, even though really we were working in parallel. Now it's
# time to merge my changes back to ditch-node and get rid of the pyconform branch

# Switch to ditch-node
  515  git checkout ditch-node
# Pull in the changes that are on GitHub
  516  git pull
# Merge from my pyconform branch
  517  git merge pyconform
# Push the merged commits back up to GitHub
  519  git push
# Delete my branch locally
  520  git branch -d pyconform
# Delete the branch on GitHub.
  521  git push origin pyconform
# Ooops, that didn't work, so do this magic to remotely delete the branch
  522  git push origin :pyconform

I regret not being more comfortable with this kind of git usage. I am sort of OK with git by myself but it’s a lot more complicated when collaborating.

openaddresses-conform Node code notes (plus bonus Python)

I’m working on porting openaddresses-conform from NodeJS to Python. First time I really sat down and read the code from start to finish. It’s remarkably clean and easy to follow, once you read past all the async-back-bending.

The basic flow of the tool is to take arbitrary source files, convert them to CSV files in a schema similar to the source, then convert that source CSV schema to the out.csv schema of OpenAddresses, the one with LON,LAT,NUMBER,STREET. It works by creating a lot of files on disk to hold intermediate results of transformations.

Here’s the core logic, which starts at processSource(). ConformCLI() is the command line tool entry point.

processSource(): download a source from the Internet, conform it, upload out.csv to S3.

conformCache() is the meat of the extract and transform process. It has comments!

  • Convert to UTF8: if source.conform.encoding is set, use iconv to convert source file to a new file with UTF8 encoding.
  • Convert to CSV: turn all types of sources in to a CSV file (see below on convert.js)
  • Merge columns if source.conform.merge is set.
  • Advanced merge columns if source.conform.advanced_merge is set.
  • Split address if source.conform.split is set.
  • Drop columns: prepare a new CSV file with just the core LON,LAT,NUMBER,STREET fields picked out of the processed source CSV.
  • Reproject to EPSG:4326. Only for CSV and GeoJSON files, creates a VRT file pointing at the processed source CSV and uses ogr2ogr to convert it to WGS 84.
  • Expand abbreviations: Fix Capitalization & drop null rows. This code is a bit woolly; it has a comment “I haven’t touched it because it’s magic” and there are no tests.

convert.js has five separate functions for converting different source types to a CSV file in the source schema.

  • shp2csv(): uses OGR2OGR to convert a shapefile to a CSV file. Also reprojects to EPSG:4326. Quite simple code.
  • polyshp2csv(): very similar to shp2csv(), but handles polygons.
  • json2csv(): uses geojson-stream to convert a GeoJSON file to a CSV file. Figure out headers from the first object’s properties. Converts polygons to points with a very simple average.
  • csv(): uses Node CSV modules to read the source CSV file and transform it into a cleaner CSV for further processing. Implements source.conform.headers and source.conform.skiplines.
  • xml(): uses ogr2ogr to convert an XML input to CSV, with reprojection. Very simple code, may not be used yet?
  • there’s code for computing the center of a polygon that’s duplicated in polyshp2csv() and json2csv().

openaddresses-conform has a small test suite. I believe it works on full source files, it’s more like functional tests than unit tests, running big chunks like conform or download and verifying the output is reasonable.

Existing Python port

Machine has its own Python code for doing the equivalent of downloadCache() and updateCache(). It’s quite different from the Node code strategy and is extra complicated because of the way Machine was a wrapper for invoking the Node code.

Very little of the extract and transform logic of conformCache() has been ported to Python but @iandees did some back in November. That code lives mostly in conform.py:ConvertToCsvTask. It works differently from the Node code. It basically takes whatever input file has been downloaded and uses Python OGR bindings to convert it to a CSV file in the schema of the source, plus an extra computed centroid. There’s no code yet to extract attributes or merge columns or anything. It’s streaming code, never loads the whole thing in to RAM.

I’m considering this choice to lean so heavily on OGR to process source files, it’s different from how the Node code is designed. I asked Ian and he said at the time all sources could be processed with ogr2ogr, so no need to write extra code for source CSV parsing, etc.

  • Check the type is .shp, .json, .csv, or .kml
  • Open source with OGR and figure out what field names are in it.
  • Set up OGR to transform the source SRS to EPSG:4326
  • Create a CSV file using csv.DictWriter with headers from the field name.
  • Iterate over features in the open OGR
  • For each feature, write a row to a CSV file with columns set to all fields from the feature. Also compute a centroid column.

I’ve never used the Python OGR bindings before. It’s pretty un-Pythonic and now I understand why Fiona exists. This list of Python Gotchas in GDAL will be a useful reference going forward. Apparently all the calls to Destroy() are unnecessary, but you do need to take care to manually dereference data sources.

NFS: Ubuntu server, MacOS client

I’m finally fed up with Mavericks broken SMB implementation. It’s appalling how bad it is. For awhile I had it working by forcing SMB 1 via cifs:// share naming, but that stopped working. Suddenly SublimeText and TextEdit were creating files with mode 0764, god knows why. MacOS touch was creating 0644 as expected. Anyway, fed up, it’s broken, so I’m going back to NFS. (Apparently Yosemite is shipping a new SMB 3 stack, maybe that’s better? Yosemite is broken in so many other ways though...)

I used NFS 3 years ago and those notes still apply. However, some changes.

Ubuntu server: as simple as can be. The wrinkle is that unless you want to get all fancy with Kerberos or idmapd or something user IDs don’t get mapped. Last time I just changed my numeric IDs on my Mac to match the Linux server. This time I’m trying something new, this cheese in /etc/exports:

/home/nelson 192.168.0.0/24(rw,insecure,async,no_subtree_check,all_squash,anonuid=30193,anongid=30193)

I’m abusing NFS anonymous ID mapping to force all requests to look like user ID 30193 and group ID 30193, my personal IDs on my Ubuntu box. It looks wrong on the Mac client, and it’s not appropriate for a multiuser server. But it gets the basic job done.

Mac client: more confusing now. Mavericks removed the graphical NFS configuration tool that I used to use. However the default automounter setup is not so bad. The path /net/ub/home/nelson is magically the NFS share ub:/home/nelson and seems to automount usefully. I think it’s using NFSv3. Haven’t needed to tune any parameters yet.

It wasn’t my primary goal, but as a bonus I get better speed out of NFS. The SMB 1 implementation seemed limited to about 10 megabits / second when writing to the server. NFS is running at the full 100 megabit link speed.

Happy Leap Week!

So leap weeks are a thing. In the ISO week date system “week 1” is “the week with the year’s first Thursday in it”. Today, Monday Dec 29 2014, is actually ISO week 1 for the year 2015. How’s that for confusing?

Rumor has it this weird calendar math is responsible for Android Twitter being broken. Some part of Twitter’s servers were returning a date a year in the future, in the year 2015, which is causing invalid OAuth signatures because of an expired certificate or something like that. Presumably the engineer used the ISO week-year by accident.

This is a bug that keeps on giving; two years ago iPhones got stuck in Do Not Disturb mode, probably for the same bug.

In Java SimpleDateFormat the difference is whether you ask for “yyyy” or “YYYY” and the docs don’t make it obvious you really want “yyyy” unless you’re doing something weird.

In Unix date’s format language (strftime?) the weird year to avoid is %G. %Y does what’s expected.

$ date -u
Mon Dec 29 15:47:54 UTC 2014
$ date -u +'%G-W%V-%u'
2015-W01-1

GitHub pull requests are too heavyweight 2

New version of an old rant. The GitHub pull request model makes sense if you plan to submit one giant PR a week. It’s terrible for rapid collaboration. Today I wanted to submit a 5 line patch to openaddresses/machine, in the branch ditch-node. I already have a fork NelsonMinar/machine. I had to:

  1. Switch to master branch in my clone of NelsonMinar/machine
  2. In my clone, manually set up an upstream remote for master
  3. Pull changes from upstream merge them with a fast forard.
  4. Push the merge result back to GitHub
  5. Repeat steps 1-4 manually for the ditch-node branch. I guess you’re expected to do this manually for every branch you care about.
  6. Create a new branch in my clone. I branched off the ditch-node branch
  7. Make my changes and commit them.
  8. Push my new branch back to GitHub with “--set-upstream origin”
  9. Use the GitHub UI to create a pull request.
  10. Fix the pull request so it’s a diff against ditch-node, not master. Note the branch I’m creating the PR in was branched off of ditch-node; no idea why GitHub didn’t respect that.
  11. Submit the pull request. Never ever touch that branch again until it’s accepted.
  12. As a bonus, the project maintainer warns me he has to rebase my pull request so it’s going to break my fork until I update.

It’s too much work on GitHub to follow along some repo and make occasional friendly improvements to it. I could use some simplified workflow which is just “keep my forked repo updated at all times with upstream unless it would clobber some work I did”. I imagine I could write a script to do that.

Maybe GitHub expects frequent committers to have write access and not go through pull requests. I like the review and auditing of pull requests, though.

Update: John Firebaugh recommends git-up and git hub to help make this better.

Need a simple reprojection tool

I want a simple tool to reproject a crappy whole-sphere image like this to something nice like Mollweide or Winkel Tripel. It seems like this would be easy enough with gdal, just have to learn enough about CRS to do it. The source looks like Plate Carree, no doubt produced by someone naive with a raster array of lat/lon samples.

Here’s a great StackExchange answer on reprojecting a bunch of tiles that’s more complicated than I need.

Edit: Mike M. to my rescue. He saw my blog post and offers

1. Turn the raw JPEG into geodata by creating a VRT file with a projection and an extent.
gdal_translate -a_srs EPSG:4326 -a_ullr -180 90 180 -90 -of VRT moon.jpg moon.vrt
2. Reproject the raster into the projection you want.
gdalwarp -t_srs EPSG:54009 moon.vrt moon-moll.tif
I chose projection 54009 based on a simple search for Mollweide on Spatial Reference, finding this: http://spatialreference.org/ref/esri/54009/. VRT is an XML-based format that leaves the original JPEG untouched: http://www.gdal.org/gdal_vrttut.html.
moon-moll
I should turn this to a single-serving site. Upload a Plate Carrée, download in one of several tasteful projections.

video frame rates

A question I’ve been pondering: are there only a few standard video frame rates? Asking on StackExchange and on Metafilter.

My suspicion is that in practice only 24, 25, and 30 fps works everywhere. I definitely had some issues trying to play downloaded YouTube 60 fps video. And my 15 fps experiment was a failure. Part of what’s complicating things here is that unlike resolution changes, frame rate resampling is a tricky non-continuous problem. Converting 30 to 60 is easy, just double. 24 to 60 is not awful, double 2 of every 3 frames. But converting 19 to 60 is, well, prime numbers don’t divide well. OTOH I would hope the file formats let you express whatever the source truly is and make it the player’s problem to represent it correctly.

Particularly peeved that 16 fps is not supported anywhere; that was the 8mm standard.

Code in The OpenAddress Machine

I’m trying to help with the OpenAddress project, particularly Mike Migurski’s “machine” code for running a full analysis of the data. Particularly particularly the ditch-node branch. Managed to get the tests running after some version hassle.

Now I’m taking inventory of what all code is in the repo to understand where to work. These notes are probably only useful right about now (December 2014) and only for the ditch-node branch.

openaddr/*.py

This is the big thing, about 1700 lines of Python code. The architecture is a bit confusing. I don’t really understand how it’s managing threads / processes for parallelism. Also the actual ETL code is a bit convolved with the download and cache code, including S3.

  • __init.py__: grab bag of top level stuff. Key methods:
    • cache() and conform() are wrappers around Python code to download and process data from sources. This code wraps Python modules and uses multiprocessing.Process to run them as separate jobs. (see also jobs.py) The comments say these are Node wrappers, but they no longer are in this branch.
    • excerpt() pulls bits of data out of source files for user presentation. Contains some logic for parsing CSV, Shapefiles, etc to get a few rows out of them. See also sample.py. Excerpt does not use Process.
  • cache.py: Download from HTTP, FTP, and ESRI sources. I believe this code entirely writes to local disk and does not use S3. The ESRI code has logic about doing database-like queries on URLs and rewriting the ESRI proprietary JSON to GeoJSON
  • conform.py: python code to translate source data to the OpenAddress CSV output schema. Uses the OGR Python bindings, etc. I believe this is not complete.
  • jobs.py: script code to run a bunch of cache jobs, conform jobs, etc as separate threads. I’m not clear how this multithreading interacts with the multiprocessing code in __init.py__
  • process.py: a main program. this invokes all the work described in jobs.py, then does some processing to extract report-like information (like the map). This is doing I/O via S3 and caches, not so much local disk.
  • render.py: Cairo and geo code to draw the map of data sources
  • run.py: a wrapper for running stuff on EC2
  • sample.py: extract some sample features from a GeoJSON file, used for excerpts?
  • summarize.py: produce a report about the job run using an HTML template.
  • template/state.html: the actual HTML file that is visible at http://data.openaddresses.io/. Or rather a Jinja2 template.
  • template/user-data.sh; not sure what this is. It seems to be a templatized “run” script that installs everything from scratch on a new machine. I imagine this is what Mike runs first on a fresh EC2 instance.
  • geodata/*: shape files. I think this is used by render.py to draw pictures of FIPS codes.

openaddr-*

Not part of the Machine repo, these are four small Node projects that contain code for managing OpenAddresses data. This is the code that’s being “ditched” in the branch, and in fact I think it’s no longer used outside the tests.

  • openaddr-source: this is the openaddresses project itself. The main thing is sources/*.json, a bunch of JSON files that describe data sources and their conforms.
  • openaddr-download: code that takes a source URL as input and downloads it. lib/connectors.js has the actual code to do FTP and HTTP requests. Also is able to get data out of ESRI services using esri-dump, another program by Ian Dees that has both Python and Node versions.
  • openaddr-cache: another downloading program, this one is focussed on caching source data in S3.
  • openaddr-conform: the big program, glues together all the other scripts into a single thing that takes a source JSON as input, emits a processed CSV as output. So it has a little download and cache logic in it as well as a bunch of ETL code for extracting data out of source files and emitting it in the simple CSV schema OpenAddresses publishes. it in turn relies on ogr2ogr and other tools for extraction.

test.py, tests/

Test suite for The Machine. All the code is currently in test.py, just 11 tests. tests/ is test data files.

chef/

Scripts to set up an Ubuntu server to run The Machine. I haven’t actually run these on my dev box, just copied out bits of it as necessary. Some of the things it does:

  • run.sh: install Ruby and chef, the invoke chef-solo
  • role-ubuntu.json: spec for The Machine. Installs Python, Node, and four openaddr-* Node modules.
  • **/default.rb: specs for each package. There aren’t many interesting bits here. Node is wired to version 0.10.33. Python installs Cairo, GDAL, and PIP. The openaddr-* modules get installed in /var/opt. Only openaddr-conform is now needed for the tests to run in ditch-node, although I’m not sure about the full machine loop.

kvm and Ubuntu snappy

I just launched my first Linux virtual machine ever, thanks to Ubuntu Snappy. Ubuntu 14.04 as the host and the stripped-down Snappy as the guest OS. The “locally with kvm” instructions worked fine except I had to add -nographic to the kvm command line to get it to launch headless.

The guest image has 512MB of RAM available, but the host qemu process has 940MB mapped. Wonder what that’s about? Presumably there’s ways to configure the resources availalbe on the guest machine.

I like the idea of Snappy, an Ubuntu distribution specially stripped down for VM guests, Docker, etc. I don’t know the market well enough to know if it’s competitive. I am much more inclined to use a guest OS if it feels like Ubuntu though. Confused about what snappy is doing as a package manager. apt-get is not enabled. dpkg is there and a bunch of stuff is installed, but I think you manage the Ubuntu core OS with snappy.

The guest reboots in about 11 seconds.

disk speed

2TB USB drives are now under $100. Which is awesome! But boy that’s a lot of disk to write. How long does it take?

Sadly my iMac is USB 2.0 only. In practice that gets about 21 MBytes/second with the disk. At that speed it takes about 27 hours to read or write all 2TB.

My Linux box has USB3 ports, so the data interface is no longer the limiting factor. In practice I’m getting about 110 MBytes/second, at least at the start of the disk. That’s 5 hours and is presumably gated by how fast the bits are spinning by the read head. Update: took nearly 7 hours, aggregate speed was about 82 MB/s.

(Side note:  how do you know you have a USB 3 connection? The plastic inside the port is colored blue, that’s the first tip-off. On Linux you can also inspect the interface speed with “lsusb -t”; 5000M means USB 3. Details on Stack Exchange.)

I’m not finding a reliable source for theoretical throughput on a 5400 RPM spinning platter. Numbers I’ve seen are in the realm of 50–150 MBytes/second. I’d forgotten it depends on the density of the disk. The little 2.5″ disks I prefer should be faster than bigger 3.5″ disks, all things being equal.

There are a few 7200 RPM 2.5″ portable drives out there now, but they’re unusual enough that they are expensive and I don’t fully trust them. Naively, at best that’s a 33% speedup for bulk throughput, not a huge difference. Faster seek times though.

All the rivers (Australia)

Got a decent looking work print of a map of all the Australian rivers, as inspired by Chad Ajamian’s map. It’s on Imgur as a JPG, wordpress.com seems to have done a reasonable job with the full PNG, compressed it better than I can (!).

I produced this in TileMill, using data imported to PostGIS with ogr2ogr. I hoped to use the new MapBox Studio but it’s kind of a pain. Working with local data sources is awkward and there’s no simple exporting to a hires image. TileMill still gets the job done, what a champ! QGis also works and is faster (caching?), but its pixel rendering isn’t as beautiful as TileMill’s.

Map is styled on two parameters. Color is brown or blue depending on whether the stream is perennial, line width varies by UpstrGeoLn, the length of all line segments that contribute to this line segment. That’s not a bad proxy for stream importance, actually, I’m using it in lieu of Strahler number. I like the results.

Here’s the relevant part of the TileMill style sheet.

#streams2[perennial="Perennial"] {
  line-color: @stream;
  line-width: 0.5;
  [upstrgeoln > 10000] { line-width: 1.0; }
  [upstrgeoln > 100000] { line-width: 1.5; }
  [upstrgeoln > 1000000] { line-width: 2; }
}

australian-rivers_c21b28

SRID 900914

Here’s a new one on me; I used ogr2ogr to import the Australian river data into PostGIS and it ended up being labeled with SRID 900914. WTF? According to this discussion that’s what ogr2ogr does if the SRID isn’t already defined in the PostGIS tables. It adds a new entry with the CRS info gleaned from the source file. And since the largest defined SRID in most PostGIS installations is 900913 (the bogus Google entry) why, the next one created will be 900914.

The data is actually in EPSG:4283 which PostGIS already knows about.

While I’m here, this Stack Exchange answer has some useful ogr2ogr flags for big imports. -progress and --config PG_USE_COPY YES. According to the docs COPY may now be the default, but I’m not sure it is. Adding it cut my running time to 20% of without.

python-pip is broken in Ubuntu 14.04

Running pip on my Ubuntu 14.04 box gives the error “ImportError: cannot import name IncompleteRead” when trying to import the requests module. Turns out this is a known bug going back to at least April. It’s subtle though; a different Ubuntu box with the same versions of python-pip and python-requests is fine. It’s apparently a bug in python-requests, see also Migurski’s workaround.

A quick workaround is to remove Ubuntu’s python-pip and install pip manually.

Classifying Australian rivers

So the Australian river database doesn’t have Strahler numbers for streams, which I need to classify streams in order of importance. I got a very nice reply from the AHGF team asking about Strahler number with some ideas on what to do.

One option is to classify on a different measure. AHGFNetworkStream has a couple of features that are useful; UpstrGeoLn and UpstrDArea. They are “Combined geodesic length of contributing upstream AHGFNetworkStream features (incl. segment).” and “Combined albers area (m²) of contributing upstream AHGFCatchment features (incl. segment).”, respectively. Ie: how long the line is that feeds into this line, or how big the area that feeds into this line. It’s worth a look. Of course what I really want is actual water flow, but that’s not readily available.

The other option is to calculate the Strahler number myself. It seems like a simple enough algorithm. As long as the data is clean, that is, a strict tree. The AHGF folks warned me their data has loops and splits that might cause problems.

ESRI tools apparently calculate Strahler, but that’s not useful to me.

GRASS also apparently has some Strahler calculations. (Or Horton, which is similar. “Stream order” is the generic term.) More details here. I wonder which is easier; using GRASS or writing my own code? :-P

Notes on Australian rivers

Inspired by this map of all Australian streams I’m taking a crack at extending my rivers map to Australia. There’s a great open data site which has what I need, sort of.

I’ve found two different layers that are likely candidates. I think what I want is AHGFMappedStream from SH_Cartography. There’s also a AHGFNetworkStream in SH_Network but it has slightly fewer entries and also has stylized geometries.

Here’s an image zoomed in near Strahan in Tasmania. Brown is the network view, blue is the mapped view.

Screen Shot 2014-12-04 at 5.04.19 PM

 

Hierarchy appears to be only “minor” or “major”. “Perennial” is an interesting field.

Unfortunately what I can’t find is the Strahler number of a stream. I need that, both for nicely rendering bigger streams in heavier lines and also to simplify when zoomed out. I think I can figure out calculating it myself (using NextDownId on the table) but it’s a pretty big project. May be easiest to do that on the Network layer; it appears I can join across layers on HydroID.

$ key="HIERARCHY"; ogrinfo -al -sql "select $key from AHGFMappedStream" *.gdb -geom=no | head -100000 | fgrep "$key" | ~/src/accumulator.py
   29682 .8906   HIERARCHY (String) = Minor
    3646 .1094   HIERARCHY (String) = Major
       1 .0000 HIERARCHY: String (0.0)

Here’s the full schema. The site has some PDF docs that are helpful too.

Layer name: AHGFMappedStream
Geometry: Multi Line String
Feature Count: 1927331
Extent: (113.375345, -43.629382) - (153.632074, -9.242297)
Layer SRS WKT:
GEOGCS["GCS_GDA_1994",
    DATUM["Geocentric_Datum_of_Australia_1994",
        SPHEROID["GRS_1980",6378137.0,298.257222101]],
    PRIMEM["Greenwich",0.0],
    UNIT["Degree",0.0174532925199433]]
FID Column = OBJECTID
Geometry Column = Shape
HydroID: Integer (0.0)
AHGFFType: Integer (0.0)
Name: String (0.0)
Hierarchy: String (0.0)
Perennial: String (0.0)
AusHydroID: Integer (0.0)
From_Node: Integer (0.0)
To_Node: Integer (0.0)
NextDownID: Integer (0.0)
Enabled: Integer (0.0)
FlowDir: Integer (0.0)
SrcFCName: String (0.0)
SrcFType: String (0.0)
SrcType: Integer (0.0)
SourceID: Integer (0.0)
FeatRel: DateTime (0.0)
FSource: String (0.0)
AttrRel: DateTime (0.0)
AttrSource: String (0.0)
PlanAcc: Integer (0.0)
Symbol: Integer (0.0)
TextNote: String (0.0)
GeodesLen: Real (0.0)
UpstrGeoLn: Real (0.0)
Shape_Length: Real (0.0)

Vector rivers back online

I brought my vector rivers map back online. It was a casualty of my server meltdown a few months ago, and I thought that no one really used it and it requires 3 daemons to work and it was a pain so why bother? I put a note saying “email me if you miss it” and every couple of weeks someone wrote, so I felt bad and finally fixed it today.

Code rots. Fortunately this didn’t rot too badly. All told took 5 changes (see Dec 2 2014 a7a9424..77debec), 14 lines. And a bunch of stuff to install, although it’s easier now in Ubuntu 14.04 which has newer versions of PostGIS and pgdbf.

It’s funny I never thought of the actual river maps themselves as my product, but rather my nerdy code project. I suspect at most two people have gotten my code working themselves, so that was a failure. But a lot of people like looking at pretty river maps. I should make an effort to make an even prettier one, just for the aesthetics.

Other project is to productonize the thing, specifically startup scripts and logging for Gunicorn. Kind of a PITA, may not bother.

netstat only shows some stuff as tcp6?

Weird, Apache doesn’t show up as tcp when running netstat -l on my Ubuntu 14.04 box.

tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost:postgresql *:* LISTEN
tcp 0 0 localhost:smtp *:* LISTEN
tcp6 0 0 [::]:http [::]:* LISTEN
tcp6 0 0 [::]:munin [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 localhost:postgresql [::]:* LISTEN
tcp6 0 0 localhost:smtp [::]:* LISTEN
udp 0 0 107.150.51.74:ntp *:*
udp 0 0 localhost:ntp *:*
udp 0 0 *:ntp *:*
udp6 0 0 fe80::52e5:49ff:fea:ntp [::]:*
udp6 0 0 localhost:ntp [::]:*
udp6 0 0 [::]:ntp [::]:*

Apache is definitely running on port 80 and serving live traffic. It does show up with the tcp6 entry, and I believe [::] means “all addresses” so that must account for it. Odd not to see it bound to the old IPv4 name. (Same with munin, but not ssh.) I wonder if this change was in netstat, the kernel, or how Apache binds ports? Anyway you can’t just ignore the tcp6 part of netstat even if your box doesn’t have a public IPv6 address, IPv4 stuff may be hiding there.

Life at 100Mbit

I can report that having 100 Mbit at home is a good thing. I know, who would have guessed? The raw speed makes an enormous difference. For instance a couple of days ago I installed Skyrim. 10 GB of download. On my old DSL that would have been 4 hours, something to schedule overnight. Now it’s less than 20 minutes. Also means I can stream an HD movie without worrying whether something else using the link will ruin the playback.

But the best thing is having so much capacity greatly simplifies the router. I used to go to great lengths to have QoS routing. Right now I’m experimenting with not bothering at all, it’s completely disabled. I don’t notice any problems even when running a full speed BitTorrent both up and down.

Part of the advantage is my Internet is now faster than a lot of the backbone, so “full speed” for the average site won’t saturate my link. I also think it matters that the packets are relatively smaller. On my shitty 1Mbit link a 1500 byte packet is 12ms wide. Even with perfect packet scheduling there’s going to be uninterruptible 12ms delays sometimes. With this good link that time goes down to 0.12ms, making it much easier to share the link between multiple applications.