FightSkillz.com - Life, Code, & Idiocy

August, 2008

WhoCallsMe?

Saturday, August 30th, 2008
Usually when I get a call from some strange new number my first reaction is to do a little background to find out if it's a telemarketer, stalker, or someone ligit. Typically this involves doing a reverse phone lookup on yellowpages.ca, and/or a google search trying to get a hit on some company's site or social network. Last time this happened I stumbled onto WhoCallsMe.com, and within 20 seconds I had what I was looking for. The site lets visitors review and comment on phone numbers. Take #605-500-0015 which has 3 pages of comments starting with,
Received a text message from 600-500-0015 with a request to call some 13 digit number. What kinda weird crap is this?
The commenters quickly identify the company calling and continue to share their weird experiences with the calls. It's also a good place to hold you over between prank calls, say you're at work and can't prank people you can just peruse the site for lines like the following about #480-999-1234
...  Nobody seams to be able to stop these people.  They are speaking spanish, I think, tell them to remove my number, don't call me, etc... and they keep calling.  ...

KATG Yard-Sign

Friday, August 29th, 2008
Someone asked me for this.. if you feel like using it feel free to use and edit it like any other KATG promo material. I'd appreciate it if you didn't just link to it directly on my site; if you wanna use it save a copy and put it on your own site. click to zoom -> right click -> save as

Bus Stop Swing Set

Wednesday, August 27th, 2008
These college students get the big picture. Maybe when they graduate there'll be more of these around.

Technorati

Sunday, August 24th, 2008
So last night I went to close my bedroom window and got that feeling that I just walked into a whole lot of spiderwebs. Well this time it wasn't just a feeling, I actually did. After 5 minutes of vainly brushing them off in front of a mirror and not seeing anything I went into another room and checked my arm again only to find a ginourmous spider hanging out. I won't describe the sounds I made while trying to get it off my arm, I wasn't even going to write about the it then I decided to claim my blog on technorati and something brought back the whole visceral ordeal. I'm supposed to post this link to claim it, so there: Technorati Profile

My Leaky Waterbed.

Sunday, August 24th, 2008
It finally broke down, it was a second-hand 20 year old waterbed. The old style where it has a vinyl bladder full of water that you cram into a wooden frame, water heater underneath, safety bladder and it all sat on this wooden frame. Now that I think of it I Think I had it upside-down the whole time..

Actually I'm certain now that I did, I had the bladder sitting in the base which was sitting on the frame instead of the frame sitting on the base... Strange that it never occurred to me before. Then again I'm an idiot so it's to be expected. Now I have to find a new bed. You don't realize it until you need one but a bed is a big commitment. An investment in sleep. I like those hammocks they sleep in in Venezuela that wrap around you, but I don't think these paper thin Canadian walls could support something like that. The only problem with a bed like that is trying to fit 2, 3 or 4 people in it without at anyone falling out. Until I find the bed for me I'm just gonna take a "puppy approach" to sleep—that is: finding comfortable spots wherever I can, floor, couch, pile of blankets.

New Blog Design

Thursday, August 21st, 2008
So I made the sketch at the top blue-er, from not being blue at all, it's now very blue. I also changed the background.

Danielle G. Clothing Website

Thursday, August 21st, 2008
Last night I put up the website for my cous's clothing label, it's got cool animations and contact forms so go check it out, oh and that shirt design is actually on a shirt now.[DanielleGClothing.com]

Passing a Multi-dimensional Array Between Javascript And Php.

Thursday, August 21st, 2008
Passing data between client and server is pretty straight forward, we use HTML structured forms and AJAX calls to put data up, and echo/print methods to bring it down. The data types transmitted are usually strings and numbers. Unfortunately Javascript and Php don't have built in conventions for you to pass arrays or objects between one another. This article shows you how to pass an array from server to client, and then from client to server. Looking around Google there are a number of other developers who've found ways to do this, but the methods they use tend to limit the number of tiers in the array being passed from client to server, use up unwarranted resources for multiple form items and variables to hold each array item, and limit your overall control of the task. This method focuses on getting your data from an array to a string and back again using 1 hidden input, 1 variable, and allows you to have as many tiers to your array as you have characters to use as delimiters. Passing an array from Php to Javascript is quite simple, because our array starts in Php, and Php is parsed first by the server. The whole process can be done in one block of code. Loop through the array in Php echoing it into Javascript code, which when parsed by the clients browser will generate a Javascript array. Say we have a Php array:
 array("model" => "Prophecy Les Paul Ex", "neck" => "Mahogany"),
     "Fender" => array("model" => "Lite Ash Telecaster", "neck" => "Birdseye Maple" ),
     "Washburn" => array("model" => "Idol WI15", "neck" => "Rosewood")
     );
?>


On the page to be served add the following Php which will loop through the array generating the Javascript code to re-create the array on the client-side. You may also want to wrap the generated Javascript in a function if you don't want the array to be generated on page load, or want to be able to refresh/reset the array:
 
var Guitars = new Array();
 


That's it. 

Now if you want to pass the array back from Javascript to Php it's a bit more complex. We'll use the Javascript array Guitars that we just created. First we'll need an HTML form:
<form method="post" action="/example.php">
 
 
</form>
Note the use of both id and name. Name will be assigned to the posted variables we'll need to pick up on the server, as for referring to the input in Javascript you could use the getElementByName(); but I find it to be less reliable and harder to keep track of which elements have a name and which have an id. Using id throughout your application is more uniform. Anyway remember we still have the array Guitars from before, now we need to write the function called by the Submit button:
 
function fn_SubmitForm() {
     arr_Guitars = document.getElementById('arr_Guitars'); //get the element
     arr_Guitars.value = ""; //make sure the value is empty in case the user double clicked
     //loop through the array Guitars concatenating the values into a formatted string
     for(var i in Guitars) {
          arr_Guitars.value += Guitars[i]['model'] + ':' + Guitars[i]['neck'];
          /*
          //Nest this for(){} loop within itself for every tier of your array
          //for each nesting move the delimiters over, if you used a ; next, the
          //nested loop would look like the following:
          for(var ii in Guitars[i]['avail_colours']) {
          arr_Guitars.value += Guitars[i]['avail_colours'][ii]['colour'] + ';';
          }
 
          //to add more array items to this Guitar[i] replace the last delimiter of
          //the output of the last nested loop with that of the tier above it
          arr_Guitars.value = arr_Guitars.value.replace(/;$/,":");
          //or if you're finished with this Guitar[i] remove it
          arr_Guitars.value = arr_Guitars.value.repalce(/;$/,"");
          */
 
          arr_Guitars.value += ',';
          //the preceding line could be added to the end of the first line of the
          //loop if you're only passing a two tiered array
     }
     //remove the last , from the formatted string
     arr_Guitars.value = arr_Guitars.value.replace(/,$/,"");
 
     document.form_Decision.submit();  //submit the form
}
 
Note the formatted string uses the following structure model:neck,model:neck. Also for those new to regular expressions the expression used in the value.replace(); method in plain english means "the comma before the end of the string". Forward slashes mark the beginning and end of the expression, the comma represents a comma and the dollar sign represents the end of the string being analyzed.

Now on the server:
<?php
//get the formatted string
$Guitars = mysql_real_escape_string($_POST[&#039;arr_Guitars&#039;]);
//make sure the array being passed is not empty
if($Guitars != &#039;&#039;){
     //Php&#039;s explode function breaks apart the string into an array of strings based on the delimiter
     //Here we break apart the string into it&#039;s sub-strings <em>model:neck</em>
     $Guitars = explode(",", $Guitars);
 
     //for each exploded array item separate the model and neck values and elaborate the array
     foreach($Guitars as $key=>$row) {
          $row = explode(":",$row);
          $Guitars[$key] = array(
               "model" => $row[0],
               "neck" => $row[1]
               );
     }
}
?>
And that's it, you now have $Guitars again on the server. This method of passing arrays is extensible in that each level of the array can have unlimited values, and the array itself can have unlimited dimensions. For every dimension added to the array you need a new delimiter and you have to run a variation on the second foreach() statement above based on that delimiter.

Coppers

Wednesday, August 20th, 2008
Apparently any physical activity at 4:30am makes me look like a criminal. My first day running after a long stint of lazyness, only 4km and I stopped at the tiny beach down by the lake for a while to take in the view. Almost home free and a cop stops beside me to ask some questions. "Where do you live?" he asked me twice, after watching 3 seasons of Numbers over the last weeks I figure he was trying to see if I lied the first time, you know for a moment I actually thought he was interested in my workout—I mean he did follow me for a block before pulling me over. I wanted to ask him if my form was in disarray but the expression on his face while I tried to explain why I hadn't been running the last few months illustrated he was in fact not interested and over hearing the dispatch after he finally went ahead of me to wait at the address I gave him led me to believe he thought I was a vandal. Oh the shame I felt as my dyslexia caught up with me and I thought for a moment that I was actually a burglar before reality and the cops wild imagination stretched back into their true positions in my head and I quietly opened the front door. At least the last time I got pulled over the cop had reason to, I mean I had been biking for 3 hours straight to Niagara Falls(it's 40km there and back, mostly uphill there, and I had only started biking that week after not being near one in 4 years). I was exhausted—and looked it—in addition I had a backpack and for some reason there's this confusing round-about which I exited orbit of too soon and ended up cycling on a freeway service road towards the United States border, which I believe at the time was on an orange alert or red or whatever one it is where they look for tired people on bicycles trying to torture themselves for a mild endorphine kick.

Danielle G. Clothing

Wednesday, August 13th, 2008
My cousin's in the process of getting a web site for her designer/clothing/fashion label. It should be live in the next while when she'll launch her first line of tees [DanielleGClothing.com]. She sent me some of her designs and one of them stuck with me in a weird way until I realized what I was subconsciously seeing in the negative space. I sent her back a rough sketch of it and she claims it's just a coincidence; naturally I then photoshopped it to make it look cool and posted it here. Original Photoshoped