How To Treat A Coder (a Geek)
I have been thinking a lot lately about what it means to write code. What is a coder exactly? I have asked myself the question, “Why are there some companies who understand how to treat coders, and others who do not?”
I have been thinking a lot lately about what it means to write code. What is a coder exactly? I have asked myself the question, “Why are there some companies who understand how to treat coders, and others who do not?”
I started working on a project that requires a single login for multiple user types. Because of the way my mind organizes things, I was having difficulty getting my mind around multiple models pointing to the same table in the database. It just felt messy. But I found this to be the best solution. I can provide single user login and keep the user functionality separated.
In this case, I have managers and tenants both pointing to the users table. I simply add a ‘type’ column to the user table to track what type of user it is. Then in my callback methods on the models, I set the conditions for the beforeFind and the beforeSave within each model to it’s corresponding type. This keeps both the data it displays and the data it saves in check and accurate. Here is what my manager model looks like.
<?php
class Manager extends AppModel {
var $name = 'Manager';
var $useTable = 'users';
// only return users where type = Manager
function beforeFind($queryData) {
$queryData['conditions']['Manager.type'] = 'Manager';
return $queryData;
}
// Ensure the Type is set to Manager before saving this record
function beforeSave() {
$this->data['Manager']['type'] = 'Manager';
return true;
}
}
?>
The same would apply to the tenants model. This works like a charm. It helps to provide excellent separation between user types without writing a lot of extra code to manage and check for the differences in user types.
Happy coding!
I have had some discussions with a project manager about how we use technology and the decision making process behind it. During one such discussion I raised issues with the choice of technologies for the development of some tools we were developing. The debate came to an abrupt end when he said, “The customer is always right.” This got me thinking. Is that true? Should it be that way?
Read more
I am getting more focused in my engineering career. Lately I have been feeling a strong desire to contribute to the open source community. Of course by open source community I mean contributing code and making it available to anyone who wants to use it… for free. As such, I decided to pick something I am passionate about. I have decided to create components, helpers, and other bits of code that are usable with the CakePHP framework. I have also decided to make these snippets of code available on GitHub.
Read more
So you have heard of the iMac, the iPod, the iPhone, and the iTouch. Well, Apple is at it yet again with the introduction of their newest hybrid of Mac and iTouch rolled into one. Introducing the new iPad! Shipping in March, this unit is supposed to have 3G technology (wireless anywhere) and will handle the latest apps from the app store. What’s more, is Apple has simultaneously released an SDK (Software Developers Kit) with it. This means we will be seeing new applications developed specifically for the iPad.
The iPad will be built with WiFi so it will make for a great media device around the house or office. Maybe even your favorite hot spot where WiFi is available. Since they are touting it as the “best way to experience the web, email, photos, and video. Hands down.”
Price starts at $499. It comes in 16GB, 32GB, and 64GB models. It also appears to have the ability to connect an external keyboard. Want to learn more, you can visit the Apple website to find out all the details.
Linus Torvalds is the man who started Linux. Known in it’s early stages as the Open Source Unix. Since then, it has evolved into something even bigger than I think he even imagined. Maintaining the source for a project that large can be time consuming and difficult. Linus said that he would maintain revision control with tar balls and it was easier than using CVS. But he needed something that would work in a distributed fashion and allowed for easy merging. But there were no open source options available.
This, GIT was created. It is designed from the ground up to be a true distributed repository. Think of torrent source coding. There is no one central location, but everyone has the master branch at any one time.
I have been a big fan of subversion, but after listening to this talk, given by Linus at Google, I am considering switching to GIT. And to think, I recently paid $60 for a Subversion application to run on my mac. Ouch!
Do you ever get an email that looks legitimate, only to find out later that it wasn’t? I hate that! Just like this email I received from someone I THOUGHT was facebook.Just by looking at the email itself, you cannot determine that it is in fact NOT from facebook. Aside from the red warning label that gmail attached across the top.
Good thing I was using gmail as my provider. One of the great benefits of using gmail is they filter your mail for spam and imposters (aka phishers)to protect you from potential harm. If I would have clicked through to this website and entered my login information, the phisher would instantly have access to my facebook account to do whatever they wanted. Could you imaging the destruction they could do? Not only to your information but to your reputation and relationships with everyone connected to you.
Read more
So you have a Comcast connection as home and you want to run a server? The problem is your IP Address is DHCP (Dynamic Host Configuration Protocol) assigned so it is constantly changing. In order to do this I will be assuming two things: 1) you are using linux on the server you want to setup as your local web server and 2) you already have your domain name registered from somewhere like godaddy.com. Once your domain is registered, you will also need to make sure to set your DNS records to point to ns1.everydns.net, ns2.everydns.net, ns3.everydns.net, and ns4.everydns.net.
If you have these in place, we are ready to move on.
Read more
By the time I finish writing this, there will probably be 10 new domain validation routines uploaded somewhere on the Internet. The only problem is, the majority of them are incomplete. Incomplete would be the equivalent to wrong, depending on what you are looking for in a validation routine. The problem? Most developers don’t read the requirements / specifications. The majority of developers do not take time to RTFM (read the freaking manual) for anything. What makes you think we will spend time reading the ever so boring RFC documents?
Domain validation is a common issue as evidenced by the more than 42,000,000 results on Google when you search for domain name validation php. But who can you trust to do it right? If I were to ask you what makes a valid domain name, do you know? Do you know how long a domain name can be? Do you even really know what a domain name is? Continue reading, and I bet you will be enlightened.
Read more
A few days ago, I wrote a post about validating NANPA regulated phone numbers. So late last night, I figured since I have already done the research and figured out the work, why not build a class and put it online for everyone? So that’s what I did.
During the process, I realized how easy it would be to apply the “optional” filters I discussed in my previous post. I document them on the Google Code wiki where my open source repository is.
Read more
Follow Me (digitally you stalker)