Software

Bubble Breaker Using Canvas!

Posted in Programming, Software on March 2nd, 2010 by Jamie – 1 Comment

I wanted to try out some canvas element functionality, given that I have a feeling it will steal a lot of Flash’s thunder. I whipped up a bubble-breaker game (the mechanic should be very familiar to you) in a few hours. Enjoy the demo! I may do a quick write up at a later point.

I’ve only tested it in Firefox 3.6. I do not know whether it will work in other browsers.

Demo
Project site

bubble breaker 13x13

bubble breaker 13x13

bubble breaker 30x30

bubble breaker 30x30

Drupal Org Chart – Graph Viz Update

Posted in Programming, Software on February 24th, 2010 by Jamie – Be the first to comment

I have updated the Google Code repository with updates to integrate GraphViz. It expects the PEAR GraphViz package to be installed.  To install it, issue command:

# You must install the beta package.

sudo pear install Image_GraphViz-beta

If you’d rather not mess with PEAR, download the package, extract the class Image_GraphViz, and alter two two lines of code that depend on the PEAR::System package. It should be trivial to change these. They are both basically calls like this:

// create a temporary file with the prefix "graph_"
$file = System::mktemp('graph_');

One possible replacement:

// will use default tmp dir
$file = tempnam('', 'graph_');

Stikked Patch

Posted in Software on February 16th, 2010 by Jamie – Be the first to comment

We’ve been using Stikked for an internal pastebin. The current version on Google Code has a few bugs. I modified this code to fix two problems specifically:

  1. The Download Code link was not working properly
  2. The Short URL functionality was not working, as Snipr had deprecated the version of the API that the program was using

Below is a consolidated diff of the changes. You should be able to use it to apply a patch to 0.5.4 if you are having these issues.

stikked.diff

Index: trunk/system/application/models/pastes.php
===================================================================
--- trunk/system/application/models/pastes.php	(revision 1)
+++ trunk/system/application/models/pastes.php	(revision 2)
@@ -156,14 +156,55 @@
 			$data['snipurl'] = false;
 		}
 		else
-		{
-			$target = 'http://snipr.com/site/snip?r=simple&link='.site_url('view/'.$data['pid']);
+		{
+			// this next blob just copied from snipr's examples,
+			// with some modifications of course
+
+			// REQUIRED FIELDS
+			$sniplink  = site_url('view/'.$data['pid']);
+			$snipuser  = $this->config->item('snipr_user');            // YOUR USER ID REQUIRED
+			$snipapi   = $this->config->item('snipr_apikey');               // FIND IN YOUR "SETTINGS" PAGE
+
+			// OPTIONAL FIELDS
+			$snipnick   = '';            // MEANINGFUL NICKNAME FOR SNIPURL
+			$sniptitle  = $data['title'];  // TITLE IF ANY
+			$snippk     = '';                      // PRIVATE KEY IF ANY
+			$snipowner  = '';                      // IF THE SNIP OWNER IS SOMEONE ELSE
+			$snipformat = 'simple';                      // DEFAULT RESPONSE IS IN XML, SEND "simple"
+			                                       // FOR JUST THE SNIPURL
+			$snipformat_includepk = "";            // SET TO "Y" IF YOU WANT THE PRIVATE KEY
+			                                       // RETURNED IN THE SNIPURL ALONG WITH THE ALIAS
+
+			//----------------------------------
+			// NO NEED TO EDIT BEYOND THIS POINT
+			//----------------------------------
+			$URL        = 'http://snipr.com/site/getsnip';
+			$sniplink   = rawurlencode($sniplink);
+			$snipnick   = rawurlencode($snipnick);
+			$sniptitle  = rawurlencode($sniptitle);
+
+
+			$post_data =  'sniplink='  . $sniplink  . '&' .
+			              'snipnick='  . $snipnick  . '&' .
+			              'snipuser='  . $snipuser  . '&' .
+			              'snipapi='   . $snipapi   . '&' .
+			              'sniptitle=' . $sniptitle . '&' .
+			              'snipowner=' . $snipowner . '&' .
+			              'snipformat='. $snipformat. '&' .
+			              'snippk='    . $snippk
+			  ;
+
+
+			$target = $this->config->item('snipr_link');
 			$ch = curl_init();
 			curl_setopt($ch, CURLOPT_URL, $target);
+			curl_setopt($ch, CURLOPT_POST, true);
+			curl_setopt($ch, CURLOPT_HEADER, 0);
+			curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
 			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

 			$data['snipurl'] = curl_exec($ch);
-
+
 			curl_close($ch);

 			if(empty($data['snipurl']))
@@ -189,6 +230,7 @@

 	function checkPaste($seg=2)
 	{
+
 		if($this->uri->segment($seg) == "")
 		{
 			return false;
Index: trunk/system/application/config/routes.php
===================================================================
--- trunk/system/application/config/routes.php	(revision 1)
+++ trunk/system/application/config/routes.php	(revision 2)
@@ -46,6 +46,7 @@
 $route['cron/:any'] = "main/cron";

 $route['view/raw/:any'] = 'main/raw/';
+$route['view/download/:any'] = 'main/download/';
 $route['view/options'] = 'main/view_options';
 $route['view/:any'] = 'main/view';
 $route['lists'] = 'main/lists';
Index: trunk/system/application/config/config.php
===================================================================
--- trunk/system/application/config/config.php	(revision 1)
+++ trunk/system/application/config/config.php	(revision 2)
@@ -308,4 +308,16 @@
 $config['rewrite_short_tags'] = FALSE;

+/*
+|--------------------------------------------------------------------------
+| Snipr Settings - Used for short URL
+|--------------------------------------------------------------------------
+|
+| Settings for Snipr API
+|
+*/
+$config['snipr_link'] = 'http://snipurl.com/site/getsnip';
+$config['snipr_user'] = ''; // snipr user name
+$config['snipr_apikey'] = '';
+
 ?>
\ No newline at end of file
Index: trunk/system/application/views/view/download.php
===================================================================
--- trunk/system/application/views/view/download.php	(revision 1)
+++ trunk/system/application/views/view/download.php	(revision 2)
@@ -1,6 +1,6 @@
 <?php

-header('Content-disposition: attachment');
+header('Content-disposition: attachment;filename='.$title.'.'.$lang_code);
 echo html_entity_decode($raw);

 ?>
\ No newline at end of file
Index: trunk/system/libraries/URI.php
===================================================================
--- trunk/system/libraries/URI.php	(revision 1)
+++ trunk/system/libraries/URI.php	(revision 2)
@@ -186,8 +186,15 @@
 	{
 		if ($str != '' AND $this->config->item('permitted_uri_chars') != '')
 		{
-			if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str))
+			$matches = array();
+			$pattern = "|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i";
+			if ( ! preg_match($pattern, $str, $matches))
 			{
+				echo '<pre>*'.$str.'*<br>';
+				echo 'allowed: '.$pattern.'<br>';
+				var_dump($matches);
+				var_dump(debug_backtrace());
+				echo '</pre>';
 				exit('The URI you submitted has disallowed characters.');
 			}
 		}

Stikker

Posted in Programming, Software on February 11th, 2010 by Jamie – Be the first to comment

Some coworkers and I have been working on Stikker, a cli interface for the Stikked FOSS php pastebin. I haven’t used it for awhile, but we recently set it up at work to facilitate code sharing. Unfortunately, it hasn’t been updated recently and there are some things which are broken which I’ll need to address. One of the great things about OSS is that fixing things yourself is possible!

CiteThis! Update 0.17

Posted in Software on February 3rd, 2010 by Jamie – Be the first to comment

I modified CiteThis! with the following features this weekend:

  • Added a citation list box, where you can queue all your citations.
  • Removed the custom citation box from the preferences pane (it was not of use anymore)
  • Fixed APA citation format to include last accessed date.
  • Added some handling of author/titles:
    • If title includes the host name of the site such as “news blah blah – CNN”, then the host name will be removed from the title.
    • If the author ends with any special characters, they will be removed
    • If author contains AP, or Associated Press, that will be stripped.
  • Author determination:
    • Added handling of some common author classes, like when an element has a class called “byline” or “author”
  • Site-specific handling
    • Added handling of some more sites: ABCNews, Fox, CNet, Yahoo News

https://addons.mozilla.org/en-US/firefox/addon/7972

CiteThis! Update 0.16

Posted in Software on January 18th, 2010 by Jamie – Be the first to comment

I made an update at the request of someone who e-mailed me.  This post describes this version:

  • Custom citation formatting broken! (Will be addressed in next update.)
  • Added variable citations depending on what fields are specified
  • Added custom date formatting based on datejs
  • Added custom handling of Wikipedia citations

https://addons.mozilla.org/en-US/firefox/addon/7972

Thirteen Facebook Application

Posted in Programming, Software on December 24th, 2009 by Jamie – Be the first to comment

Update to CiteThis!

Posted in Programming, Software on December 6th, 2009 by Jamie – Be the first to comment

I updated my CiteThis! Firefox Extension with a few of the following features:
Several updates including:

  • Created preferences pane to allow selection of different reference styles
  • Provided option for a customized citation string
  • Implement some automatic author discovery for the page
  • Improved performance by avoiding updates when hidden

https://addons.mozilla.org/en-US/firefox/addon/7972

Sicbo Facebook Application

Posted in Software on June 12th, 2009 by Jamie – Be the first to comment

This is a Facebook application I wrote after the Thirteen application. It improves upon the first Facebook App with a new architecture. Animation uses the Facebook Animation library, and rendering is done via Smarty PHP Template engine. Lots of work went into the architecture, and there is even a localization scheme built in.

Facebook Thirteen Application

Posted in Software on June 12th, 2009 by Jamie – Be the first to comment

This application was written primarily as an exercise in creating Facebook Applications. It was very instructive! Here is the project blog if you’d like more details http://thirteengame.blogspot.com/.

It is an adaptation of a web app I originally wrote in 2007. You may play either by logging into Facebook and trying it out, or logging in here http://www.angelforge.org/thirteen/LoginPage.php. To login outside of Facebook, you may either use the user name and password guest or login with your Facebook credentials using Facebook Connect.