Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Slashdot.org

Journal Journal: Drunk with Power. 12

/. loves me! In the last three months, I have recieved moderation powers about 14 times. In the last three weeks, about seven times. In the last week, three times. In fact I used up my moderation points this morning and recieved five more this evening! As my power grows so does my ego.

I just wish there were more interesting stories. The moderation of most stories is horrible if my judgement about topics that I know something about is any indication. However, I usually moderate only in those stories since I can't fairly judge the worth of a comment outside of my field. So people, I implore you to submit fascinating articles about engineering, physics, programming, science, the semantic web, etcetera!

User Journal

Journal Journal: Racial Slurs and Jiu-jitsu Tourney 6

On Racial Slurs:

While practicing jiu-jitsu with a friend, he referred to me with a racial slur at one point. I don't care personally. In fact, it made me fight that much harder when sparring. We're still cool, and I understand it was in jest. I don't think my friend is a racist.

The topic still preoccupies my brain however. I don't feel offended - more like puzzled. Why should I care? Why do I still think about it? Then there are also labels like 'nerd' and 'geek' that can also be used as pejoratives. (He didn't used them.) Why is it not a hate crime when we are bullied for liking science but other groups are? I can't think of any answers to these questions.

Jiu-jitsu Tourney:

Much to my surprise I found a summary of my match (Men's No-Gi Beginner) at the Kumite Classic. I'm rapidly forgetting what happended during the match, which usually happens since I'm too busy to comit it to memory! ;-) However, I was under the impression that I lost due to a key lock. I confess that I don't yet know what an americana is though - hey I only have a month and a half of experience so far!

User Journal

Journal Journal: On the Top Bands/Artists...EVER. At this moment. ever.

One the subject of Top Bands/Artists... EVER. An honorable mention must go to Jerry Goldsmith for The Enterprise and Leaving Drydock from Star Trek: The Motion Picture Soundtrack. With that pseudo-symphony Goldsmith defined the adjective bombastic. I must rank that work among the best classical ever with Bach, Beethoven, Mozart, and the like.

P.S. Evenso, I like rock too.

User Journal

Journal Journal: A Different RDF/XML Serialization

I think the Official RDF/XML Serialization has the right heart, but makes a few mistakes. Here's how I would design an RDF/XML serialization:

I'd start with having the root element be anything. It isn't important in the long run.

I'd use a stripped syntax to start with, then just iterate properties. That is, instead of:

<root> <type> <property> <type> <property>

I'd use:

<root> <type> <property> <property> <property>

This is because:

  1. 90% of the the time, when the rdf:type abbreviation is taken advantage of, is for shallow trees.
  2. Contrary to the term doctype, I believe that an element's name represents its behavior rather than type. Since properties describe something happening (this associates with that via the property), I think they are a good fit for element names.
  3. rdf:parseType is super annoying!

So how would you identify resources after the first property in the chain? Just add an rdf:about attribute of course for named nodes and rdf:id for blank nodes! Thus the following RDF/XML:

<e:root
xml:base="tag:example.com,2005-06-04:ex:"
xmlns:e="tag:example.com,2005-06-04:ex:"
xmlns:r="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<e:Person r:about="jimmy">
<e:address r:type="Address">
<e:street>123 Name Road</e:street>
<e:city>New City</e:city>
<e:state>ST</e:state>
<e:zip r:dt="usformat">12345</e:zip>
</e:address>
<e:wrote r:about="mybook"
r:type="Book"
e:pages="42"
>
<e:id r:dt="isbn>123-45-6789</e:id>
</e:wrote>
</e:Person>
</root>

That identifies the triples:

e:Jimmy
r:type e:Person ,
e:address [
r:type e:Address ;
e:street "123 Name Road" ;
e:city "New City" ;
e:state "ST" ;
e:zip "12345"^^e:usformat
] ,
e:wrote e:mybook .
e:mybook
r:type e:Book ,
e:pages "42" ,
e:id "123-45-6789"^^e:isbn .

If slashdot didn't have braindead indenting, that would look pretty and easy to read/parse. Note that I'm using r:dt to identify data types. It is too bad I can't use xi:type, but anyhoo. :-/ Now what if you want xml content to be interpreted as a literal instead of with the semi-striped syntax? Just add r:dt="the datatype". RDF predefines a datatype for XML documents; just use it! OR you could just start the element's content with non-whitespace text. So that you have (with the xmlns not shown>:

<e:doc>
<e:Body>
<h:div>
<h:p>This is <h:strong>strongly</h:strong> advised.</h:p>
</h:div>
</e:Body>
</e:doc>

That means the following:

[
r:type r:Body;
h:div "<h:p>This is <h:strong>strongly</h:strong> advised.</h:p>"^^r:XMLLiteral
]

Note no datatype was defined in this case, but it was added to the output. Also note that the entire element is included with the literal. This involves a little bit of backtracking, but not much. (An alternative is to say an element with any text document MUST be literal, but this could potentially involve too much backtracking.) That example is exactly the same as (ignoring the insignicant whitespace):

<e:doc>
<e:Body>
<h:div r:type="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>
<h:p>This is <h:strong>strongly</h:strong> advised.</h:p>
</h:div>
</e:Body>
</e:doc>

Now what about elements with no content? In that case nothing special happens. Check out this example (again no xmlns for brevity):

<u:urlset>
<u:Page>
<h:link
h:ref="http://example.com"
h:type="text/pudding"
h:rel="food"
/>
</u:Page>
</u:urlset>

That means the same as:

[
r:type u:Page ;
h:link [
h:ref http://example.com" ;
h:type text/pudding" ;
h:rel food"
]
]

Now what if you really wanted an element name to be parsed as the r:type of the resource? Well, then just say r:type="'". Yes that is a hack.

To say that some elements, besides some predefined ones I haven't told you about (basically all the properties in the RDF/RDFS/OWL specs that link to resources instead of literals), link to a resource instead of a literal use the r:refs attribute on the root element (yes, I said it was ignored... in the graph):

<e:root
xmlns:e="ex:eee#"
r:refs="ex:eee#Prop1 ex:eee#Prop2 ex:eee#Prop3" />

And so on. Blank Nodes are identified by r:node, r:id is basically my equivalent to r:ID (not rectification), and r:arc is used for rectification. r:resource is the exact same thing as r:about in my langauge (and really, it is the same in the offical RDF/XML serialization).

Finally if you want to use "namespace" prefixes instead of full uris - even though that's evil, then you need to use the a different namespace for "r:", "http://www.w3.org/2005/06/04-rdf-syntax-abbr-ns#", and declare all prefixes in the attribute r:ns like so:

<e:root
xmlns:e="..."
xmlns:r="..."
r:ns="e ... prefix2 uri2 prefix3 uri3
f ... prefix5 uri5"
/>

You get the idea. There's more, but I'm tired. Hope it spurs your imagination!

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.

Slashdot Top Deals

Happiness is twin floppies.

Working...