Archive for the ‘Tech Tips’ Category

Free Helvetica Font Alternative

Friday, September 3rd, 2010

People like Paula Scher despise the classic font Helvetica, but to my untrained eyes, it is a fantastic font for clean headings. Unfortunately, the many variants of Helvetica are not free. Linotype and Adobe both have their implementations, but they cost around $25 per variant. That’s just too much to pay for a font. What to do?

Today, I was working on a project where Helvetica would have came in very handy, so I did a web search and came upon a FREE decent alternative released under the GPL by Red Had a few years ago called Liberation Sans, designed by Steve Matteson. Obviously, it’s not exactly like Helvetica, but it’s close enough to fool the average (read: non-typesetter) person. Besides, it looks a lot better than Microsoft’s ripoff Arial. Check out the sample below that shows all four variants that are available:

liberation_sans_sample

For me, this is an excellent find. Very importantly, it is released under the GPL so you can use it for anything you like, as long as you promise to allow others the rights to always use it too.

If you like Liberation Sans, click here to download it. Many thanks to Red Hat for allowing this great font to be freely used and distributed.

Handbrake 0.9.4 Encoding Settings that Work with a Blackberry Curve 8310

Sunday, January 31st, 2010

Through a lot of trial and error, I finally figured out what video encoding settings in Handbrake 0.9.4 produce video that will play on my Blackberry Curve 8310. Here’s the settings I used to produce working video, broken down by options or the tabs in Handbrake:

  • Container
    • MP4 File
  • Picture
    • Width:320
    • Checked Keep Aspect Ratio Box will automatically set properly proportioned Height.
  • Video
    • Video Codec:MPEG-4 (FFmpeg)
    • Two-Pass Encoding box checked (to improve quality)
    • Framerate:24
    • Average Bitrate radio button checked @ 768kpbs
  • Audio
    • Audio Codec: aac (faac)
    • Mixdown: Stereo

Any options I have not listed were left to the default settings. The video produced by this is perfect quality for a screen as small as a Blackberry. I’m not a videophile, though, so your mileage may vary. As far as speed of the encoding, a 44 minute episode of  House ran through a Two-Pass encoding in about 9 minutes on this system.

Introducing Phind, a simple PHP script for finding foreign keys in MySQL tables

Tuesday, October 27th, 2009

For years, I have wanted a way to programatically find foreign keys in MySQL tables using PHP. After a lot of thought, I have written Phind. Phind basically consists of one function getForeignKeys() whose only parameter is the table name. If that table has foreign keys, Phind returns a multidimensional array containing an index for the key as the first index, and the part of the key as the second index.

My ultimate goal is to use Phind to create a PHP CRUD generator written entirely in PHP. That’ll probably be a long way off, though. I just don’t have time to sit down and finish something like that right now.

The source code for phind is here: Simply rename the file from phind.txt to phind.php when you save it. You can also go here to see Phind in action on a table in a database on my server named ‘contacts.’ Eventually, I will add more examples to the documentation included with the phind.php file, but for now, it’s sparse. However, I’m sure there are enough PHP guys who have been looking for a way to make sense of what foreign keys are in a table and where exactly they are pointing to.

I hope this helps somebody.

How to Fix Image Resizing Problem in the Arthemia WordPress Theme

Friday, July 31st, 2009

I downloaded the Free Arthemia Wordpress theme the other day to use with my students’ FBLA site. I really like how the theme looks like a professional newspaper like the New York Times as wells as how easy it is to add Headline and Featured stories just by assigning a category to them.

One thing I could get working was the images that show up with the Headline and Featured stories when you add the Image custom field to an article. The images would just show up as a red x. When I tried to view them in Firefox, I got the following error:

finfo_open(): Failed to load magic database at ‘/usr/share/misc/magic’.

After poking around on the Internet for a minute, I found that there are some files that PECL finfo uses to sniff out the MIME type of files. Apparently, the files are some sort of flat file database that holds, well, MIME types.  Luckily, I extrapolated a solution after seeing a workaround on a forum. If you’re using Arthemia Free Version 2 and are having the same problem getting your images to load, here’s all you must do.

Replace lines 216-220 of the /wp-content/themes/arthemia/scripts/timthumb.php with the following code:

$file_cmd = "file -ib  \"$file\"";
exec ($file_cmd, $exec_output);
$mime_type =  $exec_output[0];

That’s it! The only other thing you have to make sure to do to get your images to resize and show up properly is to put the absolute path to the images without your domain. So, in my case, I have an image whose full path is:

http://breathittfbla.com/wp-content/uploads/2009/07/foreman.jpg

To make it work, the value for the Image custom field has to be set to:

/wp-content/uploads/2009/07/foreman.jpg

After changing those lines of code and then putting the right file path in the Custom Field, Arthemia is resizing and displaying images in Headlines and Featured Stories without issue.  I hope this helps somebody!

WordPress Meta junkies: Use Headspace2

Sunday, July 12th, 2009

I haven’t been a Wordpress user very long, but I have found one plugin that eased a big issue with me: Good meta descriptions in Wordpress posts, categories, and archives. Out of the box, WordPress isn’t really equipped o use Excerpts as the Meta Description for a post. Enter Headspace2, which allows WP authors to edit Meta Descriptions to their heart’s content.

Solution to Deployment issue using Netbeans 6.5.1 and Tomcat 6.0.22 on OX 10.5.7

Thursday, June 25th, 2009

Somehow I always find myself in the middle of a very strange computer problem. This particular issue is a result of my wanting to learn to write JSP applications using Netbeans 6.5.1 with Tomcat 6.0.20. I don’t have time to do a full writeup, so here’s a nutshell version of the problem and my solution:

Problem

When I tried to use the Deploy option to push my Netbeans project to my Tomcat webapps folder, the deployment would fail. I could manually copy the .war file into my Tomcat webapps folder and everything would work fine. But, I thought, “Why should I have to do this if Netbeans is supposed to do it for me?”

Solution

Since I’m running OS X 10.5.7, I opened the Netbeans configuration file at

/Applications/NetBeans/NetBeans6.5.1.app/
Contents/Resources/NetBeans/etc/Netbeans.conf

and added the following to the netbeans_default_options line:

-J-Djava.io.tmpdir=/tmp

Note: This must be added within the double quotes. Also, I didn’t distrub anything that was on the line already but merely added that tidbit of code.

Explaination

I found this piece of advice buried deep in a forum. Apparently, Netbeans puts the deployed files into a temporary folder before deploying them. The temporary folder it tries to use on OS X isn’t accessible (a permissions problem I guess). Adding that snippet of code tells Netbeans to use the OS X default temporary folder tmp for its intermediate work.

Enjoy!

What to do if Cygwin Does Not Work Properly in Vista

Friday, May 8th, 2009

So, I tried to install Cygwin on my Windows Vista Business machine today.  The install, via the setup.exe that downloads what you want to install, launched and completed as it always had in WIndows XP. I was pleasantly surprised considering how Vista has refused to install things normally before. Just when I was about to be happy, I clicked on the Cygwin Bash Shell shortcut, the prompt came up, but no commands worked.  Not ls, not dir, not anything! I let out my usual sigh of annoyance and cursed Vista (for the millonth time).

I then proceeded to Google to find a solution.  Nothing. The forum posts pleading for help were responded to with the usual worthless suggestions (such as “Don’t use Vista“) and RTFM talk. I don’t really want to use Vista, but it has been forced upon me and I have little recourse but to use it.  Anyway, after trying a few things that didn’t work, I finally figured out what to do: Set your system path environment to the Cygwin bin directory and everything works fine!

To do that, all you gotta do is follow these simple steps:

  1. Install Cygwin normally with the setup.exe program, selecting what you want to install.  For the purposes of this walkthrough, I’m going to assume you installed Cygwin in the default C:\cygwin location.
  2. Click on the Start Menu (or Windows Orb, for those of you Vista fanboys).
  3. Right Click on Computer, and choose Properties.
  4. Click Advanced system settings in the left-hand context sidebar (and accept the UAC prompt to go proceed as an Administrator).
  5. Click the Advanced tab
  6. Click the Environmental Variables button at the bottom of the dialog.
  7. In the Environment Variables list box, find the variable Path and double click on it
  8. In the resulting Variable Value box, move your cursor to the end of the line of paths already there and add ;C:\cygwin\bin Do not forget the semicolon before the path!

That’s it! Remember, if you installed Cygwin somewhere other that C:\Cygwin, you’ll have to change your path to be different from my example. I’m hoping that if you did a non-standard install that you can figure out how to adjust the path!  I hope this helps somebody!

Using MS Server 2003 Admin Tools with Vista

Tuesday, February 24th, 2009

Today I tried running the Windows Server 2003 Admin tools with Vista Business and was a little surprised when I got the error message:

MMC could not create the snap-in.

I guess the only reason I was shocked was that I got no errors whatsoever. The install went just fine. Normally, when you attempt to install an older Microsoft tool that isn’t compatible, Vista will freak out and let you proceed no further.

After a some Googling (and several leads that did not work), I found a fix on the Microsoft Knowledge Base: http://support.microsoft.com/kb/930056

The fix was actually quite easy: Finding the fix was another story!

Compiling Squid in Ubuntu 7.10

Sunday, March 23rd, 2008

Compiling Squid 2.6 in Ubuntu is easy, once you know that there are different command line options you must use aside from the defaults (which are specific to BSD-flavored systems).  Note that I specifically enabled digest authentication with the –enable-auth=digest  switch because our intended application of Squid  needed a more secure password transmission method than Basic Authentication.   Here’s some general steps:

  1. Download and upack the Squid source. I used Squid 2.6 for this.
  2. Open a terminal and change to your Squid source directory.
  3. Type the follwong and press enter:

    sudo ./configure –enable-auth=digest –prefix=/usr –localstatedir=/var –libexecdir=${prefix}/lib/squid –srcdir=. –datadir=${prefix}/share/squid –sysconfdir=/etc/squid

  4. After a hundred lines or so scroll by, enter the following:

    sudo make
  5. After several, even more ugly lines go by, type the following:

    sudo make install

  6. There is no way to set the default location of the log files with Squid using configure, and I couldn’t get the recommended patch to work, so I came up with an easier solution.  Issue the command:

    ln -s /var/log /var/logs

That’s it. Squid is installed. Now, I didn’t say Squid is actually configured on Ubuntu at this point.  Getting it all set up is a story for another day! Depending on several factors, you’ll have to do a lot of chmods to make sure the permissions are right! Someday, I will probably post my PHP-CLI scripts that control user authentication and site blocking! Until then, good luck.

Xfolders 1.5.1 Crashes in Leopard (and how to fix it!)

Friday, February 1st, 2008

I’ve had my MacBook now since September and I really like it.  Apple has a good thing going. That said, some things about OS X are strange, such as you can’t see certain parts of your filesystem with Finder unless you a) resort to some odd Terminal commands that need to be flipped on and off depending on how much of your filesystem you want to see or b) get a wonderful piece of software such as Xfolders to let you see everything when you need to.  Xfolders is great. It was one of the first things I downloaded and installed when my MacBook still smelled new.

Then I did something stupid: I upgraded to OS X 10.5 Leopard.  I haven’t had as much trouble as some who have taken the plunge, but one side effect was that in Leopard, Xfolders would crash anytime I tried to click on the root drive (cheerfully known as Macintosh HD on my MacBook). No matter which pane I clicked on, attempting to access root would bring up the OS X crash log.  Oh the horror! I may as well be running Vista! :)   After much agonizing and digging around, I found the solution to the problem:

  1. Open a new Terminal window
  2. type rm ~/Library/Preferences/com.kai-heitkamp.Xfolders.plist and press Return

That’s it! I’m not sure why, but sometimes, Leopard can corrupt the Xfolders configuration file, which causes Xfolders to crash upon launching.  By simply deleting this configuration file in your home directory, Xfolders can once again give you easy access to viewing 100% of your files whenever you need to.  I hope this helps someone!

Author’s Note (February 18, 2008):  I have some reports that this was a problem with Xfolders on some versions of OS X prior to 10.5.  This fix may work for OS X 10.4 Tiger sometimes, too!