postaweek2011


29
Mar 11

UBB AVP… same difference

Sadly this seems completely accurate…

In order to be effective as an economic ITMP, the usage based price component needs to be established so as to discourage use above the set limit. The price should incent use in excess of the limit only to the extent that the consumer would gain significant value from that usage. If the price is set substantially below the consumer’s value, it will have little influence on usage.

via: http://www.michaelgeist.ca/content/view/5711/125/


20
Mar 11

Setting up PHP 5.x on webfaction

PHP 5.2

1. Create a “Custom app listening on port” call it phpstack, note the port number you are assigned.
2. SSH into the server into the new application directory (~/webapps/phpstack/)
3. run: wget http://wiki.webfaction.com/attachment/wiki/MiscellaneousFiles/build_php_worker.sh?format=raw
4. Check that the file is executable by running: chmod +x build_php_worker.sh
5. Run the script ./build_php_worker.sh . PORT_NUMBER
6. Wait for it to finish building and read the instructions at the end.
(This can take 1 to 2 hours to complete.)

PHP 5.3

1. Create a “Custom app listening on port” call it phpstack, note the port number you are assigned.
2. SSH into the server into the new application directory (~/webapps/phpstack/)
3. run: wget -O build_php_worker531.sh ‘http://nero.webfactional.com/build_php_worker531.sh’
4. Check that the file is executable by running: chmod +x build_php_worker531.sh
5. Run the script: ./build_php_worker531.sh . PORT_NUMBER
6. Wait for it to finish building and read the instructions at the end.
(This can take 1 to 2 hours to complete.)


6
Mar 11

Instead of just Killing off IE6…

Why not kill off IE7 while we are at it?

So, IE6 is on the death march. It’s support ended July 13th 2010. Unfortunately it persists because of Windows XP, as it’s support lasts until 2014.

http://www.theie6countdown.com/

I figured I should help out, but I want to help kill of IE7 as well, so I found an IE6 notice script here: https://code.google.com/p/ie6-upgrade-notification-bar/. I have made quite a few changes to it, and here is the result:

http://seanja.com/demos/ie7-notice/.

The source is available on github https://github.com/SeanJA/ie7-notice.


12
Feb 11

Drupal: Page Not found when returning from an OpenID provider

Apparently there are some issues with the OpenID module sometimes (I found this out when I switched over to hostgator from my previous webhost)… so here is the solution that worked for me:

This is the patch that is provided:

// © by Andriy Gerasika from GerixSoft, Ltd.
if (is_int($return) && $return == MENU_NOT_FOUND) {
	$uri = $_SERVER['REQUEST_URI'];
	$path = parse_url($uri, PHP_URL_PATH);
	if ($path == '/openid/authenticate' || ereg('^/user/[0-9]+/openid$', $path)!=false) {
		$path = substr($path, 1);
		$query = 'q=' . $path . '&' . parse_url($uri, PHP_URL_QUERY);
		$_SERVER['QUERY_STRING'] = $query;
		parse_str($query, $_REQUEST);
		parse_str($query, $_GET);
		$return = menu_execute_active_handler();
	}
}

I made a small change for PHP 5.3 compatibility

// © by Andriy Gerasika from GerixSoft, Ltd.
if (is_int($return) && $return == MENU_NOT_FOUND) {
	$uri = $_SERVER['REQUEST_URI'];
	$path = parse_url($uri, PHP_URL_PATH);
	//FIX: SeanJA don't use ereg, use preg_match
	//also, preg_match returns a count, so compare to 0 instead of false
	if ($path == '/openid/authenticate' || preg_match('/^\/user\/[0-9]+\/openid$/', $path)!=0) {
		$path = substr($path, 1);
		$query = 'q=' . $path . '&' . parse_url($uri, PHP_URL_QUERY);
		$_SERVER['QUERY_STRING'] = $query;
		parse_str($query, $_REQUEST);
		parse_str($query, $_GET);
		$return = menu_execute_active_handler();
	}
}

This gets applied to the index.php file, just under:

//~line 18
$return = menu_execute_active_handler();

Source: http://www.gerixsoft.com/blog/drupal/openid-page-not-found


26
Jan 11

PHP SQL Query Builder

As an excersise I have started building another php based sql query builder (separate from my stagnating php framework). So far I can do SELECT [columns] FROM table WHERE [conditions]

This is how it should be used (so far):
(for the examples, assume that $q is a query object)

$q->table('test')
	->column('test_2', 'test')
	->table('test_3', 'test_2');
//=> SELECT test_2 as test FROM test, test_3 AS test_2

You can also group conditions:

$q->table('table')
	->begin_and()
	->and_where('col_1', 1)
	->or_where('col_2', 2)
	->end_and()
	->or_where('col_3', 3, '!=');
 
//=>SELECT * FROM table WHERE ( col_1 = '1'  OR col_2 = '2' ) or col_3 != '3'

which is fun.

I have just tried this example and am pleased to say that you can put multiple groups at the start of the query:

$q->table('table')
	->begin_and()
	->begin_and()
	->and_where('col_1', 1)
	->or_where('col_2', 2)
	->end_and()
	->end_and()
	->or_where('col_3', 3, '!=');
 
//=>SELECT * FROM table WHERE ( ( col_1 = '1' OR col_2 = '2' ) ) OR col_3 != '3'

You can follow along here if you want, suggest improvements, criticize it to no end because I am doing it toally wrong, or “steal” my ideas and make your own (but give me some of the credit at least).