jQuery: Detect enter key

By blobaugh, June 6, 2010 7:54 pm

Sometimes it is nice to be able to detect when the user has pressed the enter. This is great for super custom forms and Javascript games. Or maybe a totally custom built app that is waiting for the user to hit enter for some reason. But how to detect the enter key? Luckily jQuery once again comes in handy. Check out the following bit of code to grab the enter key.

 
$('#keyed_element').keyup(function(e) {
    if(e.keyCode == 13) {
        // Put your key handler code here
    }
});
 

New Website Launch: Leon Powers

By blobaugh, June 4, 2010 3:08 pm

Leon Powers commissioned me to build a website for his publishing entity Look-About-Books and his Boy Scout pseudonym Doc Hawk. It came together pretty well. Take a look and order his new book while you are there.

Visit Leon Powers Website

Finally Back on Linux in the office with Wubi

By blobaugh, June 3, 2010 8:02 pm

All of the Web Development office computers at Northwest Nazarene University are managed by IT and contain a Windows XP image that is parceled out over the network. I do not particularly enjoy working on a Windows machine and today I ran across the Wubi project again. It allows a user to install Ubuntu Linux on their Windows based machine to try it out. There is no need for any extra partitioning as Wubi installs as a Windows program. It sits inside the Windows partition and can be remove at any time through the control panel, thus keeping your Windows install safe. Upon computer boot the Windows boot menu will pop up asking you to choose to boot Windows or Ubuntu. It works great and now I have my full Linux development studio setup again. Should have figured there would be a project out there that let me have my Linux without hurting the Windows image. Go Linux!

Check out a screenie. I even got OSX to run inside VMware Player inside my semi-virtual Linux!

New Website Launch: Naomi Speed Skater

By blobaugh, June 3, 2010 7:53 pm

Naomi O'Hare is a Speed Skater on quad skate in the Nampa, Idaho area. Naomi is working on getting to the national competition and getting sponsored as a full-time skater. Naomi needed a website for fund raising information and to show off her sweet skills.

Visit Site

Naomi O'Hare Speed Skater

Apache: Force HTTPS with .htaccess

By blobaugh, June 3, 2010 7:47 pm

When HTTPS is required and you are working with an Apache server that parses .htaccess files, here is a handy snippet of code to put in the .htaccess that will cause the server to force every page in that directory and all subdirectories to use HTTPS by sending them to the HTTPS URI if they are not already there.

 
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
 

PHP: Function to force HTTPS

By blobaugh, June 3, 2010 7:44 pm

Quite often HTTPS is required for security reasons, but the question is how to force HTTPS with PHP?  Really it is quite simple. Copy the following function into your functions file and call it on top of every page that requires HTTPS to ensure it is used.

 
function forceHttps() {
 $pageURL = 'http';
 if (!isset($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != "on") {
	header("Location: https://" . $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
 }
}
 

PHP: Remove empty array elements

By blobaugh, June 3, 2010 7:37 pm

I've run across a couple instances where I needed to either remove empty array elements or perform the equivalent of a trim() on PHP arrays. There are two pretty good ways to do this.

The first way involves building a custom function to loop through an array and unset empty elements like so:

function arrayRemoveEmpty($Array) {
	foreach($Array AS $k => $v) {
		if($Array[$k] == '') {
			unset($Array[$k]);
		}
	}
	return $Array;
}
 

The second is probably a more preferred, and certainly faster way. PHP has a built in function to handle filtering out empty elements, and it can be extended to do virtually anything you can imagine. Take a look:

$Array = array_filter($Array);
 

Removing those pesky .svn folders Subversion l leaves behind with find

By blobaugh, May 27, 2010 7:27 am

When I am working on a project that unnecessarily has .svn folders strew about from Subversion I get a little annoyed. Luckily Linux has a solution (or is the solution!), the find command. find is a tool that can be very simple or very complex depending on how it is used. In this instance I simply want to find all directories names '.svn' and delete them.

Here it is, short, sweet, and removes all .svn folder in the sub-tree

find . -name ".svn" -type d -exec rm -rf {} \;

Enjoy!

Second Beard Culling

By blobaugh, May 22, 2010 5:27 pm

After my First Beard Culling I spent a couple days with my new look. The short strap and the longer goatee. Decided I did not really like that so I shaved off the strap too. Amazing what that small change did to how I look. It does seem weird now that no fur folds up on my face when I rub upwards from my jawline. That was kinda a neat feeling. I am liking the goatee for now, we will continue to watch and wait.

Diane Leclerc or John Wesley’s Grandfather in Disguise?

By blobaugh, May 21, 2010 9:34 am

I ran across a picture of John Wesley's grandfather on the Wesley Center website today. He bears a striking resemblance to Diane Leclerc, a religion professor at NNU. Is Diane the almighty John Wesley's grandfather come back to haunt us? You decide.

Theme by Blam Designs
Based on Themocracy