Archive for February, 2009
T-Mobile Twitter Troubles
Oh yay, alliteration.
Since last night, I have not been able to use Twitter via my mobile device. When I send a tweet, my phone immediately says “Sending Failed, Message in Outbox to be sent later” [paraphrase].. after about 5-10 minutes, I get another message box that says “Message #NUM cannot be sent, see outbox for message status.” Checking the status of the failed message simply says “Sending failed.”
I can still receive tweets, but I cannot send them via SMS. Is this a temporary problem? Or is T-Mobile playing god and blocking Twitter again?
Bound for Washington D.C.
I have been apart of FIRST robotics since I was in the eleventh grade. During my twelfth grade year, I was asked to help as an emergency volunteer at the New Orleans Regional. They were extremely understaffed and it was their inaugeral regional. I found that volunteering was very interesting. I was part of the field reset/repair crew. Whenever a match was over, we’d quickly reset all the game pieces for the next match. This was great, not only did I get to help (and get free lunch!) but we got to be up close & personal with game field – best seats in the house.
Well since then I’ve volunteered at any regional I can. I was volunteer staff at New Orleans ‘07, Philadelphia ‘07, Atlanta ‘07, Philadelphia ‘08, Atlanta ‘08. This year I will be volunteering at the Washington DC and Philadelphia regionals. I will not be able to attend the Atlanta championship.
Starting with Philadelphia last year, I was a scorekeeper. This means that I am responsible for the commission of the scores to the database at the end of every match. I don’t do anything during the match, I just start the match when all robots are placed and everyone is ready. There’s only one point of authority too. As a scorekeeper, you only take directives (in relation to the final score) from the head ref – no one else. You don’t even answer to any one about the internal score, that’s the head ref’s job – easy peasy.
Unfortunately, at Washington D.C. there was already a person lined up for scorekeeping. Instead, I am being placed as an official scorer, which is considered to be an officiating position. Yay. This involves keeping track of the game as it is happening. I take tally of every point scored in real time. The score I input is placed on the screen for the audience. It’s an intense and high pressure position. Yikes. Luckily at Philadelphia, I’ll go back to being scorekeeper.
I will be leaving Wednesday the 25th. We’ll be staying at a hotel in Virgina and have a 20 minute-or-so drive to DC every morning. We’ll be returning that Saturday night.
The organization I participate in is called FIRST Robotics. And no, it’s not like battlebots.
PHP Datatype Validation
So, let’s say that you’re writing a function or some sort of script. and you need to sure you’re only getting a certain datatype as a value. Then you realize that PHP has no actual datatype enforcement like C or C++. You can set any variable to contain any kind of structure (strings, integers, arrays, etc) and you can later change it to any other structure later on the fly. This can be problematic depending on what you need to do.
With the function you’re supposedly writing, let’s say you wanted to make sure a argument you’re accepting via the PHP call is an integer. Well you could perform and is_int() function call by yourself, but thats not the point. The point of functions is to reduce tedious/repeated code. I made a class that has a function inside it that does all the testing for you depending on what you, as a coder, is expecting. So passing “hi” into the validator when you specify you’re looking for an integer wouldn’t pass. It would pass if you stated you were looking for a string, though.
What’s also nifty is that i wrote it to accommodate for the event of expecting multiple kinds of datatypes. Like let’s say you want either an integer or a double (a decimal), you can simple combine them when you call the validator. If the value you give the validator is an integer or a double, it’ll spit back the datatype.
Okay, how do I have it check for datatypes? Every datatype that I could look for is assigned a number in base 2 (1, 2, 4, 8, 16, 32, etc) . I assign them base 2 values in hex, simple because I felt like it.
define(“SCRAPBOOK_DATATYPE_STR”, 0×01); // STRING
define(“SCRAPBOOK_DATATYPE_ARR”, 0×02); // ARRAY
define(“SCRAPBOOK_DATATYPE_INT”, 0×04); // INTEGER
define(“SCRAPBOOK_DATATYPE_DOUBLE”, 0×08); // DOUBLE
SCRAPBOOK_DATATYPE_STR is set to 1, _ARR is 2, etc etc. You get the point. When I call the function, the first argument/parameter is the value I need to test. The second is the (possible) datatype(s) I’m expecting. What you may or may not know about bit addition is that its very easy to figure out what bits are included. For example, the value of 6 is ONLY made up of 2 and 4, which in this are the bits that are assigned to _ARR and _INT. Using this logic, we can pass multiple datatypes we might get (for example, we want a number which might be an integer or a decimal) and the function can check to see if the datatype of the value I’m checking for matches one of the datatypes I’m looking for.
Here is an example of looking for one datatype and then two datatypes:
//first instantiate the object
$validate = new Validator();//would return SCRAPBOOK_DATATYPE_ARR
print $validate->validateDatatype(array(), SCRAPBOOK_DATATYPE_ARR).”\n”;//would return SCRAPBOOK_DATATYPE_INT
print $validate->validateDatatype(5, SCRAPBOOK_DATATYPE_INT|SCRAPBOOK_DATATYPE_DOUBLE).”\n”;
//would return SCRAPBOOK_DATATYPE_DOUBLE
print $validate->validateDatatype(5.3, SCRAPBOOK_DATATYPE_INT|SCRAPBOOK_DATATYPE_DOUBLE).”\n”;
As you can see, the pipe (|) is used to add multiple of these bits together. The function would return the bit of the dataype found. this way if you’re expecting two datatypes, you can validate it and then see the exact type that was actually sent in.
Now how do i actually do the tests? well in the function I have something like this:
function validateDatatype($value = NULL, $expectedtypes = SCRAPBOOK_DATATYPE_STR)
{
//are we testing if this datatype exists? || now we test!
if ( ($expectedtypes & SCRAPBOOK_DATATYPE_STR) && (is_string($value)) )
return SCRAPBOOK_DATATYPE_STR;
if ( ($expectedtypes & SCRAPBOOK_DATATYPE_ARR) && (is_array($value)) )
return SCRAPBOOK_DATATYPE_ARR;
if ( ($expectedtypes & SCRAPBOOK_DATATYPE_INT) && (is_int($value)) )
return SCRAPBOOK_DATATYPE_INT;
if ( ($expectedtypes & SCRAPBOOK_DATATYPE_OBJECT) && (is_object($value)) )
return SCRAPBOOK_DATATYPE_OBJECT;
Essentially, i’m testing to see if we’re asking for each datatype, if we are asking for that datatype, i perform a function call to see if it actually is. If it’s not it keeps going until it returns something. if it gets to the end of the function, that means it didn’t validate, so false is returned. The (x & y) test basically checks to see if bit y exists within value x. So again, for example, lets say you have a number 13. The only way to get a number 13 through this method is with numbers 8, 4 and 1 (8+4+1 = 13). So if you did (13 & 4) it’d return true. So on and so forth.
Ok, now that I gave you little snippets, check out the entire script so you can see how it all blends together.
Google’s Malware Labeling Slipup – People’s Lack Of Common Sense
So this Saturday, there was a relatively huge slip-up/oopsies done by Google. They updated their definition file that contains a list of potentially bad sites that host malware and somehow (by human error) a single ‘/’ get entered as an entry. In terms of a file path in this context, the / is interpreted as a wildcard – so every site. Essentially, every single result was marked as a “This site could harm your computer” kind of website in the search results. It even flagged its own sites as dangerous:
Now you see, this is causing web-masters and companies ALL OVER THE WORLD to call foul. Apparently because of this slipup are causing “potential visitors/customers to be steered away from our site because we have been labeled as a malware provider.” Uhm. That’s just stupid. I think anyone with half a brain could see that every single result is being flagged as dangerous… will realize that there must be SOME mistake. I mean it’s kind of obvious. I mean, before this glitch, I’ve only come across a few of these flags… so if all of a sudden every single result from Google starts displaying this flag, especially with a legitimate search string (ie not “cracks for photoshop”, “movie torrents”, etc), it’s obvious there is a problem.
No doubt some idiot is going to try to initiate either an individual lawsuit or a class-action suit against Google for something along the lines of “defamation of character” or some bogus claim. And I hope it gets shot down.
Accidents happen. Get over it. Get over yourselves.
Though I will say – the guy that made the typo – is probably jobless right now.
