Computer Programming

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

The TDD/BDD Religion, Getting The

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.

Python Logging to Syslog, and Filtering with RSyslog

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.

Script to set up Python virtualenv

This script sets up both python 2.* and python 3 virtual environments in a directory.

#! /bin/bash

# sets up the packages/python directory's virtualenvs 
# make sure these envs are in .gitignore
#
virtualenv env
virtualenv -p python3 env3

. env3/bin/activate
for i in pip grip requests setuptools six wheel mysqlclient coverage; do
    pip install $i
done

deactivate

. env/bin/activate
for i in pip setuptools; do
    pip install $i
done

deactivate

Why bother? Because this is a way to redeploy the environment on an empty computer.

Visual Basics: VB, VBA, MS Office

This is a collection of related notes. I will not be updating them as I'm not using the platform at this time.

They're out of order, but there's a lot of potentially useful information in here. Maybe I'll compile it into a short ebook at some point.

Python Packaging, Development, Git, and an Epiphany about Contemporary Development

So, I have this library, and it's always a pain to release it onto my internal computers (or any computers). Unlike the web apps it's not running from a virtualenv. It's right on the system. Maybe it shouldn't be :/

Anyway, that was my motivation for learning Python packaging. It's not hard, but you have to follow every step in the tutorials, and really repeat them a few times. After a couple tries, I had my "eggs" working locally. I also found out that I'm supposed to use pip to make "wheels" instead. I was behind the times.

Making Some Promises (in Parse, but also relevant to jQuery and Backbone)

What a confusing topic. Unfortunately, if you start wanting to add "library" features to your code, like I did, you have to study Promises.

These are notes about Parse.Promises, and the end product is a small object that caches models.

Some Parse.com Cloud Code Gotchas

Getting back into CC has been full of annoying gotchas.

console.log() prints incorrectly

It stringifies the objects instead of using the formats favored by FireBug and Chrome's dev tools. So you will see things like {"foo":1} which aren't plain JS objects, but are really Parse Objects. Parse Object properties are accessed via get() and set().

Assume printed objects are really Parse Objects, which are like Backbone objects, and have a get() and set() method.

How do you get to the object that was saved?

request.object

Translating Angular Events into D3 Events

Converting or translating Angular events into d3 events was a lot easier than I thought it would be. Here's the code:

disp = d3.dispatch('resize');
angular.element(window).bind('resize', function() {
    disp.resize('foobar');
});

disp.on('resize', function(arg) {
    console.log(arg);
    // resize code is here
});

DOM tests in Jasmine

This continues some notes about working on sf-active-js, moving it to a contemporary Javascript development environment.

Here's a Jasmine spec to instantiate an HTML5 widget and test a few of the method calls. These method calls cause changes in the DOM, and these tests verify that the changes happened.

describe("comment", function() {
    var comment;
    beforeEach(function() {
        var elements = $('<div id="disclose"></div><div id="edit"></div>');
        $('body').append(elements);
        comment = Comment('#edit', '#disclose');
    });

Browserify libraries that can be tested with Jasmine... before they are rolled up by Browserify

This is part of a series of notes about bringing a JS project, sf-active-js, over to a contemporary Javascript development environment.

This is a trick to write modules that are testable in a browser, without subjecting the test to Browserify. Why?

I want to develop without the compilation step. It's easier and faster to work in the browser. (This particular app is mostly DOM manipulation, so headless isn't important.) Once the module has settled down, it can be added to the library.

The rest of this note assumes you know the Jasmine sample test runner included with the distro.

Notes on migrating to a contemporary javascript development environment

I'm writing this after writing the first two notes in this series about migrating sf-active-js to a contemporary Javascript development environment.

I wrote the original experiment a couple years ago. It's a JS client that retrieves some json data from the la.indymedia.org server, and displays it. I ran out of time, and didn't finish it then.

Upon revisiting the code, I found it a little confusing. It was around 800 lines of jQuery-style JS.

Node Package Manager, Bower, Yo, Jasmine Beginner Notes

Some rough notes related to the JS development toolchain. I've known JS for years, and have done Crockford-style dev a while, but this JS toolchain stuff is mindblowing and pretty complex. The docs are also pretty confusing. So these are rough notes. Not really a tutorial or the voice of experience.

Local, Global

"Local" means "local to the project".

"Global" can mean "global to the computer" or "global to the user, meaning really local to the user, but global across multiple projects."

It's a bad idea to install things globally to the computer system.

d3 dispatch (the d3 event system) notes

Learning d3 events this afternoon. These are the notes I'm taking while I'm learning it. I hope it helps.

It's called d3.dispatch. d3.dispatch('eventname1','eventname2') returns an object that manages setting event handlers, and dispatching events. The event system isn't global (unlike in most frameworks, where the event system appears to be globally available)- it's contained entirely within the object.

var dispatch = d3.dispatch('say');

That created an object that has a method dispatch.say() that dispatches/rasies/throws/broadcasts the "say" event to the listeners.

How many steps are there in a simple user registration and login?

We all take it for granted that most sites will have a user registration system, and way to log in. We're used to it, and most people are unaware of how complex it is.

So, how complex is it?

It's around 15 different steps or screens.

Fifteen.

I've done it a dozen times, and I think that's about right.

Bitten by the "this" scope issue in JavaScript callbacks

I took a step away from Angular and jQuery style coding conventions and dropped back to the traditional JS-style OOP, mainly because I wanted to get familiar with regular JS programming using the MDN docs, and learn the new HTML5 calls (which aren't new anymore).

I ended up coding using an MVC style, and consequently, added an event handling system. It was easy-but-cheesy so I eneded up using Backbone's event system. (It makes me look more hip.)

BTW, here's one way to use Backbone events within traditional JS code:

FooController = function() {
  var obj;
Syndicate content