vineri, 28 octombrie 2016

Golden Timestamp Logger

@:expose('Console')
class Test {       
    @:keep
    static public function timeStamp( message : String ) : Void {
        var pad:Int -> String -> String = function(n:Int, val:String) { 
            return StringTools.lpad(val, '0', 2); 
        }
     var date:Date = Date.now();
        var ms = untyped __js__("(new Date()).getMilliseconds()");
   var timestamp:String = pad(2, Std.string(date.getHours())) 
            + ':' + pad(2, Std.string(date.getMinutes())) 
            + ':' + pad(2, Std.string(date.getSeconds())) 
            + '.' + pad(3, ms);
        untyped __js__("console.log('%c' + timestamp + ' %c' + message, 
                       'color: #B8860B', '')");        
    }
    
    static function main() {
        untyped __js__("console.timeStamp = Console.timeStamp");
    }
}

Try running this: https://try.haxe.org/#21b7b

miercuri, 26 octombrie 2016

Methylene Architecture

The Methylene Architecture is a particular case of MVC architecture where the Controller is the central point of the application and it has access to two separate channels:

  • Controller-Model Channel
  • Controller-View Channel
In this context, a channel is any mean that can be used to exchange any type of message.

In the classical MVC concept the Controller manipulates the Model  and the Model updates the View.

With this Methylene Architecture, only the Controller is able to update the Model. This means not only that Model cannot push values to the View, but also the View is not allowed to get values from the Model. Which first means that the user will get the View output from the Controller and not the View itself. Secondly, the Controller is able to send data back and forth between Model and View as follows:

  • A request is received by the controller
  • A model query is initiated based on this request
  • The result from the model is handled by the controller and passed into the view
  • Controller initiates view rendering and fetches the result
  • The result is send as a response to the user

The main advantage in this case is that dependency channels can be easily managed, reducing the overall complexity of the application.


luni, 29 august 2016

Palindrome in PHP

function is_palindrome(array $list) {
    return array_reverse($list) == $list;
}

joi, 25 august 2016

Features


Design Goals

...

Main Features

  • compile time type checking for PHP code (using Hack language by Facebook)
  • sane code reuse - no more copy/paste programming or manually unzipping tons of archives downloaded from the internet; Barebone provides support for: 
  • buildpro - a cross-platform, cross-language, cross-compiler build system for transpliation to PHP and JavaScript
  • cross-platform development using Haxe
  • support for containerization, virtualization, continuous integration/build/delivery, automated testing and deployment; 
  • configuration management: 
    • multiple devleopers and multiple hosts per developer
    • multiple customers per platform and multiple project per customer

The story behind Barebone framework

The story behind Barebone framework...