Skip to content

Instantly share code, notes, and snippets.

View diverted247's full-sized avatar

Ted Patrick diverted247

View GitHub Profile
@diverted247
diverted247 / gist:4265062
Created December 12, 2012 05:22
div element css properties in Chrome(webkit) within empty div element
//274 properties on an empty div element in Chrome (webkit)
//via CSSStyleDeclaration class thus lacks standard - syntax
alignmentBaseline: "auto"
background: "rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box"
backgroundAttachment: "scroll"
backgroundClip: "border-box"
backgroundColor: "rgba(0, 0, 0, 0)"
backgroundImage: "none"
backgroundOrigin: "padding-box"
@diverted247
diverted247 / M.ts
Created December 13, 2012 14:09
TypeScript - Modules: Module syntax results in JS Closure with private properties. compile: tsc --module AMD M.ts
module M {
var s = "hello";
export function f() {
return s;
}
}
@diverted247
diverted247 / initializer.js
Created December 13, 2012 18:27
TypeScript Function Initializers
function strange(x, y, z) {
if (typeof y === "undefined") { y = x * 2; }
if (typeof z === "undefined") { z = x + y; }
return z;
}
@diverted247
diverted247 / gist:4626756
Created January 24, 2013 19:28
Android build automation for Puzzle
app_project=bridges
app_name="Flipz Bridges"
app_url=http://abbeyswallpaper.com/flipz/${app_project}.php
app_package=com.flipz.${app_project}
if [ -d "SRC/src/com/flipz/project" ]; then
mv SRC/src/com/flipz/project/ SRC/src/com/flipz/${app_project}/
for file in SRC/src/com/flipz/${app_project}/*
do
@diverted247
diverted247 / gist:4685243
Last active December 12, 2015 00:38
Using easeljs? To prevent element selection on clicks to canvas...
// prevent default selection when canvas is clicked!
// does not interfere with catching events in easeljs apis
<canvas id="appCanvas"></canvas>
document.getElementById("appCanvas").addEventListener( "mousedown" , function(e){ e.preventDefault(); } , false );
document.getElementById("appCanvas").addEventListener( "mouseup" , function(e){ e.preventDefault(); } , false );
@diverted247
diverted247 / gist:5013385
Last active December 14, 2015 02:28
Dynamically extend a TS Class with Backbone EventDispatcher
module base.managers {
export class EventManager{
constructor(){
base._.extend( this , Backbone.Events );
}
//Call interface for Backbone.Events
//TODO: tighten with definition
@diverted247
diverted247 / gist:5173656
Created March 15, 2013 22:30
Event walking up a .manager hierarchy
walkManagerChain( manager:any , event:any ):void{
while( true ){
if( manager.hasOwnProperty( '_' + event.type ) ){
manager[ '_' + event.type ]( event );
}
if( manager.hasOwnProperty( 'manager' ) ){
manager = manager.manager;
}else{
return;
}
@diverted247
diverted247 / App.light
Created March 28, 2013 16:40
A small light.ly hello world app.
//imports
appjs : import = js/app.js
core: import = light/core.js
html: import = light/html.js
easeljs : import = js/easel.js
//references
application:@ = core.application
event:@ = core.listener
hc:@ = html.canvas
@diverted247
diverted247 / gist:5391120
Created April 15, 2013 20:40
Use of unref() via request.socket
var http = require( 'http' );
var server = http.createServer( function( request , response ) {
request.socket.unref();
console.log( request.socket.remoteAddress );
response.writeHead( 200 , { 'Content-Type' : 'text/plain' } );
response.end( 'working!' );
});
server.listen( 1492 , '127.0.0.1' );
@diverted247
diverted247 / gist:5853847
Created June 24, 2013 21:40
What happens if I type: "if()" and build in TypeScript. Same a cat across keyboard.
ts:
[echo] ts: start
[echo] ts: copy src/app into build
[echo] ts: preprocess html templates into .ts classes
[echo] ts: compile app/app.ts and all linked files
[exec] /coderoot/big-box-js/main/build/app/controls/Image.ts (1066,17): Check format of expression term
[exec] /coderoot/big-box-js/main/build/app/managers/ImageManager.ts(139,78): Expected type
[exec] /coderoot/big-box-js/main/build/app/controls/BackgroundImage.ts(3,41): Expected type
[exec] /coderoot/big-box-js/main/build/app/controls/ComponentFactory.ts(96,83): Expected type
[exec] /coderoot/big-box-js/main/build/app/editors/ImageEditor.ts(5,16): Expected type