Emacs + Bash on Windows

This is my second week working for my previous client, Platt Electric. It's tough working on a Windows desktop again, but I discovered a few new tricks to make it even more Unix-like.

Pretty excited about having Bash inside Emacs inside Windows. Without Bash, Emacs for Windows was kind of half-ass.

I added a couple commands to my .emacs file to make it happen:

;; For the interactive shell
(setq explicit-shell-file-name "c:/bin/cygwin/bin/bash.exe")

;; For subprocesses invoked via the shell (e.g., "shell -c command")
(setq shell-file-name "c:/bin/cygwin/bin/bash.exe")

Cygwin is required for this.

An Introduction to PDF Generation

This article attempts to make a good starting point for generating a PDF file from scratch, without using a PDF generation library, or for creating your own library. It's written in Ruby, but it can easily be translated to another high level language of your choice.

My dot emacs file (.emacs)

It's not pretty, but it (mostly) works:

APIs - Eliminate the Ambiguity

Programmers who design Application Programming Interfaces need to maximize the meaning that their APIs convey, while still keeping them short and simple.

In PHP, when the user uploads a file to your script, it is represented by an associative array with these five elements:

  $_FILES['userfile']['name']
  $_FILES['userfile']['type']
  $_FILES['userfile']['size']
  $_FILES['userfile']['tmp_name']
  $_FILES['userfile']['error']

This is an example of an API, albeit a static, read-only one. It has names you can use to access data that you want.

Can you guess what these elements are, exactly? What is 'type'? Does that indicate whether it is a binary or ascii file? Or does it mean its either a word processor document or an image file? What is 'error'? It could be an error message, or an array of error messages, or just an error number.

Displaying a Maintenance Page for Your Web Site

Update: I found what appears to be a much easier maintenance page setup in the book Agile Web Development with Rails, second edition, page 626, in the section titled "Step Five: Connect Apache to Mongrel". When I try it out, I'll post my results here.

PHP Coding Tips

Debugging Output as Code Comments

Often programmers will print out a complex array to aid the task of debugging a program. Sometimes it's good idea to copy and paste that debugging output back into the source code as code comments. At a later date, you or another programmer can look at the comment to see what kind of data is available to use.

function login($username, $password) {
    $user = db_find_user($username);
    // print_r($user): Array ( [id] => 321 [username] => 'moxley' [pass] => 'XXXXXX' )

    // ...
}

Object Notation over Array Notation

Welcome

Hi. Thank you for visiting. This site was put together primarily to promote my skills as an Internet software developer. Follow the links on the left side of the page.

I am currently working a contract at Oregon Catholic Press (OCP). I will be leaving in October with a some very significant experience in AJAX, PDFlib and the publishing industry. The product is called Worship Program. Please take a test drive.

Also in heavy development is my open source project, Modern Merchant an e-commerce storefront manager and shopping cart.

Syndicate content