Being a geek means I cringe when easily parseable data isn't. The AADL is a fine public library and offers pretty cool online tools, but they only give us a RSS feed of checkouts with the due dates in the "summary" stanza. Although they send us an email reminder 2 days before the item is due, that doesn't fit into my iCal feed grokking calendar. There are a few other such RSS feeds that hide the event data within and being sure that I'm not the only one facing this problem I looked around for a generic solution and finally hit upon a few others using Yahoo Pipes!. It took far too long to get it just right (and even then timezone parsing is still off) but I made my first publically somewhat useful pipe, described as part of a thread on the AADL forums. If you want to see the source for the pipe or use it, read the forum post and then click on http://pipes.yahoo.com/rpaditya/aadlduedates.
random walk through fields of musings
Showing posts with label tech. Show all posts
Showing posts with label tech. Show all posts
Thursday, March 4, 2010
Tuesday, December 23, 2008
terminal reset and why enter doesn't return
occasionally, if for some reason, my ssh session to a remote machine, probably running screen, doesn't terminate cleanly, and I have to return-~. to kill it, my Mac OSX terminal gets "screwed up" -- the number of rows gets reduced, the characters don't all echo, etc.. Usually, running the
reset command will fix things, but sometimes it doesn't help. Of course I can't find the reference now, but some site suggested entering ^jreset^j (ctrl-j reset ctrl-j) repeatedly till it works. Incredulous, I tried it, and indeed it does work!Monday, December 15, 2008
searching UMOD with JNDI
For some of the support tools I've been writing for CTools (in JSP with JSTL) I need to authorize against a group in the LDAP interface to UMOD. JNDI is very complete, so it should have been an easy task, but searching to see if a given logged-in (via Cosign) user was in the requisite group wasn't working. I had some example code in Perl that a colleague had once sent out, and a 1-to-1 transcription into Java using JNDI didn't work. It turns out that the scope for searches in JNDI does not default to "SUB" AND if you try to bind (even anonymously) the query tries to ADD the attribute instead of searching for it, and so had to be explicitly set. To help you (and remind me) avoid this pain, here is the requisite code:
There must be a better way of formatting code in HTML without JS.
private boolean isMember(String grp, String un) throws Exception {
boolean isMem = false;
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://ldap.itd.umich.edu:389/dc=umich,dc=edu");
try {
javax.naming.directory.DirContext ctx = new javax.naming.directory.InitialDirContext(env);
String[] attrIDs = {"member"};
javax.naming.directory.SearchControls ctls = new javax.naming.directory.SearchControls();
String filter = "(&(cn=" + grp + ") (objectclass=rfc822MailGroup))";
ctls.setReturningAttributes(attrIDs);
ctls.setReturningObjFlag(true);
ctls.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE);
String searchBase = "ou=Groups";
javax.naming.NamingEnumeration s = ctx.search(searchBase, filter, ctls);
String positiveMatch = "uid=" + un + ",";
while (s.hasMore()) {
javax.naming.directory.SearchResult sr = (javax.naming.directory.SearchResult)s.next();
javax.naming.NamingEnumeration e = (sr.getAttributes()).getAll();
while (e.hasMoreElements()){
javax.naming.directory.Attribute attr = (javax.naming.directory.Attribute) e.nextElement();
javax.naming.NamingEnumeration a = attr.getAll();
while (a.hasMoreElements()){
String val = (String) a.nextElement();
if(val.indexOf(positiveMatch) != -1){
isMem = true;
}
}
a.close();
}
e.close();
}
s.close();
ctx.close();
return isMem;
} catch (javax.naming.NamingException e) {
System.err.println("Problem getting attribute:" + e);
return false;
}
}
There must be a better way of formatting code in HTML without JS.
Subscribe to:
Posts (Atom)
Blog Archive
travels
- Addis Ababa, Ethiopia
- Mombasa, Kenya
- Victoria Falls, Zambia
- Siem Reap, Cambodia
- Bangalore, India
- Billund, Denmark
- Cambridge, United Kingdom
- Paris, France
- Modena, Italy
- Berkeley, CA, USA
- Vancouver, Canada
- Rio de Janeiro, Brazil
- Popayan, Colombia
- View my profile
- Create your own travel map or travel blog
- Travel Info at TripAdvisor