Friday, May 23, 2008

Upgrading RubyGems without outside or proxy access

Just something I ran into recently and thought I would write a quick note about. I had rubygems 0.9.4 on a closed off server and was able to upgrade it. I was trying to do some form of the “sudo gem update –system” and giving the path to the actually rubygems-update-x.x.x.gem, but I couldn’t get it to fly. Instead I downloaded the latest tarball and ran the setup file in it. I was nervous that it would install a second instance of rubygems, but I saw this lovely message come up while installing it:



Removing old RubyGems RDoc and ri
rm -rf /usr/lib/ruby/gems/1.8/doc/rubygems-0.9.4


After it installed I checked the version of rubygems and it was what I installed. All my gems were still good too. The light is green, the trap is clean.

Wednesday, May 21, 2008

Firing up Firefox 3 RC 1

Recently I have been noticing Safari 3.1.1 has been running like doody for gmail when I am at work and at home as well. I also have been having more occurrences of it crashing lately. While I am trying to stick with the “Mac Mindset ™” and use mac only or cocoa apps, or some other kool-aid-ish type thing, I decided to try out Firefox 3 RC 1.



I used to be a HUGE FF fan when it was in its 1.x days. Anyone who would let me, I switched them to using FF. It was like a whole other world. Browsing was just better. Tabs were the norm. Finding text on a page was awesome and you could highlight, etc. And it rendered faster too. I kicked IE to the curb and only used it when QA’ing any work I had.



Fast forward to FF 2.x. I tried to stick with FF, but safari was rendering much faster in its 3.x incarnation, the memory footprint seemed to be way more manageable, and I couldn’t resist it. It’s search was as good, if not cooler than FF. I dove it and actually found I liked it more than FF 2.x and it became my default browser.



That leads me up to now. The past 2 days I have begun using Firefox 3 RC1 more and more and I am liking it. It reminds me of the zippy 1.5. I am also finding it fits well with OS X all the same and by just changing a few settings, I am able to take advantage of some of the little “it works” type of things you get with Safari in OS X 10.5 Leopard.



So, give it a whirl. It is not full release, but it is good enough for me… for now. Maybe I will write more about it, but if I don’t, it probably means I am still just sticking with Firefox 3 now.

Sunday, November 4, 2007

RegExp, Java, Email, RFC 2822 & YOU!

I am sure a lot of you have dealt with using regexps for validating email.  Its lots of fun. Regexps are extremely readable, make perfect sense the first time you look at them and are very intuitive…. oh what… what’s that? They are not? No crap!

Well, I had to improve one that was pretty limited in what it would allow.  After reading a few articles on the best way, I found one at Les Hazlewood's site that had a nice java implemention of the RFC 2822 standard.  While overall, it worked ok, it still allowed some emails that were not ok or stifled some that were ok.  So I changed his pattern a little:

private static final String sp = "!#$%&\'*+-/=?^_`{|}~";
private static final String ftext = "[a-zA-Z0-9]";
private static final String atext = "[a-zA-Z0-9" + sp + "]";
private static final String atom = atext + "+"; //one or more atext chars
private static final String fatom = ftext + "+";
private static final String dotAtom = "(\\\\.|-|_)" + atom;
private static final String localPart = fatom + "(" + dotAtom + ")*"; //one fatom followed by 0 or more dotAtoms.

//RFC 1035 tokens for domain names:
private static final String letter = "[a-zA-Z]";
private static final String letDig = "[a-zA-Z0-9]";
private static final String letDigHyp = "[a-zA-Z0-9-]";
public static final String rfcLabel = letDig + letDigHyp + "{0,61}" + letDig;
private static final String domain = rfcLabel + "((\\\\.|-)" + rfcLabel + ")*\\\\." + letter + "{2,6}";

//Combined together, these form the allowed email regexp allowed by RFC 2822:
private static final String addrSpec = "^" + localPart + "@" + domain + "$";

//now compile it:
public static final Pattern VALID_PATTERN = Pattern.compile(addrSpec);


and a method using that pattern:

public static boolean isValidEmail(String address) {
return VALID_PATTERN.matcher(address).matches();
}


This seems to catch all that I need it to catch and still follows the standard.  Thanks to the original author for the inspiration. ^.^