Recent blog posts
Yes, a bit specific, but I need to store some links!
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.
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.
I'm having one of those mornings, where nothing works quite right.
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.
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.
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 "foobar.com". They can all point to the IP address your dev server exposes via Vagrant, usually 192.168.33.10.
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.
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:
So, I need to change the URL, replacing the first part with "firstname.lastname@example.org:" I also like to add a setting for [push] to get rid of the long mes
This is here so you can laugh at the first mistake.
Gotcha: resolve(), not return:
Spot the bug:
It's probably easy, given the headline. Line 3 is in error. It should be:
"return" exits the function.
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.
There are several ways to implement the Fluent Interface in JS, and this is one I was using in a project, and halfway forgot.
This is a rough note, because I finally figured this out after several hours of trying. If I'm wrong, please email me, and I'll fix it.
I had a problem because I wanted to centralize my $http requests in services rather than having XHR calls in controllers. My first attempts used callbacks, but I wanted to convert them to promises, which are a lot nicer. Thus, I had to test promises that used $http.
I must admit that I'm fully drunk on the Kool-Ade.
The tl;dr : testing isn't just writing tests, but also using mock objects and services to simplify testing, and using package managers to port code to new versions of modules. It takes days to learn how, but it's worth it.
This article describes how to use Python's logging library to send logs to syslog. Then, using rsyslog, a fancier syslog, we produce a log of pre-filtered output.
I have a process that runs a few times an hour, and it spits out results to STDOUT, which cron dutifully emails to me.
This script sets up both python 2.* and python 3 virtual environments in a directory.
Why bother? Because this is a way to redeploy the environment on an empty computer.