Sunday, November 16, 2008

New Personal Project

I call it EAV. In the database world, this is short for Entity-Attribute-Value. This concept is one of many solutions for adding, editing, deleting custom fields to a table without altering the existing table. Please read the wiki: http://en.wikipedia.org/wiki/Entity-Attribute-Value_model/ . EAV in this scope is a Site Management System that builds on the EAV database concept.

Already developed some of my recursive thoughts. http://eav.blanquera.com/eav/ this is the documentation of EAV. The actual web application that generates the content for this documentation parses code comments from PHP and JS files in the EAV diractory and is written using EAV. That's a mouthful.

If you live in San Francisco, and are a PHP or JS developer and like to hear my stupid pitch about EAV, I can use all the help I can get.

Monday, November 03, 2008

Drupal 6 Le sigh

Back to work from a long vacation. Work asks me if I know Drupal? I say yes I have used Drupal before back in version 3 or 4.7. They say they have a project for me. Getting back to work was an easy adjustment because while in the Philippines I dreamed about coding.

Here we go!

Case Study:
Client wants to extend create an event functionality to include timezones, the option to choose a duration or an end time and set how many people can RSVP to it. Client also wants me to build an RSVP module in the front end attached to events.

Problem: Extending Drupal Modules; Despite what some people think, drupal is not Object oriented. It relies on virtual function callbacks (not methods) which in PHP cannot be overloaded.

I found this conversation to be really funny.
http://drupal.org/node/15943

I thought "Well maybe Drupal has another way of extending modules?" This is false. Searching on google I came to a consensus that the way to extend module functionality is to customize the module you want added functionality for and when an upgrade comes for that module by the original author, "Good Luck."

Thursday, August 21, 2008

WAMP Server with SVN

Been looking around for a tutorial on this. I have a great idea of creating a secure mp3 repository only I have access to update all my computers (1 desktop and 3 laptops)

Note: If any links are broken consider this post depricated.




** Download Svn1ClickSetup-1.3.3.exe
** Execute “WampServer2.0c.exe” - When you get to the “Select Destination Location” Step remember the location (ie. C:\wamp). This will bee the {WampServer2.0c.exe install directory} in this instructions

** Download WampServer2.0c
** Execute “SvnClickSetup-1.3.3.exe” - When you get to the “Repository Location” Step remember the location (ie. C:\svnrepos). This will be the {Repository Location} in this instructions

** Download mod_dav_svn.so
** Download mod_authz_svn.so
** Copy “mod_dav_svn.so” and “mod_authz_svn.so” to {WampServer2.0c.exe install directory}\bin\apache\apache2.2.8\modules\

** Download libdb44.dll
** Download intl3_svn.dll
** Copy “libdb44.dll” and “intl3_svn.dll” to {WampServer2.0c.exe install directory}\bin\apache\apache2.2.8\bin\

** Execute {WampServer2.0c.exe install directory}\wamp\wampmanager.exe (a white half circle will show up on the right side of the task bar)

** Left click the white half circle -> Apache -> httpd.conf (this opens the file)

** Find:
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so

** and add in new line after:
#LoadModule dav_svn_module modules/mod_dav_svn.so
#LoadModule authz_svn_module modules/mod_authz_svn.so

** Right click the white half circle -> Exit

** Execute {WampServer2.0c.exe install directory}\wamp\wampmanager.exe (a white half circle will show up on the right side of the task bar)

** Left click the white half circle -> Apache -> Apache Module -> dav_module
** Left click the white half circle -> Apache -> Apache Module -> dav_fs_module
** Left click the white half circle -> Apache -> Apache Module -> dav_svn_module
** Left click the white half circle -> Apache -> Apache Module -> authz_svn_module

** run cmd (Start -> run: cmd )
** run in cmd
C:\{WampServer2.0c.exe install directory}\bin\apache\apache2.2.8\bin\htpasswd.exe -c C:\{WampServer2.0c.exe install directory}\bin\apache\apache2.2.8\passwd {Whatever username you want (ie. myuser)}

** It will ask you for a “New Password”: Make up your own
** It will ask you to “Re-type new password”: repeat

** Left click the white half circle -> Apache -> httpd.conf (this opens the file)

** Find:
</IfModule>

Include

** and add in new line after:
<Location /svn>
DAV svn
SVNPath C:/{Repository Location}
Order allow,deny
Allow from all
AuthType Basic
AuthUserFile passwd
AuthName “Internal area”
require valid-user
</Location>

** Left click the white half circle -> Restart All Services

Wednesday, June 18, 2008

OOP in Javascript... Don't be fooled.

In JavaScript, "new" does not mean you get a clean instance of a class. class properties still have a link reference to the prototype. Here is an example of the problem.

//example class
var testClass = function(){};
//class definition
testClass.prototype = { arr: [], obj: {} };

/*
* This example shows how instance 2
* indirectly gets instance1's array
*/

//new instance 1
var instance1 = new testClass();
//push some stuff in the array
instance1.arr.push('this is data 1 for instance 1');
instance1.arr.push('this is data 2 for instance 1');
instance1.arr.push('this is data 3 for instance 1');

//new instance 2
var instance2 = new testClass();

//instance2 has instance1's array!
alert(instance2.arr);


/*
* This example shows how instance 1
* indirectly gets instance2's object
*/
//put some stuff in instance2's obj
instance2.obj['one'] = 'this is data 1 for instance 2';
instance2.obj['two'] = 'this is data 2 for instance 2';
instance2.obj['three'] = 'this is data 3 for instance 2';

//instance1's obj was changed to instance2's obj!
alert(instance1.obj.one + ' ' + instance1.obj.two + ' ' + instance1.obj.three);

The solution that works is using Object.clone(new testClass) after instantiation, however not very optimal. So in the end I made sure in my constructor class, I manually reset arr and obj (this.arr = []; this.obj = {}). It's important that if you use "new testClass" you are not making a real instantiation, it's more like a simulated one. Plan on manually resetting array and object properties in your constructor so this won't happen to you!

Tuesday, May 27, 2008

Event Handlers ... and the winner is ...

Quirksmode 's archive posts Mr.jQuery John Resig Winning a new addEvent, removeEvent function. Found Here

The code is as follows:

function addEvent( obj, type, fn )
{
if (obj.addEventListener)
obj.addEventListener( type, fn, false );
else if (obj.attachEvent)
{
obj["e"+type+fn] = fn;
obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
obj.attachEvent( "on"+type, obj[type+fn] );
}
}

function removeEvent( obj, type, fn )
{
if (obj.removeEventListener)
obj.removeEventListener( type, fn, false );
else if (obj.detachEvent)
{
obj.detachEvent( "on"+type, obj[type+fn] );
obj[type+fn] = null;
obj["e"+type+fn] = null;
}
}


I actually used this code to help build my framework and under further testing since it manages events using an associative, this method would not work for wrapper functions like lets say Prototype's bindAsEventListener because once you remove event it will remove everything with that wrapper.

Proof of concept:

var someFunction1 = function(one, two, three){alert(two)};
var someFunction2 = function(one, two, three){alert(three)};
var someWrapper = function(func){
var __method = func; args = [0,1,2];
return function() {
__method.apply(this, args);
}
}
addEvent(element, 'click', someWrapper(someFunction1));
addEvent(element, 'click', someWrapper(someFunction2));
removeEvent(element, 'click', someWrapper(someFunction2));

//onclick addEvent(element, 'click', someWrapper(someFunction1))
// will not work

Sorry I know it's 2008 but that post is still in the top google. I wanted to get that clarified with everyone. Chris says no to Associative array in this manner.

Friday, May 23, 2008

The Best JS Framework in the world?



Okay I been on this question for a really long time now. I first implemented PXP using Prototype in early 2007. This was back when 1.5 was out and I realized that jQuery looked better and had more of functionality that I wanted. I suddenly switched to jQuery and was excited that I finally had the chance to call simple JS to build my epic application. I soon realized most of the plugins (or UI) weren't fully developed and/or not working as I expected them to. Also I reviewed my code when I finally got draggable boxes, menus and tab features up and running and saw that it was real spaghetti. about 3 months later I found that prototype had updraded to 1.6 with promises of a brighter future.



I delete my jQuery code and defected back to Prototype and it was good! I loved the new code structures I was coming out with but the "look and feel", cross browser and styling this mofo became where most of my time went to. As a product developer all you want to be concerned with are higher level thoughts. I'm not a designer nor want to be. I am a programmer mastering my craft!



After 3 more months with working with prototype and getting frustrated with my design templates not working out, I began my search for a new framework. I remember Nate Koechley from Yahoo came to my work about a month ago with promotions of YUI. I looked at YUI long before that but was unimpressed with the framework and the support for it. For someone like me, I don't like posting a question in the group and waiting for a response. I need fast support. It was only recently that I found YUI had blown up to a lot of features built around many fundamental practices. The framework still didn't impress me but the massive widgets that were already "skinned" gave me no choice but to switch to it. I always dreamed of a library with styled widgets! Again I dump my prototype code and switched to YUI and in 2 weeks of coding I was able to go as far in my product than I ever had in a year!

Of course after 4 weeks I start hating the "YUI Sam Skin" and look for other skins. After 22 pages of google searches I concluded there were no other YUI skins in this world, which made me sad considering my direct competitors had awesome styling. I also noticed that my epic application basically requires to use every single freaking thing that YUI offers and I noticed a performance drain because of the large files (even though they were compressed) and yes I was using the YUI Loader to load scripts only when it was needed. It wasn't that, I also realized that in YUI they have made executive decisions on how to implement their widgets without giving clear documentation on how to rawly access their core widget functions. I call it being "bloated". Also, although YUI code is organized their dependency list per file is spaghetti. So imagine if you will a widget that requires 4 functions of a utility class made up of 5000 lines of code.


MY OWN FRAMEWORK

I was tired of YUI but there really isn't anything better that fit my project needs. I started searching for maybe other libraries that matched up to YUI and thought "You know what? I should just make a library!" and I did! It was the coolest thing I ever did in JS and I only say that because it was my own code and I finished the framework in less than 900 lines of code. It had Selectors, Events Manager, Element Traversing, AJAX Management with caching and abort features, Class creation/extending and Namespace Management. I loved my framework. The only thing that turned me off of it was Effects! I hate coding effects. So really what is the best framework out there?

Please don't say ExtJs. I don't want to get started there. Mootools maybe, but I need widgets pertaining to a software application and I just don't think Mootools has it. So I guess it's YUI for now at least for my needs and I'm really not happy with that decision.

Anyways this weekend will be a power weekend for me. It's a 3 day weekend and no Girlfriend. Happy Memorial Day to everyone.

Wednesday, May 14, 2008

PXP Admin Development

Switched the admin JS library from Prototype to YUI. I was able to get alot more done in a shorter amount of time.

Just Letting you guys know that I'll be closing my admin demo on March 23. You can view it now at http://www.dev.blanquera.com/admin/ . I know there's an extra comma somewhere in te js that's stopping it from loading in IE, but it works in FF. Let me know what you think.

In a rush because I'm still programming. Thanks for reading...