johnk's blog

Perl Rocks (even yet)

Perl still rocks. People still say it's hard to read (true), but it's because the language is terse.

sub getAccountIdsOfSitesToSuspend
    $sql = <<EOQ;
        SELECT account_id
        FROM account
            account.account_balance < (SELECT triggerAmount FROM fk_suspension_rules)
            AND (
                    SELECT IF(SUM(transaction_ammount), SUM(transaction_ammount), 0)
                    FROM transaction
                    WHERE transaction_date > DATE_SUB( CURDATE(),
                        INTERVAL (SELECT paymentWindow FROM fk_suspension_rules) DAY)
                    AND transaction.account_id = account.account_id



A good tutorial at DDJ.

There's going to be a conflict with Prototype, because it also uses $, but differently.

Add HTML Tags to PHP...; A

One cool thing about geeking out with Josh is that new ideas happen. The latest one that came up was to make <SPAN> and <DIV> (and their closing tags) part of the PHP language syntax. This isn't going to happen, but think...

Those two tags could be treated like double quotes, and the content within them can, by default, echo to the page. Example:

if ($i==true) 
  <div>Hello, world.</div>

If you need to evaluate:

if ($i==true)
  <div>Hello, {ucfirst($name)}</div>


while ($line=readline($fh)):

On second thought, this isn't just for PHP. Pretty much any language could use it. It just doesn't make sense in other languages, because they don't spit out web pages.

Typewriter as Computer Keyboard

How cool is this?

Project 1

Project 2

Linux Point-of-Sale Spotted at Mitsuwa Market

The Mitsuwa Market in Los Angeles is using a POS system that runs on Ubuntu Linux. The POS was odd, because it didn't disable the menu bar. The Ubuntu logo was right up there. It even used the default orange theme.

Coding Tactics, Mysteries of Access

Tactics, tactics, tactics: an essay about how to become a better programmer by studying code. Great analogies.

Why does Access hurt? It's just weird how you can modify the standard controls in Access, but they usually look like crap. You get a lot of control, via the numerous object properties, but, the interface never looks very nice.

OMG: Audiophiles...

OMFG. This is wrong. It seemed the "in" thing for audio geeks, circa 2001, was to start using XLR connectors to wire together their stereos... to get balanced signals. Or "balanced", because those heavy duty cords and connectors are supposed to deliver mono audio signals.

Old Atheros-Based WiFi Cards

For a number of reasons, Linux works well with Atheros cards, but not so well with Broadcom (unless it's in an embedded router). It seems like the distros all have support for the old MadWiFi driver. This is a short list of cards with ebay links:

Netgear WG311T

SysRank, a Scoring System to Determine Computer Performance

This is a simple formula to rank computers, so you can determine which machine in the network should probably be upgraded first.

SysRank = Sqrt( (CPUs * CPUSpeed) ^ 2 + Memory^2 + DiskSize) )

This doesn't account for things like the actual performance you get when you're using the computer, what the computer's purpose is, and other more important qualities. It's just a basic formula you can use to sort your list of computers, to get a good idea of which one could use some help.

Gentrification Perspective

I was researching gentrification, and came up on a ton of interesting articles, but this one was particularly interesting because it's from someone who identifies with the displaced.

Brown Kingdom

He sites the origin of gentrification in the decline of locally owned business. True enough, I suppose, but even locally owned businesses tend to spawn remotely owned ones, over time, when the second generations of owners move away to fancier areas, and sell out to ever-larger entities.

The blog is good, with a lot of interesting historical information and opinion.

Drupal: Upgrade Notes

Crap... this upgrade didn't work out so great. A detailed check of the tables show that the tables are okay. For some reason, the data isn't quite right, and I need to fix up the themes.

Drupal: Upgrade Notes

Been upgrading from an old Drupal 4.5 (aka Civicspace 82) to Drupal 5.1.

Dropping CiviCRM

I had to get rid of the unused civicrm tables. Installing it seemed like a good idea at the time, but no point of using it for a tiny campaign. Here's a script that will delete the tables. It's posted here because the InnoDB engine complains if you drop these in the wrong order, and violate some constraints.

drop table if exists `civicrm_activity`;
drop table if exists `civicrm_activity_history`;
drop table if exists `civicrm_activity_type`;
drop table if exists `civicrm_address`;
drop table if exists `civicrm_county`;
drop table if exists `civicrm_custom_option`;
drop table if exists `civicrm_custom_value`;
drop table if exists `civicrm_donation_page`;
drop table if exists `civicrm_email_history`;

Types of Information

For a while, I've bought into an idea that some folks (like Dave Winer) have promulgated about information. They say that there are three ways to organize information: chronologically, tabular, and hierarchically. (Notably, project management software combines all three.)

It seems about right, though the description seems too facile. Right now, computers can have tables and hierarchies, but there's not much support for storing and querying collected time-interval data. Most time data are treated as "atoms," when, in reality, most time data is some kind of interval.

One other kind of information seems to be missing: indeterminacy. Quantum mechanics (a subject about which I know little) and fuzzy logic (again, don't know much) both deal with the fact that you don't really know the value of a measurement, until you also know how accurate your measurement is. In other words, you need to know how much confidence you have in your data; statistics and statistical methods (a class I didn't do well in) are important.

What's Going On


It's been a while since I've blogged, because of a short term overload of things to do, putting in full time at a client's, and also taking a business class at the CC. Yes, business. It was a little bit of a shock to my anarcho-socialist mind to learn that most of the ideas we hold aren't different from the ideas taught in biz school... it's the "masses" who are uninformed about it... and it's only the anarcho-socialistic types who think something is wrong with the way things are. The biz class attitude is to just get yourself on top of the pyramid, and hope to avoid a revolution. I suspect biz school is also a leading vehicle for teaching the finer points of shady business practices and political corruption, but I can't be sure of this.

What I was hoping for were lessons on accounting and standard business practices, negotiation, and laws. Being an intro class, though, none of that was being taught. So, I'll have to just take some specific classes for those things. What was taught: money, organization, government, marketing. It's just basic capitalism, and as enlightening as sitting through an intro to Marx, Weber, or Gramsci. The book was okay, but was biased in favor of business, and also had some factual errors. The factual errors kind of killed it for me.

FileMirror in Perl

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. is a script that uses the class.

Syndicate content