Re: Simple things should be simple

2010-09-10 Thread brianh
Just to be contrary ;)

A one time investment of 2 minutes (I did have to scrounge in contrib
to locate these after all):

(defn make-stupid-simple-script [f content]
  (spit f content)
  (sh chmod 755 (.getName f)))

for the eternal pleasure of using:

user= (make-stupid-simple-script (File. /usr/local/www/apache22/cgi-
bin/hello-world.sh) #!/bin/sh\n
echo 'Content-type: text/plain\\n'
echo Hello World)

Feel free to take this and run with it :)

On Sep 9, 9:47 am, Mike Meyer mwm-keyword-googlegroups.
620...@mired.org wrote:
 On Thu, 9 Sep 2010 16:28:48 +0100

 Edmund Jackson edmundsjack...@gmail.com wrote:
  Hi Mike,

      Could you perhaps present a counter-example of greater simplicity ?

 $ cat -  /usr/local/www/apache22/cgi-bin/hello-world.sh
 #!/bin/sh

 echo 'Content-type: text/plain\n'
 echo Hello World
 ^D
 $ chomd 755 /usr/local/www/apache22/cgi-bin/hello-world.sh

 Done. Three lines of source code. 0 lines of framework setup. 1 tool
 (sh). Pretty much the same thing works for python, perl, etc.  It's
 about as robust as can be asked for - that's the nature of
 apache. Performance is going to be mediocre at best. That's the
 trade-off for simplicity.

       mike
 --
 Mike Meyer m...@mired.org          http://www.mired.org/consulting.html
 Independent Network/Unix/Perforce consultant, email for more information.

 O ascii ribbon campaign - stop html mail -www.asciiribbon.org

-- 
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: update-in! (?)

2010-01-20 Thread brianh
Any chance you could rethink your approach  use a zipper?

On Jan 20, 9:32 am, Gabi bugspy...@gmail.com wrote:
 I posted a question on SO about it. Interesting 
 discussion:http://stackoverflow.com/questions/2102606/algorithm-to-implement-non...

 On Jan 20, 5:39 pm, Christophe Grand christo...@cgrand.net wrote:



  I concur: a map (or a sorted map if you need to emulate access to a
  subtree) can be an option.

  [[1 2] [3 4]] is represented by {[0 0] 1, [0 1] 2, [1 0] 3, [1 1] 4}

  On Wed, Jan 20, 2010 at 4:24 PM, Sean Devlin francoisdev...@gmail.com 
  wrote:
   How about a sorted set w/ a custom comparator?  Of course, this rules
   out transients, but maybe the flatness will make up for it?

   On Jan 20, 10:15 am, Gabi bugspy...@gmail.com wrote:
   I need to add/delete much more frequently than just updating
   actually.

   On Jan 20, 4:59 pm, Sean Devlin francoisdev...@gmail.com wrote:

Gabi,
A similar technique is used with sparse matrices.  You usually have
severals arrays, one for the non-zero elements, and another one for
indexing the column and a third for indexing the rows.

   http://pasadena.wr.usgs.gov/office/baagaard/research/papers/thesis/fi...

This should be fast as long as you're only updating.  If you're
inserting/deleting, you might be able to get away with using a
collection of 1D trees.

Sean

On Jan 20, 9:18 am, Gabi bugspy...@gmail.com wrote:

 These vectors represent trees which need to updated very frequently.
 So If there was an efficient way to use transients to represent
 transient trees the whole process would be much more efficient (so
 each update to a tree would be done in place instead of creating new
 one.) As discussed above, naive usage of transients won't help.
 Another approach would be implement in Java, but I wish there would
 some way to achieve this directly from Clojure.
 Now that I think about it, maybe the solution is to represent the 
 tree
 as one dimensional vector instead of nested one (any good clojure
 algorithm for this ? Representing and traversing non binary trees as
 one dimensional vector?)

 Jan 20, 12:53 pm, Christophe Grand christo...@cgrand.net wrote:

  Hi Gabi!

  Can you tell us more about your problem, what do those deeply 
  nested
  vectors represent and how are you going to update them? (are all
  updates batched in one part of your program?)

  With transients current implementation you can't write an 
  efficient update-in!

  Christophe

  On Wed, Jan 20, 2010 at 9:15 AM, Gabi bugspy...@gmail.com wrote:
   Guys, I really need your expertise here.
   I have lots of deeply nested vectors, which i need to manipulate
   frequently (thousands of times)
   What is the most effective way to do this ?

   On Jan 17, 4:27 pm, Gabi bugspy...@gmail.com wrote:
   Right. I thought that transient performing deep 
   'transientivity'.
   Here is a fixed version. It takes a regular coll converts 
   whatever it
   can to transient and update the stuff.
   The problem is that doing persistent!(assoc!(transient m)) on 
   each
   level probably misses the whole point of performance.
   So while it work, it probably slower than the regular update-in.
   I need a better solution.

   (defn update-in!!
     modified version of core/update-in that works on, and return
   transiants
     ([m [k  ks] f  args]
      (if ks
        (persistent!(assoc! (transient m) k (apply update-in!! 
   (get m k)
   ks f args)))
        (persistent!(assoc! (transient m) k (apply f (get m k) 
   args))

   On Jan 17, 3:57 pm, Chouser chou...@gmail.com wrote:

On Sun, Jan 17, 2010 at 8:25 AM, Gabi bugspy...@gmail.com 
wrote:

 user= (persistent!(update-in!(transient v) [0] reverse))

 Forgot to mention that v in the example is defined to  [[1 
 2] [3 4]]

So you've got a transient vector of persistent vectors of
numbers.  The problem is your update-in! then calls assoc! on
each level, but of course assoc! on the inner persistent 
vector
fails.

You either need to make the inner vectors transient (and then
call persist! on them when you're done) or use assoc! only at 
the
outer level.

--Chouserhttp://joyofclojure.com/

   --
   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: javafx

2009-06-23 Thread brianh

In case you haven't seen it, there is a java api to JavaFX called
Scene Graph that's been around for some time now: 
https://scenegraph.dev.java.net/faq.html

I've been monitoring it for some time now as a potential replacement
for Piccolo2D.  I last played with it several months ago and it was
doing a terrible job of culling the scene graph compared to the same
setup/scenario in Piccolo2D.  Unfortunately, even now, it seems very
immature and appears to be fairly dormant as well.  So... I'd say it's
probably a dead end but you can investigate  decide for yourself ;)

-Brian

On Jun 22, 1:45 pm, Rob rob.nikan...@gmail.com wrote:
 On Jun 21, 11:02 pm, Pinocchio cchino...@gmail.com wrote:

  CuppoJava wrote:
   I'm still not very clear about what JavaFX actually is and what's its
   relation to Java. Do you know of any links that explain it clearly?

  Its basically a way of declaring Swing GUI items and their layout. One
  of its cool features is that it allows binding
  code to changes in declared items, making it a reactive, event based
  system for handling GUIs. I have not used
  it though...
  Interop with Clojure is definitely an interesting intellectual exercise.

 Sorry, but I'd like to correct the record here. :)  It's not Swing --
 it's a completely new GUI toolkit.  And interop with Clojure may
 necessary if you want to use Clojure to write web apps with video or
 animations in the near future.  Some animations are eye candy, but
 when they are done right they can make a better UI.

 Rob

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---