Amptools.Net

simplify your life.

Blog

Missing ValidationMessageFor ?

No Gravatar

Looking for the method ValidationMessageFor() ? Or at least wondering what happened to it? Same here.

I see the example of it’s use on Scott Gu’s Blog for Asp.Net Mvc 2.0 preview 1. Yet I have not been able to google/bing a blog, tweet, or official mention of why this was dropped.

I checked the bits using , source code, and release notes for . The bits and source code do confirm one thing. The extension methods for ValidationMessageFor() are not available in Preview 2.

Unfortunately I do not have a bat phone (or a direct message on twitter) to anyone that works on Asp.Net Mvc. But I’m sure someone will pick up on this.

Tags: , , , ,

Top Ten Worst Opensource Names

No Gravatar

The top 10 offenders of opensource projects for bad or offensive naming and branding their software.  Viral? Ignorance? Offensive? Bad? Genius? You decide.

The Top Ten Worst Names

10. Gnome – What does bigfoot have to do with a hobbit like creature?  There is not even an a clippy version of a gnome on the desktop.  Not that I’m a clippy advocate.

9. The Gimp – Derogatory term and it sounds like the software is inept.  A good reason not to use GNU as part of your name. Imp is cooler.

8. GNU/Linux - Having to type GNU in front of Linux is both time consuming and pointless. Which is on par with anything from Mr. Stallman these days.

7. openSuse – um. Is it still a mystery why there are not as many women as men in software development?  Open in front of any one’s name is probably never a good idea.

6. Mono – In Spanish it is a monkey, in English it is a disease.

5. Tomboy – Who is going to go around admitting to using this aloud?

4. Yum – I don’t know which is worse. A food related acronym?  Or that it stands for is yellowdog updater modified.

3. PHP – Recursive acronym? “PHP: Hypertext Preprocessor”?  Why? Just why?  This is the same  evil as made-up words used by the press like “athleticism”, then having it added to the dictionary. ick.

2.  god – A ruby plugin.  It brings shame that developers fight over software tools and languages like it is politics or religion. Ridiculous, I know. Then someone  just had to bring religion into it?

1. Sperm Reports – I’m thinking someone was either downing pints at a bar, or lost a bet. I really don’t want to even think about other reasons for this name.

Honorable Mentions.

Any web 2.0 project like drupal or joomla. Netoops (.net object oriented portal) or Xoops (extensible object oriented portal).  Scrum & Scum Master. PR nightmare.

Feel free to add more below.

Tags: , , , , , ,

Website Redesign Underway

No Gravatar

Amptools.Net has the beginnings of a new design.

The site is now HTML 5 and uses parts of CSS3. There is definitely more to come. Spicing up content, pulling in eye candy, debauchery with HTML 5 and CSS 3, and entwining them into blissful marriage.

A simple example of blending content and design: certain links for certain domains like twitter or facebook now have little icons by them. It will work for browsers that support CSS3 selectors. This is achieved by using CSS 3 selectors looking for those domains in the ‘href’ attribute.

a[href*="twitter.com/"] {
     background: #fff url(path/to/image.png) no-repeat;
     padding-left: 24px;
}

The above example is a good use of how to enhance content presentation that degrades in older browsers. Internet Explorer, overlord of software web browsers, even allows for a few of these CSS selectors in version 8.

The links might not display images in IE 6 or 7, but the additions will not be sorely missed. It provides a nice incentive to upgrade the browser.

The design of the site as for 9/28/09.

initial redesign of amptools.net

initial redesign of amptools.net

EdUI 2009, Branding, Site Updates.

No Gravatar

Site Updates and Mix-match UI

Excuse the mess. This site will be undergoing a redesign to match the current logo and branding over the new few weeks. I will also be spending time on filling in huge content gaps and weak areas of the story of this website as I have time. The blue hues do not match and in my haste, I used a word-press template rather than creating my own theme. There are some issues in different browsers due to the decoder theme. Another issue is that sometimes the site takes longer to resolve than it should, if it does resolve (hosting provider is having mysql issues of some sort).

EdUI2009

So I’ll be off to EdUI 2009 tomorrow, up earlier than usual and probably looking like a vampire trying to hide from the sun (microsoft used to have this cool add of a developer hiding from the sun for visual studio 2005 I was hoping to insert here, but the 400 plus differences and defy all challenges websites are gone). That should be fun. Though I’m kinda bummed that all the presentations I want to see are tomorrow morning at the same time.

  • Usability Testing Without the Scary
  • New Insights in Web Standards
  • Beyond Blah Blah: Creating Great Content for the Web
  • Visual Design Essentials for Non-Artists

I’ll probably have to hit up the creating great content for the web, since I generally keep up with web standards, ui testing, and have a communications major specializing in media graphics (though yes, i know the site is currently lacking, I am working on it, Rome and all that.).

Branding

Branding or a brand can be described as creating an image that sets yourself or goods or services apart from everyone else. Branding yourself or a product or service is just as an important part of the business process/model as it is to have to having a great resume on file, quality code, great client relationships, an amazing product or service to sell.

I have been doing a great deal of debating, contemplating, and researching in what direction do I want to take this lil side project, website, and my own life in general in. What kind of image do I want to display and answering various questions. To what end? Why do it? Is it fluid enough to keep up with the times? What is my target audience? How does this relate to “main street”? (I loathe that term with extreme prejudice as much as one can despise words). Branding is more than a logo, its an attitude, persona that people associate with a company, person, service, product. In example, google’s “do not be evil” philosophy. Also what image should be avoided?

Even though I have determined a rough vision statement, a road map, a temporary logo, and other details, I’m still working on the branding, narrowing down the target audience, and road that I wish to travel upon. So please excuse the current mess.

When being professional, discard religion and politics at the door

On a side note, I find it sad, that a decent amount of well known developers on twitter and even in blog posts who have branded themselves well, whether they know it or not, putting up political views. I myself have been guilty of this in the past and have resolved to keep anything related to amptools.net religion, race, and politics free. If you have a professional blog, twitter account, etc. Keep it professional. Its your name and sometimes you are directly insulting your end users and other people in the industry who might hold opposite views or beliefs.

Everyone has their own belief system even if you are an atheist or politician, or even a jedi . That belief system will influence your decisions in life and even on a daily basis. However, it does not mean you are above others who share different views. Nor is it wise to insult your user base. As such, it would be wiser and professional to show restraint of the tongue or in this case the next 140 characters you type. If you live in Charlottesville, I believe that means also removing those vile bumper stickers off your vehicle.

New Business Cards

The osc business card is based after the one Youssef Chaker did using a website called moo.com for business cards. The amptools one is using the newer temporary logo, i removed the gears and left in the accent/ angle bracket symbolizing the windows command line.

osc business card frontside, 150 DPI, png 8

osc business card frontside, 150 DPI, png 8


osc business card backside, 150 DPI, png 8

osc business card backside, 150 DPI, png 8


amptools business card frontside, 150 DPI

amptools business card frontside, 150 DPI


amptools business card backside, 150 DPI, png 8

amptools business card backside, 150 DPI, png 8

Tags: , , , , ,

midori notes stardate 9.14.09

No Gravatar

Geek Specs

Ignore the Trekkie reference.  I’ve started to work on the data abstraction layer for Midori, after narrowing down the supported out-of-the-box relational databases.  In no particular order, they are SqlServer, SqlServerCe, MySql, Postgress, and Sqlite. Its being written in .Net 4.0 and hopefully it should port to Mono.

The main abstraction class Midori.Data.SqlAdapter makes use of the System.Data interfaces, like System.Data.IDataReader. Obviously this class will grow as other crud operations are added.  Each RDMS will have a class that will inherit Midori.Data.SqlAdapter, like Midori.Data.Sqlite.SqliteAdapter, which will hold code specific to each database.

There is a Connection class that wraps other connection objects and supplies OnConnect and OnClose events, which should be helpful for closing the connection objects for methods that pass back datareader objects.

Interesting Notes

System.Data.Common.DbConnectionStringBuilder is a handy class for building and inspecting values of a connection string in a hash like way.  Some Ado.Net layers, like System.Data.SqlServerCe, does not implement their own connection string builder. While it is nice to have, its not a necessity, especially when the common dbconnectionstringbuilder will suffice.

Postgres or Npgsql, has some interesting behavior. The following select query has Pascal casing for the names of the columns.

SELECT 'column1' AS Column1, 10 AS Age

However when the DataReader for Postgres returns the names of the columns, they are all lowercase, all the other databases return the column aliases in the same case as specified in SQL.

So in the tests, I had to rewrite the query to use all lowercase column aliases, like so:

SELECT 'column1' AS column1, 10 AS age

Tags: , , , , , , ,

Where is the documentation?

No Gravatar

I’ve been spinning my wheels on the concept of scalable, portable documentation and how to get that into opensource and internal projects that I work on.  It is no wonder so many opensource products lack good documentation, not only is it taxing to do to, but the tools for generating decent documentation either suck or are too costly (such as Adobe’s Framemaker or oxygen XML).

Wiki’s help, but writing docs in a specific wiki format is not exactly portable.  HTML is sort of portable, especially XHTML to which you could apply XLST against it to transform it into whatever XML format.

The docbook format has value, especially version 5 and the fact that O’Reilly, PHP, Fedora, and other large groups/company’s use it. The sting is that the tools still seem lacking and most are in Java.  My only concern is that it seems that Java does not seem to be progressing and Sun/Oracle is only servicing the byte code layer for things like Scala, JRuby, etc as a friend of mine and fellow developer Ashish Tonse pointed out.   I’m not about to cry wolf and say “Java is dead” or say its evil, when it has many stable, mature frameworks and libraries and probably better build processes and continuous integration like Maven and Hudson. Java is just an all around wonder for the opensource community in general.  I just wonder about the long term and think that things like Mono/C# would be the way to go, as it will allow for things like Iron Python and Iron Ruby which are widely used dynamic languages to be tied into it.

I’ve used tools like sandcastle,PHPDoc, and Rdoc to generate documentation. Each have their own strengths, but mostly they have weaknesses at this point.  The ability to easily extend, change the output, or search ability of the documentation generated is definitely weak in all documentation tools that are out there.   I’m wondering what if the community developed some kind of docbook like system with easy templates to modify whether XSLT or T4, or even Ruby with Rails like templates,whatever flavor you are interested in.

For now, I guess i’m stickying to putting html tags into a wiki on github, with hopes of using the github api and parsing the XHTML later into a different format.

Tags: , , , , , , ,

TAB PHP Alpha Available

No Gravatar

is now available for both download or pulling from git hub. I’ve seen people try to clone rake before, but it generally lacks cause well PHP lacks as a language, especially compared to Ruby. However, since PHP 5.3 is now out, there is no reason not to take advantage of namespaces and anonymous functions.

This is basically a usable prototype, hoping to get some feedback and do a real release later with documentation and tests. If you know how to use rake and the command line in general, this should not be too hard to figure out, however some basic usage examples are posted on the wiki on git hub.

Tags: , , ,

Zend Framework Image Captcha

No Gravatar

The Zend Framework documentation lacks when it comes to showing the ins of out of some of its components, the seems to fall under that category. You would think there would be a ton of useful blog posts and if there are useful posts, I don’t think google is catching them. I did find some useful code on this blog, . It does make some decent notes, so please go read this post first (and thank him, cause so far he has the best notes on the ZF captcha thus far), but the code did not seem to work with the current version of Zend that I have which is currently version 1.7.8. The other post is using some kind of Iterator and expecting the zend namespace to have a getIterator method, for some reason this was not working for me.

Here is the modified/refactored version that creates a static wrapper Captcha class using the image captcha. To reiterate what the other blog says, Make sure you have GD enabled, make sure you have a font file, make sure you have the file paths pointing to the right place, and make sure you have the right permissions for the folders that contain the images and font file.

PHP Captcha Class

class Capatcha
{

	/**
	 * validates the last image captcha that was created
	 * and put into the current session.
	 *
	 * @param string $postPrefix  the prefix of the post value i.e. 'captcha[id]'
	 * @return boolean
	 */
	public static function validate($postPrefix = "captcha")
	{
		$captcha = $_POST[$postPrefix];
        	$captchaId = $captcha['id'];
        	$captchaInput = $captcha['input'];
        	$captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaId);

        	$captchaWord =   $captchaSession->word;
        	if( $captchaWord )
        		return $captchaInput == $captchaWord;
       		return false;
	}

	/**
	 * generates the captcha image and returns the image id.
	 *
	 * @param string $postPrefix  the prefix of the post value i.e. 'captcha[id]'
	 * @return string
	 */
	public static function generate($postPrefix = "captcha")
	{
		// replace the path/to with the correct path...
		// same with /images/captcha
		$captcha = new Zend_Captcha_Image(array(
		    'name' => $postPrefix,
		    'wordLen' => 6,
		    'timeout' => 600,
			'font' => "path/to/IMPACT.TTF",
			'imgdir' => "path/to/images/captcha",
			'imgurl' => "/images/captcha"
		));

		return $captcha->generate();
	}
}

PHP ZF Controller

// in your action in the controller,
// it would look like some variation of this
if($this->getRequest()->isPost())
{
	if(!Capatcha::validate())
        {
        	$id = Capatcha::generate();
        	$this->view->captcha = $id;
        	$this->view->message = "captcha was invalid";
        	return;
        } else {
               $this->view->message = "saved!";
        }
}
else
{
        $this->view->message ="";
        $id = Capatcha::generate();
        $this->view->captcha = $id;
}

XHTML View


<!-- above your form using with short tags on -->
<div class="error"><?= $this->message ?></div>

<!-- somewhere in your form -->
	<img src="/images/captcha/<?= $this->captcha ?>.png" alt="captcha" />
	<input type="text" name="captcha[input]" value="" />
	<input type="hidden" name="captcha[id]" value="<?= $this->captcha ?>" />

Tags: , ,

Boxing and Unboxing in PHP

No Gravatar

If you are not familiar with type/value boxing using objects, head over to to grasp the concept. While languages such as Java and C# support this natively, PHP does not. However it can be accomplished, to some degree in PHP, just not eloquently as the language itself does not have constructs to support it.  Having box types in PHP could help with chaining, keeping everything object oriented and allows for type hinting in method signatures.  The downside is overhead and the fact that you now have extra checking to do using the “instanceof” construct.  Having a type system is also a plus when using development tools that have intellisense or code assist like PDT. Rather than having to google/bing/yahoo for the method, it exists on the object, and you can use the tool to provide a drop down.

Boxing and Unboxing with Midori PHP

In I’ve add box types for native values in PHP. Granted not all the types are there yet, as i’m slowly porting them in, writing documentation, writing tests, and refactoring what currently exists from the prototype.  The key classes to look at would be the , , and .  The Midori_Nullable class currently abstracts a nullable value into a class which is built on the Midori_Object and is the parent of Midori_String.  So using these box classes might look like the follow: 

PHP


	// boxing example
	$str = new Midori_String("my cool new value"); // value is now boxed
	$str2 = $str->replace("value", "test");

	// unboxing
	$unboxedStr = $str2->value; // unboxed value

	echo $unboxedStr; // my cool new test
	echo $str // my cool new value
	echo $str2 // my cool new test

Midori_String uses the magic method __toString to allow echo to called on the object and the Midori_String will even allow for dot concatination since it has __toString.  The “value” property is the actual value inside of the Midori_String box object to which it wraps. The Midori_String also returns the new value and does not affect the original value, during each method call, so that actual object acts just like a value type.

Understanding Chaining Methods after Instantiation

Another problem in PHP is that when you instantiate an object, it does not allow for chaining right away, which can be bothersome.

PHP


	// incorrect way to chain in PHP
	$str = new Midori_String("don't objectify me, sidekick")->concat("!"); // epoch fail

	// correct way to chain
	$str = new Midori_String("don't objectify me, sidekick");
	echo $str->concat("!"); // don't objectify me, sidekick!

So in hopes of getting around that and to use common box types often: I propose creating and using functions “box_x” to wrap the instantiation of a box type and to allow for chaining.  I also thinking having an “unbox” function to allow for unboxing of values if the object is an instance of Midori_Nullable, would also be handy.

PHP


	// boxing example with forth coming helper methods
	// these methods are prototypes and would like feed back.

	$str = box_str("my cool new value")
		->replace("value", "test")	//chain 1, replacing a value
		->toUpper()			// chain 2, uppercasing.
		->value;				// chain 3, returning the unboxed value

	echo $str; // MY COOL NEW TEST 

 	$str = box_str("my cool new value!")->trimEnd("!");
	$unboxed = unbox($str);

	echo $unboxed; // my cool new value!

PHP does not allow for operator operations on objects

Unfortunately, PHP does not allow for operator overload on objects like Ruby, C#, and other languages do, so you will have to unbox objects in order to do math routines or apply conditional statements to them.


	// example of what you have to do to add two box objects in PHP
	$grade = new Midori_Int32(90);
	$grade2 = new Midori_Int32(60);

	// correct way to add 2 boxed objects in PHP using Midori
	$sum = unbox($grade) + unbox(grade2);
	$sum = $grade->value + $grad2->value;
	echo $sum; // 150

	// incorrect way, though it would be nice if PHP could support it
	$sum = $grade + $grade;

Tags: , , , , ,