2008-06-21
| 06:34 | Lau_of_DK | Hey guys |
| 10:04 | Lau_of_DK | Anybody here familiar with a good Java FTP lib ? |
| 10:13 | Lau_of_DK | I'm going with sun.net.ftp.FtpClient - If anybody is aware of a better alternative for simple up/downloads, then let me know |
| 12:38 | blackdog | rhickey, something that may interest you http://www.malhar.net/sriram/kilim/ |
| 13:32 | Lau_of_DK | blackdog, that looks pretty sweet - its supposed to outperform Javas native threading? |
| 13:35 | blackdog | didn't really look into it , but i listened to rhickey concurrency video recently where he was asked about such things |
| 13:39 | Lau_of_DK | One thing that I was a little onsure of, is that are we supposed to used threading via send-off and such, or is it nessacary to get comfortable with Java Thread. lib ? |
| 13:39 | rhickey | blackdog: saw that, thanks |
| 13:59 | Lau_of_DK | IO Writers seem to default to writing in the home directory on Linux - Is there a global I can use to redirect to the folder the .clj file is executed from that will work on mac/win/nix ? |
| 14:01 | blackdog | (defn getCwd |
| 14:01 | blackdog | "get current working directory" |
| 14:01 | blackdog | [] (. System getProperty "user.dir")) |
| 14:01 | blackdog | that's where the program is started in |
| 14:02 | blackdog | i move myself into my app dir first before firing up java |
| 14:03 | blackdog | or you could do an explicit (. System getenv key)) and get a working dir from an environement variable |
| 14:03 | blackdog | there may be other ways |
| 14:04 | Lau_of_DK | Thanks blackdog, good tips :) |
| 14:05 | blackdog | yw |
| 15:04 | Lau_of_DK | rhickey: Generally for starting single worker threads, it send-off the best way to go about it ? |
| 15:05 | rhickey | if the threads don't block, send is better than send-off |
| 15:05 | Lau_of_DK | ok - They dont. So there's really no reason to start using all of Javas .Thread functions for this type of job? |
| 15:06 | rhickey | no, agents wrap all of that |
| 15:06 | Lau_of_DK | sweet - Thanks |
| 15:21 | Lau_of_DK | I've got a question about the primitive support |
| 15:22 | Lau_of_DK | byte[] a = new byte[1024] |
| 15:22 | Lau_of_DK | (make-array byte 10240) |
| 15:22 | Lau_of_DK | Thats how I would have imagined the port, but it throws a class erorr |
| 15:22 | Lau_of_DK | error |
| 15:22 | Lau_of_DK | why ? |
| 15:24 | rhickey | the class corresponding to byte is Byte.TYPE |
| 15:25 | Lau_of_DK | Ok thats works. If I didnt have you to ask - Where would I find this info? I read through the Java-Interop section of Clojure.com |
| 15:49 | Lau_of_DK | rhickey: Ok thats works. If I didnt have you to ask - Where would I find this info? I read through the Java-Interop section of Clojure.com |
| 16:49 | lisppaste8 | Lau_of_DK pasted "FtpUpload Corruption" at http://paste.lisp.org/display/62622 |
| 16:50 | Lau_of_DK | Gents - This function (upload-file) sorta works. It tries to upload the file, it uploads the correct amount of bytes, but the data is throughly corrupted. Any input is very welcomed! :) |
| 16:51 | Chouser_ | are you uploading a binary file? you might trying using binary mode. |
| 16:53 | Lau_of_DK | hehe |
| 16:53 | Lau_of_DK | gimme 1 sec |
| 16:58 | Lau_of_DK | Chouser: Im sure you're right, it has to do with switching to binary, unfortunately this old sun lib is causing alot of trouble, so now Im getting array out of bounds error, will take some time to sort out |
| 16:58 | Lau_of_DK | but thanks for lending me your sharp eyes |
| 17:07 | Chouser_ | so if I were, hypothetically, compiling Clojure to JavaScript, what would a quoted symbol look like? Would I need a new class Symbol? |
| 17:07 | lisppaste8 | Lau_of_DK annotated #62622 with "Clojure bug?" at http://paste.lisp.org/display/62622#1 |
| 17:08 | Lau_of_DK | Ok, I'd say that the upload procedure is pretty textbook, switching to binary throws index out of bounds exception - is this a clojure bug? |
| 17:08 | Lau_of_DK | (def bytes (. in read buffer)) & (. out write buffer 0 bytes), shouldnt produce this error unless either read or write was failing ? |
| 17:12 | Chouser_ | when will that loop terminate? |
| 17:12 | Lau_of_DK | the the reader returns a negative value |
| 17:12 | Lau_of_DK | EOF = -1 |
| 17:12 | Chouser_ | which you then add to counter, right? |
| 17:13 | Lau_of_DK | 1 sec |
| 17:13 | Lau_of_DK | it was supposed to say "bytes" |
| 17:14 | Lau_of_DK | ok, except for a picture quality issue, the upload is working now |
| 17:14 | Lau_of_DK | Sorry about the level of stupidity introduced here tonight :) |
| 17:15 | Chouser_ | no need to be ashamed of bugs in your code. We all write bugs. |
| 17:15 | Chouser_ | In any given example, though, the chances of the bug being in clojure are pretty low. |
| 17:15 | Lau_of_DK | Why ? |
| 17:16 | Chouser_ | because there are lots of people beating on clojure from lots of different angles, compared to how many people have been beating on any one example any of us may come up with. |
| 17:17 | Lau_of_DK | Sure - I looked through the Googlegroups and I wondered how the guys who posted Clojure bugs (that Rich ended up fixing) could be so confident that it was bugs, so I figured - I'll act confident :) |
| 17:17 | Chouser_ | heh. well, that's one approach... |
| 17:18 | Lau_of_DK | which I'll change, but anyway, I've actually made a small image manipulation program now, that uploads the resulting files on an ftp server, thats progress |
| 17:22 | Chouser_ | cool! |
| 17:24 | Chouser_ | If you think you've found a bug in Clojure, but you want to be sure, just try to isolate it yourself -- try to track down the simplest thing that will trigger the bug. You'll either produce a nice compact bug report for Rich to look at, or find the bug in your own code. |
| 17:24 | Chouser_ | I generally end up with the latter result. :-) |
| 17:24 | Lau_of_DK | Thats definately the way to go - And I need some practice on isolating stuff |
| 22:02 | jcrites | hey |
| 22:03 | jcrites | how do I call a static function? |
| 22:03 | jcrites | I tried... |
| 22:03 | jcrites | (. java.net.InetAddress getAllByName "localhost") |
| 22:03 | jcrites | oh! |
| 22:03 | jcrites | I got it. |
| 22:03 | jcrites | (. java.net.InetAddress (getAllByName "localhost")) |
| 22:07 | dudleyf | jcrites: or |
| 22:07 | dudleyf | (.getAllByName java.net.InetAdress "localhost") |
| 22:07 | jcrites | how can I print out the type contained in some Var? |
| 22:08 | jcrites | I'm trying to figure out how to process the result of that function call but don't know quite what type it is ;-) |
| 22:09 | dudleyf | (.getClass varname) |
| 22:09 | dudleyf | But, that call returns a Java array |
| 22:10 | jcrites | well an array has a class doesn't it ? :-( |
| 22:10 | jcrites | hmmm |
| 22:10 | jcrites | something isn't working right ? |
| 22:11 | jcrites | I did this: |
| 22:11 | jcrites | (def a (. java.net.InetAddress (getAllByName "localhost")) ) |
| 22:11 | jcrites | now I'm trying: |
| 22:11 | jcrites | (. a toString) or (.toString a) |
| 22:11 | jcrites | I don't expect it to return a useful value, but I'm getting an error saying: |
| 22:11 | jcrites | Unable to resolve symbol toString in this context |
| 22:12 | jcrites | hmmm, maybe Java arrays actually aren't Object.... |
| 22:12 | dudleyf | I get "[Ljava.net.InetAddress;@1bbbafc" |
| 22:12 | dudleyf | Which is what I would expect |
| 22:13 | dudleyf | You can use (vec a) to get a Clojure vector from that array |
| 22:13 | jcrites | user=> (def a (. java.net.InetAddress (getAllByName "localhost")) ) #<Var: user/a> |
| 22:13 | jcrites | user=> (.toString a) java.lang.Exception: Unable to resolve symbol: .toString in this context clojure.lang.Compiler$CompilerException: NO_SOURCE_FILE:13: Unable to resolve symbol: .toString in this context |
| 22:13 | jcrites | am I doing something wrong? |
| 22:13 | jcrites | ohhh |
| 22:13 | jcrites | vec is definitely in a later version than I am using |
| 22:14 | jcrites | maybe I just need to upgrade? |
| 22:14 | dudleyf | Definitely |
| 22:15 | dudleyf | You may have a version before the (.javaMethod) syntax was legal |
| 22:16 | jcrites | but (. a toString) should still work? |
| 22:16 | jcrites | no matching field found: toString |
| 22:16 | jcrites | I will just upgrade; no use spending time debugging this before doing that |
| 22:16 | dudleyf | Absolutely right. |
| 22:21 | jcrites | interesting |
| 22:21 | jcrites | does def do something different in the new version? |
| 22:21 | jcrites | now it says #'user/a rather than something about var |
| 22:21 | jcrites | hey, is there a page describing Clojure shorthand syntax? |
| 22:21 | jcrites | I remember someone showing me a shortcut fn syntax |
| 22:24 | dudleyf | jcrites: http://clojure.org/reader |
| 22:25 | dudleyf | And I think Vars just print differently |
| 22:25 | jcrites | ah ok :-) thanks for your help! |
| 22:26 | dudleyf | jcrites: anytime |
| 22:28 | jcrites | (#(+ %1 %2) 1 2) |
| 22:28 | jcrites | 3 |
| 22:28 | jcrites | I love Clojure :D |
| 22:28 | jcrites | such short nice syntax, such library elegance |