//

Retweeting private Tweets

So now that you are part of the "VIP" crowd and you are one of those special friends that is allowed to see your friend's private tweets, let me ask you. Is it acceptable for you to ReTweet something that is has been marked as private? After all it was private to start with but at the same time it could be some nice piece of information that you want to share with the word and you want to give credit to your friend.

It is as easy as writing "RE" in front of your ReTweet you are passing along or putting a (via @fancyNameGoesHere) at the end of it and it is again out in the open and the "privacy" is out of the window.

So I say, think accordingly before you ReTweet those private Tweets.

Tags: ,

//

YourPay some common errors and solutions

When working with YourPay service there some small issues you might run into and so I can remember in the future I am listing them here.

Fraud issue

If hit the server several times for testing you might be tempted to hit it with the same amount but remember that even though for you they are different hits, the store is receiving the same "client" hit so they will reject you request by marking it as a fraud.

Fraud Solution

Hit the server with different totals, even a minimum of 1 cent in difference between transactions is enough for you to get successful transactions with the store.

Store not able to process orders

One common issue is that when you hit the server from a page that is not registered with the application, YourPay will not recognize your store request and thus reject your request and it will break the whole experience.

Store not able to process orders solution

Always remember to change the location where YourPay is expecting your request, this could be easily forgotten when you are testing from different points on your servers or you are testing from Dev and then move everything to production.

Tags: , ,

//

Getting UPS Rates with PHP fixing small issue

There is an great class in Google Code written in PHP that works as a wrapper to the UPS API, I started using it about a year ago and never had issues with it since I was using it with Flash/AMFPHP/PHP, but now that I am working with a new shopping cart where I need this functionality but the front end is PHP only, I noticed that I was starting to get the following error:

PHP:
    Parse error: syntax error, unexpected $end in path.../UPSRate.php(131) : eval()'d code on line 1[php]

    After investigating the issue further I was able to fix the issue by only using eval on those elements where 'value' wasn't undefined.

    [php]if (isset($xml_elem['value'])) {
             $php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
             eval($php_stmt);
    }

Notice that these parse errors do not break the application and that is why they weren't raising a flag in Flash but working on PHP alone we have to squash all these kind of warnings.

Tags:

//

Actionscript dispatch event fails and solution.

The Problem:

A event too close to the instantiation of an object is not being fired, I believe the speed of the code execution is too fast for the listener to be able to register for the event.

Lets take a look at the following class to understand the issue.

ActionScript:
    package application.views
    {

       import flash.display.Sprite;
       import flash.events.Event;

       public class TestView extends Sprite
       {
          
          public static const NAME : String = "TestView";
          public static const THE_EVENT : String = NAME + "The_Event";
          
          private var holder : Sprite;
          
          
          public function TestView ( )
          {
          
          init();
             

          }
          
          private function init () : void
          {
             holder = new Sprite;
             holder.graphics.beginFill(0x000000)
             holder.graphics.drawRoundRect(0, 0, 100, 100, 0);
             holder.graphics.endFill();
             addChild(holder);
             
             dispatchEvent ( new Event ( THE_EVENT))
          }
          
       }
       
    }

In the example above what we are doing is dispatching an event after the creation of a simple object. If you notice the call to the init function is right after the construction of this specific object, in this case the object that is listening for that specific event is never able to "hear" the event, although it has been fired.

Here is the construction of the TestView and the listening for the event:

ActionScript:
    private var testView : TestView;
    testView = new TestView;
    testView.addEventListener ( TestView.THE_EVENT, theEventHandler ) ;

    private function theEventHandler ( event : Event ) : void
    {
       trace("Event Fired");
    }

The Solution

The solution is very simple, add a delay as low as 1/1000 before the code execution.

ActionScript:
    package application.views
    {

       import flash.display.Sprite;
       import flash.events.Event;
       import flash.utils.setTimeout;

       public class TestView extends Sprite
       {
          
          public static const NAME : String = "TestView";
          public static const THE_EVENT : String = NAME + "The_Event";
          
          private var holder : Sprite;
          
          
          public function TestView ( )
          {
          
          //delay the execution of init by 1/1000
          setTimeout(init, 1);
          //init();
             

          }
          
          private function init () : void
          {
             holder = new Sprite;
             holder.graphics.beginFill(0x000000)
             holder.graphics.drawRoundRect(0, 0, 100, 100, 0);
             holder.graphics.endFill();
             addChild(holder);
             
             dispatchEvent ( new Event ( THE_EVENT))
          }
          
       }
       
    }

Conclusion

There are ways to go around this issue, that is for certain but being able to find where your problem is located at is important to provide the right solution at the right time. I am going to do some more research in regards to why this specific problem happens at a lower level but for now it allows me to trust that the listener is going to be able to "listen" for a specific event.

Am I happy with this solution? NO. but for this specific application I am working on I need to make sure all the elements are in place before continuing the chain of events rather than just trusting that items are drawn or attached on the display list.

//

SVN PROPFIND 405 Method Not Allowed

Problem

I was getting the following error after trying to update a SVN repository.

PHP:
    PROPFIND of '/': 405 Method Not Allowed

And had no idea what it meant. I read on the internet that could be from trying to checkout a file that is none existent. The interesting thing is that I was just doing an update (svn update).

Solution:

PHP:
    svn cleanup

That solved my problem immediately. After running the cleanup command I was able to make my update.

Tags: ,

//

Learning PureMVC from HydraMVC

Intro

This post is not specifically on how to learn everything about PureMVC with HydraMVC but mainly points out their notification workflow document that they have on their site and some other statements they make on their site.

Keep in mind that HydraMVC is a complete rewrite from PureMVC, made specifically for the Flex framework.

HydraMVC Notification Workflow

Beautiful (technically speaking) document that allows you to follow their notification system from beginning to end (tip: start from the view component and follow along).

Screenshot:

Direct link to original PDF file in HydraMVC website (full resolution).

Briefly about HydraMVC

If you are using PureMVC keep in mind the following.

PureMVC intends to be language-agnostic where HydraMVC is a compromise by design

Meaning that the team at HydraMVC took the time to make the framework beautiful to fit their needs within Flex framework while PureMVC has kept it open so that you can extend to other languages such as PHP, Javascript, Objective C, Ruby and more. This gives PureMVC the room to breath without having to be tied up to a specific language.

But in the end that doesn't mean that we can't learn from HydraMVC if you are working on PureMVC, specially since Hydra is based (and complete rewrite) from PureMVC.

Hydra Events and Implementation

In addition to using Events vs. an independent Observer pattern, HydraMVC also streamlines implementation, encapsulating much of the initialization code that needed to be written when implementing PureMVC.

I am familiar with Flex and have written couple test applications with the framework but I haven't used HydraMVC with Flex but I am curios on their initialization code which for the sound of their statements you have to write less code while still keeping the same functionality.

Here are some useful links:
PureMVC
HydraMVC

//

Send multiple parameters to event handlers

At one point or another during the time you write applications with ActionScript 3 you will have to send parameters from to an event handler. By default you can't send information unless you use the DataEvent, but that only allows you to send a string. That is OK if that is all you need to send but how about multiple parameters? How about an object or references?

In the example below we create a square on the stage that then will dispatch a custom event with 3 parameters (two strings and one number).

ActionScript:
    package {

     import flash.display.Sprite;
     import event.CustomEvent;
     import flash.events.Event;
     import flash.events.MouseEvent;

     public class App extends Sprite
     {

       var square : Sprite ;   

       public function App()
       {
          init ( ) ;
       }

       private function init ( ) : void
       {

        //add the event listener to the Document class.

       this.addEventListener(
            CustomEvent.MOUSE_CLICK,
            customEventHandler  ) ;           

        // Draw a square on stage and add a mouseEvent
        // that then will dispatch a custom event

        square = drawSquare();
        square.buttonMode = true;
        square.addEventListener (
        MouseEvent.CLICK,dispatchCustomEvent ) ;

        addChild(square);

        }

        private function dispatchCustomEvent ( e : Event ) : void
        {
        dispatchEvent ( new CustomEvent (
                            CustomEvent.MOUSE_CLICK ,
                            "myParam1",
                            "myParam2",
                            3 ) ) ;
        }

        private function customEventHandler ( e :CustomEvent )
        {
            trace( "Param 1: " + e.param1 ) ;
            trace( "Param 1: " + e.param2 ) ;
            trace( "Param 1: " + e.param3 ) ;
            }

        private function drawSquare ( ) : Sprite
        {

            var square:Sprite = new Sprite();

                square.graphics.beginFill(0x000000);
                square.graphics.drawRect(100, 100, 100, 100);
                square.graphics.endFill(); 
                return square as Sprite; 
             }

        }

    }

Custom Class

ActionScript:
    package event
    {   

     import flash.events.Event;

     public class CustomEvent extends Event
     {

        public static const MOUSE_CLICK : String = "mouseClick";

        public var param1 : String ;
        public var param2 : String ;
        public var param3 : int ;

        public function CustomEvent(
                            type : String, 
                            param1 : String,
                            param2 : String,
                            param3 : int,
                            bubbles:Boolean = false,
                            cancelable:Boolean = false )
        {

            super ( type, bubbles, cancelable ) ;

            this.param1 = param1;
            this.param2 = param2;
            this.param3 = param3;

         }

         override public function clone(  ): Event
            {
                return new CustomEvent( type, param1, param2, param3,
    bubbles, cancelable );
            }   
     }
    }

//

PureMVC Framework from The Flex Show podcast

These are notes that I took while listening to the podcast, by no means the information should be taken as final.
Feel free to listen to the podcast and let me know if you notice any discrepancies from what it was said on the podcast and what was written here.

Notes from PureMVC Framework - The Flex Show

Intro

Cliff Hall - Architect of the PureMVC project
Cliff stared doing Assembly language for Commodore 64 in 1982 ( one analogy Cliff used was that programming in Assembly is like building a skyscraper out of molecules you are constantly evaluating the number of bytes that the arguments and instructions are taking, you are constantly just looking at things on a microscopic level, and it is awesome because you really make it do what you want it to do, but it is difficult to make really large applications. Higher level languages that are more English like allows to express our thoughts in a much more natural way to us)

Newer OOP languages allows you to use Design Patterns to assemble "teams" to fix issues just as you would assemble teams to fix business issues.

Problem that needs to be solved

Flex is a big framework and in some ways it is a toolkit. Tools that you can take and assemble, but the important thing is how you assemble those items together properly.
All different applications people build break down to basic small problems
Once you use PureMVC all you have to worry about is problem domain and concentrate only on this
Assuming I am new to Flex and PureMVC how would you explain it to me?

Understanding the scope of what the framework is trying to do for you

PureMVC separates the issues in 3 piles

MODEL : Data
VIEW : Representation of Data
CONTROLLER : Bridges the two ( model + view ) and it is where the hefty logic in the application happens (update view and model)

Using MVC allows you to use views components and transfer them to a different system since it is not tied specifically to one application. Similar happens with Model, you can take it and use it in a different environment.

By making this separation you can move your Views to a different area and in a similar way you can move your Models since they do know about the existence of each other.

The Logic is not spread across the whole application but contained in their own area. You can also scale easier.

The business logic often goes into the controller?

Into the controller region, usually it is embodied in commands that are executed by the controller.

PureMVC has been ported to different languages. The issue is not if MVC is the wrong solution is the implementation that needs to be studied.

Proxies are objects that represent the Data.

Expanding on the Mediator Pattern

Move the data from the Model, for instance the Command
A command start up the application and instantiate the Proxies that will represent the Model and model will insatiate that will wrap around the view components

The application will build itself first and then tells PureMVC to start up. then builds proxies and mediators, Proxies might go and request data right away or when it is required

Say the proxies ask data that is needed to populate the application. Once the information is back into the Proxy, the proxy will send a notification.

In the view component you will use an event (like clicking on a button) and sends an event "add user".

The Mediator will be listening for that event and the will send a notification that might be picked up by a command that will tell a proxy "Go get me a user".

The Mediator when they are registered with the View Component they list all the notifications they are interested in. When the notification comes back from Proxy then it acts upon it, and that is how data gets from the Model to the view without binding.

The components expose an API and knows nothing about the API apparatus at all. events it will emit and properties that can be set. And the Mediator knows properties it can edit and events it can listen to.

Compare PureMVC to Cairngorm

The viewHelper and how they are implemented.
You access through the components, you bind items directly and tie up to the system.
Have worked with it and it is good but a lot of people didn't get it, saw some some prototypes ready to be turn into an app scrapped and started from scratch because the people didn't know much about design patterns, Flex or Cairngorm. So it seemed like Cairngorm set a high bar just to get started.

Other ports

There was a talk about some ports during the recording of this podcast but by now there has been almost 10 ports.

//

Project 10th to the 100th from Google

Last fall Google launched project 10^100 where they requested ideas from the public to make them reality... well not all of them, after the ideas were submitted they selected the top 16 ideas they liked and now they are asking the public to select the final 5 ideas that they are going to help be a reality.

My favorite idea:

Create genocide monitoring and alert system:

Build and refine tools capable of disseminating genocide-related mapping and related information in order to save lives. Much of the necessary technology and data-gathering methodology already exists both for general crisis mapping and for early warning systems capable of preventing mass atrocities. A key remaining step is to make this data more widely available to strengthen international aid agency coordination, improve resource allocation, develop timely policy and help evaluate current humanitarian practices.

I believe having a service such as this will help all of us the severity of the problem. Because we sit at our desks for 8 hours a day and then relax at home it is easy to forget that issues as genocide exist and what a better way to use Technology to do so. Twitter anyone?

It will be interesting to see how far these ideas will go and which will become a reality.

http://www.project10tothe100.com/vote.html

//

Some things I didn’t know about TextMate and ActionScript 3

I have been using TextMate for a couple years now and I am used to write almost everything by hand. Since AS3 I have been using the AS3 Bundle and mainly it has been to highlight my code and create new documents from the Templates. But I noticed that there are a couple features that might speed up your coding by a bit.

List imported classes

After the ":" you will get a list of the already imported classes that you can use to declare the type of variable you are declaring.

Auto Import classes

If you Hold down Shift+Option+I after highlighting a Class name on your application. The class you are highlighting will be imported at the head of the file. This is helpful because you can keep coding your class and as you are making your declarations you can import the classes necessary for the application.

List class Members

If you type this.[TAB] you will get a list of properties and parameters that are available for that specific class. Useful if you forgot something, but you are a professional so you probably won't need that.

Insert Color

Ah! You need that color but you don't remember the hex value for it, no problem just do Shift+Command+C and you will get a color picker component where you can select the color you need and it will insert the hex value into your document. This works for HTML/CSS as well!

Documentation for Selection

My favorite by far! Highlight a word on your application, then key combo control+H and you will get a new window with options to select the right property/method you have selected and you can access the documentation directly. It can't get easier than that.

Change Document Type

Hold Option+Control+Shift+(Letter for Document Type) and you can change document types rather quickly. When would you need to do so? Well say you are working on a HTML/CSS/PHP (or ASP) project. Now you can use the shortcut to switch document types fast.

Conclusion

There you have it, some shortcuts that might help you speed up the way you code in TextMate, Also remember you can add your own behaviors for a specific language, for example I created couple snipplets that would allow me to navigate up/down between method names (Shift+Command+UpArrow or Shift+Command+DownArrow).