jQuery Auto Datepicker

Posted 3 days ago

I somewhat recently started using jQuery datepicker in place of the dhtml_calendar Rails plugin. The change was for various reasons which are beyond the purpose of this blog. After using it a few times I realized it would be nice if I could just set a class on my text field and it would automagically become a jQuery datepicker enabled text field. Of course I am sure someone has likely already conquered this, I thought it would be a fun learning experience to write my own.

if (jQuery && jQuery.datepicker) {
  $(window).load(function() {
    jQuery(".datepicker[id]").map(function(i) { $("#"+this.id).datepicker(); }); 
  }); 
};

Since I am using these to almost always store into a database I like to set the default date format.

if (jQuery && jQuery.datepicker) {
  $(window).load(function() {
$.datepicker.setDefaults({ 
      "buttonImage" : "/images/calendar-icon.png",
      "constrainInput": false ,
      "dateFormat" : "yy-mm-dd", 
      "showAnim" : "slideDown", 
      "showOn" : "button"
      });
};

I am also overriding some other default options, using showOn and buttonImage I change the behavior of the datepicker to use an image of my choice to activate the calendar instead of the field itself. I change the animation to slideDown, personally I just think it looks a little more slick. I do not normally turn off constrainInput, since it adds another level of validation but in some cases it may be necessary so I thought it would be useful to demonstrate. Without disabling input constraint by setting constrainInput to false jQuery datepicker will not allow any characters that are not included in the defined format.

Hopefully this will prove helpful to someone, and if not I learned a little by doing it. I certainly welcome any feedback or constructive criticism or general cursing of my code.

Posted in  | Tags , , ,  | no comments

Installing vim-rails on OpenSuse 11.2

Posted 3 months ago

Get vim-rails either download the rails.vim from vim.org or clone vim-rails from github.com. Follow the instructions on the vim.org site or in the README on GitHub, installing the files into the appropriate VIM folder, probably ~/.vim/.

Note that I had the following VIM packages installed:
  • vim-enhanced
  • vim-base

Before you try anything further!

Additionally I needed to install vim-data. Afterwards you will find a plethora of scripts in /usr/share/vim/current/syntax, I initially had tried installing some of these for example xhtml.vim from vim.org and experienced much grief. Eventually I realized I just needed to install the Suse package mentioned above.

Once I start to become a vim-rails ninja I might post another blog on my findings, good and bad habits.

Posted in , ,  | Tags ,  | no comments

Long Overdue Freedom

Posted 3 months ago

During the 4 hour drive back to Canton from Lansing, Michigan from the Great Lakes Ruby Bash I had a realization. Its been long past due, I couldn't even bring myself to guessing how long its been since I last booted to it. Its a waste of time, space and hurting my morals.

Step 1- Staring off positive...

Something good to drink

Step 2 - A good song and it makes sense...you'll see

Something good to listen to

Step 3 - NTFS hrm wonder what that could be?

Looks like we have a problem here

Step 4 - Ah, who cares!

All better

It should be noted that I am so confident in my actions that I didn't even take the time to look through the files to see if I wanted anything on the file system...obviously its nothing important otherwise it would be on a journaled file system!

As reward for my accomplishment, I decided to subscribe to a Twitter account.

Posted in , ,  | Tags , , ,  | no comments

Linux High Availability Part 1

Posted 7 months ago

 I have been itching to dive into high availability clusters for quite some time now. As a network administrator uptime is a crucial part of my field. My goal in this series of blogs is to share my experience with setting up a high availability cluster using Linux systems.

Debriefing:

I will set up two virtual machines using VirtualBox. The two machines will both run Debian 5.0.2 i386 and will be on their own private network 192.168.2.0/24. The two nodes will together provide a high availability web and database service via Apache2 and MySQL using HA. With clustering an important factor is keeping data synchronized, that will be handled by DRDB.

 

Getting Up To Speed:

At this point I have setup my two virtual machines, Bravo and Echo, yes very original. I am using iptables on the host machine to masquerade the packets that need to go out to the Internet for the virtual machines. I have installed HA and drbd8 via the Debian packaging system. I configured HA using the Installing Heartbeat (Newbie) screencast tutorial. Similarly I configured a very simple setup of DRBD following the documentation. Now then, lets get into the details of my progress so far.

Networking Woes:

Ok, so the networking part of this mission was a slight barrier. I recall in the past I struggled to get multiple virtual machines to communicate with each other with VirtualBox. This time I seem to have planted that issue right on its ass, and I'm going to explain just how I did it.

In order to get virtual machines to network we need to change the guest operating systems from "NAT" to "Host Interface" in the "Network" settings. If only it were this simple! Well we actually need a "TAP" interface for the guest operating system to use. Lets hop into the trenches shall we?

First we need to let the kernel know wish to act like a router, forwarding packets:

Note this can also be set in /etc/sysctl.conf then it will not have to be set at every boot.
echo 1 > /proc/sys/net/ipv4/ip_forward

Next we need to create our TAP interfaces:

The interface names are arbitrary but it is important that the same name is used when assigning them to each virtual machine.
tunctl -t tap0 -u username
tunctl -t tap1 -u username
ifconfig tap0 up
ifconfig tap1 up

Now lets create a bridge interface and add our TAP interfaces:

The IP assigned is arbitrary but do make note of it
brctl addbr br0
brctl addif br0 tap0
brctl addif br0 tap1
ifconfig br0 up
ifconfig br0 192.168.2.1

Now assign each one of the TAP interfaces to each virtual machine and start them up. Assign an IP address to each virtual machine that is in the same network as the bridge interface on the host system. The virtual machines should be able to ping each other as well as the host system. Notice that they can not get out to the Internet though. For this we will need some help from iptables:

Beware that using MASQUERADE target is not technically proper with static IP addresses, however its the only way I can get NAT to work properly in this situation. The rule below should not be considered a permanent solution, I don't plan on leaving it that way at least.
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE

Now the virtual machines should be able to ping each other, and also make it out to the Internet, assuming that other barriers do not exist like firewalls etc.

I will end part 1 at this point. I will catch up on configuring HA and DRBD in part 2 and hopefully at that point also have some more information to share, for now its off to bed and preparing for Monday.

So long

 

Posted in , ,  | no comments

Dell Inspiron Zino HD Where Is Linux

Posted 7 months ago

Although I was extraordinarily excited about Dell's Zino HD I was quickly let down to find out Linux is NOT offered as an operating system choice.

At the base model (even adding some some features) the price point is great in my opinion. The base model of the Inspiron Zino HD can be had for just a little more than $200. I had read rumors that Linux was offered on the Zino HD, after attempting to customize one of the models I found there was no Linux option available. After a few days I called Dell and spoke to sales representative who assured me the Zino HD was not available with Linux. The rep was quick to push me toward another Inspiron for around $500 that came with Linux. At this point I explained that my interest was more involved with purchasing a unit that does NOT come with Windows, than a unit that is offered with Linux, even if a discount is not granted.

Still the response was the same.

If Dell does offer the Inspiron Zino HD with Linux or at least without Windows I will most certainly purchase a unit. Of course this assumes they will not only offer Linux on a high priced model. My guess is that Dell has some contract with Microsoft on the Inspiron Zino HD in relation to the new release of Windows 7.

Until then I'm off to find other low priced mini/multimedia computing solutions that are more open to the idea that not EVERYONE wants a Microsoft product.

Posted in ,  | Tags , , , ,  | 2 comments

Damn Capacitors!

Posted 9 months ago

I can not believe how unbelievably difficult it is to find a 470uF 10V capacitor that is less than 8mm in diameter. I need one that is about 1/4in (roughly 6mm). The fact that these are so difficult to find tells me that perhaps they are too small to begin with hence the reason they are failing.

Everything I find is 8mm or bigger! I need 4 of these to replace bulging capacitors in a Gateway machine that went south. Its still a very capable machine though and I would love to ressurect it from the dead.

Back to scraping the net to hopefully find a match.

Update: I did find the capacitors I needed at the following eBay stores:

PC Motherboard Capacitors Store
A website also exists at:www.capselling.com

sunpec

Posted in  | Tags , , ,  | no comments

Replacing Square Brackets With Sed

Posted 10 months ago

For me the following do not work:

sed 's/(\[|\])//g'
sed 's/[[]]//g'
The following do work:
sed 's/[][]//g'
sed -e 's/\[//g' -e 's/\]//g'

Example:

echo '[foobar]' | sed 's/[][]//g'
>foobar

echo '[foo]bar' | sed 's/[][]//g'
>foobar

The environment is Debian 4.0, GNU sed version 4.1.5.

Posted in ,  | Tags  | no comments

Setup Amavisd-new

Posted 10 months ago

I finally configured amavisd-new with my Postfix configuration. It is a simple setup using only ClamAV and Spamassassin. However I do want to implement DKIM through amavisd-new of course that requires a newer version of amavisd-new than is in the packaging system of the release of Ubuntu I am running.

Further I would like to switch my Linode to Debian over Ubuntu.

It is safe to expect some downtime soon likely tonight as a result of upgrading through two releases.

I will post a part 2 once the upgrade is complete and I implement DKIM with the details of what I did.

Posted in , , ,  | Tags , , , , , , , ,  | no comments

Rocky Migration

Posted 10 months ago

So the move to Typo has not gone as smooth as I'd hoped. Not to any fault of the Typo software, I feel that the issues are mostly related to typical migration from a custom built application to a prebuilt solution. Furthermore I am not turning back by any means. I know that once I get some of the details ironed out the site will get more attention and I will be much happier with it.

I need to tweak my Capistrano deployment scripts to be Typo friendly. Some confusion seems to exist when Capistrano tries to restart Typo, I have concluded that when Typo tries to stop the current running daemon it cannot find the pid.txt because it exists in the previous release which has already been unlinked. Some simple Capistrano magic will fix that.

I am also having some issues with themes. They worked fine at first but now it seems that only the default Typo theme actually installs its images and stylesheets into public. Each theme when active installs its custom images and stylesheets into public/images/theme and public/stylesheets/theme. The proper URL's are not generated either.

Lastly I have only migrated in the old blogs, I have migrated categories but none are linked up yet. I will probably migrate the comments, but since so few exist I have prioritized getting the site functioning the way I want it.

Posted in , , ,  | Tags , , , , ,  | no comments

Considering Moving To Typo

Posted 10 months ago

I am considering moving the site to Typo to replace the blog and using Flickr to manage the photo album. I am not sure what I will do about the Utilities. I need to see if I can easily extend Typo or not.

The main reason for this is simply that I end up spending more time managing code and adding new features than I do managing the content of the site. I have yet to dive into Typo and see what capabilities are there. Hopefully if I decide to make this migration, the change will cause me to upload more photos, write more blogs about stuff nobody cares about, and just improve the content of the site in general.

Sean

Posted in , , ,  | no comments