Offshore Recruiters

Back in 2005, the Information Technology industry in the United States began offshoring software development at a rapid pace. Suddenly there was a booming IT industry in India, but a floundering one in North America.

It was a grand experiment… that failed.

As project lead times spiraled into months, Quality Assurance became almost non-existent.

It’s turns out that all the money companies thought they would save wasn’t worth the low quality of products they were getting. You really do get what you paid for.

One interesting side effect is that I’ve started getting contacted by recruiters in India. Mind you, they always claim that they are in New Jersey, Chicago or California, but the telephone connections are flaky and the accents often incomprehensible.

I have nothing against companies trying to make money, but I find it ironic that they are trying to profit from the IT jobs they are losing. It’s pragmatic if nothing else.

I do however tell them all the same thing. Thank you for your interest, but I only work with companies that maintain a physical presence in Columbus Ohio (where I live).

Copy an existing MySQL table

Occasionally, it’s helpful to run complex queries against the data but you would prefer not run a risk of doing a mass update against live data. Maybe you would just like to create a backup. Either way, it’s really easy to replicate existing data.

You simply need to execute two commands.

10
CREATE TABLE products_new LIKE production.products; INSERT products_new SELECT * FROM production.products;

That’s all there is to it. It’s pretty fast too. I’ve been able to copy large tables with lots of fields in a matter of minutes.

Validating email with PHP 5.2 or higher

For years, we’ve all used variations on various methods to validate email, usually, some complicated regular expression (regex) that checked the format for us.

Since php 5.2, we’ve had a much simpler built in filter.

10
11
12
13
14
15
16
17
18
function checkemail($femail) {
	if (filter_var($femail, FILTER_VALIDATE_EMAIL)) {
  		// The email address is valid
  		return true; 
	} else {
  		// The email address is not valid
  		return false; 
	}
}

It’s much easier, cleaner and above all, faster.

PHP Wrappers, Reading XML with php://input

Most of us are used to utilizing the request object in PHP to access the associative array created by form posts. Most traditionally, $_GET, $_POST or if you are really lazy like me, $_REQUEST.

Newer versions of PHP (5.1+) also allow direct access to input streams. It’s a little less memory intensive than traditional ways, though you should be aware that it cannot be used when forms are submitted with enctype=”multipart/form-data” because of their reliance on writing submitted resources to disk.

More impressively, it allows access to ANY data input to PHP

I recently wrote a server API that had to accept XML objects and parse them for data.

10
11
12
$xml_object	= file_get_contents('php://input');	# read submitted xml
$xml		= simplexml_load_string($xml_object);	# extract contents into useable form
$id 		= $xml->id;

Once the php input data is stored as an object, you can parse it with the built in PHP function simplexml_load_string which immediately makes individual node values accessible by their name.

jQuery Child Inheritance

See the DEMO

This is one of my favorite examples of how versatile jQuery is. A complex requirement made simple with child inheritance.

Recently, I was asked to make a none of the above option for a checklist. Basically, if any of the options were checked, “None of the above” would remain unchecked. If “None of the above” where checked, it would deselect previously selected options.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<html lang="en">
	<head>
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
	</head>
 
	<body>
		<script type="text/javascript">
			$(document).ready(function() {
				$('#nota_wrapper').delegate("input", "click", function() {
					if ($(this).attr('id') != 'nota') {
						$('#nota').attr('checked',false);	
					} else {
						$(this).closest('#nota_wrapper').find('input:checkbox').attr('checked',false);
						$('#nota').attr('checked',true);					
					} 
				});
			});
		</script>
 
		<form action="test.html" method="post">
			<div id="nota_wrapper">
				<input type="checkbox" name="child[]" id="ch1" value="1" /> <label for="ch1">Child 1</label><br />
				<input type="checkbox" name="child[]" id="ch2" value="2" /> <label for="ch2">Child 2</label><br />
				<input type="checkbox" name="child[]" id="ch3" value="3" /> <label for="ch3">Child 3</label><br />
				<input type="checkbox" name="child[]" id="ch4" value="4" /> <label for="ch4">Child 4</label><br />
				<input type="checkbox" name="child[]" id="nota" value="n" /> <label for="nota">None of the Above</label><br />
			</div>
			<input type="submit" value="submit" />
		</form>	
	</body>
</html>

As you can see. It’s pretty straight forward. All of the checkboxes exist as elements within the nota_wrapper div. That id could have just as easily been assigned to the form or to a wrapper around the form. We then simply delegate the click function to the nota_wrapper. When a click event occurs, it looks to see if anything other than the nota checkbox was clicked. If it was, it sets the nota element checked value to false.

If the nota element WAS checked, it removes any checked values from and of the other child checkbox elements.

See the DEMO

The Queer Man’s Guide for Straight Girls (QMGFSG)

QMGFSG_landscape

Hey gang. I’ve been told so many times that I should write a book. What many of you don’t know is that I actually am. It’s really mostly a part time hobby. I don’t really expect it to go anywhere, but who knows. Here then is the preface and an excerpt from Chapter One:

The Queer Man’s Guide for Straight Women
By Daniel Saint James

Preface

Oh god. Not “another” guide written by some self involved twit with a laptop. Let’s face it. Every swinging dick on the planet has advice for you. Opinions are like assholes. Everyone has one and they all stink (unless you shell out sixty bucks for a bleaching kit, but more on that later).

Why would you want to read “this” particular guide. What makes “this” one special? Well I’m glad you asked (just play along here). “Queer Eye” meted out wonderful advice to hapless straight men. “What Not To Wear” attempts the same trick with straight women with mixed results (WNTW is technically not a gay show, but when one of your advisors is a gay man, that tends to be a given). There are dozens of guides, television shows and websites purporting to be “the” solution to all of your problems.

I’m not here to do that. This book is about obtaining the perspective you need to figure things out on your own. Not about giving you the answers to things. Give a man a fish and you feed him for a day. Teach a man to fish, and you’ve added a new competitor to the already over crowded fishing industry.

Sure, you will find plenty of, “Maybe you should try this” and lots of “Never, never under any circumstances do this” but think of it like Algebra 1 class, where you’re given the basics that you need to solve larger more complex problems. The only difference is that I’m not a fat man in polyester pants and a short sleeve button down shirt with pit stains on it.

Who should read this book? Well, personally, I think everyone should, but that’s because I have bills to pay. Specifically, this book is written for single heterosexual women between the ages of 25 and 45. I think parts of it might be appropriate for anyone. Granted, there may be parts that AREN’T appropriate for ANYONE.

But there. I’ve outlined my target audience. My editor is no doubt having a seizure right now. Let’s get on with it.

How am I qualified to give advice to love lorn spinsters? I’m a 42 year old bisexual father of four. I have a gay daughter, a bisexual daughter, a straight son and an infant daughter of un-determined sexuality (at least until she’s old enough to figure out what she is). I’ve dated men, I’ve dated women. I have a ton of advice, but it’s not about what you should do. Basically, it’s a list of things you shouldn’t do. Why am I an expert? Because I’ve made a lot of mistakes. Learn from my mistakes. It may be that the purpose of my life, is merely to serve as a warning to others.

I haven’t given up. While love is a fairy tale based on neurochemistry, there have been precedents. I do think it’s possible. Beyond a shadow of a doubt, I HAVE figured out what not to do.

Call me a “Hopeful Romatic”, but I know that the right person just might be out there. The real question for anyone is: “Am I ready to find them?”

Think of this guide less as a “guide” and more of an open letter from your queer best friend that you never have to buy drinks for (unless you really want to).

Chapter One
Get Over Yourself

“You would worry a lot less about what people were saying about you, if you realized how little they were” – Stacey G

No one will ever care more about you than you do. That’s the truth. You’ll “hear” lots of people say otherwise, but when push comes to shove, we always look out for number one. Your mother “might” care almost as much for you as you do, but I doubt it. Consider this possibility, especially if you have siblings, a step father, or a family cat.

You may occasionally meet men who seem to have unnatural relationships with their mothers. When you meet them, run. They do. There is nothing more unnatural then a thirty-four year old man who still puts his mother first, unless of course, she’s the Queen of England.

Just because we are our own built in number one fans, doesn’t mean that anyone else will think that. Ever. This is a very real possibility that you need to come to grips with before we can go any further in this book. When someone tells you that you are the most important thing in the world to them, you need to ask yourself what else they are lying to you about.

I’m not trying to be cynical here, and I’m not trying to suck the joy out of any relationship you might have. I’m just trying to get you to admit the truth to yourself.

The person you pretend to be when you are around others is only half as interesting as the person you actually are. Don’t be afraid to let those around you see you for who you actually are. You might be surprised by the number of people that suddenly list themselves as your friend.

The truth is, we can usually only guess at what the people around want us to be anyway. Generally, they want us to be silent so that they can talk about themselves. The easiest way to be the most interesting person at a party, is to ask everyone else about themselves.

About the only time people actually take notice of us, is when we do something in incredibly poor taste. Then they LOVE to talk about us. Lets not worry about this particular situation right now, but we will address that later in the book.

Right now, we need to make you realize that no matter how fabulous you think you are, the people around you only get about ten percent of that off of you. That’s all right. Would you really want everyone to worship you and hang on your every word? Well, maybe you would, but for the sake of argument right now, we’ll say that you don’t.

Perspective can be a bitch if it happens too fast. Cosmologists and Mathematicians have gone insane trying to fathom the un-fathomable. We aren’t dealing with anything even close to that scale. We are going to keep it simple.

Fire is hot. Water is wet. In the grand scheme of things, you just aren’t that important. A freckle on a wart on a homeless dog.

Before I take this analogy too far, be mindful of one fact. It’s really all a matter of perspective. I’m sure even Nicole Kidman has days where she feels like no one loves her.

/end

The Evolution of PHP and the rise of Composer and Git

This could be a really long post, but I’m going to keep it pretty short. PHP has been around in various forms since 1994. That’s almost 20 years, which is ancient in the tech world.

It’s gone through many changes over the years but it’s truly beginning to mature. Like most evolutionary changes, it took a couple of things to accelerate the process.

There are a number of content versioning systems. Over the years, I’ve used most of them on various projects hear and there. Git has been around for a while too, but it was always relegated to the status of the “geek cvs” with it’s arcane command line interface, and often difficult to grasp methodologies.

I’m not sure when the community began to rally around git or why. Perhaps the community at large finally became savvy enough to comprehend it, or git itself had enough useful tools and utilities mature so that the entry point or ease of accessibility became more attainable.

For whatever reason, git has become the gold standard. Developers who aren’t using it are missing out on an effective tool to track code changes and a vibrant community of knowledgable people exchanging ideas.

Git made the next major step possible. A lovely dependency manager called Composer.

PHP has had dependency managers in the past. Everyone has wrestled with PEAR. It has still been a struggle to keep software up to date and organized. Spaghetti code has been rampant and often left in place simply because the only alternative was to re-develop an entire project from scratch.