Validating Existence of a Nested Model in Rails
Posted by Daniel on 03/05/2010Validating Existence of a Nested Model in Rails
I'm a big fan of Nested Attributes in Rails. It makes my head hurt less, and forms look better. I did have trouble wrapping my head around one aspect of Nested Attributes through, and that was ensuring that a user could not have less than X nested models.
Renaming, Changing, or Moving Print Queues
Posted by Daniel on 02/12/2010Renaming Print Queues
Renaming printer queues on a Windows print server is easy. Getting all the client machines on your network to switch over to the new queue name is not easy. It is for this very reason that you'll see numerous print queue shares, each with the same driver, pointing to the same port on print servers.
If you have say 10 printers shared across 100 devices, this isn't as much of an issue. You use login scripts, or Group Policy to deploy the print queues across all of your systems. But if you have 80 printers shared across 500 devices, it can more troublesome. It's not practical to add all the print queues to eachmachine, and you probably won't be able to use Group Policy to deploy the printers based on relative physical location of the client machine to the physical printer. Scripting to the Resuce!
Installing id3lib-ruby on OS X Snow Leopard
Posted by Daniel on 10/30/2009I've got a rather large MP3 library, and it has started to become cluttered and unorganized. I decided to create a Ruby script that utilizes the id3lib-ruby gem. There are a few other options out there, but id3lib-ruby is a wrapper for the C library id3lib. It is pretty much full featured, allowing me to embed an album cover image directly in the MP3. I did have some trouble getting it installed however.
Install id3lib via MacPortsdwestendorf$ sudo port install id3lib ---> Computing dependencies for id3lib ---> Fetching gperf ---> Attempting to fetch gperf-3.0.4.tar.gz from http://distfiles.macports.org/gperf ---> Verifying checksum(s) for gperf ---> Extracting gperf ---> Configuring gperf ---> Building gperf ---> Staging gperf into destroot ---> Installing gperf @3.0.4_0 ---> Activating gperf @3.0.4_0 ---> Cleaning gperf ---> Fetching libiconv ---> Attempting to fetch libiconv-1.13.tar.gz from http://mirrors.kernel.org/gnu/libiconv ---> Verifying checksum(s) for libiconv ---> Extracting libiconv ---> Applying patches to libiconv ---> Configuring libiconv ---> Building libiconv ---> Staging libiconv into destroot ---> Installing libiconv @1.13_0 ---> Activating libiconv @1.13_0 ---> Cleaning libiconv ---> Fetching zlib ---> Attempting to fetch zlib-1.2.3.tar.bz2 from http://www.zlib.net/ ---> Verifying checksum(s) for zlib ---> Extracting zlib ---> Applying patches to zlib ---> Configuring zlib ---> Building zlib ---> Staging zlib into destroot ---> Installing zlib @1.2.3_3 ---> Activating zlib @1.2.3_3 ---> Cleaning zlib ---> Fetching id3lib ---> Attempting to fetch id3lib-3.8.3.tar.gz from http://voxel.dl.sourceforge.net/id3lib ---> Verifying checksum(s) for id3lib ---> Extracting id3lib ---> Applying patches to id3lib ---> Configuring id3lib ---> Building id3lib ---> Staging id3lib into destroot ---> Installing id3lib @3.8.3_1 ---> Activating id3lib @3.8.3_1 ---> Cleaning id3lib
SSH Key Generation with Capistrano and Ruby
Posted by Daniel on 10/05/2009Adding SSH Keys with a custom Capistrano Recipe
Capistrano is great for deploying applications, but the ability to write custom recipes makes it a valuable tool. I've found that every time I deploy a new Linux box, setting up SSH keys to avoid password prompts makes things easier. I am lazy, and can't ever remember the commands to execute this though, so I created a custom recipe to handle it for me every time.
Displaying multiple form fields for Nested Models
Posted by Daniel on 06/21/2009accepts_nested_attributes_for
Rails 2.3 brought around the ability to seamlessly nest models in forms. This works wonderfully, and saves a bunch of time, but what if you want to have multiple instances of said nested models? It is easier than you would think.
Success in the Tech Industry, and the Image it Requires
Posted by Daniel on 04/11/2009Image defines winners and losers
If you're in the tech industry, hopefully you know that the image your company projects means success or failure. If you don't know that, you need to change industries. Companies that are known for doing shoddy work doesn't get keep customers, and potential customers must be naive and uninformed to pay for their services. Companies that provide unfriendly, inaccurate, or shady customer service will loose customers before they've even stepped in the door. Operating a successful company isn't knowing what to do as much as knowing what not to do.
Backing up files with Ruby and Amazon's S3 Service
Posted by Daniel on 04/02/2009Always have a backup plan, and keep it cheap
I've been putting this off for a while, but I finally took the time to write a backup script for my Ubuntu webserver. Client priorities come first. There are basically three types of files that I need to backup.
- SQL data
- Dynamically added assets
- Git repositories
Since this isn't a lot of data, and everything is stored in flat files (I use SQLite, as the data sets will stay super small), and I set up a directory structure to where all of the above files are under the /var/www directory, everything is super easy. But, where to backup to? Amazon S3 to the rescue.
Eliminate Typing Repetitive Commands, such as Deploying Rails Apps with Capistrano and Git
Posted by Daniel on 04/01/2009Deploying with Capistrano & Git
If you aren't using capistrano for deployment, you are wasting your time. It speeds up the deployment process in unmeasurable amounts. It basically automates deployment, trimming the commands you type by about 5000%. Git makes version control easy.
As cool as it is, I still find myself typing:
dwestendorf$ git add . dwestendorf$ git commit -m "blah" dwestendorf$ git push origin dwestendorf$ cap deploy
Stop Spam with Javascript and Ruby on Rails
Posted by Daniel on 03/23/2009Spammers suck
We've all seen the blog comments. You know the ones I mean. The ones that reference pictures or videos, the kind that aren't exactly 'socially acceptable.' Spam has become a huge issue in today's world, especially spam delivered via email. We all hate it, but it comes anyway. Entire companies have sprung up just to stop it, and still it comes, relentlessly. That relentless annoyance has started spilling over to the web, in the form of blog comments, and forum posts. If you're fortunate enough to have a semi-popular website, you know that spam is a real issue.

iPhone OS 3.0 Beta vs. 2.X Jailbroken
Posted by Daniel on 03/20/2009iPhone 3G, 3.0 OS
Apple announced a new version of the iPhone OS this week, version 3.0. It brings a bunch of cool features to the table, like system wide copy/paste, MMS, turn-by-turn GPS, etc. If you're reading this, you probably already know about the features being added. Since I have access to Apple's iPhone Developer program, I have access to the beta version of the OS.
Uploading Multiple Files using Safari 4's multiple='true' attribute
Posted by Daniel on 03/18/2009Safari 4 and Selecting Multiple Files for Upload
I've long been in need of uploading multiple files via a web page. The truth of the matter is, HTML and HTTP aren't made for this. One file can be uploaded, but it's clumsy.
Websites have been creating workarounds for this type of feature for years. Some do it with Flash, which makes me quiver. Some do it by adding multiple file input fields to a form, which is not enjoyable for the end user. Safari to the rescue.

New Blog, new Design, first entry
Posted by Daniel on 03/18/2009Revamped design, new blog!
I've been rewriting my website for the last week or so in my free time. I've revamped the design, and completely rewritten the blog portion of the application. I wrote the application in the newest version of Rails (2.3.2) which was just released yesterday.
I've added an atom feed, gravatars, and the ability for visitors to edit their comments up to fifteen minutes after it's been posted.
Very exciting!!
