Archive | 2007

PHP: Remote Kill Switch – Make Sure You Get Paid

Web Developers: Have you ever gotten to the end of a project, and had a client withhold the last of your fee to exact additional changes or features that were not in the original plan? Perhaps a client that decided your work “wasn’t what we expected” and tried to withhold payment?

Well worry no more. Put the power back in your hands with a Remote Kill Switch. The idea is this: you build into their website a small function that checks with a server you control to make sure the client’s account is in good standing. If it is, the site loads as normal. If not, their site doesn’t load, and they get a message asking for payment.

We’ll accomplish this with a little PHP and a protocol called XML-RPC (remote procedure call). Your client’s server will transmit an XML encoded, unique string identifying itself to your server. Your server will check to see if that unique string is one you’ve specified as disabled. If there is a match, it responds with a XML encoded string telling the client’s server to disable the application.

Sound like something you’d want to implement? Here’s how it breaks down:

Part One: Your server. You’ll need a fairly reliable host, and a fast one at that. You don’t want to slow down the remote application load with requests to your server. However, the below code is set to continue loading the remote application even if it does not receive a response from your server, ensuring that downtime on your end does not cause downtime on their end.

Part Two: The code on your end. Also known as the RPC server. Create a new file and paste the following:

	require('XMLRPC.inc.php');
	function checkapp($the_app)
	{
		$deactivateMe = ""; // to disable a webapp, enter it's short code here
		if (isset($the_app) && $the_app == $deactivateMe)
			return true; // Application Disabled
		else
			return false; // All systems go
	}
	$server = new IXR_Server(array('activation.checkapp' => 'checkapp'));

You’ll also need to download XMLRPC.inc.php and upload it to your webserver in the same directory as the file you created above. You will need to change the file extension from .phpp to .php.

Part Three: The client code. Also known as the RPC client. Insert this code in your client’s site, preferably toward the beginning of execution:

	require('XMLRPC.inc.php');
	$appname = "UNIQUE_APP_SHORTCODE";
	$client = new IXR_Client('http://path_to_file_created_earlier.php');
	if (!$client->query('activation.checkapp', $appname)) {
		if($client->getResponse() )
		{
			die("Application Disabled. Please pay your web developer.");
		}
	}

Again, download XMLRPC.inc.php and upload it to the server in the same directory as the file you created above. This library is required both by the client to make the request, and the server to respond to it.

That’s it! If the client ever doesn’t pay you, and you want to shutdown the site you developed for them, just set $deactivateMe in Step 1 to the “UNIQUE_APP_SHORTCODE” you entered in the code in Step 3.

You can see that the above setup allows you to protect multiple web apps at once, just remember what shortcodes you assigned at what sites! I recommend keeping them in comments at the top of your XML-RPC server PHP file. However, a limitation of my code is that you can only disable one remote site at a time. I’m sure my code could be expanded to use an array that would allow you to disable multiple sites at once.

I realize that this is significantly more technical than my typical fare (which I will return to next post), but I hope it’s helpful to some people, if only as a demonstration. Feel free to rip my code apart in the comments, I’m sure I’ve left something out.

Disclaimers and warnings: You use the above code at your own risk. It is probably buggy and insecure (though it does work). I take no liability for any harm that should befall your data, your bank account, or your person as a result of implementing this idea. You should obviously remove the activation check as soon as the client has paid you for your work. It’s definitely unethical (and insecure) to leave this backdoor in place after you have finished the project. Also, this kind of system won’t work against someone who knows anything about how their site is programmed. But then again, those people probably wouldn’t be hiring freelance web developers would they?

Why Starbucks Integration is the Best Feature on iPod Touch and iPhone

jobs_iphone.jpgToday in San Francisco, Steve Jobs presided over one of the more product release packed press events in recent memory. We saw the entire iPod product family overhauled – new colors on the shuffle, a total redesign of the Nano (with video), larger hard drives and lower prices on the iPod Classic (as well as a new enclosure), and the introduction of the new iPod Touch with WiFi.

Jobs also had a guest on stage toward the end of the program: Starbucks Founder and Chairman Steve Schultz. Schultz was there to promote the new partnership between Apple and Starbucks, which is basically this: You walk into a Starbucks and order your latte. The song playing on the store’s stereo catches your ear. You pull out your iPhone/iPod Touch, which automatically senses that you’re in a Starbucks, and knows what song is currently playing. You can purchase the song over Wi-Fi before the barista is finished making your coffee.

Cool, but it’s certainly not going to “transform the marketplace” (to quote Steve) is it? I’m telling you that it will. And not just the coffee market, or the phone market, or the MP3 market. I mean the whole market.

Why is this such a big deal? Because the iPhone and iPod Touch are now location aware. We’ve been hearing about location based services for a while now, and there definitely some cool startups out there that try to bring people together based on location. However, this is the first time (to my knowledge) that it’s been leveraged to drive consumer spending. iPhone users can now make a purchase that is directly tied to the location they’re standing at that very second.

starbucks_cups.jpgThe feature as it stands now is not that amazing, nor is it going to radically change many people’s lives. However, imagine the ways that location based purchasing could be extended: Pre-order the DVD/MPEG of a movie as you walk out of the theater. Buy a song’s MP3 as your favorite artist plays it on stage at a concert. Receive a coupon for 10% off upon walking into a department store, encouraging you to buy more. The possibilities are endless.

Sure, all of this requires that infrastructure be built out in all of these places to notify your iPhone of its location. It will take time. But if Apple is smart (and I think they usually are), they will continue to expand the location based services on their mobile devices, and open up additional revenues for both themselves and entertainment venues and stores that did not exist before.

Selling Ads on Your Site – Why ‘Forever’ is a Long Time

I was recently approached by someone that wanted to purchase advertising space on my blog. The offer looked something like this (numbers have been changed):

Offer price: $500
Pages ad would be placed on: 6
Duration of Agreement: Forever

Bloggers, let me ask you – does that sound like something I should agree to? On one hand, you might say it’s pretty good for a personal blog I write in my free time. However, once we break down the numbers, we’ll see that it’s not.

My reasoning hinges on understanding two financial concepts – opportunity cost and net present value of a perpetuity. I’ve linked those terms to explanatory articles – make sure to have a basic grasp on the two terms before we move forward.

While the $500 sounds pretty good, we can use net present value math to convert the one time payment of $500 in today’s dollars to its equivalent amount in yearly payments, every year, forever. Because we’re working the formula backward, I will use $500 as the net present value (what I would be paid today), and solve for the equivalent yearly payment amount. I will use 4% as the risk free rate, which is just slightly below the return on a US Treasury Bond.

Net Present Value = Yearly Payment Amount / Risk Free Rate of Return
NPV = P / R
$500 = P / 0.05
$500 * 0.05 = P
P = $25 per year
Because the original $500 was for advertisments on 6 pages, divide the final number by 6:
$25 / 6 = $4.17 per page per year

So it turns out that the $500 offer is really equivalent to only $4.17 per ad per year! And not only is that rate extremely low, I’m locked into it forever! It doesn’t seem like nearly as good a deal anymore does it?

Things start looking even worse when we consider the opportunity cost of taking the offer. If I agree to place new ads on my pages, they will replace the Google Adsense ads that exist there now. This means that I would forego the revenue I would normally receive from those ads. That lost revenue is my opportunity cost.

The Adsense banner ads at the bottom of each post don’t do particularly well, but, for estimation purposes, they return about $10/year. This is obviously higher on more popular posts and lower on less popular ones, but $10 is a good average. So, by accepting this new advertising offer, I will be earning $4.17 per page per year from the new ads. However, I will also be foregoing $10 per page per year from Adsense. This means that I will actually be losing $5.83 per page, per year, FOREVER if I accept the offer!

So it turns out what looked like a good deal from the beginning is actually not such a good deal after all. Bloggers – as you consider ways to monetize your blog, be very careful to weigh your alternatives and consider your opportunity costs. Also remember – forever is a long time to be locked into anything, especially a contract that could be costing you money!

If you want to learn more about present value and the time value of money, checkout this powerpoint from the University of California, Santa Barbara.

Another Note: I’m not writing this blog for the money. Anything I take in goes first to cover hosting, and whatever is left over I loan out to budding entrepreneurs in the developing world using Kiva.org. It’s a way to give back to the entrepreneurial community that brings a lot of personal enjoyment for me. You should all check out Kiva, it’s very cool.

Libraries and the RIAA

09librarystacks.jpgI came across a very interesting post today on the Freakonomics Blog titled “If Public Libraries Didn’t Exist, Could You Start One Today?” It’s an interesting question in today’s age of the RIAA, MPAA, and seemingly ubiquitous DRM. In a world where sending my friend a song by a new band he may like is illegal, is borrowing a favorite book that different? From the article:

If there was no such thing today as the public library and someone like Bill Gates proposed to establish them in cities and towns across the U.S. (much like Andrew Carnegie once did), what would happen?

I am guessing there would be a huge pushback from book publishers. Given the current state of debate about intellectual property, can you imagine modern publishers being willing to sell one copy of a book and then have the owner let an unlimited number of strangers borrow it?

I don’t think so. Perhaps they’d come up with a licensing agreement: the book costs $20 to own, with an additional $2 per year for every year beyond Year 1 it’s in circulation. I’m sure there would be a lot of other potential arrangements. And I am just as sure that, like a lot of systems that evolve over time, the library system is one that, if it were being built from scratch today, would have a very different set of dynamics and economics.

Best of Banking Blogs

There are a ton of blogs out there, and sometimes it’s hard to separate the wheat from the chaff, especially when we’re talking about finance and investment banking blogs. I’ve done my best to assemble here the best of the internet: a blend of news and humor, insightful commentary and satire. There is definitely something for everyone, and plenty of sources for intra-office link sharing.

  • DealBreaker – Set this one as your homepage. Updated between 5 and 10 times daily, DealBreaker brings you the real news with hilarious commentary. A perfect blend of humor and fact.
  • The Leveraged Sellout – Written anonymously, this blog is a scathing, sarcastic critique of the Wall Street culture and the people who exemplify it. A favorite around the office.
  • Banker’s Ball – Another New York lifestyle blog written for the banking audience. Occasionally runs some great articles, but only updated once a week or so.
  • iBanking Oasis – More of a forum and less of a blog, the homepage stories are selected daily from threads started by visitors. The discussions are enlightening, but often laced with a bit too much machismo. Still a great resource.
  • The All Nighter – A satirical look at investment banking from a junior perspective. Funny articles that any I-Banker can relate to.
  • Under the Counter – This blog focuses on the people that run Wall Street and make tons more money than I ever will. Also sometimes strays to macroeconomic topics.
  • Going Private – The tagline says it best: “The sardonic memoirs of a private equity professional”. This blog covers all things PE, with the occasional extremely insightful post on industry trends and our perceptions of the market.
  • Living the Dream – Another humorous take on Investment Banking, unfortunately less frequently updated than some of the others on this list. The post on the 5 stages of banking is a classic.
  • An Investment Banker’s Take on Life – I became a fan of this one after the author ran a series of five posts detailing the history of investment banking, starting even before John Pierpont Morgan’s arrival in New York City in 1857. He’s now begun a similar series on Private Equity that is equally interesting.
  • The Stalwart – This one reads like an online version of the Journal or The Economist, though slightly less formal. Some interesting articles, and not always centered on business.
  • Trader Mike – The list wouldn’t be complete without a trading blog. Not much humor here, just an interesting look at the market as well as individual stocks. Also gets into some trading strategy, and is definitely not too complex for a beginner. A solid, educational read for those wanting to learn about trading.

That’s all I have for now, I hope I’ve been able to add a few links to your bookmarks/RSS readers. Now you tell me: Have I missed any? Share your own favorite links in the comments.