Originally from: 2007-09-26 15:17:44 -0700
We wanted to know how Bernie Sanders did in several electoral districts.
What are our data sources.
There are two public databases that can help us discover these vote totals. One is the election results broken down by voting precinct. The other is a database that maps the precinct numbers to district numbers.
lavote.net's precinct reports
The Los Angeles County Registrar Recorder publshes vote tallies aggregated by precinct. The problem is, these are reports, not raw or cooked data.
(This is one of those articles I sometimes fear writing, because it reveals a vast gap in my knowledge. I've spend most of the past decade in PHP programming, with numerous forays into other langauges and frameworks, but mostly in the app dev end. I have to deploy my code and that's made me take forays lower into the stack.)
It's hard to concentrate when you're tired and cranky, so I wasted some time writing a simple calculator in several different languages.
This is a rough watchdog script to restart apache on the local machine when the website gets slow. If a GET to the url fails, or takes longer than 60 seconds, the local web server is restarted.
I started to use this after installing a new version of Apache. The system hadn't been properly tuned, and the side effect was that Apache would be nearly wedged, but the rest of the system was merely slow. This happens when Apache or MySQL are getting wedged, but it's not due to the system overloading with too much traffic. Why does it happen?
This is something I wrote to learn some of the latest Perl tech to scrape pages. What's cool about this demo script is that it doesn't use regular expressions that much. Instead, it uses HTML::TreeBuilder::XPath to treat the HTML as a queryable hierarchical data structure. How cool is that?!
Vim/GVim has great features to make it easy to read C (and PHP and Perl) code. They treat your code like a hypertext or web page, where you can jump between files easily.
First is the "go to file" feature. If you move the cursor onto a file name, and type gf, you'll be taken to that file. To return to the previous file, press Control-o. The file opens are kept on a stack, so you can drill down into file, and climb back out.
This script below will accept a URL parameter, download the HTML, convert it to a .mobi file with kindlegen, and copy the file onto your Kindle.
This was an odd project. Taking several PDFs of layoff data and turning them into text, so they might be used more like a database. This info should be offered up by the state as a database, but it's not (at least it wasn't to me). I ended up using a PDF to Text application to generate text files, then wrote these scripts to scrape the data out of the text. My goal was to dig up all the unionized workplaces.
This script is being used to move files around in a Maildir. A bunch of spam goes into the "new" directory.
Sometimes, you have textual data, like log files, with IP addresses. You sometimes want this data to show hostnames instead.
Perl still rocks.
This is a Perl version of the VB FileMirror class shown earlier on this site. The class helps you write scripts to (semi) safely mirror or move a file system from one directory to another. It does this by building the correct destination paths, making destination directories, and deleting files only after they appear to have been copied over.
Docs are in FileMirror.txt, attached.
DriveGMover.pl is a script that uses the class.
This is a repository of "novice" articles, written with the intent of driving more traffic to the site, and getting more ad clicks. It's pretty crass, I know, but the information may be very useful.