Sunday, September 26, 2010

Mediterranean cruise

My Mediterranean 12-night cruise on the Brilliance Of The Seas. See my Photo Album and Video . My favourite destinations were Pompeii, Venice, and Pisa. I was really impressed by the Leaning Tower, and the overall beauty of Venice. I gained 2.5 lbs in weight during the cruise. They certainly feed you well! I tried a Caesar Salad and sushi for the first time, amongst many dishes. Can't say I cared much for the sushi, though.

Saturday, September 11, 2010

Hacker News | The Single Most Important Secret to Success

Hacker News | The Single Most Important Secret to Success

1 point by RiderOfGiraffes 1 hour ago | link

My version of "The Secret" comes in two parts:

* Do lots of stuff

* Make failure fast and cheap

Also, this was submitted 6 months ago:

which in some way is a validation that it's an itme of (at least passing) interesting. Comments are closed there so you can't add to that (rather minimal) discussion, but it's interesting to see the points of view.


2 points by mattparcher 1 hour ago | link

There are two rules for success in life.

Rule #1: Don’t tell anyone everything you know.


1 point by kranner 1 hour ago | link

> "So the secret to success is to realize that there isn’t a secret."

Disingenuous title.

Allow me to contribute a short and glib alternative: "Keep failure cheap."


Sunday, September 5, 2010

DrRacket: a dirt-simple exception handler

Exception-handling in Racket is very powerful - but a little overwhelming to me. Suppose you want to do some very very simple exception handling: try something, but if it fails, return an error-value. The way you do this is by using with-handlers:

(with-handlers ([exn:fail? (lambda (exn) 

There's a lot of goo here, which can be tidied up with some macrology. I give this simple macro, and a couple of examples below:

(define-syntax catch-errors
  (syntax-rules ()
          ((_ error-value body ...)
           (with-handlers ([exn:fail? (lambda (exn) error-value)])
             body ...))))

(catch-errors "Oops" (/ 1 0)) ; "Oops"
(catch-errors "Oops" (/ 6 3)) ; 2
(catch-errors "Oops" (/ 6 3) (/ 16 2)) ; 8

Twitter account

I created a Twitter account recently. It will probably mostly just link back to this blog - for now, anyway.

Saturday, September 4, 2010

YT: Brian Tracy Fear of Failure

In a Youtube video, Brain Tracy recommends the following:

At the top of a clean sheet of paper, write the question "What am I afraid of?". Make a list, and select the one you feel holds you back the most. With your biggest fear in mind, write your answer to these three questions:
  1. How does this fear hold me back?
  2. How does it help me, or how does it help me in the past?
  3. What would be the payoff for eliminating this fear altogether?
Instead of backing away from your fears, move towards them. Instead of avoiding them, confront them. Eventually, you will reach a point where those fears will no longer play a major part in your decision-making. 

Friday, September 3, 2010

DrRacket: a first attempt at a web server

This is my first attempt at  a web server using DrRacket. It is supposed to calculate VAT given an input of Net or VAT. It doesn't actually do any calculations, but it does respond to buttons and suchlike.

#lang racket

(require web-server/formlets

(define init-input-string (λ(val)
                              (text-input #:value


(define vat-page%
  (class object%
    (init-field (rate "17.5") (amount "0"))
    (define vat-formlet
       (div "Amount: " ,{input-string . => . amount}
            (p "")
            "VAT Rate: " ,{(init-input-string "17.5") . => . rate}
            (p "Still in form. Hello Brooks."))

    (define (button-clicked request)
      ;(define-values (amount rate)
        (formlet-process vat-formlet request)
      (print "insert-post-handle")
      (print amount)
      (render (redirect/get))      )
    (define/public (render request)
      `(html (head (title "My Calculator"))
              (h1 "Simple VAT calculator")
              (form ([action ,(make-url button-clicked)])
                    ,@(formlet-display vat-formlet)
                    (input [(type "submit") (value "Calculate")]))
              (p ,amount)
              (p ,rate))))))

(define (render-vat-page-new request)
  (define vat-page (make-object vat-page%))
  (define (response-generator make-url)
    (send vat-page render make-url))
  (send/suspend/dispatch response-generator))

(serve/servlet render-vat-page-new #:port 80 #:listen-ip #f)


(define vat-formlet
       (div "Amount: " ,{input-string . => . amount}
            (p "")
            "VAT Rate: " ,{(init-input-string "17.5") . => . rate}
            (p "Still in form. Hello Brooks."))
       (values amount rate)))

(define (render-vat-page amount rate request)
  (local [(define (response-generator make-url)
            `(html (head (title "My Calculator"))
                    (h1 "Simple VAT calculator")
                    (form ([action
                            ,(make-url button-clicked)])
                          ,@(formlet-display vat-formlet)
                          (input [(type "submit") (value "Calculate")]))
                    (p ,amount)
                    (p ,rate))))
          (define (button-clicked request)
            (define-values (amount rate)
              (formlet-process vat-formlet request))
            (print "insert-post-handle")
            (print amount)
            (render-vat-page amount rate (redirect/get)))]
    (send/suspend/dispatch response-generator)))

(serve/servlet (λ(request) (render-vat-page "0.0" "17.5" request)) #:port 80 #:listen-ip #f)