RSS
 

Archive for the ‘Programming’ Category

Hawkins Computer Services has an office!

28 Feb

Well after almost 2 years of working from home, we at Hawkins Computer Services finally have a real office space! About two weeks ago, Emmett went on a hardcore search for a good office space in the area that would suffice for the 3 of us. In the span of a week he signed the lease, got internet and phone installed, bought desks, computer equipment, etc, and generally got the place setup.

Entrance to Office

The couple of days before we officially moved in we brought equipment over and Jennifer, Ray, Emmett, and I got the new desks built, painted the walls, put up decor, ran networking, etc. Thursday was our first official day over there and we’re getting settled in. I can’t wait for our first full week over there… should help us all be more productive and improve our communication with each other and clients.

Left: My desk ~ Right: Ray's Desk

Left: My desk ~ Right: Ray's Desk

Ray and I occupy the front room of the office. We’ve got our desks facing each other and have all the power/networking stuff between them. Not that pretty, but a reasonable solution for now. I think we’re going to put a printer against the wall under the “square” on the wall.

My desk, desktop, laptop, etc

I have created my little corner. Emmett bought chairs and desks and monitors. I brought one of my spare desktops over to use for the time being and I’ve been bringing my laptop for…. well I don’t really know what… I just find it’s useful to have two computers sometimes :)

Kermit's Office

Kermit's Office

Emmett got the back office…there are a couple of chairs for clients on the opposite wall.

Contents of my top drawer

This is Tiffany’s favorite part. The contents of my desk drawer. CDs, network tester, tools, and a stash of taco sauce in case I get lunch one day and want some taco sauce. Not sure why that’s so hilarious, but she insisted on taking a picture.

 
 

Latest work – Internal Kiosk Site

27 Jan

I finally have something really cool to show from my job. We have a client who wanted a “Kiosk” in their rental office that guests could browse through the various units they have available. It did not need to do anything that different than our normal web work….choose arrival date, number of nights, number of guests, etc. The challenge was how to do it all with JUST a touch screen for input. The “kiosk” was going to be one of the new “all-in-one” MSI Wind Top PC’s with a 20″ touch screen.

Index Page

Index Page.... simple, no nonsense. Also -- Boring

I had some idea of what was going on since I built a small .mobi site for this company last year geared toward the iPhone/iPod Touch. It turned out OK, but was nothing I really felt stood out. It works, but I honestly don’t think it gets much attention. I’d like to revisit it sometime and make some improvements with what I’ve learned on this project.

Date and Nights Selection

The site will not be available outside of this office, but I’ve got some screenshots AND A VIDEO showing off the functionality. I’m not much of a designer, so it’s not as pretty as it could be probably, but it works I think. I’ll post a couple of the fun jQuery stuff I found/did as well. I think the most instructional and entertaining part was modifying the jQuery quicksearch plugin from www.rikrikrik.com to be able to use an on-screen keyboard.

And somehow I don’t have a screenshot of that…will update later :)

Rather than creating a separate keyboard and try to tie it into the event handling for quicksearch, I ended up extending the plugin, adding new functionality through the options passed during the .quicksearch() call so the keyboard was fully integrated. It took some trial and error, and it likely could be done “better”, but it works, and functions great.

$('table#cabin_names tbody tr').quicksearch({
				position:'after',
				attached:'#uber_wrap',
				labelText:'',
				inputClass:'sel wide',
				watchElement:'li.alpha_btns',
				keyboard: true,
				keyboardId: 'alpha_btns'
			});

The ‘watchElement’ option is the elements that should trigger the qs() function in quicksearch. ‘keyboard’ defaults to false, but when set to true, it renders the html to insert the keyboard and bind the events to do the proper stuff. ‘keyboardId’ just lets you define the element Id so you can style at will. This extension of the plugin likely has no real use beyond sites designed for touch screens, but it was still educational, and was an interesting introduction to plugins in jQuery. I’ve never written my own, but if I find some functionality I need in the future, maybe I can break into that field too.

# of Guests

Anyhow, there’s not much else to say. This site was designed specifically for this screen, specifically to run in Firefox, specifically in Fullscreen mode. If I had more time I think it could be made to be a bit more flexible, but I suck at CSS, and I just didn’t know how to make a few things flow fluidly on different sized screens. Enjoy!

kiosk_demo

List of cabins available for selected dates and # of guests

One of the other really fun things to write/integrate was the scrolling buttons. I realized after the initial design that having regular scrollbars just wouldn’t be usable with a touch screen interface. Theoretically I could have altered the Firefox userContent.css to enlarge the scroll bars to the point they would have been usable, but that just didn’t feel right. Once again, though, jQuery plugins to the rescue! I found a nice little scrolling plugin that allowed me to bind relative scroll positions with easing to click events on the fixed-position nav-box on the right side. Not sure I’m thrilled with how it looks right now, but at least it’s functionally complete. Can always tweak it down the road.

Fun screen to write. "Buttons" are actually labels for hidden checkboxes. jQuery styling changes make it look fancy

Individual cabin page...small photos are clickable to rotate through pictures

 

couple of fun and useful jQuery Plugins

12 Nov

I am far from an accomplished web developer, but jQuery is one tool that helps out immensely in writing javascript that “just works”. As many of you are aware, browser differences create all sorts of havoc when trying to write code that navigates the DOM. And writing code from scratch to validate forms is a serious pain in the butt. So here are a few jQuery plugins that might make your life a little easier in that regard.

First off, there is the the combined magic of the jquery Form plugin from malsup.com which creates a nice AJAX-submitted form with one quick line of code

$('#form').ajaxForm();

Optionally, you can pass the .ajaxForm() function any options that you would normally pass to a regular jQuery .ajax() method like so….

Now that’s fun, but it can be extended just a LITTLE bit more with the jquery validate plugin. Here we can define some simple rules in JSON format and the validation plugin will automatically display customizable messages for any errors that are found before submitting the form. The validation function takes the option submitHandler to create the ajaxSubmit event from the Form plugin above.

Here is an example:

$('#contactus_form').validate({
	submitHandler: function(form){
		$(form).ajaxSubmit({
			success: function(msg){
				alert(msg);
			},
			error: function(msg){
				alert(msg);
			}
		});
	},
	rules:{
		name:"required",
		email:{
			required:true,
			email:true
		},
		message:"required"
	},
	messages: {
		name:"Name is required",
		email:{
			required:"Email is required",
			email: "Email is in an invalid format"
		},
		message:"Some message to the staff is required"
	},
	errorLabelContainer:"#ajaxmsg",
	wrapper:"li"
});

Obviously you need to validate the data in whatever script you are handling on the server side, but the jQuery error messages are a great way to improve your forms usability and they can be styled to be attractive and make any input errors very clear to your users.

 
Comments Off

Posted in Programming, Websites

 

The Evils of PHP magic_quotes_gpc

17 Oct

I’m honestly surprised this hasn’t bit me before now. I was working on some OLD code that didn’t have much of any escaping built into it. Ok, I take that back. It had /no/ validation methods whatsoever. So I’m rewriting a good chunk of it so that doing things like entering a person’s name that happens to have an apostrophe in it actually works and doesn’t break the SQL query.

So, you take a query in php with no validation and add mysql_real_escape_string() to the values you are inserting/updating right?

Well, it turns out it’s not /quite/ that easy if the lovely php magic_quotes_gpc is on. The insert or update will succeed (albeit with nasty escaping characters in your data). But now go try and select row (imagining your searching for a name) using a query such as :

“SELECT * FROM guest WHERE name LIKE ‘%”.mysql_real_escape_string($name).”%’”;

MySQL at least will not find your data. If the name field you were searching for contained “test\’s name” and you searched for “test’s”, the escape function above would insert the backslash and if you viewed your MySQL log, it would appear that MySQL had gone off the deep end. You print your table and clearly see “test\’s name”, but your query (truncated to the relevant portion) ” name LIKE ‘%test\’s%’” returns zero results.

My first thought was to “escape the escape character”. So like a dumbass, I try this mess: addslashes(mysql_real_escape_string($name)). I figured there’s no way that they would make you jump through this many hoops to deal with escaped data, and in that regard at least I was right. It’s much, MUCH easier than all that. (For the record, not even the previous monstrosity worked. Playing with queries manually in MySQL’s CLI, i found if you ran a search ” LIKE ‘%test\\\\’s%’ ” it would FINALLY find it. But that looks terrible, and there’s no way that such a commonly used language would get that way if it required ugly unreadable code like that.

So, the solution I found after plenty of reading:

#1) If you have full access to your server (dedicated, VPS, your home test server), in /etc/php5/apache2/php.ini (for Ubuntu Server at least) change the line:

magic_quotes_gpc = On

to

magic_quotes_gpc = Off

Be sure to then restart your apache service using

sudo /etc/init.d/apache2 restart

#2) if you do not have root access to your server (Shared hosting, etc), you can use a rule in your webroot’s .htaccess. Add the line:

php_flag magic_quotes_gpc off

preferably in the top of the file so it’s nice and easy to find. I believe this will only work on linux apache servers. Windows does not support .htaccess for anything but password authentication I believe. But you should be running your apache server on linux anyhow :)

So, this was a really newb mistake, but I learned my lesson and figured maybe this could help someone else out.