arbscht

Adventures in Shaken Milk

September 23, 2008 on 11:03 pm | In Uncategorized | 4 Comments | arbscht

Milkshakes are very easy to make. All you need is a banana or two, some milk, and a blender. But that’s not very interesting.

Milkshakes are also very easy to extend. The basis is extremely versatile. It’ll take just about any of fruit, some vegetables, confectionery or dairy products and other stuff. Now that is interesting.

To demonstrate, here are some simple milkshake recipes I’ve tried or plan to try…

Basic smoothie

  • 2 girls bananas
  • 1 cup hot milk
  • 1 orange
  • 2 tbsp porridge oats (rolled)

Partly cook the oats in the milk. Dice bananas and orange. Blend everything. Serve chilled.

I find the oats add a non-uniform chunky texture whereas a plain smoothie is too smooth.

Juicy shake

  • 2 bananas
  • 1 cup hot milk
  • 2 tbsp porridge oats (rolled)
  • 1/2 cup fruit juice of any sort (I used a bottled “tropical” type)
  • 3 scoops vanilla ice cream

Same principle as above, except this serves more. And there’s extra creaminess from the ice cream. I prefer to blend it rather than serve scoops on top, just out of laziness.

Speaking of laziness, I’ve yet to make tonight’s shake. I’m planning on:

Chocolate shake

  • 2 bananas
  • 1 cup milk
  • 1 diced mango
  • half cup ground milk chocolate (Whitaker’s Kiwi Fruit here)
  • 3 scoops vanilla ice cream

At this point I’m just putting together whatever is on hand, really. And that’s the great thing about milkshakes. Tasty, fresh, and ridiculously easy to create. Now go make one.

arbscht

Even Smaller Snake

June 23, 2008 on 8:57 am | In Uncategorized | 5 Comments | arbscht

In 35 lines. (It had to be done.)

Here’s a take on Jeremy’s Snake, implemented in Clojure (a Lisp for the JVM). As you can see, I’m still using the same library classes. Only the language is different.

A major difference is that this is the whole application code, including incantations and setup. Excerpting the Snake-specific bits would make it shorter — maybe under 30 lines even.

Still, it is a little messy for the sake of brevity. With a more liberal style, it could be a neat 50-100 line Snake.

Update [Tue Dec 30 12:58:04 NZDT 2008]: The original code in this post was written to an old version of Clojure (Jun 2008), which has since been replaced by newer versions that introduce breaking changes. An updated snippet follows, which is known to work with Clojure SVN rev 1185 (Dec 2008). Thanks to Chouser and Stephen C. Gilardi for additional idiomatic updates, reducing line count.

These versions of the program are intended to be abnormally terse. For an expanded and readable presentation, check out Mark Volkmann’s edition, which is more instructive to humans.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(import '(java.awt Color) '(javax.swing JPanel JFrame Timer)
         '(java.awt.event KeyEvent ActionListener KeyListener))
 
(defn gen-apple [_] [(rand-int 750) (rand-int 550)])
(defn move [{:keys [body dir] :as snake} & grow]
   (assoc snake :body (cons (vec (map #(+ (dir %) ((first body) %)) [0  
1]))
                            (if grow body (butlast body)))))
(defn turn [snake newdir] (if newdir (assoc snake :dir newdir) snake))
(defn collision? [{[b] :body} a]
   (every? #(<= (- (a %) 10) (b %) (+ 10 (a %))) [0 1]))
(defn paint [g p c] (.setColor g c) (.fillRect g (p 0) (p 1) 10 10))
 
(def dirs {KeyEvent/VK_LEFT [-10 0] KeyEvent/VK_RIGHT [10 0]
            KeyEvent/VK_UP   [0 -10] KeyEvent/VK_DOWN  [0 10]})
(def apple (atom (gen-apple nil)))
(def snake (atom {:body (list [10 10]) :dir [10 0]}))
(def colors {:apple (Color. 210 50 90) :snake (Color. 15 160 70)})
(def panel (proxy [JPanel ActionListener KeyListener] []
              (paintComponent [g] (proxy-super paintComponent g)
                              (paint g @apple (colors :apple))
                              (doseq [p (:body @snake)]
                                (paint g p (colors :snake))))
              (actionPerformed [e] (if (collision? @snake @apple)
                                     (do (swap! apple gen-apple)
                                         (swap! snake move :grow))
                                     (swap! snake move))
                               (.repaint this))
              (keyPressed [e] (swap! snake turn (dirs (.getKeyCode e))))
              (keyReleased [e])
              (keyTyped [e])))
 
(doto panel (.setFocusable true)(.addKeyListener panel))
(doto (JFrame. "Snake")(.add panel)(.setSize 800 600)(.setVisible true))
(.start (Timer. 75 panel))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
;(import '(java.awt.event KeyEvent ActionListener KeyListener)
;        '(javax.swing JPanel JFrame Timer))
 
;(defn gen-apple [] {:x (int (* 790 (. Math (random)))) :y (int (* 590 (. Math (random))))})
 
;(def snake (ref {:body (list {:x 10 :y 10}) :dir {:x 10 :y 0}}))
;(def apple (ref (gen-apple)))
;(def dirs {(. KeyEvent VK_LEFT) {:x -10 :y 0} (. KeyEvent VK_RIGHT) {:x 10 :y 0}
;           (. KeyEvent VK_UP)   {:x 0 :y -10} (. KeyEvent VK_DOWN)  {:x 0 :y 10}})
 
;(defn move [{body :body dir :dir :as snake} & opts]
;  (merge snake {:body (cons {:x (+ (:x dir) (:x (first body)))
;                             :y (+ (:y dir) (:y (first body)))}
;                            (if (:grow (apply hash-map opts)) body (butlast body)))}))
 
;(defn turn [snake newdir] (if newdir {:body (:body snake) :dir newdir} snake))
 
;(defn collision? [{[b & bs] :body} a]
;  (and (>= (+ 10 (:x b)) (:x a)) (<= (:x b) (+ 10 (:x a)))
;       (>= (+ 10 (:y b)) (:y a)) (<= (:y b) (+ 10 (:y a)))))
 
;(defn run-snake []
;  (let [panel (proxy [JPanel ActionListener KeyListener] []
;                (paintComponent [g] (proxy-super paintComponent g)
;                                    (. g (fillRect (:x @apple) (:y @apple) 10 10))
;                                    (doseq p (:body @snake) (. g (fillRect (:x p) (:y p) 10 10)))
;                                    (if (collision? @snake @apple)
;                                      (dosync (ref-set apple (gen-apple))
;                                              (alter snake move :grow true))))
;                (actionPerformed [e] (dosync (alter snake move))
;                                     (. this (repaint)))
;                (keyPressed [e] (dosync (alter snake turn (get dirs (. e (getKeyCode)))))))]
;    (doto panel (setFocusable true) (addKeyListener panel))
;    (doto (new JFrame "Snake") (add panel) (setSize 800 600) (setVisible true))
;    (. (new Timer 75 panel) (start))))

Edit: fixed per cgrand’s comment.

arbscht

Multitasking

June 20, 2008 on 9:44 pm | In Uncategorized | No Comments | arbscht

So I came upon this article on the Myth of Multitasking. I think its premise is something like: multitasking is really impossible, perhaps dangerous to attempt, and detrimental to learning. Or something like that. You see, I don’t know for sure because I couldn’t actually bring myself to read the lengthy piece.

In fact, when I got past the first paragraph, I couldn’t help but interrupt my reading to wryly note how funny it was that I just did that. And then, in the following hour or two, I skimmed a few other websites and blog posts, played a game, wrote some code, updated some software, ate cake, chatted a bit, and wrote this post.

BRB.

arbscht

Cups of Brown Joy: Harney Teas, Black and White

June 10, 2008 on 5:58 pm | In Food | 1 Comment | arbscht

For lack of content, it seemed like a good idea to post reviews of teas. We’ll begin what could become a series (if I bother) with a double-review.

Our two flavours are both from Harney Teas: Big Red Sun and Winter White Earl Grey. Big Red Sun is a bold black blend of Kenya and Ceylon, while Winter White Earl Grey is a subtle Chinese white tea with lemony bergamot. They represent an interesting contrast — in fact, two opposite ends of the tea spectrum — so I thought they would be a good way to sample Harney’s teas.

Continue reading Cups of Brown Joy: Harney Teas, Black and White…

arbscht

A Post Longwards Bound

February 7, 2008 on 5:42 am | In Contemplation | 2 Comments | arbscht

How easy is the task of creating a long post without making use of pronouns?

Not easy at all. Pronouns are like nuts and bolts in a large contraption — metaphorically, grammar. Very useful.

Especially confounding is the following fact: words can belong to multiple
parts of speech, being polymorphic. As a rule, no polymorphic pronouns are
used here. Just for fun.

Consequently, several natural idioms are precluded from use, severely
deforming the tone of the text, worsening as the length increases.

A programmer would relate, if given a similar rule: to not use local variables
in code. Lexical referencing is a powerful technique to have; otherwise
unnatural protracted constructs result.

Fortunately, however, not all referencing is lost without pronouns.
Adverbs can pick up the slack a little. For example, “here”, “thus”, etc are
helpful. Similarly with prepositions (strongly encouraging spatial thinking, for example: see below).

Perhaps circumventing the rules, as described above, makes the exercise too easy.
How about disallowing adverbs or prepositions too?

No wait. Sod that.

arbscht

Muffin Inefficiency

October 29, 2007 on 11:34 pm | In Kumara | 4 Comments | arbscht

Are muffins inefficient to eat? If so, how inefficient are they? If not, how efficient are they? Aren’t those quantities really the same thing? Can we describe it with a differential equation? Should I stop asking questions?

We seem to have a distinct split amongst the PLT1 populace over this issue. There are those who believe muffins are difficult to eat and those who believe they are easy to eat.

Difficult:

  • Entry requires consuming the edge first.
  • Then the cup must be peeled.
  • And then the remainder must be eaten cleanly.

Easy:

  • It really only involves biting skills above those of a 2-year old’s.
  • Bite the muffin, avoid the cup.

There we have it. But I’m sure discussion on this issue will not end with this half-baked post.

arbscht

I.T. helpdesk of the Middle Ages

February 18, 2007 on 4:10 pm | In YouTube | 1 Comment | arbscht

“Introducing the book” [youtube.com].

arbscht

Potentially the best

February 9, 2007 on 3:00 am | In News | 4 Comments | arbscht

game review [youtube.com] ever.

arbscht

Identify this spider

January 13, 2007 on 7:20 pm | In Kumara | 1 Comment | arbscht

Unknown spider

… and win nothing.

Next Page »

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^