Wednesday, November 30, 2011

Hebrew Flash Card Web App

While evaluating different web app frameworks, I put together a little web app to help me get back up to speed with my biblical Hebrew vocab. And if you know anything about trying to read the Hebrew Bible, knowing a good amount of vocab is (unfortunately) essential. The flash card app is built using Sencha Touch's framework and is at http://hebrewflash.me/ ... check it out on your smartphone or iPod touch. The chapter divisions are based on Basics of Biblical Hebrew by Pratico and Van Pelt (Zondervan) so it is a great free vocab tool for students using this textbook.

Thursday, November 17, 2011

Partition and Mount a Drive on CentOS

I have a few servers over at Softlayer. I recently procured a monthly computing instance with an additional 200 gigs of drive space. Thing is, the extra HD space doesn't come partitioned, formated or mounted. So, here is what you do:

First things first. Find the name of the physical drive: fdisk -l

This command will return a list of drives and information about each. You should find one that hasn't been partitioned with a name like /dev/sdb (or in my case /dev/xvdc for a computing instance) or similar. Check the size of the drive to make sure it is what you are looking for.

Next, partition the drive: fdisk /dev/xvdc (using the name of the drive, of course)

Once in the fdisk utility, press p to print the partitions to the screen. There should be none, because you haven't created any yet. If there are, are you sure you are using the right drive?

Next press n to create a new partition, press p for a primary partition, 1 for the first partition, and then use the default first and last cylinder (unless you know what you are doing, of course). Once this is set up, you can press p to make sure it worked and then finally, and most importantly, press w to write the changes to disk.

In the previous command, you'll get a slightly different name for the partition you created. It probably added a letter, something like /dev/sdb1 or /dev/xvdc1 would be right. You'll need it to format the drive: mkfs -t ext3 /dev/xvdc1 (I've used the ext3 file system, here, because it suited me just fine and is probably the most common.)

Now, where would like the disk mounted? You'll have to create a folder as the mount point. If you want the disk to be used for a new /data directory, then you'll have to create a folder with this name: mkdir /data

Next, add the drive and mount point to the /etc/fstab file so that it will be mounted at boot time. Use your favorite text editor, as they say. I used vi /etc/fstab and I added a new row, matching the spacing of the other rows: /dev/xvdc1   /data    ext3   defaults   1 2

Lastly, you mount the drive using mount /dev/xvdc1 and you are all done.

Head on over to cd /data and check it out. Or run mount without parameters to check out the details.

PS. Here are a couple websites I used when I was working through this problem myself.

Wednesday, November 2, 2011

Synchronize Facebook Status & Twitter

There is so much unhelpful junk out there on the web when you do a Google search on synchronizing your Facebook status' with Twitter. So, a quick post.

If you want your Facebook status to auto-tweet, go to http://www.facebook.com/twitter/

If you want your Tweets to auto-Facebook-status-update (why is there no verb for this?), go to http://apps.facebook.com/twitter/

It's just a slight change in the sub-domain. You don't need any 3rd part software or other service. Facebook and Twitter worked this out among themselves already.

Monday, October 3, 2011

jQuery Mobile Date Picker

I've been working with jQuery Mobile on a new form. I have the need for a datepicker and was really impressed with what a man by the name of jstage has put together. It is really thurough. So, if you are looking a flexible, mobile date picker, this is a good one.

Wednesday, September 28, 2011

2 reasons I dislike Google's new look

Google has been rolling out a new look lately. They are going with a very simple gray and red scheme (and orange in blogger?) for most of their products. I like the idea of it. I also think it is very attractive. But I also have 2 problems with it. And they both have to do with the usability of the new design.

1) They removed all but two visual cues. They've oversimplified it. When our eyes scan pages they pick up visual cues as to what is important and where to find things. It is very quick and very subconcious. Google used to have a lot of visual cues around the page with their old, colorful look. Now, they have red buttons, blue search buttons and everything else is gray. The red indicates something important. Everything else, they are saying, is not important. The problem is that is WAY over simplified. The fact is that this binary visual cue system (that is, red or gray) really slows me down. It is hard to find things quickly or to even orient myself on a page. I even have to think more when I try to figure out what Google service I am using. Their new look doesn't help my brain instantly digest a page. It slows me down because it is ultimately camouflaging the entire page of non-red text links and text interactions in a sea of gray.

2) The new look also makes lots of space for the top of the page. The Google search bar is prominent and then the actions. Then the rest of the page, the area I spend most of my time working and interacting with important data (whether it is a calendar, email list or voicemail transcripts), is now smaller. Not a lot smaller but enough that it really is annoying. This area should be bigger if they are going to change things, not smaller. This is the most important part of the page. The search bar does not need 1/4 of the site. Search is a single input and I spend only a fraction of my time there.

Friday, September 16, 2011

WordPress - Template for Parent Slug

WordPress allows you to create special template files for each category. You can name these theme template files cateogry-ID.php or category-SLUG.php, which is nice. However, if you are viewing a category and it does not have its own template, WordPress doesn't look for a parent template file. It just skips that. In lui of creating a template file for every child category (which would be a real pain), I found a nice script that I've edited and improved to provide expanded support (it didn't support slugs in the template name).

 Place this in your functions.php file:
// Use a parent category slug if it exists
function child_force_category_template($template) {
	$cat = get_query_var('cat');
	$category = get_category($cat);

	if ( file_exists(TEMPLATEPATH . '/category-' . $category->cat_ID . '.php') ) {
		$cat_template = TEMPLATEPATH . '/category-' . $category ->cat_ID . '.php';
		
	} elseif ( file_exists(TEMPLATEPATH . '/category-' . $category->slug . '.php') ) {
		$cat_template = TEMPLATEPATH . '/category-' . $category ->slug . '.php';
		
	} elseif ( file_exists(TEMPLATEPATH . '/category-' . $category->category_parent . '.php') ) {
		$cat_template = TEMPLATEPATH . '/category-' . $category->category_parent . '.php';
		
	} else {
		// Get Parent Slug
		$cat_parent = get_category($category->category_parent);
		
		if ( file_exists(TEMPLATEPATH . '/category-' . $cat_parent->slug . '.php') ) {
			$cat_template = TEMPLATEPATH . '/category-' . $cat_parent->slug . '.php';
			
		} else {
			$cat_template = $template;
			
		}
		
	}
	
	return $cat_template;
}
add_action('category_template', 'child_force_category_template');

Monday, August 29, 2011

JavaScript Array Scrambling

Ever need to randomly re-order an array in JavaScript? I have. And, unfortunately, there is no native support for a function like shuffle() in PHP.

I found a few people suggest this technique, but I have found it to not be very good. The elements weren't all that random especially for the first and last elements in particular (they were usually one of two values).

myArray.sort( function(a, b) {
return Math.round((Math.random() * 100) - 50);
});

It uses the native sort() function requires a function that will compare two values to determine which one comes first. If the number returned is negative it indicates that the 'a' item goes first and vice-versa if it is positive.

I found the following function to be more random:

function mixArray(arrayIn) {
var arrayOut = [];
var origLength = arrayIn.length;
for (var x = 0; x < origLength; x++) {
var randIndex = Math.floor(Math.random() * arrayIn.length);
if (randIndex == arrayIn.length) randIndex--;
arrayOut.push(arrayIn.splice(randIndex, 1)[0]);
}
return arrayOut;
};
myArray = mixArray(myArray);