Deleting trailing whitespace for auto savers

real-auto-save is a great package if you like that sort of thing. For example, I like every file to always be saved without me worrying about doing it myself, so I stick with the default save occurring every 10 seconds. A really nice function to call on write-file-hooks is delete-trailing-whitespace, but, with 10s saves this means that in the middle of typing you have spaces eaten and this is clearly unacceptable!
Here is an attempt at a tweaked cleanup function that cleans up every line in the file but for the current line on which your cursor sits:

(defun gcr/delete-trailing-whitespace ()
  "Apply delete-trailing-whitespace to everything but the current line."
  (interactive)
  (let ((first-part-start (point-min))
        (first-part-end (point-at-bol))
        (second-part-start (point-at-eol))
        (second-part-end (point-max)))
    (delete-trailing-whitespace first-part-start first-part-end)
    (delete-trailing-whitespace second-part-start second-part-end)))

Cask for the truly impatient

Thanks to some kind Emacsers I’m now in the modern age using Cask, and what ease it brings to using Emacs. It is truly a joy; anyone not using Emacs for fear of difficulty pulling in packages can let go of their hesitation. It is as easy as writing one config file, installing the packages, and adding a couple lines to your Emacs init script. Here are the basic steps:

  • Clone the cask repo.
  • Add the bin dir to your path.
  • Create a file named Cask, add it to your VCS, and create a link to it from your .emacs.d directory
  • Add a repo and packages to the file.
  • From your .emacs.d directory, run ‘cask’
  • Add the cask load and init to your init file.
  • Start Emacs.

Excellent work by that team.

Used Motorcycle Checklist Email Template

Here is a template that I have found successful in minimizing the hassle for a motorcycle seller and maximizing the information summary for a motorcycle buyer. Credit is due to those who helped me with this; foul is due to me for any mistakes. It follows:
Hello,
Regarding your motorcycle for sale, I put together the following questions to make it pleasant both for you as a seller and me as a buyer:
In case I want to set up an appointment to test-ride and purchase the bike, at what phone number(s) are you reachable throughout the day?
My cell phone number is ###-###-####.
Why are you selling it?
Do you have the title?
Is the title in your name?
Is there a lien against the title?
Does the VIN on the bike match the VIN on the title?
Has this bike been rebuilt?
Did you follow the standard maintenance schedule for the motorcycle?
Are service records available?
If so for how long?
When is the last time that the the brake pads, hoses, or any of the fluids were changed (and which ones)?
When is the next service due?
What year is it?
How many miles does it have?
Has it ever been tipped over?
Does it come with any after-market items:
* Body (seat, fender extension, foot pegs, levers, tip over bars, handlebar risers, passenger backrest, heated grips, throttle lock, tank bra)?
* Braking(lines, pads, rebuilds, rotors)?
* Electrical(battery, horn, power outlet for heated gear)?
* Engine/Transmission(air filter, seals, cooling, spark plugs, exhaust)?
* Fuel System(fuel tank quick release, carbs, jet kit, filter)?
* General(vendor owners manual, Clymer manual, cover, wheel lock (any method))?
* Hardware(stainless screws)?
* Lighting(mounts, light kits, dual-headlight, tail lights)?
* Luggage(top case mount, top case (Givi etcetera), tankbag?
* Suspension(shocks, fork brace, )?
* Windshield(Givi, Rifle, lip add-on)?
Do you allow a test-ride before purchasing the bike?
Do you accept a cashiers check?
How much are you asking?
Is that negotiable?
Best wishes,
firstname lastname

IntelliJ Settings

IntelliJ Idea is best Java development environment out there. It can be an IDE or a text editor—configure it however you wish because whatever you do it will be simple. At its simplest you only need 4 settings to make it better out of the box:

  • Right margin (columns): 80
  • Editor tabs: 100
  • Show line numbers: true
  • Appearance Theme: IDEA (4.5)
  • Key-map:
    • Emacs
    • Project Toolbar: M:1
    • Structure Toolbar: M:2
    • Changes Toolbar: M:3
  • Font: DejaVu Sans Mono 12

How to Create a New and Empty Branch in Git

git checkout --orphan NEWBRANCH
git rm -rf .
touch .gitignore
git commit -a -m ""

Via bitflop.

Addendum: 2014-02-28:

Create an orhan branch
git checkout --orphan lp
git rm -rf .
touch .gitignore
git add .gitignore
git diff --cached
git commit -m "Initial import."
Create a remote branch
git push -u origin lp
Obtain a remote branch
git checkout -b lp
Delete a branch
Remote: git push origin :lp
Local: git branch -D lp

Interactive Image Generation with Racket

Not sure whether I blogged about this or not already, but I sure could not find it so here goes.
A while back my buddy Bruce needed some randomly generated images in a particular format for a project. The specs were more of a “I’ll know it when I see it” kind of thing so I volunteered to help out and have some fun with Racket in the process.
The nifty part is that during development and also use you may preview the images directly inside of DrRacket. This feature made the work so, so fun (other editors do this, too).
Here is a copy of the code. Try running manual.scm and the image will show up in the REPL. If you run automatic.scm it will dump the image in /tmp.