Archive for August, 2008

free this speech!

sic semper tyrannis
Have you seen this freakin’ outrage

When I heard this story, I could not believe it! How can something like this happen in what is supposed to be the land of the free?! Watching it again now, I have crossed over from disbelief to super pissed!

Look at these fat bastards! This is exactly what 1984 was talking about. Check out the sanctimonious nonsense!

They have to make up the charges later. Because dude was not doing anything illegal.

Turns out, just trying to do your job is now illegal! If your jobs is to show the $$$ side of the political circus.

I guess part of me has to laugh to think anyone could be so naive… but the rest of me is just enraged!

Check out the justice and how they run it!

Is it just me? Isn’t this nuts? Maybe it’s just me… I’m shocked.

Here’s another the video.

You know what would be funnier than hell? Ask Obama or McCain what they think of this sh!t!

I know… the video really says it all… you can hear that “boo” at the end? I hope that’s Obama booing this… I hope it’s McCain… Somehow… kinda doubt it.

Leave a Comment

using java.util.jar.JarFile

Of course Java can read zip files / jars. It’s pretty straightforward:

import java.util.jar.JarFile;
import java.util.Enumeration;
//...
    public void print( String arg ) throws Exception {
        this.print( new JarFile( arg ) );
    }

    public void print( JarFile jarFile ) {
        this.print( jarFile.entries()  );
    }

    public void print( Enumeration entries ) {
        while ( entries.hasMoreElements() ) {
            System.out.println( entries.nextElement() );
        }
    }

program, compile and execute thyself!

I wrote a little test program called Jarout.java, which is a “self-compiling” program:

% ./Jarout.java ~/.m2/repository/org/springframework/spring/2.5.5/spring-2.5.5.jar

This works (in reasonable environments) because the first 4 lines are a shell script protected by a block comment:

/*2222222 2>/dev/null
javac Jarout.java && java Jarout ${*}
exit ${?}
*/

import java.util.jar.JarFile;
import java.util.Enumeration;
//...

The first line keeps the shell quiet and the exit keeps the rest of the program from being interpreted. It’s a silly trick, but useful sometimes. I also use it for C and C++. The gcc is so fast that it gives traditional interpreted languages a run for their money!

Even though it is a silly trick, it allows you to use any compiled language like a scripting language…

:-D

Leave a Comment

using libzip

jar tf too slow

So I recently had occassion to notice that “jar tf” was much slower than “unzip -l”

% for f in 0 1 2 3 4 5 6 7 8 9 ; do time jar tf velocity-dvsl-0.43.20020711.010949.jar > a ; done 2>&1 | grep ^real | cut -f2- -dm | cut -f1 -ds | xargs | tr ' ' + | bc -l
2.750
% for f in 0 1 2 3 4 5 6 7 8 9 ; do time unzip -l velocity-dvsl-0.43.20020711.010949.jar > u ; done 2>&1 | grep ^real | cut -f2- -dm | cut -f1 -ds | xargs | tr ' ' + | bc -l
.096

So the jar command is almost 3 times slower! But it prints the list of contents in a simple format I like. Instead of grep/cut/sed’ing up, I decided to write a custom application.

zip_print.c

% sudo apt-get install libzip-dev libzip1

Here are the highlights:

#include <zip.h>
...
int
main( int argc, char *argv[] ) {
  struct zip *zip_ptr;
....
  for ( i = 1 ; i < argc ; i++ ) {
        path = argv[ i ];
        zip_ptr = zip_open( path, ZIP_CHECKCONS, &errorp );
...
        max = zip_get_num_files( zip_ptr );
        for ( j = 0 ; j < max ; j++ ) {
            printf( "%s\n", zip_get_name( zip_ptr, j, ZIP_FL_UNCHANGED ) );
        }
...
       zip_close( zip_ptr );
% for f in 0 1 2 3 4 5 6 7 8 9 ; do time ./zip_print velocity-dvsl-0.43.20020711.010949.jar > b ; done 2>&1 | grep ^real | cut -f2- -dm | cut -f1 -ds | xargs | tr ' ' + | bc -l
.092
% diff a b

Now I’m not going to claim zip_print is faster than “zip -l”… that .004 is basicly bunk, but it is certainly faster than “jar tf”

Leave a Comment

Amazon S3 Library for SOAP in Java

Woe is me!

After looking a lot of tools, I decided I need to write a one-off for my application to update aACL’s. All the tools I found wanted to pull back every ACL and update it! I want all my keys in this part of my bucket to have the same ACL.

I tried to use the wsimport’d libary, but….

javax.xml.ws.soap.SOAPFaultException: The SOAP 1.1 request is missing a security element
    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:171)
    at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:102)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:240)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
    at $Proxy33.getObjectAccessControlPolicy(Unknown Source)
    at us.versus.them.jarczar.publisher.AppTest.testApp(AppTest.java:44)

OSS to the Rescue

I cursed and cried and then found the Amazon S3 Library for SOAP in Java. The only bit I really wanted was com.amazon.s3.AWSAuthConnection which takes care of the blasted authentication nonsense.

Compiling s3-example-libraries

Compiling it was fun:

% javac -d out $( find com -name "*.java" ) -classpath ${HOME}/.m2/repository/org/codehaus/castor/castor/1.2/castor-1.2.jar:${HOME}/.m2/repository/org/apache/axis/axis/1.4/axis-1.4.jar:${HOME}/.m2/repository/com/sun/javaee/javaee/5.0/javaee-5.0.jar
% jar cf  s3-example-libraries.jar -C out .
% addToRepo.sh com.amazon.s3 1.0.0 s3-example-libraries.jar
${HOME}/.m2/repository/com/amazon/s3/s3-example-libraries/1.0.0

Using it

Using it was trivial:

import com.amazon.s3.AWSAuthConnection;
import com.amazonaws.s3.doc._2006_03_01.*;

//....

AWSAuthConnection aws = new AWSAuthConnection( awsAccessKeyId, awsSecretAccessKey );
AccessControlPolicy acl = aws.getACL( bucket, key );

Maven Dependencies

It did pull in a few deps....
        <dependency>
            <groupId>org.codehaus.castor</groupId>
            <artifactId>castor</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>com.amazon.s3</groupId>
            <artifactId>s3-example-libraries</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.javaee</groupId>
            <artifactId>javaee</artifactId>
            <version>5.0</version>
        </dependency>
        <dependency>
            <groupId>commons-discovery</groupId>
            <artifactId>commons-discovery</artifactId>
            <version>0.4</version>
        </dependency>
        <dependency>
            <groupId>axis</groupId>
            <artifactId>axis-wsdl4j</artifactId>
            <version>1.5.1</version>
        </dependency>

Leave a Comment

so much free stuff!!!

Yeah… I know… I was doing stuff, but then I went totally nuts on Google’s App Engine!

HEY! ARE YOU A DEVELOPER! GO GET IT! WAKE UP! WAKE THE FnCK UP!

Just wanted to say: go and get at it! Sure it is suck ass pythong, but at least it’s not perl.

What else? S3 is what else?

Waiting on YAP to drop. I’m out…

Parting shot:

% mkdir amazonS3
% wsimport -d amazonS3 -s amazonS3 http://s3.amazonaws.com/doc/2006-03-01/AmazonS3.wsdl
% javadoc -d javadoc $( find amazonS3 -name "*.java" )
% jar cf amazonS3.jar -C amazonS3 .

HEY! GO AND GET IT!

Yeah… let me try to write something useful…

Here is a good tip on managing your own key on bulkload with GAE.

Here is what I got (names changed to keep my sh!t on the d/l):

from google.appengine.ext import db
from google.appengine.ext import bulkload
from google.appengine.api import datastore
from google.appengine.api import datastore_types
from google.appengine.ext import search

class LoadMyJunk( bulkload.Loader ):
    def __init__(self):
        bulkload.Loader.__init__(
            self
            , 'SomeJunk'
            , [
                  ( 'sha1',    str )
                , ( 'pwd',     str )
                , ( 'filesize', int )
                , ( 'datal',    db.Text )
            ]
        )
    def HandleEntity( self, entity ):
        name = 's' + entity[ 'sha1' ]
        newent = datastore.Entity( 'SomeJunk', name=name )
        newent.update( entity )
        ent = search.SearchableEntity( newent )
        return ent

if __name__ == '__main__':
    bulkload.main( LoadMyJunk() )

I would say how neat it is, but I am too busy kicking ass. STOP Suggest you do same STOP

NOW GO GET IT!

Client/Server is dead! Long live, commodity computing!

Power to the people!

Peace!

Leave a Comment

Older Posts »