Libraries

Mobile JS Framework Comparison

Posted in Libraries on July 27th, 2010 by Jamie – 2 Comments

I did a quick matrix to compare various mobile JS frameworks in late May. It is probably a little outdated, especially with the recent Sencha merger, and I did not know DashCode could create web applications at the time, but maybe it will help someone. Enjoy! http://bit.ly/d6Gsaj

Scifihifi-iPhone Keychain Wrapper

Posted in Libraries on July 26th, 2010 by Jamie – 1 Comment

Here’s a great wrapper that really simplifies working with KeyChain in iOS http://log.scifihifi.com/post/55837387/simple-iphone-keychain-code. The code is on GitHub as well http://github.com/ldandersen/scifihifi-iphone/tree/master/security/.

Apple’s official documentation is here, and there is also a sample project, but it’s not a good example for getting up and running quickly. The version of the project (last updated 10/2009) doesn’t even run on the simulator.

Mediawiki-Usage/Changes Storage and Visualizations

Posted in Libraries on March 12th, 2010 by Jamie – Be the first to comment

A coworker and I have been doing some work on visualizations of wiki updates. The server-side code, written in Ruby, stores changes from a media-wiki feed.

Media-wiki Changes Feed

Media-wiki Changes Feed

I got a chance to use the Google Visualization API, which is really simple and useful for a wide variety of domains.

He also turned me on to HAML, which offers a concise, structured way of specifying HTML.

Project Page: http://github.com/hectcastro/mediawiki-usage/
Demo: http://www.angelforge.org/mediawiki-usage/

Media-wiki Changes Visualization

Media-wiki Changes Visualization

Graphiz Problem!

Posted in Libraries on February 20th, 2010 by Jamie – Be the first to comment

I was working on the Drupal OrgChart module tonight, specifically the rendering of the chart image via GraphViz, and I got stuck for at least an hour on a trifle! I planned to use the PEAR library for GraphViz (Image_GraphViz) and I wrote a function using the class it provides. I run the procedure and get weird errors about not being able to find files and such. After debugging for awhile, I find out that there is a property binPath that is not present. I had expected this to point to my install of GraphViz, which I knew to be especially important because it was in a weird macports directory.

It turns out that I had not installed the version I needed! I didn’t realize the version I wanted was beta, and to download a beta package, you need to explicitly state so in the PEAR command.

sudo pear install Image_GraphViz-beta
#instead of
sudo pear install Image_GraphViz

After downloading the most recent package, it turned out my code worked almost perfectly. What a waste of a night!

The past few days, I also worked on a few other modifications. I removed the requirement for a “subordinate_id” field. Also, I made the profile field names options in the administrative settings page.

The project page is here: http://code.google.com/p/drupal-orgchart/.

Ruby Hiccups

Posted in Libraries on January 28th, 2010 by Jamie – Be the first to comment

I decided to try out some Ruby stuff this weekend. I wanted to do a quick little game with the rubygame gem, but I got some weird error attempting to install it on my 64-bit Snow Leopard Intel Mac Powerbook. I abandoned the effort, since I hate to expend time in system administration and installation.

Next, I decided to try running through a Rails demo. I wanted to use MySQL instead of the default SQLite, but got an error, whose text is below, when I tried installing the mysql gem.  I resolved it by using the command string that follows, which I found on a MySQL website forum post.  I think the main issue was that I had a non-standard installation of mysql on my machine via macports, so I had to specify the locations of the various MySQL directories in the gem install command.

Error:
cdERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb --with-mysql-dir=/opt/local/bin
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Command:

sudo gem install --include-dependencies mysql -- --with-mysql-dir=/opt/local/bin --with-mysql-config=/opt/local/bin/mysql_config5

Javascript Gaussian/Banker’s Rounding

Posted in Libraries, Programming on April 16th, 2009 by Jamie – Be the first to comment

Here’s a function for Gaussian/Banker’s Rounding in Javascript adapted from code written by Michael Boon at http://boonedocks.net/.

This can be useful if you’re working with Microsoft languages such as VBScript, which use Banker’s Rounding by default in their Round function. Javascript has no built-in gaussian rounding and, instead, uses Arithmetic rounding. For more information on this, see Wikipedia’s article on rounding, specifically, the Round to Even section.

/*
    Adapted from <a href="http://boonedocks.net/code/bround.inc.phps">http://boonedocks.net/code/bround.inc.phps</a>
Provided under the GNU General Public License
    Contact me for use outside the bounds of that license

    ---------------------------------------------------------------
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    The GNU General Public License can be found at:

http://www.gnu.org/copyleft/gpl.html

*/
<a href="http://boonedocks.net/code/bround.inc.phps"></a>
Number.prototype.gaussianRound = Number.prototype.bankersRound = function bround(iDec) {
    return Math.gaussianRound ( this, iDec );
};

Math.gaussianRound = Math.bankersRound = function (dVal, iDec) {

    // banker's style rounding or round-half-even
    // (round down when even number is left of 5, otherwise round up)
    // dVal is value to round
    // iDec specifies number of decimal places to retain

    var
		dFuzz=0.00001, // to deal with floating-point precision loss
		iRoundup=0, // amount to round up by
		iSign= dVal != 0.0 ? Math.floor ( dVal/ Math.abs( dVal ) ) : 1;

	dVal=Math.abs(dVal);

    // get decimal digit in question and amount to right of it as a fraction
    dWorking = dVal * Math.pow ( 10.0, iDec + 1 ) -
		Math.floor ( dVal * Math.pow ( 10.0, iDec ) ) * 10.0;

	iEvenOddDigit =
		Math.floor ( dVal * Math.pow ( 10.0, iDec) ) -
		Math.floor ( dVal * Math.pow ( 10.0, iDec-1 ) ) * 10.0;

    if ( Math.abs ( dWorking - 5.0 ) &lt; dFuzz)
		iRoundup= iEvenOddDigit &amp; 1 ? 1 : 0; // even testing using bitwise and
    else
		iRoundup= dWorking &gt; 5.0 ? 1 : 0;

    return iSign * ( ( Math.floor ( dVal * Math.pow (10.0,iDec ) ) + iRoundup )/ Math.pow(10.0,iDec) );
};

JSXGraph

Posted in Libraries on March 24th, 2009 by Jamie – Be the first to comment

Awesome JS graphics library compatible with JQuery and Prototype.

JSXGraph » Examples

Gesture Recognition

Posted in Libraries on March 24th, 2009 by Jamie – Be the first to comment

I came across an awesome article on simple gesture recognition.

This page implements a “$1 Gesture Recognizer” that is easy, cheap, and usable almost anywhere. It requires under 100 lines of easy code and achieves 97% recognition rates with only one template defined for each gesture below. With 3+ templates defined, accuracy exceeds 99%.

http://depts.washington.edu/aimgroup/proj/dollar/