los angeles singles events

prostitutes cheap

singles in st louis

personal dating

cheating wifes com

hook up tonight

meet mature

onenightstands

couple seeking

singles dvd

wife swapping movies

singles outreach

gay man dating

one to one sex chat

asian girls chat

us personals

web cam girl

delta singles

british singles

teenage dating online

my personals

women dating website

boys looking for sex

hotwife personals

get laid get

las vegas dating sites

singles colorado springs

jewish singles atlanta

middle aged singles

escort service california

mature women personals

outdoor singles

sex datin

phone date

local wives

live 121 chat

singles destinations

dating sites

valley personals

black lesbian chat rooms

meet beautiful women

dirty singles

real sex contacts

free escort service

sensual massage for couples

seeking black women

valdosta singles

baltimore swinger

dating website reviews

catholic dating website

what are the best dating sites

singles in hampton roads

singles events ny

lds singels

weston singles

nairobi singles

singles milwaukee

freecam girls

tickling personals

lonely ladies

bedford singles

real date

husband swapping

live gay chat

looking for sex gay

singles holidays uk

phone sex chatline

baptist dating service

adaultfriendfinder

blur singles

tempe singles

cell phone dating

swinger party san francisco

swinger wifes

urban singles

mail ordered brides

www bestfriendsmom

aisan girls

cam sex chat

butch personals

safe online dating sites

catholic friend finder

arab personals

bi female seeking couple

date in

az swinger

ukranian dating

arkansas dating

wanna date

livelinks com

singles over 45

online date chatting

dating seniors

live lesbian chat

www fat women com

oakland singles

single russian men

live video adult

swinging site

swinger contact

Google Charts from Clojure 1

Posted by jonathan on February 16, 2008

I wrote up a very simple example of calling Google Charts api from Clojure.

Example Google Charts Graph

Note: Rich Hickey actually emailed with some suggestions, and these have been added. I added a comment on the one I found most interesting, which is a function literal. Thanks Rich!

(in-ns 'google-chart)
(clojure/refer 'clojure)

(def *amp* "&")

; ---- connect to google charts and retrieve a chart ----
(defn get-google-chart [request]
  (new javax.swing.ImageIcon (new java.net.URL request) "Google Chart"))

; ---- pop-up a png in a dialog frame ----
(import '(javax.swing JLabel JFrame))

(defn show-chart [request]
  (println "Showing chart: " request)
  (doto (new JFrame "Google Chart")
    (add (new JLabel (get-google-chart request)))
    (pack)
    (setVisible true)))

; display the hello-world chart
;(show-chart (str "http://chart.apis.google.com/chart?"
;                 "cht=p3&chd=s:hW&chs=250×100&chl=Hello|World"))

; ---- simple encoding to 0 - 61 in chars ----

(defn encode [val scale]
  (if (nil? val)
      "_"
      (let [val (. Math (floor (* 61 (/ val scale))))]
        (nth "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" val))))

; ---- build a chart ----

(defn base-url []
  "http://chart.apis.google.com/chart?")

(defn chart-size [x y]
  (str "chs=" x "x" y))

(defn chart-type [type]
  (str "cht=" type))

(defn chart-data [data]
  (let [mx (apply max data)]
    (apply str "chd=s:" (map #(encode % mx) data))))   ; function literal

;### fix spaces -> +
(defn chart-title [title]
  (str "chtt=" title))

(defn chart-axis [x y]
  ; really basic, just an x and y axis
  (apply str "chxt=x,y" *amp*
         "chxl=0:" (concat (interleave (repeat "|") x)
                           ["|1:"] (interleave (repeat "|") y))))

;; Test it out ...
(comment
(show-chart
  (str
    (base-url)
    (chart-size 480 480) *amp*
    (chart-type "lc") *amp*
    (chart-data (map (fn [x] (* x x)) (range -50 51))) *amp*
    (chart-title "x+squared") *amp*
    (chart-axis ["-5" "0" "5"] ["" "" "y-axis"]))))

; Test it out ...
(show-chart
  (str
    (base-url)
    (chart-size 480 240) *amp*
    (chart-type "lc") *amp*
    (chart-data [188.5 186 181.5 183 179.5 181]) *amp*
    (chart-title "Jonathan+Weight") *amp*
    (chart-axis ["Week+1" "Week+2" "Week+3"] ["" "" "190+lbs"])))

Regular Expression Helper

Posted by jonathan on February 11, 2008

Click here to play with a simple reg exp helper for JavaScript.

Regular Expression Helper in JavaScript

Paste some text in, then experiment with typing in regular expressions, and watching the matches listed as you type.

10 Worst PC Keyboards of All Time 1

Posted by jonathan on January 10, 2008

This article on PC World lists the 10 Worst PC Keyboards of all time.

I’ll try not to spoil it but, the ZX-81 and Mattel Aquarius are represented. For those of us with long memories, where is the Sord M5?

Response to a Slashdot Post about Assembly Language

Posted by jonathan on January 10, 2008

There’s an interesting discussion going on Slashdot about programming languages.

Check here for the post about assembly language programming that made me stop and think.

My somewhat flip response was “If it generates x86 code, I refuse to look!!”

More seriously, I started assembler programming at the tender age of about 14 with 6502 code on my BBC Micro, then 68000 on the Amiga, then did a bit of (paid) ARM3 programming, but I just have never, since I owned a Speccy, been able to look at Z80, 8080 or 8086 up. I suspect the oddly named registers and vast panoply of addressing modes are the scariest things…

But tell me, is x86 code as scary as I’m treating it? Because I feel bad that I’ve ignored it for so long, but maybe I’m at the point where I’m just being dumb.

What do you think? What do people do with assembly language on these chips anyway?

LISP Running on OLPC (One Laptop Per Child)

Posted by jonathan on December 29, 2007

After a couple of glasses of red wine tonight, I decided I would try and get a JVM and LISP, in the form of Rich Hickey’s Clojure language, running on my OLPC.

Downloading a JVM was simple, and it installed quickly, once I worked out that the OLPC software saves large files that it doesn’t understand into /tmp.

I then tried several times to download the Clojure distribution, but I never managed to find where mozilla was putting the .zip file. Anyway, I was able to unzip it by opening the file in etoys which has the first decent file selector I’ve seen on the OLPC.

Once Clojure is unzipped, it can be run simply by running ‘java’ against the clojure.jar file. Expressions typed at the repl, or loaded are compiled by Clojure, then JITed by the java runtime, which (and I can vouch for this) gives extreme performance that is more than up to the task of moving multithousand line datasets around even before your finger is off the enter key.

Anyways, here’s a couple of shots of Clojure running on the latest JRE on my OLPC:

Clojure on OLPC

Clojure on OLPC

It seems like a lot of people have been worried about getting java up and running, but downloading it from java.com (See Linux Self-extracting file) worked just fine. ;-)

Refactoring: Improving the Design of Existing Code

Posted by jonathan on December 10, 2007

Refactoring: Improving the Design of Existing Code
Martin Fowler with Kent Beck, John Brant, William Opdyke and Don Roberts.
In the Addison-Wesley Object Technology Series.

Refactoring (as I’ll refer to the book from here on in) is a heavy and beautifully produced 418 page hardback book. Martin Fowler is a UK-based independent consultant who has worked on many large systems and is the author of several other books including UML-Distilled.

Refactoring is a self-help book in the tradition of Code Complete by Steve McConnell. It defines its audience clearly as working programmers and provides a set of problems, a practical and easily followed set of remedies and a rationale for applying those techniques.

Code refactoring is the process of restructing code in a controlled way to improve the structure and clarity of code, whilst maintaining the meaning of the code being restructured. Many maintenance problems stem from poorly written code that has become overly complex, where objects are overly familiar with each other, and where solutions implemented expeditiously contribute to the software being hard to understand and hard to add features to.

Typically refactorings are applied over a testable or local scope, with existing behavior being preserved. Refactoring as defined in this book is not about fixing bad designs, but instead should be applied at lower levels.

Testing a la Extreme Programming is emphasized as a control for ensuring that program meaning is not changed by refactoring. It is not over emphasized, and this is not a book about testing, but it is often mentioned and stays in the background through the book.

The refactorings presented in the book are not intended as a comprehensive solution for all problems, but they do offer a means to regain control of software that has been implemented poorly, or where maintenance has been shown to simply replace old bugs with newer ones.

The book is divided into two main sections, introductory material that introduces and discusses refactorings, and a lengthy taxonomy of refactorings that includes both examples and further discussion. The introductory material consists of a long worked example through simple Java code that implements printing a statement for a video store. Despite the simplicity of the code, Fowler shows in clear detail where improvements can be made, and how those improvements make the code both impressively easy to understand, and easy to maintain and add features.

Several key refactorings are demonstrated in the opening chapter including Extract Method, Move Method and Replace Conditional with Polymorphism. This is a book about programming in the object oriented paradigm, so as you might expect, the first two refactorings refer to extracting and moving object methods either into new methods, or between objects. The third example provides a means to replace special cased behavior in a single object type by deriving a sub type of the object and moving type specific code to the sub types. This is a fundamental technique in object oriented programming, and is discussed here in practical terms.

Now that several actual refactorings have been introduced, Fowler provides a solid and well thought-out discussion of the why’s, when’s and when not’s of refactoring. For example, code can decay as features are added, and programmers special-case, or bodge additional functionality into existing objects. Fowler argues that the bitrot and decay makes software more unreliable, leads to bugs and can accelarate as the problem gets worse. Faced with these problems, refactoring should be used to improve local design and clean up and improve code, leading to better software, that is easier to maintain, easier to debug, and easier to improve with new features as requirements change.

However, there is a caveat, in that since software functionality should remain unchanged during refactoring, the process of refactoring consumes resources, but provides no easily measureable value. Fowler confronts this issue in a section that discusses how to communicate with managers, that you are performing refactoring work. He denies being subversive, but his conclusion is that refactoring should essentially be folded in with normal work as it improves the overall result.

This is a bit like goofing off on the basis that you’ll think better after 20 minutes of fooseball. I’d definitely subscribe to that theory, but many others may not.

Kent Beck guests in Chapter Three for a review of the issues in typical software that suggest a refactoring may be needed. This chapter is entitled Bad Smells in Code, and most of the smells presented will be familiar to any reasonably experienced programmer, and they will be a great learning experience for less experienced programmers. I got the same feeling reading this chapter as I did when I first read Code Complete. Here was someone writing down names and describing problems that I had a vague unease about, but was too inexperienced to really articulate or do something about. Typically the refactorings address the same kind of issues that a code review with a skilled experienced programmer would address. Long parameter lists, too long methods, objects delving about in each others private variables, case statements, related code spread across different objects etc. None of these problems are debiliting in themselves, but added up, they lead to software that can be prone to error and difficult to maintain.

Most of the remaining substance of the book, 209 pages, is given over to a taxonomy of refactorings. These 72 refactorings are covered in detail with comprehensive simple examples presented in Java. Each refactorings is given a clear name, a number and a line or two of descriptive text. The motivation for the refactoring is then discussed, often including caveats and cautions. The mechanics of implementing the refactoring are then listed, with 1 or more (and often more) examples of implementing the refactoring. Refactorings range from the very simple to more complex examples such as Convert Procedural Design to Objects.

Due to the difficulties of reproducing large and complex sections of code, Fowler sticks with relatively simple examples. These seem to grate on him more than the reader, and he can come across as somewhat embarrassed when we look at the employee, programmer, manager pay example for the tenth time. I certainly didn’t have a problem with it though.

Conclusion

This is a very well written and fun to read book. I personally feel that much of the material is implied by from Code Complete, but Fowler does a fantastic job of expanding and formalizing the idea of applying explicit refactorings. Much like Code Complete gave a motivation for keeping code well commented and laid out, this book presents the case for care and feeding of how to structure software. To fight bitrot and technical debt, poorly structured and unclear code should be targetted and refactored to improve structure and clarity. This gives a very real payback in terms of less required maintenance, and ease in adding features later on down the line.

Despite the fact that all the examples are in Java, the ideas are easily transferable to C++ or any procedural object oriented language.

Highly recommended.

Querying MS Visual Source Safe in Perl – Counting DIFFs

Posted by jonathan on August 15, 2007

The following Perl code automates MS Visual Source Safe to get the stats on check-ins. The input should be a list of files from the output of my other script.



#!/usr/bin/perl -w
use strict;

# Read a list of check-ins and call 'ss Diff' to get what was checked-in

$ENV{'SSDIR'} = "";
my $project = " ";
my $checkInsFile = "";

# Read in check-ins from file
open( checkIns, $checkInsFile );
while( ) {

# Parse out the details from the check-in
my( $file, $ver, $use, $date, $com );
if( m/^(.*)\t(.*)\t(.*)\t(.*)\t(.*)$/ ) {
( $file, $ver, $use, $date, $com ) = ($1, $2, $3, $4, $5);
}

# Put any check for conditions here

# Check for some date range

# Check for some file pattern

# Check for some comment pattern

# Summed totals for this check-in
my $added = 0;
my $changed = 0;
my $deleted = 0;

# Special case version 1 to get the file line count of Version 1 (Check-in)
if( $ver == '1' ) {

# Get linecount for version 1 of file
my $command = "ss View \$/$project/$file -V$ver|";
open( ssView, $command );
while( ) {
$added++;
}
close( ssView );

}
else {

# Open a Unix diff from version-1 to version
my $verMinus1 = $ver - 1;
my $command = "ss Diff -DU \$/$project/$file -V$verMinus1~$ver|";
open( ssDiff, $command );

while( ) {

# Match for "number[a|d|c]number" at the start of a line
if( m/^(\d+),?(\d*)([acd])(\d+),?(\d*)$/ ) {

# Added
if( $3 eq "a" ) {
$added += ($5 gt "" ? $5 : $4) - $4 + 1;
}

# Changed
if( $3 eq "c" ) {
$changed += ($5 gt "" ? $5 : $4) - $4 + 1;
}

# Deleted
if( $3 eq "d" ) {
$deleted += ($5 gt "" ? $5 : $4) - $4 + 1;
}
}
}

close( ssDiff );
}

# Print check-in details + edit details
print "$file\t$ver\t$use\t$date\t$added\t$changed\t$deleted\t$com\n";
#print "Totals for ${file};$ver ($use) on $date added: $added changed: $changed deleted: $deleted\n";
}

# Done
exit 0;

Go Ubuntu!!

Posted by jonathan on May 23, 2007

Well I am posting this from Firefox on Ubuntu, and just great does it look! Ubuntu 7.04 (Feisty Fawn) is pretty much rock solid so far, and out of the box works great.

I have my nvidia graphics, sound, SATA, file sharing, WINE all working great, and am slowly working through getting a bunch of old documents out of Access 2.0 and Word 2.0 formats and in to PDF, which sadly takes a Mac and a copy of Office 2004, though OpenOffice made a valiant attempt. In fact I ended up printing the old Word Docs into PDF from Mac Office, straight into a SAMBA share, so I can now grab the unformatted text if I really need it.

Anyway, Ubuntu 7.04 will ship on selected Dell machines as of Thursday 24th May 2007, but you can download it and try it for free from the link above. Go try it! You’ll be impressed!

Time Enough to Crash – Backup 2

Posted by jonathan on December 12, 2006

There’s been a good lull of about 3 months or so since Nathan at the Woodlands of Houston Apple Store replaced the hard drive in my Power Book G4, and I’ve started getting nervous about it having an ‘accident’ again.

It was only a bad sector, in a single song, but it was enough to jack up my preferred method of backing up, which is to use the disk utility software after booting off the OS Install disc. Generally this is a pretty good way to get a complete image of your drive, every few weeks or so.

Anyway, now that my wife Meredith has her own MacBook I figured it was time to start a proper backup regime. A search on Google revealed a piece of software called SuperDuper.

SuperDuper installed in the usual drag and drop fashion and I was up and running with a backup after about an hour or so. I prefer to do full backups to an external drive, and a 60 Gig HD in the MacBook allows you to partition an external 250 Gig WD drive into four parts, allowing a nice rotation of backups.

I use the same model of WD external hard drive with my PowerBook, but partitioned into only three separate drives.

Name a Day Mon|Tue|Wed and Get Date in Previous Week

Posted by jonathan on October 18, 2006

I use this command-line UNIX utility for generating filenames when I know that a, sayyy, audio stream was generated in the previous week, but I only know the day …

Usage: `datep sun`
prints: 20061015 which in this case is a couple days previous to the current day. Perfect for when you want a filename friendly date from yesterday or before.

This may be backticked into any other command for generating filenames, etc. Use at your own-risk. Use ‘View source’ in your browser to get the source.

#include 
#include 
#include 

int main (int argc, const char * argv[]) {

# ifdef _DEBUG
	// Print args 0 - command, 1 - 3 letter day
	int i = 0;
	for( i=0 ; i