Skip to content

Instantly share code, notes, and snippets.

View weyert's full-sized avatar
🏠
Reading about ancient history

Weyert de Boer weyert

🏠
Reading about ancient history
  • London, Curaçao
View GitHub Profile
@weyert
weyert / human_readable.pho
Created January 22, 2011 13:16
Human readable timespans
define("SECOND", 1);
define("MINUTE", 60 * SECOND);
define("HOUR", 60 * MINUTE);
define("DAY", 24 * HOUR);
define("MONTH", 30 * DAY);
/**
* Returns the human readable timespan from now to a date/time
*/
function human_readable( $time ) {
@weyert
weyert / netstream.as
Created January 20, 2011 18:52
NetStream code
public function loadVideo(): void {
// create the video related variables
_netConnection = new NetConnection();
_netConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
_netConnection.addEventListener( NetStatusEvent.NET_STATUS, netStatusHandler);
_netConnection.connect( null );
}
/**
* Connect to the video stream
@weyert
weyert / delegation.as
Created January 15, 2011 14:45
Mock class for iModuleDelegate
public class MockModuleDelegate implements IModuleDelegate {
public function getTranslation( name: String, defaultValue: String = "" ): String {
if ( name == "title" ) {
return "Moduel Title";
} else if ( name = "currency" ) {
return "EUR";
}
// more resource strings here
@weyert
weyert / xml test data
Created January 13, 2011 08:29
what's an easy way to prepare xml data for unit testing
var types: Array = [ "slide" ];
var myXML: XML = <schedules>
<schedule>
<item type="{types[0]}"><![CDATA[An example to be displayed.]]></item>
</schedule>
</schedules>;
package tests
{
import assets.MainButton_Symbol;
import assets.dialogs.HelpDialog_Symbol;
import ch.nothing.flare.display.screens.ScreenManager;
import ch.nothing.flare.events.ScreenEvent;
import ch.nothing.flare.ui.Button;
import ch.nothing.flare.ui.inExistingViewOf;