Slashdot Mirror


User: KwaiChangLee

KwaiChangLee's activity in the archive.

Stories
0
Comments
7
First seen
Last seen
Profile
(view on slashdot.org)

Comments · 7

  1. Heh - 13 lines, take that Python! on P2P In 15 Lines of Code · · Score: 0

    It feels good to layeth the coding smack down. :D

  2. I wrote a Java version of this a while back... on P2P In 15 Lines of Code · · Score: 0

    I needed to move some data off some IBM hardware that was falling apart (literally) onto my new eMac. For various reasons I couldn't just connect a cable between them. So I connected the laptop to my old dialup isp (in another state) and the eMac I had on ADSL. In total I moved about a gig of data with it.

    Don't be too impressed with the Perl version, its actually 42 lines long, but then condensed down to 9 lines through the power of removing whitespace and line breaks.

    Also, from the sounds of it, the Java version beats the living sh!t out of the Perl version as far as performance goes. :D Booyah!

    So here's my Java version (of the mac client, the serversocket was trivial). I don't think this was the final version, so it might have some bugs, but its close. For comparison it would be about 17 lines of code by the way those guys are counting. Total characters with whitespace (but not linebreaks) removed: 1248. It could be made even smaller if I wanted to, eg choosing one letter variable names, not being in a package... you know the drill. I removed the comments to get a better idea of the number of characters.

    package rick.network; import java.io.*; import java.net.*; public class DocPuller { public static String baseDir = "//users//******//laptop//"; public static String laptopAddress = "203.221.67.2"; public static int docsock = 1234; public DocPuller(String fileName) { try { File f = new File(baseDir + fileName); Socket sock = new Socket(laptopAddress, docsock); sock.getOutputStream().write((fileName + "\n").getBytes()); readFile(sock, f); } catch (Exception e) { System.out.println("oops: " + e); } } public static void main(String[] args) { try { if (args.length == 0) { System.out.println("Address: " + InetAddress.getLocalHost()); return; } } catch (Exception e) { System.out.println("oops: " + e); } DocPuller dp = new DocPuller(args[0]); } public void readFile(Socket sock, File f) { try { FileOutputStream fos = new FileOutputStream(f, true); byte[] ba = new byte[100000]; BufferedInputStream bufin = new BufferedInputStream(sock.getInputStream()); int n = 0; n = bufin.read(ba); while (n == ba.length) { fos.write(ba); fos.flush(); n = bufin.read(ba); } if (n > 0) { fos.write(ba, 0, n); fos.flush(); } fos.flush(); fos.close(); } catch (Exception e) { System.out.println("problem while reading/writing file: " + e); } } }

  3. Re:bab5 on Babylon 5 Movie Starts Filming in April · · Score: 0

    A lot of my friends at Uni were heavily into a sci-fi club where they'd get episodes sent over from the states. They used to go on and on and on about how much better B5 was than Star Trek.
    Fast forward a couple of years. I'd been overseas and when I came back they weren't talking about B5 anymore. I thought that was unusual, since they used to rave about it all the time, and I knew season five was just winding down.
    I was confused, so I asked them about it, and all they'd say was things like "there is no season four or five" and "but there were only three seasons". Since this obviously clashed with reality I kept hounding them, wanting to know what had happened. so they showed me some season 3 episodes.
    I was really starting to get into it... massive impending galaxy ripping apart war... cooool cgi... So I'm like 'what happens?, what happens?'. And they said, "you don't want to know what happens, just remember it as it is now". But I kept hounding them, and eventually they caved in and showed me the end of the season (or at least, the episode where the Shadow-Vorlon war (or, as they refer to it, the 'Shadow-Vorlon pillowfight') is resolved.
    Worst freaking ending.
    Ever.
    Of anything.
    JMS isn't a genius, he's a moron!!!

  4. Re:Unsupported method exception on Stress Found to Accelerate Chromosome Aging · · Score: 0

    It could have been worse... it could have been *Struts*. (shudder)

  5. Re:Blacksmith on What Do People in the IT Field Do for Side Jobs? · · Score: 0

    See now, that was almost believable. I'd have believed you if you'd said you were a Linux admin, because installing Linux* is the closest I ever got to S&M. It was such a painful and frustrating experience, that when I finally rm -rf ed that #$@$^$%#&$^#, it felt so good. So good, in fact, that I reinstalled it, just so I would have the pleasure of blowing it away again. *A recent version. And no, no it hasn't, and no, it doesn't, except in rare cases, and even uber geeks report the same problems I had.

  6. Re:You didn't get it at all... on Linux 'Awfully Cathedral-Like' - Java's a Bazaar · · Score: 1

    You didn't get it either. Cathedral and the Bazaar is NOT about architecture, it is about *culture*. It is about having a culture of a priesthood (exclusive), or a culture of a marketplace (inclusive). ESR of course argues that Linux and other OS is the bazaar, and MS and other proprietary software is the Cathedral.

  7. Re:Such a huge performance improvement... on NZX Moves To Oracle On Linux · · Score: 1

    You sir, are an idiot, speaking of things which you know nothing. .... oh, hang on, this is Slashdot ... Never mind. I *have* been into the IT department of the NZSE (as it was called until recently). These guys know their stuff. The guy that most everyone I know go to to get their info on Linux (runs gentoo before anyone else has heard of it, on the bleeding edge etc, gets his info from one of the guys at the NZSE. I was sitting there one day listening to them talk BS about versioning file systems (in this case Reiser), and I thought 'okay, here's where Mr Cutting Edge lays the techno smack down, but MR NSX took everything he had and then handed him his techno arse'. Very impressive. Of course, other than who won, I have no idea what they were saying, they are so far out of my league. ----- Now, if you want *utterly incompetent* IT at a stock exchange, you have to look no further than the ASX. If they hand you an html table with data points in it, every single cell will have its own font tag... and they're all the same font!!! The HTML they hand around is about 20x larger than it needs to be, and the level of information they provide is much much less than the NZX. You could, for instance, run a Graham and Dodds style fund straight off the info you get from the NZX, at about one page view per company you're tracking, but the information required for that isn't even available on the ASX. Hell, the ASX doesn't even have a decent *index* of its companies for crying out loud!!! And their crappy rollovers don't work on my non-ie browser, so I can't even access most of their site!! (most of it was useless anyhow). For Ghu's sake, their (online) conditions of use state that you can't even download pages from their site, or store them on a computer.... how fscked up is that??? NZX vs ASX is a classic example of good web design vs god awful web design.