Archive for the 'Coding' Category

Tuesday, October 24th, 2006Tuesday, October 24th, 2006

strace

Yay, more server admin fun! Here’s a useful *nix command that will let you determine what system calls a program uses… For example, I wanted to double check that libevent calls within memcached were using epoll() and select() or poll() calls (epoll scales better) on my SuSE Linux machines…
server:~ # […]

Use Server-Side Caching When Possible (memcached)

Purely out of necessity, I’ve become a system administrator/architect for digitalpoint.com servers… and a few people have been asking me for general admin tips to make things stable and scalable, so here’s a good one for you…
Use memcached… no really, use it.
memcached is a distributed memory caching system that allows multiple servers to access the […]

Thursday, October 12th, 2006Thursday, October 12th, 2006

Google Code Search

Did I miss this somehow, or is this new?
Google’s Code Search is *really* handy for programmers. For example, say I wanted to see sample code that uses the preg_match() function in PHP, I could do this query:
preg_match lang:php
Neat!

Tuesday, September 26th, 2006Tuesday, September 26th, 2006

The $10,000 Space

If you are a programmer, have you ever had one of those bizarre situations where you know something is not working, but you aren’t getting an error or anything else that would make debugging easy?
A couple days ago I migrated a cluster of web servers to PHP 5.1.x (they were running PHP 4.4.x before). […]

Friday, September 15th, 2006Friday, September 15th, 2006

Google Gmail API

I was just thinking… Google needs to build an API for Gmail. Then we could do things like POP our email into an email client, and then run a script from within the email client that is able to go back to Gmail and tag stuff as spam, apply a label, etc.
That would be […]

Wednesday, August 30th, 2006Wednesday, August 30th, 2006

Canon VB-50i PHP Control Class

I tried to find a PHP class to control the new camera, and I couldn’t find one… so a little packet sniffing later, I was able to figure out how it’s little Java applet communicates with the camera. Anyway, I spent a few minutes to make a PHP class to control the camera, so […]

Monday, August 21st, 2006Monday, August 21st, 2006

Moving HTML With JavaScript

Someone asked me why I hide the sidebar on this blog by default, then show it in a different part of the HTML, so here’s the explanation…
Most blog themes float the main body to the left, and make the sidebar on the right “static”. I did the opposite when creating my custom WordPress theme… […]

Tuesday, June 27th, 2006Tuesday, June 27th, 2006

Forum Spy

I decided I didn’t have enough to do (that’s a joke BTW), so this morning I made a “spy” system for my forum (the general idea of course was borrowed from Digg). It’s “extra” slick in Firefox because of the fades and opacity ability Firefox has, but it still works in IE, Safari, etc…
It […]

Monday, May 8th, 2006Monday, May 8th, 2006

APC Datastore Class For vBulletin

On one of my ultra-high traffic web servers, I switched from eAccelerator to APC today (an opcode/caching system for PHP). So far it seems pretty nice… Especially the ability to disable stat for each PHP request.
I ended up making a datastore class for vBulletin also so I could use it for the forum, so […]

Wednesday, December 28th, 2005Wednesday, December 28th, 2005

I Need To Be More Dorky

I just realized that it’s been weeks since I had something dorky to say (like programming or something to do with MySQL for example).
Just so you know that I am still dorky, here’s some PHP code for you (from my post over here)…
This will put the keywords that someone searched on to reach your site […]

Wednesday, December 14th, 2005Wednesday, December 14th, 2005

Google API (Web Search) Needs Updating

Yahoo’s APIs are really nice (and there are a ton of them). Google’s API for web search is about 15x slower than Yahoo’s (no joke) and has less features. I really wish Google would bring out a new revision for it (its been stagnant for about 3 years now).
Google’s Map API is still […]

Tuesday, December 13th, 2005Tuesday, December 13th, 2005

Cross-Database JOIN With MySQL

You ever wish you could have done something for years, only to realize one day you could have done it this whole time?
I have a couple tables that I was replicating across 3 or 4 MySQL databases because I didn’t think I could reference a table from database A while working with database B.
Today I […]

Friday, November 18th, 2005Friday, November 18th, 2005

Track AdSense Clicks With Google Analytics

It would be cool if Google automatically tracked AdSense clicks into Google Analytics… But until they do, here’s a little bit of JavaScript code you can use to do it. You can then setup an AdSense click as a “goal” within the Analytics interface.

<script type=”text/javascript”>
// by Shawn - http://www.shawnhogan.com/2005/11/track-adsense-clicks-with-google-analytics.html
// Put this at the bottom […]

Wednesday, November 16th, 2005Wednesday, November 16th, 2005

Roadway Speeds In Google Local/Maps

I really don’t get why Google hasn’t added live traffic data for major cities yet. The information is out there and freely available for anyone to use. It only took me a few minutes of digging around to realtime traffic data for all of California, so why can’t Google find/use it? For […]

Google Maps API Key

Google Maps recently updated their API key system so you can use the same key within subfolders. And all I can say is thank f’ing GOD. Was so annoying that if you make a map and put it on your blog that it would need a separate key when viewing the map from […]

Friday, November 4th, 2005Friday, November 4th, 2005

Geolocation Maps

Based on some of the stuff I did for this, I made a system that can be used by any site (just copy/paste a tiny bit of HTML code and it automagically works).
Anyway, if you want to see where in the world people are from that visit this blog (or want to use it yourself), […]

Wednesday, November 2nd, 2005Wednesday, November 2nd, 2005

Google Maps API Is Pimp

It’s not the first time I used the Google Maps API, but every time I do something with it, I’m reminded about how damn cool it is.
It ended up being relatively trivial to show where in the world all the people currently visiting the forum are at in the world. Added some color coded […]

Friday, October 28th, 2005Friday, October 28th, 2005

Live Email Validation

Here’s a handy bit of PHP code that will take the email variable, lookup the mail server for the domain, log into the mail server and see if it will accept delivery for that address.<?php
$split = preg_split(’/^(.*)<(.*)>(.*)/’, $_REQUEST[’email’], -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
$email = array_pop ($split);
$split = explode (”@”, $email);
$domain = $split[1];

getmxrr ($domain, $a, $b);
if ($a) {
foreach ($a […]

Sunday, October 23rd, 2005Sunday, October 23rd, 2005

CSS - overflow: auto;

I finally solved a CSS problem that has been driving me crazy on the theme I created for this blog. The fact that if you use a border on a block item (a DIV or H1 for example), the border will overlap a floating DIV. The text will wrap properly, but the border […]

Thursday, October 20th, 2005Thursday, October 20th, 2005

MSN Requiring Cookies For RSS Readers

It seems as of last night MSN is now requiring end users to pass a cookie (specifically MC1) with all search and RSS feed requests. The cookie has 2 parts (V and GUID). V is always 3 for now (probably stands for VERSION), the second part is GUID which looks like an MD5 […]

Dude, I’m Awesome!

Well… I decided to write my own PHP script to rip out the old comments (from when this was a Blogger blog), parse them, format them and insert them into the database for WordPress.
The cool part is it all worked on the first try. That’s pretty amazing if you ask me (and that’s why […]

Monday, June 13th, 2005Monday, June 13th, 2005

Killer Coding Ninja Monkeys

Today at ninja school, we got our first uniform. What I want to know is how am I going to strike fear into my enemies wearing something like this? It definitely doesn’t make me look like I can kick ass.
It wasn’t quite what I had expected, but I guess it’s a good first […]

Thursday, March 24th, 2005Thursday, March 24th, 2005

Write Code To Mimic Evolution In Nature

I had an idea this morning.. Why not write code to mimic evolution where needed?
For example a search engine… their algorithms are constantly being changed and updated to fight spam and whatever else comes along.
It wouldn’t work as well on a small scale, but if you have a large number of end users (like a […]

Wednesday, March 23rd, 2005Wednesday, March 23rd, 2005

My First Yahoo API Use

Mucked around with the Yahoo API a little bit, and I must admit it’s pretty nice. I wish the Google API was as fast and had as much features.
My first useful thing I did with it was I added to the keyword tracker so it can track historical search engine rankings for Yahoo (I […]

Tuesday, March 1st, 2005Tuesday, March 1st, 2005

Yahoo API

Today at the SES show, Yahoo announced they are following Google’s lead and allowing people to utilize an API for making automated queries without violating their terms of service.
In some ways it’s better than the Google API because it allows you to do more than just web search (you can search images, local, news, video […]