Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
User Journal

Journal Journal: Jiu-jitsu Lessons for Life 2

On a whim, I decided to enter the no-gi Kumite Classic this past weekend. I learned several valuable life lessons there:

  1. By not eating, you can lose up to 3.5 pounds in a day.
  2. It pays to be punctual; the line gets long quickly.
  3. Overestimating your enemy is just as bad as overestimating yourself.
  4. The best don't talk too much. Ironically I shouldn't be posting in my journal then.
  5. It hurts to lose, even when it was expected. It hurts alot.

So I lost my first and only match of the day after about 1.5-2 minutes. Hey, I couldn't tell the time - too busy grappling. That embarassment will fuel me for next year.

PS: I have four moderator points to use today. What are some interesting stories to apply my god-like powers of approval?

User Journal

Journal Journal: Kevin Rose, I'm sorry!

Kevin Rose, if you are reading, I'm really sorry for not using caches of your sites. I never realized how bad the /. effect could be until now. I apologize for being so rude.

User Journal

Journal Journal: First Real Fight (we're #4?)

For the last several weeks, I've been learning to grapple at the CMU grappling club. Well, I won my first real fight at the Cinco de Mayo Round Robin. What everyone at the club called fights were basically what I (former wrestler) call matches, since there was no striking allowed. But "fights" sounds more badass. :-P Now I just got to win twice next time.... ;-)

User Journal

Journal Journal: Interesting Google Calculator Problems (updated) 3

Updated: see bottom of post.

I should know this, but I forgot. I asked google for the mass of hydrogen, and it told me the answer is 1.00794 amu according to this web page. Then I asked google to compute the mass of proton + mass of electron in amu, which it says is 1.00782549 atomic mass units. Where did the extra .00121167351 amu (2.01202991 * 10^-30 kg) mass come from? The binding energy of hydrogen?

P.S. I got moderator points again, even though I didn't metamoderate since my last journal entry. /. want's me to waste time, doesn't she? ;-)

Update:

Thanks for the suggestions: they were very insightful. According to the Wikipeida, deuterium exists in .015% of natural hydrogen, while the rest don't have a large enough lifetime to affect the natural abundance ratios. I had Google calculate (1-.00015) * (proton mass + electron mass) + .00015 * (1.009132 amu + proton mass + electron mass) in amu (odd that Google doesn't have the neutron mass in the calculator). I could have calculated proton mass + electron mass + .00015 * 1.009132 amu in amu for the same result.

Now Google thinks the mass of naturally occuring hydrogen is 1.00797686 amu. Where did the extra .00004 amu in Google's calculation come from? That's about 2.5 times the binding energy (13.6 keV), so I don't think that accounts for it. Puzzling, I think. It has been too long since chemistry class. ;-)

User Journal

Journal Journal: 99% Is Not Enough 1

I was reading about levels of indirection, via Logan, when it dawned on me that 99% is not good enough. Say you're architecture can handle 99% of whatever you throw at it without any bug showing up. Then we build a level abstracting it that can handle 99% of the cases it uses. Well, now the overall stability is 98% (.99^2). If the seven networking layers each worked correctly in 99% of the cass, then the overall stability would be 93%. That is a significant difference, and could really slow down the network's speed. So 99% is not enough; who would have guessed? (I didn't!)

User Journal

Journal Journal: Why were these modded as overrated? 5

Why were these two posts moderated overrated? The first one wasn't moderated until well after the story. The other was posted in btlzu2's journal. Why anyone would moderate those entries is beyond me. Why they are overrated doubly so. I need answers! The posts:

P.S. I have received moderation power twice in the last week, and more times in the last two months than the previous year! I don't like moderating stories about subjects that I am not an expert at, so it is a little wasteful. (Of course - dear /. deities - once a month is fine with me.) What's up with that?

User Journal

Journal Journal: In progress: Writing a Blogging Client

Danny says that Tim Bray reviewed several Blogging Clients. What a coincidence! I happen to be working on one too. Then again, isn't everybody? ;-)

Seriously though, writing blogging clients is fun. I am working on a program to post atom entiries to blogger.com. It was a beeotch to set up, so a word of advice (the purpose of this comment). Blogger.com uses basic HTTP authentication, so when you send your http headers, don't bother with WWSE. That means, if you use this excellent example, then replace:

.addRequestProperty("X-WSSE", getWSSEHeader(username, password))

with...

.addRequestProperty("Authorization", "Basic " + base64Encode((username + ":" + password).getBytes()));

BTW, there are a few other tricks needed to get that example posting instead of getting. I'll leave that an exercise to the replier. ;-)

Programming

Journal Journal: Howto: write zip files 2

I wanted to zip a data file with a vbs wsh file. However, there isn't a good way to do it without purchasing an overpowered zip program or popping a command window. So I wrote a little java utility that zips files. I'm dedicating it into the public domain, and suggestions are welcome.  Please ignore any /. typos in the code below, and please give credit if used in your program (although that is not a requirement).

import java.util.zip.ZipOutputStream;
import java.util.zip.ZipEntry;
import java.io.FileInputStream;
import java.io.File;
import java.io.IOException;

/**
* Facade around Java's zip classes to make it easier to create zip files.
* Based on
* <a href="http://javaalmanac.com/egs/java.util.zip/CreateZip.html">an
* example</a> from the Java Developer's Almanac 1.4.
* @author  James Francis Cerra
* @version 0.2
* @see     java.util.zip
*/
public class Zip {
/**
  * Writes the file arguments to a zip file and then the standard output.
  * <h2>Usage:</h2>
  * <p class="note">From a command line:</p>
  * <dl>
  *   <dt>To zip <code>filename</code> to <code>out.zip</code></dt>
  *   <dd><code>java Zip filename > out.zip</code></dd>
  *   <dt>To zip directory <code>dirname</code> to <code>out.zip</code></dt>
  *   <dd><code>java Zip dirname > out.zip</code></dd>
  *   <dt>To zip file <code>f1</code>, <code>f2</code>, and <code>f3</code>
  *       to <code>out.zip</code></dt>
  *   <dd><code>java Zip f1 f2 f3 > out.zip</code></dd>
  *   <dt>To zip file <code>f1</code>, <code>f2</code>, and <code>f3</code>
  *       and the directories <code>d1</code>, <code>d2</code>, and
  *       <code>d3</code> to <code>out.zip</code></dt>
  *   <dd><code>java Zip f1 f2 f3 d1 d2 d3 > out.zip</code></dd>
  *  </dl>
  *  <p class="note">Remember: on some systems you may need to put quotes
  *                  around long file or directory paths.  Relative paths
  *                  should also work too.</p>
  *
  * @param args array of file or directory name strings to zip.
  */
  public static void main(String[] args) throws IOException {
    ZipOutputStream out = new ZipOutputStream(System.out);
    writeFiles(out, args);
    out.close();
  }

/** Writes files built from an array of filenames to a zip output stream. */
  public static void writeFiles(ZipOutputStream out, String[] filenames)
  throws IOException {
    int numberOfFiles = filenames.length;
    for(int ii=0; ii < numberOfFiles; ii++) {
      writeFile(out, new File(filenames[ii]));
    }
  }

/** Writes an array of File arguments to a zip output stream. */
  public static void writeFiles(ZipOutputStream out, File[] files)
  throws IOException {
    int numberOfFiles = files.length;
    for(int ii=0; ii < numberOfFiles; ii++) {
      writeFile(out, files[ii]);
    }
  }

/** Writes a single File to a zip output stream. */
  public static void writeFile(ZipOutputStream out, File file)
  throws IOException {
    if(file.isDirectory())  writeFiles(out, file.listFiles());
    else if(file.canRead()) writeReadableFile(out, file);
    else throw new IOException(
      "Can't write to zip since" +
      file.toString() +
      "is not a directory nor readable."
    );
  }

/** Writes a single readable File to a zip output stream. */
  private static void writeReadableFile(ZipOutputStream out, File file)
  throws IOException {
    FileInputStream in = new FileInputStream(file);
    out.putNextEntry(new ZipEntry(file.getPath()));
    int len;
    byte[] buf = new byte[1024];
    while ((len = in.read(buf)) > 0) out.write(buf, 0, len);
    out.closeEntry();
    in.close();
  }
}
User Journal

Journal Journal: Rant: Not all Nerds were beat up + Stallman anecdote

Every time I read a story or ranking about education on /. somebody starts a flame about the American educational system. Then someone eventually makes the comment that Americans do poorly in math/science because society looks down on them. This wasn't my experience growing up.

For example, this poster said that "if a kid loves math, chess or generally science, (he/she) is branded as a nerd or freak and subject to the heavy beating by the other kids." While growing up, I loved math, chess, and science in general among other things. However, I never experienced the "heavy beatings" he suggests I would have. In fact, I only really encountered the stigma he suggests in sixth grade, when a bully decided to throw my books out the window at a bus, among other assorted little things. I was never in a fight, and I was hardly ever lonely during recess with the other "nerds".

In fact in high school, I joined the wrestling team and because a student athletic trainer. Some football players looked down on me, but most didn't. In other sports, everyone was generally nice. None of the wrestlers called me names or treated me badly either. Sure there were a few minor exceptions when I started each, but I deserved that embarassment for not thinking before I spoke. Overall, both experiences were among the best of my life.

As a side note: Stallman publically criticised a nervous nerd, who was asking him a question, during his first visit in Pittsburgh in 25 years in front of an crowd of hundreds. I thought that was pretty low; I understood his nervousness and would have tried to be more gracious. ho hum.

Sci-Fi

Journal Journal: Battlestar Galatica Links 3

Here are some Battlestar Galatica links I found off the web and from the TrekBBS. Sorry if the format stinks. After adding them to my toolbar, I simply exported the bookmarks and ran the file through Tidy. Hope someone finds them useful!

Galatica

Battlestar Galatica
Battlestar Wiki

Blogs

Ron Moore's BSG Blog

----------

BSG Pre-Flight Briefing
News and Updates
Unofficial BSG Blog
The CIC
Nixflix: BSG
News, Previews and Episode Reviews

BBS

TrekBBS: BSG
TrekWeb: BSG
Sci Fi: BSG

----------

Ragnar Anchorage
The Battlestar Galactica Forum
Colonial Fleets Forum
The Forum For Battlestar Galactica, Cylons, Warriors and Vipers!
Media Blvd: BSG

New BSG

Vipertown.Net
Galactica Station
Battlestar Galactica - The New Series : Welcome to Galactica Station & The Ragnar Anchorage Forums

----------

TGL: BSG
BSG Hub
GW: BSG
Galatica.TV

----------

Sci Fi: BSG
Space: BSG

Original BSG

BSG Fan Club

----------

BSG.com
Colonial Fleets
Sci Fi: BSG Classic

----------

Kobol.com
BSG Costume & Prop Museum
BSG 1978

----------

BSG Schematics
BSG Tech Manual
Galactica Timeline

----------

Multimedia

BSTG Icontest
BSG Picture Gallery
Galactica Station - Media

Actors

All about Tahmoh Penikett
Katee Sackhoff Fan Page

----------

Edward James Olmos (official)
Tricia Helfer (official)

Articles

(none)

I've got many more from Stargate, Star Trek, Star Wars, and loads more topics. My Bookmarks file is 1.7MB! It's like a mini-yahoo. :p

User Journal

Journal Journal: URI Help Needed 4

I have been hacking a URI encoder, and I need some help. The encoder has to percent-encode binary octets in a URI that aren't UNRESERVED characters (i.e. Anything except ASCII letters, numbers, `-`, `.`, `_`, and `~`). The specs also say that the encoding value of escaped octet depends on the character encoding used.

So say I have the string, "Iñtërnâtiônàlizætiøn" in a URI. If it was in UTF-8, after encoding it the ASCII should be:

I%C3%B1t%C3%ABrn%C3%A2ti%C3%B4n%C3%A0liz%C3%A6ti%C3%B8n

If it was in Latin-1 (ISO-8859-1) on the other hand:

I%F1t%EBrn%E2ti%F4n%E0liz%E6ti%F8n

My problem is that I need to know what happens if you start with UTF-16 in big-endian, little-endian, or self-identifying-endian mode? The main concern is that UTF-16 uses two octets per character while UTF-8, Latin-1, and ASCII use up one. Straight encoding UTF-16 (any mode) octets produces lots of `%00` escapes since a letter in Latin-1 would have a byte of zeros appended to it in UTF-16. So the sequence "a b", could be in Latin-1 "a%20b", but in UTF-16LE "%00a%00%20%00b". This output confuses me (and lots of software).

So what should I do with all the %00 (NUL?) characters? Keep them in the output? Remove them from output? What should a UTF-16 encoded string of "Iñtërnâtiônàlizætiøn" look like? In which endian?

Databases

Journal Journal: Running MySQL off of a portable USB flash disk. 2

First a rant. Nobody's blogging software is any good! I just posted a quite long comment in a journal, and the guy's software butchered it! NOTE TO DEVELOPERS: If you think your users are too stoopid to write well-formed XML fragments of XHTML's test module then don't use html at all. Use Wiki's markup or none at all.

Now to the meat. My aforementioned blog comment was about how to run MySQL off of a a portable USB flash disk. I run it off of USB disks on the (locked down) Windows boxen here at school, since I don't own a (functioning) laptop. I'm too cheap. ;-)

Here's what I did. To get the minimum practical installation, I used the zip "no-install" archive. Then I changed the root directory with my own naming conventions ("name/version/") and pruned directories until I had the smallest practical set of files. As a result of this, I had (based on output of `tree /f /a`):

in /mysql/

  • setup.cmd

in /mysql/4.1.10/

  • COPYING
  • EXCEPTIONS-CLIENT

in /mysql/4.1.10/share/english/

  • errmsg.sys
  • errmsg.txt

in /mysql/4.1.10/share/charsets/

  • armscii8.xml
  • ascii.xml
  • cp1250.xml
  • cp1251.xml
  • cp1256.xml
  • cp1257.xml
  • cp850.xml
  • cp852.xml
  • cp866.xml
  • dec8.xml
  • geostd8.xml
  • greek.xml
  • hebrew.xml
  • hp8.xml
  • Index.xml
  • keybcs2.xml
  • koi8r.xml
  • koi8u.xml
  • languages.html
  • latin1.xml
  • latin2.xml
  • latin5.xml
  • latin7.xml
  • macce.xml
  • macroman.xml
  • README
  • swe7.xml

in /mysql/4.1.10/data/

  • (My databases)

in /mysql/4.1.10/bin/

  • libmySQL.dll
  • myisamchk.exe
  • myisampack.exe
  • mysql.exe
  • mysqladmin.exe
  • mysqlbinlog.exe
  • mysqlcheck.exe
  • mysqld.exe
  • mysqldump.exe
  • mysqlimport.exe
  • mysqlshow.exe
  • perror.exe

The file, "setup.cmd", is a batch script I use to set up the environment (it is called by my custom "start cmd shell" batch script):

rem where mysql is installed
set MYSQL_HOME="%~d0%~p04.1.10"

rem add MySQL Tools to Path
set path=%path%;%MYSQL_HOME%\bin

rem This is a macro that starts mysql daemon with appropriate options
doskey start-mysql=start /b mysqld --basedir=%MYSQL_HOME%

rem This is a macro that tests that the mysql daemon is running
doskey ping-mysql=mysqladmin ping

rem This is a macro that stops the mysql daemon
doskey stop-mysql=mysqladmin shutdown

rem print messages to the user
echo Remember:
echo Make sure you run ``stop-mysql'' and ``ping-mysql'' after
echo running ``start-mysql'' or Bad Things (tm) could happen!

This script sets up the environment and creates handy macros to start ("start-mysql"), stop ("stop-mysql"), and verify if its running ("ping-mysql").

Finally note that the above directions assume that the data directory is "%MYSQL_HOME%\data". I just copied my existing mysql data to that directory. Hope that's useful to somebody. YRMV, no warranties.

P.S. /.'s journal system butchered the above too, but surprisingly not as much....

Slashdot Top Deals

"What man has done, man can aspire to do." -- Jerry Pournelle, about space flight

Working...