Computer Programming

Yes, a bit specific, but I need to store some links!

What Many Other Books Don't Tell You about CSS


A lot of other books out there don't discuss selector specificity and the Cascade in enough detail. They don't talk about ways to organize your code, either. When you read this ebook, it'll make sense.

Python-Fu: Rename a file to match a caption

This script renames a directory full of XCF files so that the filename is derived from the first line of a layer named "caption".

I wrote this to enhance the file names for Koya Hand Crafts.

Email Cloaking Script (Email Hiding)

Originally from: 2007-09-26 15:17:44 -0700

Here's a perl script that takes email addresses as arguments, and returns javascript code that hides your email address from web spiders. The email address is also linked so it's clickable.

CSS Font and Style Switcher (jQuery)

This is a bit of code to add a floating box to your page that will let you switch stylesheets and fonts. I wrote it specifically to start trying out different "themes" and fonts, not to allow the end user to do these things. But the client will be using it to preview.

It's not fully parameterized, nor does it generate the HTML for the selects, so you'll need to hack the code.

Contemporary PHP Coding

Some of the notes here are really old, and use old practices. This is a rundown of contemporary practices circa 2016. I'm a few years behind, so, it's more like 2013 practices, but, there are still tutorials being written that don't use these better techniques. Get with the times.

Don't set up Apache. Instead use "php -S localhost:8000" to start a local server from the shell. The docroot will be in the current directory, and error logs go to the screen.

Python-Fu: Save different versions of an XCF file (branded, watermarked, thumbnail)

It took forever, but I finally hunkered down and learned some Python-Fu. It's really nice, especially being able to use Python's libraries, but, like programming Gimp in Scheme, it was kind of hard.

The most important thing, which I learned only after working at it three hours, is to use the "Browser..." tool in the Python console (in Gimp). This helps you find predefined commands to do all the expected operations. Use the "Apply" button to paste an example into the console.

Adventures in Screenshotting

I'm having one of those mornings, where nothing works quite right.

LibreOffice is a Faster Tool to Load Excel Data into an SQL Database

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.'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.

PHP Frameworks get weird

I was getting the itch to write a small web application and started looking around. I had played with Laravel a while back, but it's just a little too large. I wanted to deploy cheaply on my slow server.

The features I wanted were: REST API support, OAuth (client), Routes, User Auth

Phalcon was the most interesting. It's written in C as an extension, and is fast. It does mostly traditional, Laravel style MVC. It can do REST APIs as well, but the example isn't good. It needs some more code to do REST right. Being compiled it is fast. The features resemble Laravel and Twig.

WordPress Multisite Problems with Vagrant

I had some problems setting up Multisite on WP with the Vagrant environment.

The big issue is that the the domains and URLs need to be set just right. This is a little more complicated than a typical server setup because dev setups usually take shortcuts on DNS.

You need to fix the domain names in all the locations where they're resolved.

First, set up DNS. Set up domain names for all the domains you're going to develop, but use local names like "foobar.lo" instead of "". They can all point to the IP address your dev server exposes via Vagrant, usually

A Small Library to Change WordPress Options (useful for E2E WP Testing with Selenium)

I was messing with E2E testing of WordPress, and it was going okay, but I hit a wall when I needed to mess with one of the options, to turn of a CAPTCHA. You don't want to use deal with CAPTCHAs during a test, at least not every test. There may be some where you want to see the CAPTCHA.

The right way to do this is to flip options on and off.

Configuring Git to use Your SSH Keys

Github has instructions on how to do this.

Okay, you've done it, but it's still not working.

The problem I keep having is that I clone repos via HTTPS rather than git, so my settings need tweaking.

.git/config usually has a line like this:

[remote "origin"]
    url =
    fetch = +refs/heads/*:refs/remotes/origin/*

So, I need to change the URL, replacing the first part with "" I also like to add a setting for [push] to get rid of the long mes

Angular $q Promise Gotchas

This is here so you can laugh at the first mistake.

Gotcha: resolve(), not return:

Spot the bug:

$q(function(resolve, reject) {
    if (someVarInScope) {
        return someFunctionThatReturnsAPromise();
    } else {
        reject("some error message");

It's probably easy, given the headline. Line 3 is in error. It should be:


"return" exits the function.

Problems Injecting DOM Elements from Angular Views into D3 Objects

I was having a hell of a lot of gotchas related to redrawing a D3 chart within an Angular view. It was looking like something on the Angular side was causing my DOM references to break. Maybe ng-route redrawing views?

That was bad, because my charts were being appended to a DOM element that had been passed from Angular over into D3 via a config object. It worked before changing routes, but when you toggled through routes and returned to the chart, it couldn't be redrawn.

Javascript Method Chaining, aka Fluent Interface

There are several ways to implement the Fluent Interface in JS, and this is one I was using in a project, and halfway forgot.

Syndicate content