watch this  

the official mrchucho blog

Vinyl iPod Shuffle Stickers

Posted 2005 Feb 25

ShuffleArt has will have Vinyl stickers for the iPod shuffle. Rock!

comments (0)

Java, LDAP and Active Directory

Posted 2005 Feb 24

Interface a Java application with Active Directory is a common albeit convulted endeavor. After struggling with unhelpful error codes for too long, I’ve decided to post some information that I found invaluable. First, there are a series of posts on the Sun forums that cover most of the topics:

The biggest hurdle in using Java and LDAP to interface with Active Directory is determining the way AD was configured. For instance, while the examples above indicate you should replace the “unicodePwd” attribute, I kept getting the WILL_NOT_PERFORM error (like I said, unhelpful) until I switched it to “userpassword” and did not encode it.
<pre><code>
        env.put(Context.SECURITY_AUTHENTICATION, "simple");
        env.put(Context.INITIAL_CONTEXT_FACTORY,
                "com.sun.jndi.ldap.LdapCtxFactory");
        env.put(Context.PROVIDER_URL, ldapURL );
        env.put(Context.SECURITY_PRINCIPAL, adminUser);
        env.put(Context.SECURITY_CREDENTIALS, adminPassword);
        env.put("java.naming.ldap.version","3");
        env.put(Context.REFERRAL, "follow");

        try
        {
         LdapContext ctx = new InitialLdapContext(env,null);

         String USER_TO_CHANGE = "CN=" + userName +
             ",OU=[your org. unit],DC=[your domain],DC=com";
         String NEW_PASSWORD = userPass;

        ModificationItem[] mods = new ModificationItem [ 1 ] ;
        mods [ 0 ] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE,
                    new BasicAttribute("userpassword", NEW_PASSWORD));
        ctx.modifyAttributes(USER_TO_CHANGE, mods);

         ctx.close();
        // ...
</code>
In this code the admin account logs in and sets a user’s password. I was unable to get a user to change his or her own password, even though AD was configured to do so… Check the links above for details on how to do that.

It is also worth noting that contrary to many posts SSL is not required to perform these operations.

With regards to Error Messages, there is an art to decoding those… An exception will usually include a message like so:

[LDAP: error code 49 – 80090308: LdapErr: DSID-0C09030F, comment: AcceptSecurityContext error, data 775, vece]

The part we’re after is the “data 775”. That is the hexadecimal error code. So, simply convert it to decimal, then consult the error code list. In this case, the error code is decimal 1909: ERROR_ACCOUNT_LOCKED_OUT. I built a simple lookup table of common error messages, then parse the error message like so:
<pre><code>
String err = e.getMessage(); // where e is the exception
int i = err.indexOf("data ")+5;
int j = err.indexOf(",",i);
System.out.println(err.substring(i,j));
</code>

Like I said, interfacing Java, LDAP and Active Directory to authorize, change passwords, and check group membership tricky—but possible. I hope this guide will help get you started.

comments (2)

Amazon Prime

Posted 2005 Feb 23

Oh, what have I wrought?

I signed up for Amazon Prime. I couldn’t help it! Seriously, I buy a lot from Amazon: books and CDs mostly. Enough that $79 for a year’s worth of free two-day shipping is worth it. It’s nice to be able to just pre-order something and not worry about trying to group stuff together. Also, it’s nice to - finally - be able to pick “Ship Items as they become available”!

Speaking of “Prime”, did anyone watch Robot Chicken? Totally and completely hilarious. My favorite: the Strawman in OZ.

comments (0)

SOA

Posted 2005 Feb 17

Maybe I’m not understanding, but I don’t necessarily see what is so revolutionary about SOA. Bridging disparate apps with formatted data over a simple, standard network protocol is nothing new. This seems like all the hullaballo about info-bus messaging…

Still, I’m glad to see that companies are looking for developers to solve this problem, rather than shrink-wrap solutions. I guess the good thing about SOA is that it encourages companies to embrace heterogeneity and rely on competent developers rather than trying to enforce a “standarized” environment with costly (and usually counter-productive) shrink-wrap software.

comments (0)

Rails and Templating

Posted 2005 Feb 14

There is a good post on Loud Thinking regarding Rails and its lack of a “templating” language.. which was one of my inital - I hate to use the word - complaints.

While I think that Ruby is certainly much better suited for co-existing inside the View than Java, I still think the approach that Tapestry uses (or even JSF) is preferable. It provides a nice decoupling in addition to helping during the prototyping phase. Of course, in most of my projects thus far, I’ve worn both the developer and designer hat—so I can’t speak to 37 signals’ workflow.

I stand by my claim that the less code in the HTML-portion of the View, the better—regardless of how readable the code is.

Update Read below for more thoughts on this—I tried to post this as a response the comments, but the HTML formatting was just too screwy…

When I think templating, I think of Tapestry, so here goes: Let’s say I have a table that I want to populate. During the prototyping phase, I create the HTML for the table in put in some mock-up data:
<pre><code>Employees.html
<table id="employees" jwcid="employees">
    <tr><th>Id</th><th>Name</th><th>Position</th></tr>
    <tr>
        <td>123</td><td>Joe Smith</td><td>Programmer</td>
    </tr>
    <tr>
        <td>456</td><td>Bob Jones</td><td>Designer</td>
    </tr>
</table>
</code>
So far, it’s all HTML - no code. The only thing that stands out is the “jwcid” attribute - that’s what ties the HTML table to the implementation. Now, in Tapestry, there’s a page specification that corresponds to the HTML page:
<pre><code>Employee.page
<component id="employee" type="contrib:Table">
    <binding name="source" expression="employeeList"></binding>
    <binding name="columns" expression="id,name,position"></binding>
</component>
</code>
In the Java code behind the page is a function, “getEmployeeList” that returns a collection of Employee models. The page, in turn, knows to use the id, name and position properties for the columns of the table. That’s it! And, we can leave the mockup data in place—everything between the opening and closing table tags is replaced at run-time.

Of course, this is a high-level explanation, but as you can see: there’s no code in the HTML and the View code itself just returns a List, it’s not concerned with how it is displayed, e.g. table or list or just a bunch of paragraphs! That’s pretty good decoupling! And it’s great during the prototype phase because you can tweak the layout (including mock-up data) outside of the application server and/or using WYSIWYG tool. And, even better, no major modification is necessary when the time comes to “wire” it up.

Lastly, to demonstrate your Rails example:
<pre><code>< % if @user.is_administrator? %>
  # show stuff that's only for administrators
< % end %>
</></></code>
In Tapestry:
<pre><code>.html
<div jwcid="adminStuff">
stuff for admins only
</div>
.page
<component id="adminStuff" type="Conditional">
     <binding name="condition" expression="isAdmin"></binding>
</component></code>
This is different from templating technologies like JSP or Velocity and is probably more akin to Perl’s HTML::Template.
comments (3)

iTunes Applescript - Disable Entire Genre

Posted 2005 Feb 13
I have a bunch of Live music in my iTunes library, but I don’t necessarily want it included in my iPod Shuffle when it Autofills. So, I select “Only update checked songs” in iPod preferences and run this Applescript to disable (i.e. uncheck) all songs in my library matching the selected genre.
<pre><code>
tell application "iTunes" 
    set theGenre to "" 
    display dialog "Enter Genre:" default answer theGenre
    set theGenre to text returned of the result
    copy (a reference to library playlist "Library") to mainLibrary
    repeat with i from 1 to (get index of last track of mainLibrary)
        tell track i of mainLibrary
            ignoring case, punctuation and white space
            if (get genre of it) is equal to theGenre then
                set enabled to false
            end if
            end ignoring
        end tell
    end repeat
    display dialog "Done!" giving up after 3
end tell
</code>
Or download: DisableGenre.zip
comments (0)

43 Evil Things

Posted 2005 Feb 09

I think 43 Things users are missing out on its real, untapped potential: Crime. I see the list forming like this:

My 4 things
  1. Rob a bank
  2. Start wearing ski mask
  3. Case the joint
  4. Gas-up the getaway car
  5. full HD backup

It’s a great way to assemble a posse: 12 other people want to Rob a Bank, 8 other people want to form a posse, 1 other person wants to Drive the Getaway car.

Stay Tuned—this could be big.

comments (0)

Neal Stephenson Interview

Posted 2005 Feb 09

Reason has a terrific interview with Neal Stephenson. Interviews with Neal are always entertaining and this one is no exception.

As a testament to how enjoyable Stephenson’s writing is, I actually found myself missing his characters (Jack, Eliza, etc.) after finishing “The Confusion”. Of course, I need a little break before starting “System of the World”...

comments (0)

Is it so wrong?

Posted 2005 Feb 08

To want this shirt.

comments (0)

More Tapestry vs. JSF

Posted 2005 Feb 07

Howard once again explains why Tapestry is best for Getting Things Done.

comments (0)
atom rss