Doug Bryant

Tech thoughts and notes

Transfer Email From One Google Account to Another

I recently signed up the netinlet.com email for Google apps for you domain

I had all my mail funneling to a gmail account to begin with, so I need to get all that email from the first google account to the new google apps account.

You can do with with POP, but you have to put in a different pop server name. Use pop.googlemail.com instead of pop.gmail.com. pop.gmail.com will not allow you to access via pop. Go figure.

Everything else stays the same, just make sure to use ssl on port 995.

The process takes a while. Mine has been running for about a half an hour and has only pulled over 300 emails so far. I have mine setup to pull over all email, so everything (INBOX, SENT, ARCHIVED) gets stuck into the inbox on the google apps account.

Google Apps - Html Verify Takes a Long Time

I recently signed up the netinlet.com domain and a friends work domain for the Google Apps

You have to verify ownership of the domain to get the ball rolling. They allow you to either upload a unique html page to the domain or add a cname entry which points to google.com. I chose the former because it was simple and easy to do.

Google tells you up to 48 hours before the account is active. Well, 48 hours came and went. Then a whole week came and went and I heard nothing. Searches for why this was taking so long did not turn up much.

I finally stumbled upon some http log entries which show google was trying to verify. The entries looked like this:
216.239.36.136 – - [27/Mar/2007:22:58:25 +0000] “GET /googlehostedservice.html HTTP/1.0” 412 258 “-” “Jakarta Commons-HttpClient/3.0.1”
Look, a clue! Notice the 412 error code.

After some more hunting, it turns out that the verification process is triggering Apache mod_security. Luckily, the fix is simple.

If you don’t already have one, create a .htaccess file in you webserver root directory. In this file put
SecFilterEngine Off My host is textdrive and I found a textdrive specific fix here but this fix should apply to almost everybody who is getting 412 error codes in their log files.

Reinstall Solaris 10 on a T2000

My biggest gripe with the T2000 so far is actually with Solaris package management. pkgadd sucks because it does not handle dependencies and will not automagically download stuff from Sun. I really which they had something like the FreeBSD ports collection or apt-get or yum or something which automatically downloaded and install dependencies.

The T2000 ships (the one I received atleast) with Solaris 10 1/06 release. I want to play with ZFS which was included in the 6/06 release. Plus, I hope installing some of the other packages will be easier if I install the developer packages with some amount of libraries.

So not being able to find out how to upgrade the system from 1/06 to 6/06, I downloaded the 6/06 release and am doing a reinstall.

Since the T2000 does not ship with a video card, you have to install from the console. Not having used Solaris very much , it took a little while to figure out how to get the box to boot from the cdrom.

The trick is to get to the ok prompt. You can do this by logging in as root on the console and issuing the following command:

shutdown -y -g0 -i0 now

This leaves the server running but in init mode 0.

Now, you can boot from the cdrom and start the installer with the following command.

ok boot cdrom – nowin

This will start the installer in the console mode, rather than in X.

The T2000 Has Arrived

The T2000 has arrived!

I can’t wait to see what this thing will do with ruby and postgresql. This one has 6 cores and 8 gig of ram.

I will more than likely have to send it back at the end of the 60 day trial, but i’m very excited to get to use it as a test server in the meantime.

It’s time to put on my admin hat!

Synergy - the Kvm Switch Replacement

At work, I regularly use two computers, my primary development box (linux) and my other development box for the windows specific piece of the program I am working on.

I have one keyboard and mouse two monitors. I tried using a KVM switch, but that sucked because every time I would switch from linux to windows and back, the scroll wheel on my mouse quit working on the linux box.

I also tried using VNC for a while, but found the screen drawing was too slow.

On one of my rss feeds this morning, I ran across Synergy. This is one sweet program!

You designate one of your computers the primary computer and start a synergy server on that computer. On the other computer, you start a synergy client. Now, all you have to do to move the keyboard and mouse from one computer to the other is push the mouse to one side of the screen from either computer. So when I am on the linux box and want to use the windows box, I just push the mouse to the right of the screen and I am then using the windows computer. To get control back to the linux box, I just push the mouse to the left side of the screen, and voila! I’m working on the linux box again.

This setup only works if you have two monitors and one keyboard/mouse. And… it works very, very well.

TIP:
I start synergy daemon on the linux(master) box with crontab. On the windows box, there is a gui option to start looking for the master when the computer is turned on.

@reboot /usr/bin/synergys —daemon —config /path/to/synergy.conf

Ruby 1.8.4 on FreeBSD Core Dumps

I spent the better part of the last couple of days trying to track down why after upgrading to Ruby 1.8.4 on FreeBSD, I started getting core dumps in one particular place in my application.

After much time on IRC and some gdb voodoo I finally figured out the source of the problem. There appeared to be a stack management problem. Even with 64 meg of stack space, ruby would core dump. This behavior did not occur on OSX.

I emailed the ruby-core mailing list and one of the FreeBSD guys got right back to me.

Apparently the problem is with the freebsd pthread implementation and ruby.

Solution – install the port ruby18-nopthreads

Magically the problem disappears.

Quick Script for Adding New Svn Files to Repository

svn status | grep ? | awk ‘{print $2}’ | xargs svn add

This is on a FreeBSD box. I have noticed xargs on linux is slightly different – on linux try changing the xargs line to codeprexargs -i -t svn add {}/pre/code

Updated Rails From .13.1 to .14.3

The update went very smooth with this guide

All my work thus far has been on the database side, mapping incoming xml documents to my model. But there have been some significant performance increases in active record. My unit tests were taking on average 78 seconds on a 3.4 ghz pentium box running FreeBSD 5.3. That time has now been cut to 62 seconds on the same box. And that is with transactional fixtures turned off and instantiated fixtures turned on. Not too shabby!

Great work guys! I can’t praise you enough.

Obfuscated Mailto - Ruby One Liner

I have always been annoyed at having to write email addresses online such as codefoo at bar dot com/code. Damn the spambots!

I recently ran across this technique for obfuscating email addresses on web pages so that it appears normal to the user, but not something which could be easily parsed by a spambot.

You convert the link text and href to html characters.

becomes (added line breaks for readability)

 Just a little bit more cryptic.

The core method for converting a string to an html character string is just a one line ruby method, of course.


def string_to_htmlc(s)
   s.strip.unpack(“C*”).map{|ch| “#” + ch.to_s + “;” }.to_s
end


A couple of things are going on here.

codes.strip.unpack(“C*)/code We first remove any leading or trailing whitespace with the strip method. The unpack method on string is used for decoding a string (possibly with binary data in it) into an array.  The argument code”C*"/code is an instruction that the next 0 to many characters should be turned into an unsigned integer, i.e. the number which represents the the ascii character.

We now need to convert our array of integers into the html code for each character.  The html code for a character is simply the ascii integer value for that character preceded by code#/code and ending with a code;/code.  The ruby map mehtod takes care of this for us.  Array#map invokes the block for each element in the array.

Finally we convert the array back into a string with the code.to_s/code for our html pleasure.  The code.to_s/code method on array is the same as calling codearray.join/code

All you have to do now is just put some code in your rails helper module to output a full href.


module MyHelper
def to_html_email(address)
email = string_to_htmlc(address)
“a href=\”#{string_to_htmlc(‘mailto:’)}#{email}\“#{email}/a”
end

def string_to_htmlc(s)
s.strip.unpack(“C*”).map{|ch| “#” + ch.to_s + “;” }.to_s
end

end


Now it should be safe to display an email address on a webpage.

Another Great Thing About Ruby - the Unit Testing

The more I use ruby, the more I love it. I ran across this today – the ability to run individual unit tests.

You can run an individual test method within a test case by providing the -n switch after the ruby file containing the tests. the -n argument accepts either an absolute test method name or a regular expression which will run all the tests which match the expression.

codepre
ruby test/foo_test.rb
/pre/code
This runs all the tests within foo_test.rb.

codepre
ruby test/foo_test.rb -n test_bar
/pre/code
This runs the individual test method named test_bar within foo_test.rb

codepre
ruby test/foo_test.rb -n /bar/
/pre/code
This runs all the test methods within foo_test.rb which contain the string “bar”.