Internet Strategy Guide

Together we can defeat the internet

windows vista price drop buy cubase 4 buy windows 7 ultimate cheap download inventor 2009 adobe premiere pro cs4 download adobe photoshop cs3 mac pcanywhere download 12.5 buy photoshop lightroom 2 microsoft windows vista home basic with sp2 (32 bit) buy microsoft vista online norton 360 cheapest price after effects cs3 for mac microsoft streets and trips 2010 download corel dvd moviefactory 7 pro buy adobe captivate 3 buy autodesk maya online buy windows 7 home premium online web premium cs4 download cheap adobe auditio purchase corel draw x4 buy autocad lt 2010 buy microsoft project manager buy navisworks adobe creative suite 4 web premium download buy microsoft office 2003 download quickbooks enterprise cost windows 7 ultimate 64 bit cost windows 2008 server purchase get parallels desktop 4.0 for mac windows datacenter license cost purchase powerpoint best buy photoshop microsoft money 2007 home & business buy adobe indesign cs3 autodesk lustre cost dvd moviefactory 7 pro lightroom cost microsoft office 2003 best price adobe contribute trial adobe cs4 web premium oem mappoint 2009 europe buy buy microsoft office project 2007 cheap microsoft office 2008 mac buy windows vista home premium 32 bit download office onenote 2003 adobe soundbooth cs3 download where to buy microsoft frontpage windows vista 64 bit cheap buy windows 7 ultimate license corel draw 11 mac download download autodesk inventor 2009 buy windows vista home premium adobe cs4 web premium for mac buy autoroute 2007 lightroom pricing buy photoshop elements 7.0 adobe flash price adobe contribute price windows 7 buy download buy captivate 3 windows 7 digital download access price download windows vista business 64 bit buy windows 7 home premium product key microsoft works 8.5 adobe pagemaker buy buy 3ds max 2009 master collection cs4 system requirements corel for mac download cubase 4 download full adobe acrobat 9 sale microsoft works 9 price buy microsoft visual studio 2008 windows 7 pricing oem after effects cs4 for mac buy office 2003 download buy windows vista premium microsoft mappoint 2009 cost buy norton 360 v3 purchase office 2003 professional adobe cs4 master collection price download wavelab download adobe robohelp 8 illustrator cs4 download buy adobe cs4 for mac buy microsoft visio online microsoft windows 7 professional 64-bit windows vista home basic 64 bit oem windows 7 home premium cheapest download adobe font folio 11 purchase cubase 4 price windows 7 ultimate buy wordperfect online cheap microsoft access 2007 adobe photoshop cs4 buy norton 360 sale turbotax 2009 deluxe coupons autodesk autocad 2010 price buy windows 7 oem key microsoft expression price windows xp sp3 iso microsoft frontpage sale buy windows xp product key online office onenote 2003 download visual studio 2008 professional download buy ms outlook 2007 buy adobe photoshop elements 5.0 buy microsoft works 9.0 3ds max 2010 oem buy encarta 2009 buy microsoft onenote buy microsoft excel 2003 buy sql server 2008 developer edition buy quickbooks pro 2007 buy contribute 3 adobe cs4 production premium prices microsoft excel 2007 download download autocad electrical download autocad 2010 download adobe fireworks cs3 purchase photoshop cs3 for mac windows 7 professional discount adobe photoshop best price corel painter x mac download windows 7 professional price uk buy microsoft encarta windows 7 cost oem after effects for mac trial download quickbooks premier 2008 buy microsoft visio 2007 download autodesk maya adobe premiere pro cs4 cheap microsoft office 2003 buy product key download windows 2003 enterprise buy adobe photoshop for mac buy photoshop for cheap windows 2003 enterprise edition download buy adobe cs3 web premium where can i buy powerpoint 2007 where to buy ms office 2003 windows 2008 web server edition buy adobe illustrator cs3 cheap buy mudbox 2009 buy norton ghost 12 other adobe after effects cs4 download buy windows 7 professional key download microsoft expression web 2 access pricing windows vista business 64 bit sp2 buy windows 7 product key online buy ms access online buy streets and trips 2010 navisworks download nuendo 4 download download corel draw x4 buy corel draw 12 navisworks manage cost microsoft money 2007 deluxe download cs3 design premium trial windows vista business 64 bit oem buy adobe flash for mac turbotax best buy windows 7 ultimate cheap autocad electrical 2008 download buy creative suite 4 download adobe audition 2.0 adobe creative suite 3 web premium download buy after effects cheap download autodesk autocad 2009 adobe suite cs3 price autocad 2010 download full windows 2003 enterprise license price buy symantec antivirus adobe cs4 design premium price buy windows xp professional digital image suite 2006 buy mappoint 2009 windows 7 ultimate 64 bit iso buy windows 7 digitally buy wordperfect x4 autocad architecture 2010 download adobe dreamweaver cs3 price norton ghost 12 download microsoft expression web 2 download buy windows vista business adobe font folio price buy adobe audition 3 dreamweaver for mac price buy adobe premiere elements 7 buy windows 7 oem adobe captivate demo adobe indesign download cs3 buy adobe premiere 6.5 buy illustrator cs3 buy microsoft access only windows vista home basic disc cheap windows xp os buy microsoft access 2007 download buy after effects cs3 mac buy microsoft frontpage software windows 7 home premium oem price buy windows 7 cheap buy powerpoint 2003 online download adobe premiere elements 7 download microsoft access 2003 cubase sx3 download download after effects cs4 illustrator cs3 download inventor professional 2008 download download cs4 dreamweaver windows 7 professional cost buy windows xp license online mappoint 2009 north american maps cheap photoshop cs4 buy windows vista cheap buy adobe contribute cheap corel draw x4 price buy norton ghost 2003 download windows 2008 r2 adobe indesign cs4 download windows 7 home premium best price adobe indesign download cs3 master collection price windows 2008 server prices adobe software for mac purchase windows xp operating system adobe after effects demo cheap adobe cs4 mac cs4 production premium for mac buy corel painter 11 buy adobe premiere pro mac windows 7 64 bit best buy windows 7 ultimate sale price zonealarm antivirus 8 trial buy microsoft office project professional 2003 microsoft office 2008 price wavelab 6 price microsoft office visio professional 2003 download buy windows 7 oem ultimate system requirements powerpoint cheap windows 2008 enterprise download windows vista 64 bit sale microsoft visio 2007 prices buy vista business purchase vista online 64 bit windows 7 professional turbo tax cost autodesk autocad price buy microsoft money 2006 adobe creative suite 4 production premium download buy encarta online buy quickbooks pro 2008 download corel video studio pro x2 microsoft word 2007 price autodesk navisworks simulate 2009 buy streets & trips 2010 autocad inventor lt price microsoft visio 2003 professional download purchase windows 7 64 bit buy autocad inventor 2010 adobe after effects cs3 price buy microsoft access 2003 download design premium cs3 download cheap corel draw software buy autosketch buy adobe dreamweaver cs4 buy office 2003 key adobe premiere elements price painter x for mac cheap windows 7 ultimate retail buy adobe captivate 4 buy windows 7 pro full windows 7 buy cheap microsoft office 2003 best buy windows 7 home premium 64 bit iso buy ms visio 2007 buy vista business oem windows 7 best buy buy windows xp with service pack 2 cheap windows 7 for students buy windows 7 ultimate online cheap windows 7 ultimate buy office 2003 product key buy windows 7 digital copy adobe lightroom discount code turbotax premier discount buy windows 7 oem ultimate autodesk electrical 2009 buy excel 2007 online buy ms project 2007 buy norton 360 3.0 download premiere elements 7 purchase ms office online purchase windows vista download 3ds max design 2010 buy word 2007 buy outlook express 2007 adobe font folio download buy adobe presenter 7 cheap acrobat professional buy cubase 5 dongle purchase office 2003 product key purchase quickbooks license microsoft autoroute 2007 download microsoft windows vista home basic with sp2 (64 bit) buy microsoft office 2003 student download cubase 4 cheapest windows xp pro buy microsoft streets and trips 2009 download wavelab 4 buy cs3 dreamweaver adobe flash cs4 buy buy 3ds max 2010 student adobe premiere pro cs4 mac download microsoft visio 2007 price buy adobe photoshop cs3 3ds max design 2010 windows 7 pro deals buy windows vista 32 bit purchase windows 7 professional buy cs3 after effects quicken rental property manager 2010 autocad 2010 buy windows vista home basic product key adobe premiere elements 8 cheap download microsoft autoroute 2007 europe buy corel draw software autocad electrical 2010 pricing download norton ghost 12.0 adobe contribute demo download adobe premiere full version adobe cs4 design premium download windows xp sp3 buy adobe captivate 4 download windows 7 ultimate 64 bit product key purchase windows 7 half price buy ms powerpoint windows xp buy uk cheap maya software buy corel draw 10 buy adobe framemaker buy photoshop cs3 software buy illustrator for mac autodesk inventor professional 2009 download autocad electrical 2010 torrent buy microsoft office 2008 for mac autodesk 3ds max 2010 download dreamweaver mac cs3 adobe cs3 master collection price purchase microsoft windows vista

Friday, September 25, 2009

PHP Team Development [announcement]

Apparently my php-fu has become good enough that I've been asked to review books. So sometime in the future I will talk about Packt Publishing's book, "PHP Team Development". My complimentary copy is apparently in the mail, so hopefully I learn to read by then.

Seriously though, I hope this book will help me tweak my current team practices. Guess I'll find out after it arrives.

posted by chance at 4:59 am  

Friday, August 7, 2009

visibility and inheritance.

An interesting topic came up in #phpc today. It revolved around some issues I've been encountering in my latest code designs/structures. It also leads into some side topics that I will attempt to explore.

From my point of view, the discussion centered around what is the best 'default' visibility to use for methods. Another thing touched upon is the Open/Closed principle, which I think I subscribe to or may subscribe to(this depends on my ability to determine what half of the words in the entry mean).

Out of the whole discussion, here is the points I got (aka understood) out of it. Please correct me in the comments if I'm off base in any way.

Methods should only be public when necessary. This is to help reduce the amount of side-effects that can occur because of method overrides.

K, I can accept that and in thinking about my past code, I use to use protected more than private. I used public very sparingly.
Now I find, since I started unit testing, that I have a large amount of public functions than I've had in the past. That is because I can't figure out how to test private methods. One way that I can think of is to create public methods that allow you to test the private ones. Unfortunately, this makes me wonder why the method isn't public to begin with since it seems redundant and wasteful to have these public methods to access private methods.
Please note the key word methods, property accessors are a different story.
The best solution (I can think of) to testing private methods is Mock Objects. Unfortunately, even though I've started to use mocks/doubles more, I'm unsure if my implementation is correct. Until I'm confident in my understanding of mocks/doubles, I worry about having false positives in test results.

Another assertion that was made in the discussion was that private methods allow you to preserve the class' core functionality.
Unfortunately, no matter what the visibility of the method is, you're able to override it (and potentially mess with the core functionality you were trying to preserve).
Example:

class foo{
    private function foobar() {
        echo "foo\n";
        return "foo foo\n";
    }

    public function bar() {
        echo "w00t ";
        return $this->foobar();
    }
}

class bar extends foo{
    private function foobar() {
        return "bar\n";
    }

    public function baz() {
        echo $this->bar();
    }

    public function wut() {
        echo $this->foobar();
    }
}

$f=new bar();
$f->baz();
$f->wut();

By running the above code, you get:

w00t foo
foo foo
bar

If preservation of core functionality is your main concern, then you're better off using final.

So after all that rambling, you're probably wondering what I'm trying to get to. It still comes down to visibility's effect on inheritance. The way I see it, unless you declare the method as final, you can't lock down the parent functionality because private methods can still be overridden. Trying to figure out what level of visibility for a method is a situational call. There is no correct 'default' visibility. Sure private is safer because of least privilege but it makes testing a bear (or at least a bear at my current skill level in testing). Public potentially opens you up for abuse or misuse.

What I would still like to know is, how do you do class method visibility? How does that affect your testing methodology? Can someone give me an example (that isn't a singleton) where private is a better choice over protected? I like protected because it seems less limiting to me and my current coding style appreciates that degree of flexibility.

posted by chance at 7:16 am  

Monday, July 13, 2009

mysql alter table add foreign key

I recently ran into a situation where I needed to add a foreign key to a table. This seems easy at first but was actually a 3 step process compared to the couple of lines it takes in a create table sytax.

Short version: when creating your FK column, it helps to have the column definition of the FK match the column definition. In retrospec, this seems like a no-brainer but was the heart of my problem.

So, you want create a FK to an existing table. Lets start by creating our table.

CREATE TABLE IF NOT EXISTS Role(
Id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
Name VARCHAR(255) NOT NULL UNIQUE,
Description TEXT DEFAULT NULL,
PRIMARY KEY(Id)
);

Pretend we pooped data into it and now it's a big pain in the ass to do a drop/create with how we want things.

First we add our column that will be the Foreign Key.

ALTER TABLE Role ADD COLUMN Parent int(11) UNSIGNED DEFAULT NULL;

Next we add an index. Why? because mysql says so and FKs rely on indexes

ALTER TABLE Role ADD INDEX Parent (Parent);

Now we add our constraint.

ALTER TABLE `Role` ADD CONSTRAINT `Parent` FOREIGN KEY(`Parent`) REFERENCES `Role`(`Id`) ON DELETE SET NULL ON UPDATE SET NULL;

For fun, do

ALTER TABLE Role ADD COLUMN Parent int(11) DEFAULT NULL;

for the first step. Everything will look awesome until you get to the the last step. You'll get a wonderful "Errno 150" error and spend a bunch of time googling various key words trying to figure out what went wrong. Well, at least I did.

posted by chance at 9:20 am  

Tuesday, June 30, 2009

headers exception with Zend_Session while unit testing

While the manual for Zend_Session does discuss unit testing and the read-only exception, it has no mention of an exception I encountered recently while unit testing. I admit that the reason I encountered the exception is most likely because I'm Doing It Wrong. However, given reality, I did not have time to properly make the class, or at least do it better. I received the following exception:

exception 'Zend_Session_Exception' with message 'Session must be started before any output has been sent to the browser; output started...'

The problem was, of course, that the feedback from previous tests was already outputted to the screen. I could've solved this by playing with my test suite and just starting sessions at that level but that wouldn't have been the best solution. In fact, I'd qualify that solution under bandaids (solutions that mask a problem instead of fixing them). If you can't see why it is a bandaid, I'm happy to discuss it but for once, I"m going to try to stay on topic and not digress any further than I have.

So, here's the scenario:

  • not enough time to refactor the class so that sessions are only called/created when necessary
  • sessions are being called because we're testing some auth stuff which relies on session information, we might not be able to do DI (see above)
  • we want to minimize contributing factors to test failure so session has to be called/destroyed for the tests that need it, all other tests should never have session existing

The solution? A little 'undocumented' static variable:

Zend_Session::$_unitTestEnabled = true;

Ok, undocumented is a bit misleading. You won't find out about it by looking at the Manual but will find it when you're digging through the API. So it is documented, just not well. I'm guessing because it is rare to encounter the exception. I'm not surprised that I encountered it since my projects always seem to have some degree of weirdness, which makes for an interesting learning curve thats compounded with Zend's curve.

posted by chance at 6:57 am  

Thursday, March 12, 2009

Magic __call() vs. multiple setters

I recently came across a situation where a few of my setProperty() methods where exactly the same. Since I've gotten into improving my coding, this bugged me because it was repetitious code.
Example:

public function setFoo($foo=null) {
	if (is_string($foo)||is_numeric($foo)) {
		$this->foo=$foo;
		return $this;
	}
	throw new Custom_Example_Exception("Please provide a proper string or numeric",Custom_Example_Exception::INVALID_TYPE);
}

public function setBar($bar=null) {
	if (is_string($bar)||is_numeric($bar)) {
		$this->bar=$bar;
		return $this;
	}
	throw new Custom_Example_Exception("Please provide a proper string or numeric",Custom_Example_Exception::INVALID_TYPE);
}

Notice a pattern there? Me too. If all my setters were like this, I could do

public function setProperty($property=null) {
	if (is_string($property)||is_numeric($property)) {
		$this->{$property}=$property;
		return $this;
	}
	throw new Custom_Example_Exception("Please provide a proper string or numeric",Custom_Example_Exception::INVALID_TYPE);
}

with appropriate traps in the __call() and maybe even __set() methods.

However, my situation is that not all the setters for my class follow this pattern so that solution means that I have to make __call() look for specific setters.

public function __call($method,$args) {
	$trapThese=array("Foo","Bar","Baz");
	preg_match('/set(*.?)/im',$method,$matches);
	if (!empty($matches)&&in_array($matches[1],$trapThese)) {
		if(is_string($args[0])||is_numeric($args[0])) {
		$propertyName=strtolower($matches[1]);
			$this->{$propertyName}=$args[0];
		}
		throw new Custom_Example_Exception("Please provide a proper string or numeric.\nException trapped in call to $method",Custom_Example_Exception::INVALID_TYPE);
	} else {
		$this->{$method}($args);
	}
}

And I'm pretty sure that this code snippet ($this->{$method}($args);) is the Wrong Way of Doing It. So I'll just have to settle for the redundant setFoo(),setBar,etc even though a part of me knows that there has to be a Better Way. Or maybe there is just No Way of Doing It Well.

I think it is probably only a matter of preference but in terms of testability, elegance, maintainability, whatever...what do you prefer, doing a magic __call() or making setFoo(),setBar(),setBaz,etc.

posted by chance at 7:44 am  

Tuesday, February 24, 2009

zend_log_exception ‘bad log priority’

I'm writing this post because there are a few times I've gotten this particular exception and then look at the trace and can't figure out what's wrong. More often than not, I'll get to the line in the trace and be like, "wtf! there's no priority here. It's a method call not a constant". This turns into, let's see if something is happening before this method is called and finally comes down to looking at the Zend_Log source and remember, "oh yeah, Zend_Log allows you to use log by priority name as a method in lieu of using the log method" and what I once thought of as slick when I read the documentation turns into a waste of a few minutes and added amount of aggrevation. So to save myself and others some time and aggrevation, I'm going to go into a bit of detail as to why you may be getting this exception.

Take the following for example:

// assume taht $log is a valid instance of Zend_Log
$log->addEventItem('foo','bar');

It looks like it should work, right? It won't because the correct method call would be

$log->setEventItem('foo','bar');

As I explained in the introduction, the 'bad log priority' exception will be thrown for this sort of error. This error will occur because Zend_Log overloads the __call function so that you can do

$log->priorityName('message');
// instead of logging with the log method
$log->log('message',Zend_Log::PRIORITY_NAME);

So if you're like me and get this exception but only see a method where this error is being thrown, you now know why and hopefully be less confused and aggrevated.

I wish I could provide a solution to this issue but I see no way that Zend_Log can contextually tell if you're wanting to use the priorityName shortcut or not. This only leaves the option of removing the the priorityName shortcut entirely, which will break somebody's code. The shortcut is nice because of its flexibility but definitely a case where flexibility can increase complexity or rather, flexibility leading into complications that require complex understanding. I haven't had time to read all the arguments in the comments on the flexibility/complexity issue that Federico Cargnelutti brought up recently to have an overall opinion on the matter but in regards to Zend_Log, the flexibility should've been left out. I would've preferred that Zend kept it simple and just made log the only method of logging. Or maybe I'm an edge case that logs more information than the initial event items give me.

posted by chance at 10:43 am  

Thursday, February 12, 2009

openid seems to hate me

been trying to comment on Chris Shiflett's post on the twitter "Don't Click" debacle and can't seem to get authenticated through openid. so having to post my reply here (below).

cavaet: i'm not an expert on anything and a n00b at a lot of things

liked the article, however I want to disagree that it isn't a csrf attack since "The attack works by including a link or script in a page that accesses a site to which the user is known (or is supposed) to have authenticated" (according to wikipedia [oh no, i'm that guy. *sigh*]). @ramsey said it didn't affect him because he wasn't logged in on the website.

It seems to me that it used clickjack ui redressing to carry out the authentication exploit.

Want to know the funny thing? The only reason I logged into the website was to follow @shiflett.

posted by chance at 11:40 am  

Monday, January 12, 2009

Installing Citrix client onto Ubuntu 64-bit

Recently at work, I was told to install the citrix client. This was fine since citrix has a linux install, which did not work or spit out any error message. After 68 tabs (not exaggerating) worth of googling, I found the reason for this was that citrix hates freedom only works on 32bit linux and that there is no 64bit version out yet. YAY! after a couple thousand (exaggerating) more tabs, I was able to track down the correct way to install citrix onto ubuntu 64-bit.

posted by chance at 12:04 pm  

Friday, December 19, 2008

wordle meme

Joining the wordle meme late in the game because I just got ff java plugin to work.

posted by chance at 6:14 am  

Thursday, December 18, 2008

string searching, you’re doing it wrong

First off, I'm not trying to be a complete jack-ass, just a helpful one. This article, by Stefan Ashwell, popped up on my news feed and I wanted to comment on it but can't remember my login for the site and after 10 minutes of waiting the password reset email has yet to arrive. The non-arrival of the password process is irritating me and shows in this article title and my tone.

In the article, Stefan shows how strpos or stripos to locate a desired string or block of text.

The example he gives is as follows:

if ( stripos($sentence, 'string') ) {
   // yes it does
} else {
   // no it doesn't
}

The problem with this example is that it will yield a false positive. This is a common mistake made by a lot of people. If we examine the php manual entry further we see, "Returns the numeric position of the first occurrence of needle in the haystack string." The key word being numeric. This means if the string position is 0, then the expression ( stripos($sentence, 'string') ) will evaluate to false.

EDIT: Expanded explaination on why this can yield a false positive. If the string your searching for is at the beginning of the sentence, then the position returned is 0. When php reaches the statement if ( stripos($sentence, 'string') ) it interprets the return value (0) as false.

Here is a more expanded example:


$eval=(stripos('The quick brown fox jumped over the lazy dog','The'));

echo '($eval) : ';
echo ($eval) ? "pass\n" : "fail whale\n";
echo '($eval==0) : ';
echo ($eval==0) ? "pass\n" : "fail whale\n";
echo '($eval===false)';
echo ($eval===false) ? "pass\n" : "fail whale\n";
echo 'eval is '.$eval."\n";

/**
output is:

($eval) : fail whale
($eval==0) : pass
($eval===false)fail whale
eval is 0

*/

As you can see, if you want to properly search for a string using stripos or strpos, you must test for the boolean value of false ($eval===false). Alternately, you can use regex, if you're comfortable with it. I'm of the opinion that learning some basic regex doesn't ever hurt you.

I want to re-iterate that I wanted to leave this whole post as a comment but that doesn't seem possible right now since that email has yet to arrive and the article requires login for commenting.

posted by chance at 7:01 am  
Next Page »

Powered by WordPress