Tuesday, June 30, 2009

Vim syntax highlighting on Ubuntu

To get vim syntax highlighting:

First, make sure you have vim installed in addition to plain old vi.

sudo apt-get install vim


Then, create a vimrc dot file.

vim ~/.vimrc


In that file, add the following:

:syntax on


Thats it! Next time you edit a file in vim, you should have syntax highlighting.

Wednesday, June 24, 2009

Pidgin (and Adium) not connecting to Yahoo

OK, I entered a phase where my yahoo login started failing in Pidgin with Ubuntu. I first went in through my.yahoo.com and reactivated my account. It turns out that yahoo turns off your account if you don't login for a few years. =)

After that, it was a problem with the underlying libraries underneath both Pidgin and Adium. On Mac, I updated to the latest version of Adium (1.3.5) and that fixed it.

On ubuntu, it turns out that ubuntu won't update to new versions unless their is a security problem. In order to get functional enhancements, you need to upgrade using pidgin's instructions here:
http://www.pidgin.im/download/ubuntu/

After you enter those two commands, start update manager and you should be able to upgrade pidgin.

Thursday, June 18, 2009

attachment_fu: No thumbnail generation (make sure you have a parent_id!)

I've been using attachment_fu to upload images in a rails application. Everything was working well except the thumbnails weren't generating. I think everyone follow's Mike Clark's excellent blog:
http://clarkware.com/cgi/blosxom/2007/02/24

He doesn't mention that the parent_id is required, so I thought it was simply the id of the model to which the photo/upload was attached.

After some digging, I found a conversation here:
http://www.ruby-forum.com/topic/104213

Turns out attachment_fu, creates a new entry for each thumbnail, then strings them together with the parent_id. So, make sure you keep the parent_id column otherwise attachment_fu silently fails to generate the thumbnails.

Wednesday, June 17, 2009

LDAP/Active Directory Authentication with Apache

Alright, it took a few hours to get all the parameters correct, but we finally achieve centralized authentication by linking apache authentication to our ActiveDirectory. The critical concept to keep in mind when doing it is that there are two things you need to specify. First, you need to specify the user that apache will connect as, known as the "BindDN". Second, you need to specify the query string that allows apache to locate a user in the directory. This is the LDAP url.

In the end, this is the element we needed to add to our apache config. On ubuntu, we dropped this into the site-specific configuration file in /etc/apache2/sites-available.


<Location />
AuthBasicProvider ldap
AuthType Basic
AuthzLDAPAuthoritative off
AuthName "Portal"
AuthLDAPURL "ldap://actrivedirectorymachine/DC=foo,DC=com?sAMAccountName?sub?"
AuthLDAPBindDN "CN=apache,CN=Users,DC=foo,DC=com"
AuthLDAPBindPassword "PASSWORD"
require valid-user
</Location>


In the above example, I created a user specifically for apache, with password PASSWORD. I highly recommend using JXplorer to verify your bind credentials.

When configuring JXplorer, if you are using ActiveDirectory, most likely you'll need a Base DN as well. This was "DC=foo,DC=com". The user name is the exact string from above, same with password.

The AuthLDAPURL is a query that will be used to grab the entry associated with the username that the user types in when prompted by the browser. In the example above, it will search within DC=foo,DC=com against the attribute "sAMAccountName".

I hope this helps people out.

Sunday, June 14, 2009

git installation on Mac OSX (to fix undefined method acts_as_mappable)

I recently started playing around with geokit within rails. I kept getting an "undefined method `acts_as_mappable'" error. It turns out that the script/plugin command for the installation of the geokit-rails plugin was silently failing. When I entered the script/plugin install command, the command would run and not output anything to the screen. I ended up with an empty vendor/plugins directory.

The root cause ended up being:

I didn't have git installed and on my path. So, I installed it first using this:
http://code.google.com/p/git-osx-installer/

And added /usr/local/git/bin to my path.

(Then later I installed git via ports.)

When I returned to the rails app and re-entered:
script/plugin install git://github.com/andre/geokit-rails.git

All worked properly.

Friday, June 5, 2009

WMV to FLV Conversion and Thumbnail Generation

Here are two handy command lines for converting WMV to FLV (which is a better format for hosted video), and generating thumbnails for those videos. Both use ffmpeg.

To convert from wmv to flv:
ffmpeg -i test_video_clip.wmv -ab 48 -ar 22050 -s 512x384 -g 50 -qblur 1 -pass 1 -b 800 -r 25 -y encodedvideo.flv

To generate the thumbnail:
ffmpeg -i test_video_clip.flv -an -ss 00:00:03 -an -r 1 -vframes 1 -y %d.jpg