Friday, June 27, 2008

Wife's Journey Into Online Survey Cash

As a PHP freelancer, the thought of paying off all your debts seems more interesting than when you used to have a cubicle day job. The reason is because you're more focused on how hard it is to get and maintain the cash flow, and wouldn't it be nice to not have all the cash that's coming in go right back out on bills???! Heck yeah.

So....my wife took a trip tonight into the world of online survey cash. We decided to not use our own home phone, so we used K7 to get a phone number. Otherwise, about the cheapest plan we could get would be $8.95 per month, and heck, that would eat up the profits of the service on some months when we don't work that hard at this. We also used Gmail for the email because it has the best spam blocking, and we used an account we will hardly check.

Everything else, however, and we used legitimate information except for the fact that my wife's name would be KayR instead of just Kay. (Of course, I'm not telling you my wife's REAL name because, after all, I'm Mr. Grey.)

And we installed an auto form filler for Firefox and it took a bit to get this configured. However, we managed it and I continue to tweak it for her. It does about a 50% good job on forms, and then we look it over and change everything else.

Some tips we heard were to use the form filler, to close all popups after the initial one, and when the domain name changes or you can't see the domain name, or when it says you've completed the survey, then you're done. Now, some surveys are ridiculously long and just flat out bogus, so you skip those and move on.

You can only go back to the online survey cash service and click a submit button or a completed button unless you have actually completed the survey.

Well, what's the result? You guessed it: spam! I can't wait to see what happens to our direct mail that will start shipping to us every month. I'm sure it will be like crates and crates of stuff. I'll have to work out a deal with the local postal lady that if she trashes anything saying KayR on it, we'll slip her a $50 at Christmas in a Christmas card for her. (That's what my Grandpa used to do.)

Another result was that it was *NOT* as easy as it says it is. First, the form fillers addons for your browser are imperfect and require tweaking. You have to know a little HTML to know how to make the form fillers work better. Second, some surveys are tremendously long. Third, it's hard to click those tiny little radio buttons to say no all the time, and then not accidentally click the ads that are right next to the no buttons.

Anyway, I spent 30 minutes doing surveys and getting things set up in the form filler tool, and all I managed to do was get $2.00. My wife was even slower.

So, I don't know if it's worth it to do this except perhaps to just say to yourself, "I'll commit 1-2 hours a day doing this." Realistically speaking, that comes to about $400 to $700 a month from this. So, don't expect to get rich, but you might be able to pay off a credit card.

So we think about it like this. We use wealthy people (these advertisers) to pay off other wealthy people (credit card companies), and we hate both of them. So we basically are using one to combat the other. Not a bad deal.

Thursday, June 26, 2008

ORM -- Oooooooh. I get it now!

After years of doing parameterized SQL centralized in a class of public variables (named a conf file), I think I finally see the light on why an ORM is useful.

Here's why:
  • The conf file would get huge on a project.
  • Several developers working on a project might obliterate each other's conf file under some conditions.
  • I would spend like 40 hours (over the entire course of a 3 month project) reviewing the best way to do something in SQL statements, when I could have been coding.
  • It's easy to make a syntax error in the SQL and not recognize it for a couple days.
  • I had to actually write all that SQL -- no tool would generate it for me.

However, with an ORM, here's the fix for all that:
  • No huge conf file for the SQL. You can split the database logic into classes that some guys can have, or that other guys can have, as their tasks.
  • I don't have to write out all that SQL for most of the project. Instead, I can focus on the code. Sure, if I want to build a difficult JOIN and type the SQL manually, nothing is stopping me from doing that, though.
  • Not having to write out all that SQL, there's far less chance for a bug to appear.
  • Subclassing is a beautiful thing in the right context.
So, I recommend you consider an ORM tool soon. And my favorite right now is Outlet ORM because of its small file size, the fact that it's very well written, has no bugs that I can find, and is well suited to many uses.

Wednesday, June 25, 2008

Fighting with SVN



I've been fighting with SVN on a project because several clients use Subversion. I was doing it all by command line based on my client's recommendation. I kept screwing things completely up!!!

The fix was to do 'apt-get install rapidsvn' on Ubuntu Linux. It's GTK2+ based so it works with GNOME. (I think there's qsvn or something like that for the QT/KDE environment.) Anyway, this thing is a beauty. Once I got up and running with this, I was doing great. However, some command line knowledge of SVN is essential so that you know how to get around with that first -- makes it easier to understand the Rapid SVN interface. Also, here's a VERY USEFUL ARTICLE on SVN for newbies like me.

Monday, June 23, 2008

Now Here's A Niche -- Bring Up Your Own PPC Site!

Someone posted this in a forum tonight:

http://www.textadmarket.com/

However, after seeing this, cash registers immediately went off in my head. I mean, can you build the following?

1. A site that can receive a call from a Javascript src call from another server and then do a PHP echo of an ad pulled from a database. Here's a couple clues -- you'll need to get a special bandwidth deal with your web hosting provider, and you'll need to use PostgreSQL instead of MySQL because the solution needs to scale.

2. Handle incoming clicks, update the cash transaction from the merchant, and redirect the user to the ad along with a referral ID from you as the source. (This means you go to the side with ?ref=.

3. Provide an easy way for merchants to manage ads, and for affiliate marketers to use them.

Go ahead and poke around TextAdMarket. We're not talking rocket science here.

Okay, so here's the catch. If you own one of these, then you'll have to manage cash deposits and receipts, and the legal stuff, and it gets to be kind of a hairy mess after awhile. So here's the spin -- don't keep the site! That's right, build the PPC site, get it working, manage up to about 40 merchants and a small set of affiliate marketers, and then flip the site for like $80K as fast as you can. That way, you cash out and can move on to your next great idea, or build another one of these with perhaps another twist or with an even better design. And you avoid the nightmares of people not getting paid because of quirks, or legal issues, and so on -- that can be someone else's headache.

Time To Revisit PHP.Net



We don't know it all, even when we feel like we do.

Sometimes we get stuck in our ways and think we know it all. It's interesting how I am taught a thing or two by others. Anyway, if you haven't been over to check out the latest function list with PHP.Net, I suggest you do so. For instance, I used to do posted form data entry validation and filtering/cleanup with my own string functions and preg_ (pcre API) because I had my mind stuck back in the days of PHP4. Well, turns out that everyone's now using the new filter_ API, and there's a ctype_ API out there that I didn't even know existed.

Which do you think runs faster? A bunch of calls with preg_ API or one single call to filter_ or ctype_ API? Well, each time you use a function in the global namespace of PHP, that's a slight performance hit. Of course, that hit is faster than your own code with loops and if/then's because it's calling something in C, but at least consider that one C call is going to be faster than three or four C calls. So yeah, using the filter or ctype API is going to speed you up a slight bit.

Another one to look at is mcrypt API, if you were doing your own encryption by hand. However, you can still keep your old makeshift encryption functions on hand -- just do an extension_exists('mcrypt')) call to see which API can be used on a given server. Oh, and if you've never used extension_exists(), then neither have I until today. Again, go look over the PHP.Net stuff because there's lots of new stuff in there with PHP 5.2 or better.

Of course, your server may not have these features, but they should! You can either get your web hosting provider to upgrade to PHP 5.2 (or higher) or you can see if you can get them to add the filter API extension (even if beta).

Next, the more I use an ORM, the more I appreciate it. I should have used Outlet ORM (or any ORM, such as Propel) awhile back because I would have accomplished a lot more in very little time. And no, you don't have your hands tied with the ORM -- if you are working on a complex JOIN and don't want to fight with the ORM, then don't! Instead, go grab PDO or mysql API and bring it on, old-school.

Another piece of advice I received was to use APC to speed up the performance of my pages. You can get this from PECL with 'pecl install apc' at command line.

Some more advice I received was to use page recursion on form posting. I used to HATE this it. HATE, HATE, HATE, HATE!!! It was because it would confuse the heck out of me when inheriting code like this. But now I see the light. You see, it's far easier to do data validation and kick the user back to the same form with the data filled in and an error message than it is to redirect to another page with duplicate content, or show an error. So, yeah, my advice is to do page recursion on at least most of your form posting, but do it tactfully, keeping in mind that you will have programmers one day who inherit your code. So make good use of comments, and make the if/then logic clear such as:

if ($bFormPosted) {

or at least:

if ($_POST) {

Well, gotta run. Hope this helps!

Sunday, June 22, 2008

Subtle Hint From Client -- Work Faster!




I just got a chat from a client today, on a Sunday of all things. Chat sucks. I hate chat because sometimes you get undesirables, and clients reaching you at times when you're mega-tired. I really only like using it to talk to a business associate, and only one or two of them because more than that it gets hairy to manage and sucks valuable time. I've got one person (non-client) named Steve who is always depressed and miserable all the time, and I try to be nice, but the guy just drags and drags on me, asking my advice with his miserable software testing job, wanting me to cheer him up, wanting me to call him or do online chat, whatever. I'm about to the point where I want to advise Steve to leave his job and then not to call me anymore unless he's got happy news because he's depressing the mess out of me.

Anyway, back to the client. The client read my work log. He noticed that I didn't progress much last week as far as coding. He's about right except for the fact that I spent like 10 hours on a Friday to Saturday timeframe configuring a new staging server with all the required software, fighting with custom compile of PHP and the stuff that goes into that. (My last blog post explains a one-liner script that fixed me in 5 minutes, but I had to waste 10 hours before I found that.) And when I explained that, he was like, phhht, who cares? And then I have been waiting on XHTML templates in order to make my stuff look good, and they don't have this yet, and so I shrugged my shoulders, said what the hell, and wasted two days on the project schedule doing bitmap to XHTML conversion on my own with Gimp and Blueprint CSS. What an aggravating mess that was. I finally got it going and tested in FF2 and IE 7 at least for now, and it will do until the real templates arrive. But when I mentioned that to the client, again, he was like, phhht, who cares?

Now, when the client chats you and usually uses "lol" in his chats, but then suddenly stops using that and starts saying things like, "how much longer do you think this is going to take?" then ALARM BELLS SHOULD BE GOING OFF IN YOUR HEAD THAT THEY ARE NERVOUS ABOUT YOU AND YOU MIGHT LOSE THE CONTRACT. So, my advice is to handle it like so:
  1. Ask them how long do they have for this project to be built. They'll tell you a number, but realize that no client in their right mind would tell you a reasonable number, and most clients want to not even think about how long it takes to work out quirks in the admin pages or handle bugs, so you can guarantee you'll need to take their estimate and tack on 3 weeks. Now, consider that -- their view of the timeline + 3 weeks -- and if you can't make it happen in that timeframe, then respond and say it's going to take 3 weeks longer than their estimate to handle misunderstandings and bug fixes, and then another x weeks to finish the project. When they ask about misunderstandings, I could give you countless examples. For instance, my last client wanted an admin system, so I whipped it out fairly fast based on his functional spec. But then he came back and said that he wanted to edit several member transactions at a time, rather than onesy-twosey, and that's the sort of misunderstanding that is not cleared up in the functional spec most of the time.
  2. Tell them that they'll have a significant demo of some key user features within 7 to 10 days. And bust ass to get that goal accomplished.
  3. Split the project up into 2 week periods with demos on each timeframe.
  4. Stop all chats, reading websites and news, and so on. Get some good tunes to listen to so that you can get into your zone, build a project schedule and stick to it, don't over-engineer something, and bust ass getting work done because evidently you are behind schedule in their opinion.
  5. Print up some signs for the wall above your monitor:
  • Software does not write itself. It's up to you.
  • Most clients only care about visual results in the web pages.
  • Clients want visual results every two days. If you haven't delivered, then you have one day to make that up.
  • If you consider a website as a set of forms, and haven't knocked out at least two forms a day, then your client will be disagreeable.
Note that all this gets easier once you've proven yourself to the client with the first phase of a project, or follow-on phases.

My other advice is to never ever take on more than 2 clients at once unless you can't pay your mortgage or vehicle payment, or unless the gigs are under $2000 a piece.

Listen to your conscience. If you have a sense of dread come over you about your work output, then you are more than likely right that your client feels the same thing. Every time I feel this, my client comes back and responds the next day with either bad news or "asking me how much further?" So listen to that, deal with that, and get some work done.

Saturday, June 21, 2008

Upgrading To PHP 5.2 on CentOS5

Turns out the dorks who make CentOS5 don't trust PHP5.2 yet or something. Someone should issue them the memo -- it's stable and comes with a lot more than PHP5.1, including the new Filter API.

Well, turns out I wasn't alone when I was struggling with trying to upgrade to PHP5.2 from 5.1. Here's an article I found that solved the problem right away. In a one liner, it's:

wget -q -O - http://www.atomicorp.com/installers/atomic | sh ; yum update

as root.

Going For Eden



The guys at eden.cc, makers of freelanceswitch.com and several fantastic sites, have been doing outstanding design work for awhile now. I'm not 100% pleased with everything they do in their designs, but boy it sure does look good for at least 98% of it.

One thing that Eden does is use a particular heading font of which I was not able to duplicate. So, I tweaked an existing font I found and made a new one with Linux's FontForge. Here's that font. It's fairly close enough.

Now, to make this look great, use Inkscape on Linux, create a brown colored rectangle (or your favorite color). Now choose radial gradient, edit the gradient, remove the opacity, and adjust the gradient with the gradient tool so it sort of looks like the image on this blog article. That's your backdrop. Now type onto this with the new UltraBlack font. Take the font, add a chrome gradient, then add a solid white border and keep thickening the border until it looks like the image in this blog article. Last, copy and paste the image of the font item on top of itself, but just a couple pixels to the right and bottom. Remove all coloring and make it solid brown on line and fill. Then, take the master opacity of that item and dim it slightly. Last, lower that second font item beneath the first and you've just created a shadow.

For an even more interesting effect, take a snapshot of that with ALT+PRTSCRN and import into Gimp. Then, add a slight softglow filter. This could be used for certain conditions for emphasis or an eeriness.

Tuesday, June 17, 2008

Yet Another ORM Tool

If you're looking for yet another ORM tool, here's one that might knock your socks off. It's called Outlet and it's SUPER EASY!!!

http://outlet.knowledgehead.com/wiki/index.php/Main_Page

The advantage of this system is that you build an object class that describes your content with private vars and set/get methods, and then run it through Outlet to drive your ORM automatically. If you have special SELECT needs, it can do that too.

It's written for PDO and has been tested with SQLite and MySQL 5.

Here's a Quick Start that makes it very apparent to you how easy this thing is.

http://outlet.knowledgehead.com/wiki/index.php/Quick_Start_Guide

Project Speed - Rule of Thumb



I'm on a project right now where I have a lead dev who's very picky with his own style on how things should be done. I don't fault him at all -- I'm picky too and understand the importance of being picky. He and I report to a project manager who pretty much is hands off and just keeps tabs on us in a casual, jovial way. He doesn't understand the technical detail of the work we do. Now, the PM has a boss who writes the checks, and he's very picky, very formal, not jovial, and he's all about results.

Now, going into this project, they knew I didn't know Zend Framework and were still willing to work with me in learning it as I go. I've made great strides in learning it, and I have to give myself a pat on the back for that because I dislike it's awkward nature.

However, the guy writing the checks is now seeming a bit taken aback by my first invoice when he sees I only completed a login form, a registration form, and a password retrieval form in the span of two weeks. He's wondering where all the time was spent.

I hate when that happens. This doesn't sound like this contract is going to go well. The guy has like no clue what one has to go through when starting a project fresh, or when the team lead is unavailable to respond except once a day, or when you have to completely learn a new framework super fast. Plus, when you start new projects that are very strict in their design, a lot of discussion needs to take place to iron out things that will impact the rest of the application. So heck yeah, it may take 2 weeks to knock out a login form, a registration form, and a password retrieval form. But there's much more going on than that. We're learning how to do things the ZF way, making decisions on how the project will proceed going forward, trying proofs of concepts, failing, and rewriting code, and understanding policies on how work is to be performed and problems are to be solved.

But bosses in these sorts of companies just don't understand and have to get tough with you, even if you're only billing out for peanuts.

So, as a general rule of thumb for you when you pick up a picky project, please remember that they don't care how much trouble you're having learning something, or getting answers from the team lead, or how half-assed something is. All they want are results super fast. They want to see like 2 forms created a day, not a week. They want to see you complete two major tasks a week, if not more.

Therefore, my recommendation is to get as many questions answered as soon as possible, starting out, and ask several questions a week, but then slap the code together just as fast and as logical as you think you can get it out, sticking to a goal of:
  • minimum, 2 forms a day, not a week
  • minimum, 2 major tasks a week, not every two or three weeks
  • Knock out a bunch of work super fast, then take your breaks, but report this work slowly such that it looks like you only did 2 forms a day, or two major tasks a week
Let's pray that I did a good job of convincing the big boss to keep me and not cut me. I'm nervous about that right now. And let's hope that I can deliver faster results.

UPDATE (June 17): Got good news today. My client thinks ZF is the problem, not me. We're going to ditch ZF and start a rewrite again. Yay! I'm glad I learned ZF, but I'm going to decline every one of these projects in the future. ZF sux!!!

Monday, June 16, 2008

Latest




I had two clients paying me very well, but then one stops me on one project temporarily, tells me he has something more pressing for me to do, and praises the heck out of me. If that weren't enough, a third client, a Swede, has complete faith in me and is turning to me yet again for some short scripts and some eCommerce work. It's like raining gigs right now.

You see, with a few portfolio items behind you, and a good knowledge of PHP and MySQL and some well-known F/OSS packages on top of this, and some eCommerce experience -- you can go really far and you'll be very busy with good money coming in.

My rate might be low for what I do when you compare me to a desk job kind of programmer, but then again I can double up and triple up my workload and get twice as much cash in the door as the desk job programmer. Plus, I have like no interruptions and I see so much more of my family. So why do people do desk jobs as web developers anymore? Got me.

Friday, June 13, 2008

Belief in God



I'd like to take a break from PHP work to talk to you about God. If you're a freelancer out there, struggling sometimes, turn to Him.

When you have enough people you care about pass away from this life, and you get to be my older age and start looking around and analyzing nature in great detail compared to a carefree childhood, you begin to appreciate things, and you may accidentally find yourself believing in God. Now, I might not convince you of a belief in a son of God, nor really do I care to do so. But I do want to say what I believe.

The Earth is located in a tiny, miniscule portion of a vast universe, held in a fragile state around violent, whirling planets and a star (the Sun) that has tremendous gravitational forces on us and can hurt us just as easily as it helps us. The poles are held in a fragile state such that if you moved them just a few degrees, the Earth would have major weather catastrophes.

Now visit an aquarium museum and look at jellyfish under blacklights. Some are so small and are like saucers of glass, and yet think about that. They reproduce, flash colors to attract a mate or warn them, fight for food, defend each other or themselves, sometimes mutate every once in a millennium, sense things, can sting, and yet when you go looking for a brain, you can't find it. And if you slice them in half, they still live in some cases.

And if you take starfish, and uses motion photography to speed it up, you see that it too defends itself, fight others for food, and so on, and yet doesn't have a definable brain as well.

Now look at a cadaver diagram in pictures in a health book -- the kind with translucent pages that you can flip through and examine the human body -- and you will be amazed in how complex and organized everything is in our bodies and brains.

To me, there is order in this chaos. We could be hurt or destroyed so easily in this universe, never heard from again. But on and on we wake up every morning, and here we are. And some heavenly hand must guide everything around us, and I cannot believe, I cannot comprehend it, if it were not for a God.

In my life, I grew up an atheist in an atheist family. And it's taken me years to believe in a God, to believe in the power of prayer, and to believe in an afterlife.

My Way of Doing Database Work

Right now, I use MySQL. It's what 95% of my clients are running. Now, don't get me wrong -- I love PostgreSQL and SQLite as well, but MySQL is where the cash is and where almost 100% of all the PHP sitescripts out there are based upon. If I needed a site that really had to scale for several hundred thousand users, then, hands-down, it would be PostgreSQL. And if I had a site where I invented something cute and a quick and dirty database file would do, then SQLite might be a consideration for me, or if I need an embeddable solution, then SQLite would do as well.

Now, in PHP5, you have Pear::DB, Zend_DB, PDO, mysqli, and mysql API in interacting with that MySQL database. However, all speed tests show that mysql API is the fastest except when doing prepared SQL statements. For prepared SQL statements, mysqli API is the fastest. So, since I don't use mysqli-type prepared statements, I use the straight mysql API.

Wrapping that API is very important to me. It lets me swap databases or control a problem from a central place. I stick it in a $db class and I have methods like Run, RunFast, GetRows, GetRowFromRows, GetNextRow, GetRowCount, GetColCount, Translate (builds a simple SELECT statement on the fly), and so on.

After working on enough projects, no one likes find a project where the SQL is sprayed all over the place. So, you'll find my SQL in a single class file with public variables storing parameterized SQL statements where ^ is the symbol I use to indicate where a value would go. I call it like so:


require_once('DB.php'); //this already instantiates the $db object for me in the class file
$sSQL = $settings->SQL_GET_USERS_BY_LASTNAME;
$db->Pack($sSQL, 'Smith');
$rsRows = $db->GetRows($sSQL);
while ($db->GetNextRow($rwRow, $rsRows)) {
echo $rwRow['email'] . "<BR>\n";
}
$db->Release($rwRow);
$db->Release($rsRows);


And in my $settings class, you'll see something like:


$this->SQL_GET_USERS_BY_LASTNAME = "
SELECT
*
FROM
users
WHERE
disabled = 0
AND lastname = '^'
ORDER BY
firstname;
";


See how much cleaner it is to use this sort of technique?

[EDIT: See my post on July 9, 2008 where this is superceded.]

Thursday, June 12, 2008

Some Clients Really Make Your Day




After I walked out of my day job in a fit of rage last Christmas, right before the eyes of my HR manager and two supervisors, after working miracles for that lousy company and never getting any serious praise, and after constantly getting called at all times of the day, night, weekends, and vacations, and working 60 hour weeks, I really didn't know what to expect as a freelancer where you literally have to sing for your supper.

But who would have thought I'd be getting people to pay me for $40/hr, 40 hours of the week, almost indefinitely on a laid-back project, permitting me to have another client if I still maintained my 40 hours of week for them, and getting praise for my work?

But that's exactly what has happened. I've even been paid on retainer for awhile as a freelancer, although that didn't work out, but I learned a lot in the process and I know that I don't prefer retainer as much as just getting paid by the hour. Retainer pay is usually like working for peanuts, but then they give you work in bursts and during dry periods of no work you still maintain a paycheck. The retainer pay happened simply by posting my case about quitting my job in a forum, saying that I do PHP, and the CEO of a wealthy company read it, felt sorry for me at the time, and gave me retainer pay on a project. In the end, I got along well with him and his partner, but his third partner and I disagreed too much and that was the kicker that ended that project. But oh well.

And who would have thought that so many PHP freelancers (and ex-PHP guys who now do Affiliate Marketing) are so nice, sharing advice, simply by asking? You'd think we'd be competitors, but in reality it's just like that old Christmas movie -- Miracle on 34th Street -- where the Santa tells people if they can't get a product at this department store, he would recommend where they could get it down the street. And that same sort of philosophy and sharing exists among us PHP freelancers -- we remember the talents and approximate rates of our associates, and when something is not in our price range for our services, or not in our skillset, or if we're simply too busy, we would rather deflect to another PHP freelancer in order to present ourselves to our client in the best light.

And who would have thought what a symbiotic relationship that PHP freelancers would have with web designers and with affiliate marketers? It's those great relationships that help give me cash, and then I produce things that give them cash, and then they reinvest in me. Or, I produce things for their clients, and they keep sending me gigs, or I send them work when it falls in their speciality.

Anyway, in the past couple days, one client told me, "Phew! We're so glad we found you." Another one said "I have heard some amazing things about you. I've seen some of your works as well, and you carry a fairly sophisticated portfolio with a very diverse arsenal of skill sets. I am thoroughly impressed." He also mentioned, "I fully trust the knowledge and expertise you have in your field."

Wow! If my last day job heard the good luck I've been having, they'd probably be kicking themselves that they didn't keep me.

Dealing with the IRS as a PHP Freelancer in the USA




Just so you know, I contacted the IRS the other day and asked if I have to pay extra taxes if I build websites for non-domestic clients in Europe, Canada, etc. Would I have to pay some exotic foreign work tax, or have a limit on how much I could take in per client per month?

The answer I got back was no, that the IRS treats foreign work that you perform under your USA-based LLC, sole proprietorship, corporation, or partnership as domestic work and is taxed just like that. The only exception is that other countries won't issue you a 1099-Misc form as a contractor -- although your non-domestic clients may request your Federal ID for their special government forms in some cases. And just so you know, even if you do the work on foreign soil, but get paid back to your business entity, then this is treated as domestic work and is taxed like domestic work.

The other thing you have to remember is the quarterly estimated income tax on the moment you start to earn your first check and can make a draw on the account. Now, if you never make a draw or a W2 or pay anyone at all, such as just filing checks into the bank for safekeeping and paying expenses only with that, then you never have to pay the company's federal or state income taxes until you actually make your first draw or personal payment to you or any employee or contractor in the business.

Now, a quarterly estimated income tax is a real racket. The IRS wants you to guess your next quarter's earnings. Guess too low and they could tax you more at the end of the year. Guess too high and they end up earning interest off that income, not you. So, the only realistic thing you can do is to take last quarter's earnings + the last quarter's earnings from the same quarter last year, and then divide by two to get the average estimated income tax going forward in the next quarter. This shows the recent trend as well as the seasonal trend for your business.

Plus, there are stiff penalties for missing your quarterly estimated income tax.

Now, realize that unfortunately this is how business works. I mean, do you want a whopper of a bill that you have to pay twice a year or, worse, once a year? I don't want that. So they have to break it up into quarters, but if they don't get their money, then you have placed the burden on other businesses that are like, in a sense, paying your tab while you miss paying yours.

But my beef with the IRS is that I am opposed to income and property taxes, and would prefer either a flat tax and a decent sales tax, or just give me purely a sales tax. However, this is the USA government here -- don't hold your breath.

I'm also opposed to the fact that the business estimated income tax is about 40% to 45% of your income + penalties if you have them. And if you look at big business -- remember that Enron in one year owed absolutely zero tax because they had worked all the loopholes and had the army of tax accountants and lawyers to cook the books like that. That's just not fair.

And when you look at what you get for that 40 and 45 percent, those dollars aren't spent very wisely in America.

I Don't Do Pr0n

 



No, that pic's not me, but you get the point. Many of us in the PHP web dev industry are often approached to do pr0n websites. These are lucrative and provide repeat gigs, and we just so happen to have a skillset that this industry needs desperately, with more and more guys coming online every day. I mean, one can purchase a pr0n CD package for like $1000 to $2000 and then provide it on a subscription basis on the web pretty easily -- so the barriers to entry are low.

However, I turn every one of these down. And it's not that I can't lock my office door while I work so the kids can't see it, and not because I haven't seen several parts of female anatomy. Heck, I've been emailed every kind of shock picture in the world and by now I've gotten pretty used to whatever you can throw at me.

No, the reason I don't do it is because:
  • All it takes is for that guy to post something online about me, complete with photos from the site, and my freelancing career is in jeopardy.
  • If I say no, I don't want to work for them anymore, the guy can merely send a letter to my wife's supervisor to get her fired for even being remotely related to this, or send me extortion letters about my connection unless I come back to work for him.
  • There's no way in heck this guy is going to give you his real street address, but yet he knows yours.
  • It's so easy for him to send me bad stuff in the postal mail to the point where my kids start looking at it.
  • These guys definitely get audited by the IRS and state agencies quite a lot, and that means it could trigger an audit of me as well all too easily.
  • If these guys get pulled in by Federal Agents over obscenity or child pr0n, these guys can call me the mastermind or a co-conspirator, pulling me down into that sewer all too easily.
  • Every day you help these guys, another kitten dies. Okay, just kidding.
Look guys -- dealing with pr0n websites is like playing fire. Avoid it at all costs. Sure, it's much harder to survive, but that's what squeaky clean affiliate marketing and residual income websites are for. Hop to it, and stay clean.

Wednesday, June 11, 2008

Cool New Service -- CushyCMS

 



A PHP associate shared this with me. This was a really cool new product on the web. It's free unless you want to brand the editor as your own, and then it's $28/mo USD (June 2008 prices).

http://www.cushycms.com/

Basically it lets you take any PHP page that may contain HTML or XHTML content inside, or any XHTML or HTML page, any Javascript file -- basically any text file that has HTML or XHTML tags inside. Then, you can add some class attributes on some existing tags, or wrap something in a DIV or SPAN or other tag and add the class attribute. Once you add that in and connect it to this FREE service and give it your FTP username and password, you can then export an interface to your client that's easy to use so that they can publish content to their own sites.

Now, here's a few catches where some of your clients may not like this:
  • If they are concerned about the FTP security. Although it encrypts the FTP information it stores in its database, it still could be a risk that a hacker could get this information and the way to unencrypt it.
  • If the service becomes extremely popular, can it scale to handle the load?
  • If the service runs out of cash and needs to start charging for stuff it gives away for free.
  • If the service is down and you are powerless to get it operational again for your client.
  • If your client wants excerpts for articles on their home page, and then the ability to create new article pages with a given page layout.
  • If your client wants an article archive with links for Previous and Newer entries, or a calendar to pick articles on certain dates.
  • If your client wants to be able to search for content based on title, author, categories or tags, or content.
  • If your client wants to view an image gallery for his entire site and see which images were used where on the site.
  • If you want paginated articles when they are too long.
  • If your client wants the power to create new page tabs on the site and add that content.
So, for those, you'll need a full-blown CMS, and my favorite one to recommend is TextPattern CMS (TXP, as it is called for short). Now, TXP has a lousy admin interface, and doesn't support standard markup of articles by default. However, two hacks have been created called Aeron MyAdmin and hak_tinymce. The first one, Aeron, takes the ugly CMS admin interface of TXP and makes it beautiful. The second takes the article editor and gives it a richeditor WYSIWYG editor.

And next to that, for ease of use, I recommend WordPress CMS, hands down.

TXP is great when you have a given XHTML template and you need to paste it on the site with not much fuss and then plug in CMS tags into it.

WordPress CMS is great when you don't have a given XHTML template and are willing to either purchase or download one from the web custom-made for WordPress, or to export the default one, edit it, and re-upload something geared just for WordPress CMS.

Theming phpBB

 



Son of a gun, does the darn thing (phpBB) have to be so darn hard to theme? It's got one third in the file system in a cache, one third in the database, and another third in the original base template files. Sometimes you have to guess which option to choose, and refresh cache, in order for you to see the effect of your change. No wonder a lot of people still use Simple Machines forum system.

Tuesday, June 10, 2008

80 Char Wraps, Spaces Instead of Tabs -- Grrrr

 




Look, if you're a web developer and you're not using a GUI editor, then how the heck are you productive in a day? And if you're using a terminal window and you don't have at least 110 characters available to you on a screen, then what kind of programmer are you?

Plain and simple, folks, 80 char wraps have gone the way of the dinosaurs. Most people either have these widescreen laptops now or they have at least a 19" monitor that can display 1280x1024 pixels.

Recently I was sent this link...

http://www.emacswiki.org/cgi-bin/wiki/EightyColumnRule

...and I tell you, this has vanished in today's modern world. We need to use a new standard of at least 100 characters, if not 110. (Now, 120 might be pushing it, but possible.)

Next, a team lead asked me to do spaces instead of tabs. Well, I'm sorry folks, but tabs are more efficient, take up smaller file sizes, and I don't give a dill about why emacs has trouble with tabs instead of spaces. Tabs are NOT evil.

Monday, June 9, 2008

Variable Naming Conventions

 



I use an adapted Hungarian for my PHP code. I don't know why people don't use this. When you see a variable like "$Member", you have like no clue what's inside it or how it's supposed to be used. I'm currently on a project and that's what the guy wants -- $Member -- and it's very strange to me. Anyway, here's my adapted convention:

$s + VarName = string (ex. $sVarName)
$o + VarName = object
$h + VarName = handle, like for files, SQL objects
$n + VarName = numeric (integers, floats, etc.)
$d + VarName = date or time
$b + VarName = boolean
$c + VarName = single char
$rs + VarName = recordset (rows)
$rw + VarName = record (row)

$g + above = when I have some sort of global value, which I rarely or never use

$a + above = array of whatever

$x + above = byref variable passing back value, with "x" meaning "xfer" or "transfer"

$_ + above = private variable not meant to be exposed outside the class

$a, $b, $c = iterators, with $b and $c being like nested iterators -- works better than $i, $j, $k because $i and $j almost look like each other when tired

Exception -- private variables meant to be exposed outside the class usually don't have a prefix, like .FirstName, .LastName, etc.

Styling Forms




Next time you style a checkbox or a select box, take a look at this trick:

-moz-outline: 1px solid #BBB;
-moz-border-top-colors: #EEE;
-moz-border-left-colors: #EEE;
-moz-border-right-colors: #FFF;
-moz-border-bottom-colors: #FFF;

It might work in Opera, but I know it works for sure on Firefox. It won't work in IE, but then again it won't error out on IE and you can actually style these elements in IE6 and 7 another way, I thought.

And for radio buttons, consider this:

-moz-outline: 1px solid #BBB;
-moz-outline-radius: 60%;
-moz-border-top-colors: #EEE;
-moz-border-left-colors: #EEE;
-moz-border-right-colors: #FFF;
-moz-border-bottom-colors: #FFF;

For textboxes and texareas, just use...

border: 1px solid #BBB;
background: #FFF url('images/field_background.png') no-repeat top left;
height: 16pt;
padding-top: 4px;
padding-left: 4px;

...where field_background.png is easily created by making a white box that is 800 x 400, saved as a greyscale PNG, and has a left and top margin 2 pixels wide. The outer pixel of that margin should be the color #ebebeb, and the inner pixel of that margin should be #f5f2f2.

Zend Framework Complaints

 



  • The MVC framework is stifling. There are other ways to handle doing separation of PHP from SQL from XHTML that are easier to manage. First, read my Smarty comment on this blog and that separates PHP from XHTML without having to use Smarty. Then, stick all your SQL as parameterized SQL inside a class file as private vars, and create a Pack() function to insert those vars when ready to get results. Also, create a database abstraction class so that you can swap that class out with another one when switching database platforms. Now, if you use ZF to just use its classes in a kind of toolbox way, it's better, but instead you could just find a framework that's already in a non-MVC way that provides these class function/method libraries.
  • The Zend Forms API is geared for like 1990, not the modern world. In the modern world, we draw our forms the Web 2.0 style, and it's more than styling -- it's Javascript and jQuery and CSS as well to make up for what you don't get with ordinary XHTML. Zend Forms only gives you a limited set of tools and then stifles you from being able to insert XHTML into your form such as between fields. My recommendation is that you don't need Zend Forms, so don't use it.

Why Use Smarty?

 



I've used Smarty for like 4 months now. I don't know why I need to be using it anymore. I mean, it's redundant. PHP is a templating language -- it just needs to be used in a more organized way.

Doing things the Smarty way, you usually make your XHTML template, then insert Smarty tags. Unfortunately I've been making some hairy Smarty pages with too much business logic in them for if/then and loop, and I need to, instead, put that back in the PHP code and dump something ready to go into a section.

From the XHTML template with the Smarty tags, you then move to your PHP page, load your Smarty class, set some variables on that class, and then feed it the Smarty template page.

Well, if that's the case, why not eliminate Smarty and do it in PHP? You just get your XHTML template, insert your PHP tags as , save the file as a PHP file in your templates subfolder, and then merely build the PHP vars in your pages and, as the last thing you do, perform a require_once() to load the template which will then load in all the appropriate variables.

Why does this have to be so hard? It doesn't have to be.

Still, you should learn Smarty because, unfortunately, many clients still want you to use this because they didn't get the memo on PHP being an effective template language, already.