Re: Trouble with dotrace

2012-10-03 Thread justinhj
Thanks for the info Luc

I'm fine with trace, that works for me.

Justin

On Tuesday, October 2, 2012 10:25:13 PM UTC-7, justinhj wrote:
>
> I'm trying to use dotrace from clojure.tools and having some trouble.
>
> Here's my leiningen project file 
>
> (defproject test1 "1.0.0-SNAPSHOT"
>   :description "test1"
>   :dependencies [[org.clojure/clojure "1.4.0"]
>]]
>   :dev-dependencies [
>  [swank-clojure "1.3.3"]
>  [org.clojure/tools.trace "0.7.3"]
>  ])
>
> When trying to use dotrace I get the exception below:
>
> user> (defn my-add [a b] (+ a b))
> user> (my-add 10 2)
> 12
> user> (clojure-version)
> "1.4.0"
> user> (my-add 10 2)
> 12
> user> (use 'clojure.tools.trace)
> user> (dotrace (my-add 10 2))
> ; Evaluation aborted.
>
> THROWS 
>
>   [Thrown class java.lang.ClassCastException]
>
> Restarts:
>  0: [QUIT] Quit to the SLIME top level
>
> Backtrace:
>   0: clojure.lang.Compiler$TheVarExpr$Parser.parse(Compiler.java:635)
>   1: clojure.lang.Compiler.analyzeSeq(Compiler.java:6455)
>   2: clojure.lang.Compiler.analyze(Compiler.java:6262)
>   3: clojure.lang.Compiler.analyze(Compiler.java:6223)
>   4: clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3548)
>   5: clojure.lang.Compiler.analyzeSeq(Compiler.java:6457)
>   6: clojure.lang.Compiler.analyze(Compiler.java:6262)
>   7: clojure.lang.Compiler.analyze(Compiler.java:6223)
>
> ; Evaluation aborted.
> user> 
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Trouble with dotrace

2012-10-03 Thread justinhj
I'm trying to use dotrace from clojure.tools and having some trouble.

Here's my leiningen project file 

(defproject test1 "1.0.0-SNAPSHOT"
  :description "test1"
  :dependencies [[org.clojure/clojure "1.4.0"]
   ]]
  :dev-dependencies [
 [swank-clojure "1.3.3"]
 [org.clojure/tools.trace "0.7.3"]
 ])

When trying to use dotrace I get the exception below:

user> (defn my-add [a b] (+ a b))
user> (my-add 10 2)
12
user> (clojure-version)
"1.4.0"
user> (my-add 10 2)
12
user> (use 'clojure.tools.trace)
user> (dotrace (my-add 10 2))
; Evaluation aborted.

THROWS 

  [Thrown class java.lang.ClassCastException]

Restarts:
 0: [QUIT] Quit to the SLIME top level

Backtrace:
  0: clojure.lang.Compiler$TheVarExpr$Parser.parse(Compiler.java:635)
  1: clojure.lang.Compiler.analyzeSeq(Compiler.java:6455)
  2: clojure.lang.Compiler.analyze(Compiler.java:6262)
  3: clojure.lang.Compiler.analyze(Compiler.java:6223)
  4: clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3548)
  5: clojure.lang.Compiler.analyzeSeq(Compiler.java:6457)
  6: clojure.lang.Compiler.analyze(Compiler.java:6262)
  7: clojure.lang.Compiler.analyze(Compiler.java:6223)

; Evaluation aborted.
user> 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Grabbing Rotten Tomatoes movie ratings in clojure

2011-04-27 Thread justinhj
> Neat project, have you looked into using their web service API
> (http://developer.rottentomatoes.com/) rather than scraping?

Hi

Yeah that is a good idea. The purpose of this project was that I was
finding my feet with Clojure and wanted to do something that retrieved
and parsed html pages.

Extending it to use the developer API looks like a fun next step which
I will probably do.

Justin

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Grabbing Rotten Tomatoes movie ratings in clojure

2011-04-26 Thread justinhj
An update on this little side project to grab movie ratings from popular a 
movie website:

I've add it to github and included the project file and updated the README

https://github.com/justinhj/movieratings

Also fixed it so it works with a recent change their page format. 

Justin


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Google AI contest

2011-04-05 Thread justinhj
Is anyone working on a Clojure getting started package for the next
Google AI contest?

See 
http://aerique.blogspot.com/2011/03/preparing-for-next-google-ai-challenge.html

Justin

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Grabbing Rotten Tomatoes movie ratings in clojure

2011-01-20 Thread justinhj
Interesting. Enliven looks way more concise for this sort of thing.

Justin

On Jan 20, 11:26 am, Anders Rune Jensen 
wrote:
> You might have a look at this code I wrote a while ago:
>
> https://mocomp.googlecode.com/hg/rotten-tomatoes.clj
>
> It's written using enlive :) I'm using google to search, sadly the
> google ajax api returns different results than "normal" google and
> they are not to keen on being hammered (fair warning ;-)).
>
> There is also one for imdb.
>
> https://mocomp.googlecode.com/hg/imdb.clj
>
>
>
>
>
>
>
>
>
> On Wed, Jan 19, 2011 at 11:58 PM, Mark Nutter  wrote:
> > Let me also recommend swannodette's excellent Enlive tutorial:
>
> >https://github.com/swannodette/enlive-tutorial
>
> > It's a great way to jump into the meat and potatoes.
>
> > m
>
> > On Tue, Jan 18, 2011 at 7:05 PM, justinhj  wrote:
> >> Thanks for the feedback Stuart
>
> >> I'll check out Enliven. I'm currently writing an app using Compojure,
> >> Ring and Hiccup, so it would fit nicely with that too by the sound of
> >> it.
>
> >> On Jan 16, 7:25 pm, Stuart Campbell  wrote:
> >>> Hi,
>
> >>> Have you used Enlive[1]? It's a nice tool for HTML scraping and 
> >>> templating -
> >>> it might be more robust than your regexp-based solution. It takes a bit of
> >>> learning, though.
>
> >>> Regards,
> >>> Stuart
>
> >>> [1]https://github.com/cgrand/enlive
>
> >>> On 16 January 2011 05:57, justinhj  wrote:
>
> >>> > Sharing my first useful Clojure program. Feedback welcome.
>
> >>> >http://bit.ly/clojure-rotten-tomatoes
>
> >>> >  --
> >>> > You received this message because you are subscribed to the Google
> >>> > Groups "Clojure" group.
> >>> > To post to this group, send email to clojure@googlegroups.com
> >>> > Note that posts from new members are moderated - please be patient with
> >>> > your first post.
> >>> > To unsubscribe from this group, send email to
> >>> > clojure+unsubscr...@googlegroups.com >>> >  >
> >>> > For more options, visit this group at
> >>> >http://groups.google.com/group/clojure?hl=en
>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Clojure" group.
> >> To post to this group, send email to clojure@googlegroups.com
> >> Note that posts from new members are moderated - please be patient with 
> >> your first post.
> >> To unsubscribe from this group, send email to
> >> clojure+unsubscr...@googlegroups.com
> >> For more options, visit this group at
> >>http://groups.google.com/group/clojure?hl=en
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en
>
> --
> Anders Rune Jensen
>
> http://www.iola.dk

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Grabbing Rotten Tomatoes movie ratings in clojure

2011-01-18 Thread justinhj
Thanks for the feedback Stuart

I'll check out Enliven. I'm currently writing an app using Compojure,
Ring and Hiccup, so it would fit nicely with that too by the sound of
it.


On Jan 16, 7:25 pm, Stuart Campbell  wrote:
> Hi,
>
> Have you used Enlive[1]? It's a nice tool for HTML scraping and templating -
> it might be more robust than your regexp-based solution. It takes a bit of
> learning, though.
>
> Regards,
> Stuart
>
> [1]https://github.com/cgrand/enlive
>
> On 16 January 2011 05:57, justinhj  wrote:
>
>
>
>
>
>
>
> > Sharing my first useful Clojure program. Feedback welcome.
>
> >http://bit.ly/clojure-rotten-tomatoes
>
> >  --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com > >
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Grabbing Rotten Tomatoes movie ratings in clojure

2011-01-15 Thread justinhj
Sharing my first useful Clojure program. Feedback welcome.

http://bit.ly/clojure-rotten-tomatoes



-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Entity component system

2011-01-09 Thread justinhj
Thanks for sharing.  I've also spent some time building a Common Lisp
game engine that uses a component architecture for the game objects.

For example in pong the player's paddle is made up of a visual,
physical and logical components.

(defun make-pong-player(side human sprite-def control-type name)
  (let ((phys (make-instance '2d-physics
 :collide-type 'paddle :y *paddle-start-y* :width 
*paddle-
width* :height *paddle-height*))
;   (anim (make-instance 'animated-sprite :sprite-def sprite-def
;:current-frame 'frame-1 :speed 5.0))
(visual (make-instance 'rectangle
  :w *paddle-width* :h *paddle-height*))
(pong (make-instance 'player-paddle-logic
 :control-type control-type :side side))
(obj (make-instance 'composite-object :name name)))
(add-component obj phys)
(add-component obj visual)
;(add-component obj anim)
(add-component obj pong)
obj))

The objects implement message handlers in order to operate. For
example the game engine sends update and draw messages. Users can
write their own message types with custom argument lists.

I've put the project on google code http://code.google.com/p/lisp-game-engine/

Although the pong game works I wouldn't consider this a finished
project by any means; it's more an experiment in game programming
using CL and the REPL.

It would require significant refactoring to make it work with Clojure
since I use mutable state a lot, but would certainly be possible.

Justin

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: printf output from threads

2010-12-28 Thread justinhj
On Dec 27, 10:59 pm, Alex Osborne  wrote:
> justinhj  writes:
> > On Dec 26, 11:42 pm, Alex Osborne  wrote:
> > (defn test-threads [n out]
> >   (dotimes [x n]
> >     (.start (Thread. (#(sleeper-thread %1 %2 %3) out x (+ 2000 (rand-
> > int 5000)))
>
> Ah.  The problem is here.  You're calling that lambda in the main thread
> and then passing the return value of sleeper-thread to (Thread.) (which
> doesn't make much sense).
>
> Try this:
>
> (defn test-threads [n out]
>   (dotimes [x n]
>     (.start (Thread. #(sleeper-thread out x (+ 2000 (rand-int 5000)))
>
> Or even:
>
> (defn test-threads [n out]
>   (dotimes [x n]
>     (future (sleeper-thread out x (+ 2000 (rand-int 5000))
>
> Or forgetting about passing the out argument around:
>
> (defn test-threads [n]
>   (dotimes [x n]
>     (let [out *out*]
>       (future
>         (binding [*out* out]
>           (sleeper-thread x (+ 2000 (rand-int 5000))
>
> You could turn that into a macro:
>
> (defmacro future-with-out [& body]
>   `(let [out# *out*]
>      (future (binding [*out* out#] ~...@body)))
>
> And then use it like:
>
> (defn test-threads [n]
>   (dotimes [x n]
>     (future-with-out (sleeper-thread x (+ 2000 (rand-int 5000))

Thanks Alex, I'm still struggling a bit with the different syntax
between Clojure and Common Lisp, but I made your first change and it
works now.

Justin

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: printf output from threads

2010-12-27 Thread justinhj
On Dec 26, 11:42 pm, Alex Osborne  wrote:
> justinhj  writes:
> > I tried passing *out* to my thread function and then binding it to
> > *out* in the thread, and this works but then makes the threads execute
> > one at a time, and I'm presuming that is because my use of *out* in
> > the binding block is blocking for the other threads which use it.
>
> That doesn't sound right: binding itself never blocks.  Can you post
> some example code where you see this behaviour?
>
> As I understand it binding conveyance should happen automatically in the
> upcoming 1.3 release (for futures and agents) but in 1.2 you can use
> bound-fn, or for better performance use binding explicitly as you
> suggested.
>
>     (future-call (bound-fn [] (println "log...")))
>
>     (send some-agent (bound-fn [x] (println "log...") (inc x)))

This is the code I've written so far

(defn sleeper-thread [out id t]
  "Sleep for time T ms"
  (binding [*out* out]
(printf "%d sleeping for time %d\n" id t)
(Thread/sleep t)
(printf "%d slept\n" id)))

(defn test-threads [n out]
  (dotimes [x n]
(.start (Thread. (#(sleeper-thread %1 %2 %3) out x (+ 2000 (rand-
int 5000)))

And the output is

0 sleeping for time 5480
0 slept
1 sleeping for time 6739
1 slept
2 sleeping for time 5444
2 slept
3 sleeping for time 3087
3 slept
4 sleeping for time 6753
4 slept
5 sleeping for time 3489
5 slept
6 sleeping for time 5864
6 slept
7 sleeping for time 5523
7 slept
8 sleeping for time 5659
8 slept
9 sleeping for time 5052
9 slept

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


printf output from threads

2010-12-26 Thread justinhj
What do people use for logging debug output from threads? Either
native threads created with Thread. or implicit threads via agents or
pmap etc?

I tried passing *out* to my thread function and then binding it to
*out* in the thread, and this works but then makes the threads execute
one at a time, and I'm presuming that is because my use of *out* in
the binding block is blocking for the other threads which use it.

Justin

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en