Lack of updates, link aggregation

So first off I apologize for a lack of blogging. It always seems to fall to the side when life gets busy. My main priority right now is working on (and eventually) finishing going through Florida pictures, but everything seems to get in the way including taking more pics to add to the queue.

One thing I’ve wanted to do for awhile though is have a way to manage my interesting links. I read a lot of tech and science news in the morning and like to share said articles with family and friends. So I generally share them with Facebook, or Twitter (which in turn *usually* trickles back to Facebook unless their plugin is broken), but neither is really a trust worthy place to put any information you care about. I really like the way Justin does it, but also wanted to tie a quick push to Twitter (and thus Facebook) in.  So I figured I might as well write a little social bookmarking thing.

The entire hack took about 30 minutes, including the time to register a cheap (i.e. not taken) and very short (3.2) domain name (k4v.ca) for my built in URL shortener as using kavassalis.com?blah seemed a touch long. I have yet to display my links in the blog layout, but I will probably whip up a widget tomorrow morning to appear on the right side of all the pages with the last N links. Anyway the code is pretty ugly and basic but here it is:

The actual link forwarder: (l.php)

if (sizeof($_GET)!=1) { header("Location: http://kavassalis.com/"); }
$code = key($_GET);

$dbUser = "abc";
$dbPass = "xyz";
$dbName = "nick_blog";
$dbHost = "127.0.0.1";

@mysql_connect($dbHost, $dbUser, $dbPass) or header("Location: http://kavassalis.com/");
@mysql_select_db($dbName) or header("Location: http://kavassalis.com/");

$result = mysql_query("SELECT link FROM links where code='$code'");
$rows = mysql_num_rows($result) ;

if ($rows == 1) {
$link = mysql_result($result,0,"link");
header("Location: $link");
} else { header("Location: http://kavassalis.com/"); }

(The obvious flaw is that it doesn’t give an error to the user if the database is down, but I didn’t feel like doing that so…)

and here is the link creator: (bookmark.php)

function mkCookie()
{
$pool = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
for ($i = 0; $i < 3; $i++)
{ $result .= $pool{rand(0, 61)}; }
return $result;
}

if (!isset($_GET['link']) || !isset($_GET['blurb'])) {
*** FORM HTML WOULD APPEAR HERE, THANKS WORDPRESS ***
} else {

$blurb = $_GET['blurb'];
$link = $_GET['link'];

$dbUser = "abc";
$dbPass = "xyz";
$dbName = "nick_blog";
$dbHost = "127.0.0.1";

@mysql_connect($dbHost, $dbUser, $dbPass) or die("Bah, cannot connect to my DB...");
@mysql_select_db($dbName) or die("Bah, cannot select my database...");

// make sure we dont dupe codes, even though the code space is huge (62*62*62)
while (1) {
$code = mkCookie();
$result = mysql_query("SELECT id FROM links where code='$code'");
$rows = mysql_num_rows($result) ;
if ($rows < 1) break;
}

$result = mysql_query("INSERT INTO links (code,link,blurb) VALUES('$code','$link','$blurb')");
$url = "http://k4v.ca/l?$code";
header("Location: http://twitter.com/home?status=$blurb> $url");
}
?>

Amusingly the WordPress < code > block really seems to detest HTML, i.e. WordPress renders it even though its inside the block, that just makes no sense… Too lazy to figure out how to do it for a 4 line form. So yea, thats the code. No URL tracking/stats, but thats not really what I was going after. I just wanted an easy one click way to share URLs everywhere at once, and store them somewhere safe.

Things have been generally busy work wise, home wise. I am going to try and blog more again. Today being May 5th means that Mucho Burrito has $5 12″ burritos and I’m going to go and see if I can’t manage to consume two between now and dinner. Toodles!

Comments: 5 Comments

Hello world!

So I’ve decided to catalog some of my development projects / experiments as well as make my general rants bigger than the SMS sized text field twitter allows. So for the 800th time, I’m launching a blog.

So far I think I’m going to approve comments by hand, but once someone has an approved comment they can post instantly. That shouldn’t be too much effort, but we’ll see how it goes. I’m feeling too lazy (it is Sunday morning after all) to dig up some captcha plugin and install it. WordPress is always very enjoyable to install, its quick and painless. The photo I threw uptop was taken last Fall in Mississauga’s Port Credit. Here it is in its entirety. I chose it due to fairly similar colors to the theme I chose. I will likely change it in the near future.

(I did however throw up a Twitter plugin to syndicate all my rants to my various social media outlets. I apologize for any perceived spam in advance!)

Don’t have too much to say other than that, it is Sunday morning after all. Cheers!

Comments: 3 Comments

Recent Photos

Post archives

Red List’s Species of the Day