GRUB_ boot problem.
GRUB_ boot problem., Posted in Linux/Unix, July 28th, 2010

So I updated my OpenFiler storage appliance a few days ago and I had to restart it for the first time since the update. To my surprise upon reboot, I got the following “non-error” message “GRUB_”. No other message or error code.( OpenFiler does not have a LiveCD ) I searched all over google only to find out that most people said this was some sort of error that required a LiveCD to reinstall GRUB. Well, I decided to hit the F11 key on restart ( to get the list of available devices to boot from ). Upon manually selecting the correct HD, I was able to boot. The moral of the story is, make sure your computer is attempting to boot the correct hard disk. I went into the BIOS and set that hard disk as the default boot device. Works just fine now.

Cheers,
-J

P.S. On another topic, the error “Comreset Failed (errno=-16)” has the good possibility of meaning the power for that drive has failed and to try another molex connector ( I just found out two connectors, in one chain of the power supply, just failed on me ). If it isn’t the power source ( you can tell the drive is spinning ) then its either a bug or the drive itself is causing a problem. Check SMART status.

CommitOnly is broken on BindingUtils, vote now!
CommitOnly is broken on BindingUtils, vote now!, Posted in General, July 26th, 2010

BindingUtils.bindSetter CommitOnly is broken and it got marked community so vote on this issue now!

https://bugs.adobe.com/jira/browse/SDK-26901

I know you don’t need to hear from me regarding semantics but..
I know you don’t need to hear from me regarding semantics but.., Posted in General, July 13th, 2010

The use of ‘on’ and ‘handle’ seems to daunt me. Some people do it the way I think is correct but most don’t; so here it is.

‘ON’ is used when self or this is the dispatcher of said event you are listening to. If you extend spark Group and listen to Creation Complete then it should be onCreationComplete

but..

“HANDLE’ if the dispatcher is external. If Class A is listening to Class B’s CreationComplete then you should name the internal handler handle{ObjectName}_CreationComplete.

Hope that helps. This will keep your code much easier to read in the future to determine the external and internal dependencies.

That is all!

Create a proper deep clone in AS3
Create a proper deep clone in AS3, Posted in Actionscript 3, Flash, July 25th, 2009

I’ve implemented this in com.emoten.core.data.JKDataObject in EmotenCore.swc

The [Transient] metadata is very important. ( keeps it from tying to infinitely clone itself )

I looked elsewhere and it seems that no-one has noticed that the [RemoteClass] metadata is required to reconstruct the class from its AMF-serialized state.

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[Transient]
		/**
		 * Creates a Clone of this class.
		 * <p>
		 * In order for your returned class to be typed correctly you must put the following
		 * above "public class"
		 * 
		 * <code>
		 * [RemoteClass(alias="com.emoten.core.data.JKDataObject")]
		 * </code>
		 * 
		 * Replacing "com.emoten.core.data.JKDataObject" with your class's FQN.
		 * 
		 * @return		A new copy of your class.
		 */
		public function clone():*
		{
			var ba:ByteArray = new ByteArray();
			ba.writeObject( this );
			ba.position = 0;
			return ba.readObject();
		}
?View Code ACTIONSCRIPT
1
2
        [RemoteClass(alias="com.emoten.core.data.JKDataObject")]
	public class JKDataObject extends JKObject implements Cloneable

UPDATE: Krilnon over at Kirupa made a good point I forgot to cover. The restrictions are that of the AMF specification. You cannot pass things like DisplayObjects and you cannot have required constructor arguments. If you don’t have those, your cool. The clone() functionality is only really intended for data models.
http://www.kirupa.com/forum/showpost.php?p=2489122&postcount=597

The replacement of EventDispatcher, 26% faster
The replacement of EventDispatcher, 26% faster, Posted in Actionscript 3, Flash, July 21st, 2009

I designed a pure ActionScript event method following a similar API of JKEvent. In most circumstances it just barely beats out the speed of the native EventDispatcher but EventDispatcher is left in the dust when you start timing the whole event lifecycle: “connect, dispatch, disconnect, dispatch”.

Cons: You don’t get priority

Pros: You get Silent Events, Argument Events, Remove All(event connections) from Observer, Remove All(event connections) from Sender. Its fast.

How it works: Its built using Dictionaries and LinkedLists. Turned out pretty good since I wrote it last week and never tried to actually run it until now.
Results

I recorded a variance of 0.5%+/-.

I licensed EmotenCore under LGPL and it is currently distributed as a compiled library.

Here is the License: License Here is the SWC: EmotenCore.swc Here is the docs: Emoten Core Docs

JKAbstractTranslatorLink & JKTranslatorTunnel
JKAbstractTranslatorLink & JKTranslatorTunnel, Posted in Actionscript 3, Flash, July 18th, 2009

I’ve built this methodology for allowing the easy design and implementation of sequential bi-directional data translation using the InputFlowConnector / InputFlowTerminator interface model.

I’ve uploaded the example here: http://labs.emoten.com/projects/Juki/JKAbstractTranslatorLink/TranslatorTunnelTest.html
Note: The Easy User Input Translator does not understand AM/PM.

My first reference implementation is using the class JKTranslatorTunnel as a two-way binding mechanism with translation. Essentially it makes a 2-3 line implementation to bind your Model object to some sort of View with translation. My example is a case where the Model contains a integer property representing Military time and the view displays Standard time. I’ve also attached a user-input translator that converts shorthand input to Standard time. This comes in handy so we can translate shorthand to standard then pass the standard to the translator that will translate that into military time and update the model. At the same time it will also format the View.

The reference implementation in Flex looks like this. “in1″, “in2″ are both TextInput UIControls. JKAbstractTranslatorLink is a LinkedListEntry. To add many items into the translation link just keep on populating the “.next” or “output”.
Emoten Core Docs

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<fx:Script>
        <![CDATA[
            import com.emoten.core.data.translators.JKEasyUserTimeInputTanslatorLink;
            import com.emoten.core.data.LinkedList;
            import com.emoten.core.data.JKAbstractTranslatorLink;
            import com.emoten.core.data.translators.JKMilitaryTimeTranslatorLink;
            import com.emoten.core.data.JKTranslatorTunnel;
 
            protected var _tunnel:JKTranslatorTunnel;
 
            public function onCompleteEvent( event:*=null ):void
            {
                var ls:JKAbstractTranslatorLink = new JKMilitaryTimeTranslatorLink();
                    ls.output( DirectionEnum.FORWARD, new JKEasyUserTimeInputTanslatorLink() );
 
                _tunnel = new JKTranslatorTunnel( this.in1, "text", this.in2, "text", ls );
 
 
            }
        ]]>
    </fx:Script>
Override Polymorphism versus me and a pot of coffee.
Override Polymorphism versus me and a pot of coffee., Posted in Actionscript 3, June 20th, 2009

JIRA SDK-16960
Java explanation of Late-Binding

The Issue
Subclassing has one purpose, to further specialize. If I want to extend my ‘FarmAnimal’ class and call it ‘Chicken’ that is specialization. If I extend ‘Real-Estate’ with ‘Condo’, that is specialization. So, what if I want to further restrict the acceptable properties of my sub-class? Override polymorphism allows us to redefine a inherited method from our super-class but doesn’t allow us to sub-specialize the method arguments(parameters) and return type. Why is this? If the specialized arguments and return type are fully type-safe against the requirements of the super-class then what is the problem?

The Example
Say my class ‘FarmAnimal’ has a method.

public clone():FarmAnimal {}

Now, I have a class ‘Chicken’ extends ‘FarmAnimal’. ‘Chicken’ has methods associated with it that do not exist in ‘FarmAnimal’. However, when I call chicken.clone() I still get a class instance typed FarmAnimal. Which is correct, it returns a Chicken object typed as FarmAnimal because override polymorphism says so. Now, every time I want to use methods special to Chicken. I have to retype the object as chicken.

chik:Chicken = chicken.clone() as Chicken;

This is ok. Now, what if clone() has a argument.

public FarmAnimal clone(mate FarmAnimal) {}

Thats cool but a Chicken can’t mate with a Pig so we’ve got to do something about this. Override polymorphism says we can’t change the arguments. Wouldn’t it be awesome if we could just re-define clone() as

public clone(mate:Chicken):Chicken {}

Well we can’t. What are our options? Interfaces have the same restrictions. We usually end up abandoning polymorphism completely in order to accomplish the task at hand or creating manual type checking on every override to prevent the wrong type of object being passed. All arguments aside, Chicken is a FarmAnimal so it is theoretically type-safe against the super’s version of makeSpawn. I don’t understand why the rules of polymorphism can’t be adapted to support this type of behavior.

UPDATE: Method Overloading as defined by Late-Binding in Java does partially do what I ask but does not hit the nail on the head because, ultimately, the original version is left intact whereas I would want to disallow it completely and would not be compatible when accessing typed as a Interface.

Any ideas? Hit me up on Twitter.

Safari 4 Tabs
Safari 4 Tabs, Posted in General, June 16th, 2009

With Safari 4 final, we lost our beloved top-tabs. However, hope is not lost. All you have to do is replace Safari.app with the beta version (15MB) and you’ve got your tabs back. Sadly, I cannot host the file so you need to get it some other way.

Yumm, Vegan Brownies
Yumm, Vegan Brownies, Posted in Food, June 1st, 2009

This is an extension of this recipe.

Ingredients:

  • 2 cups unbleached all-purpose flour
  • 1 1/4 cup unbleached evaporated cane sugar
  • 3/4 cup brown sugar
  • 3/4 cup unsweetened cocoa powder
  • 1 teaspoon baking powder
  • 1 teaspoon salt
  • 1/2 cup water
  • 1/2 – 3/4 cup Coconut Milk
  • 1 cup vegetable oil
  • 1 teaspoon vanilla extract
  • 3-4 tablespoon extra creamy peanut butter
  • 1 teaspoon Omega 3 & 6 oil

350 degrees, 9×13 pan is about 30 minutes. 8×8 pan is 55 minutes. And yes, when you mix this it will clump into one massive mix blob instead of a smooth batter you get with off the shelf mixes. Bake until it passes the penetration test. ( no gunk sticks to whatever your poking the brownies with )

Note: I added a few pieces of baking bittersweet chocolate, being made with Milk Fat turns this recipe into “Vegetarian” so I left it out here.

Extending Flex’s CSS w/Custom Data Types
Extending Flex’s CSS w/Custom Data Types, Posted in Actionscript 3, May 18th, 2009

Comptibility: 3.0+

You can extend CSS’s basic functionality with Custom Data Types by adding your own code to line: 7808 ( function getStyle(styleProp:String)* ) of mx.core.UIComponent. I recommend doing this by copying paste the original UIComponent class, from your destination version of the Flex framework, into your project under the same package name. This will allow your version to override the compiled library version.

I’ve extended CSS with a custom protocol for a library engine I’ve dubbed ‘Fuze’ for the moment. The implementation of the protocol in the CSS file looks like this:

1
upSkin					: "Fuze(splashelements>ButtonSi)";

The reason why implementing the override on the UIComponent class is to interject some business logic to your protocol. In my example, the FuzeService takes the protocol and returns the proper library item.

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public function getStyle(styleProp:String):*
{
    var ret:* = StyleManager.inheritingStyles[styleProp] ?
                            _inheritingStyles[styleProp] :
                            _nonInheritingStyles[styleProp];
 
    if ( ret is String && (ret as String).substr(0,5 ).toLowerCase() == "fuze(" )
    {
        if (FuzeService.hasLoaded( ret ))
        {
            // Cache it here.
            var clz:Class = FuzeService.getDefinitionByURI( ret );
 
            if ( StyleManager.inheritingStyles[styleProp] )
                _inheritingStyles[styleProp] = clz;
            else
                _nonInheritingStyles[styleProp] = clz
 
            return clz;
        }
        else
        {
            throw new IllegalArgumentException("The Requested Fuze Dynamic Skin Library Has Not Yet Loaded, Please check your code to make sure the library has loaded before you initialize any mx.* components using the CSS Fuze extension ");
        }
    }
 
    return ret;
}
« Older Entries