Skip to content

Instantly share code, notes, and snippets.

@creynders
creynders / gist:1130345
Created August 7, 2011 12:47
Use of services in loading assets
interface ILoaderDelegate
class LoaderMaxFacade implements ILoaderDelegate
interface IApplicationConfigLoaderDelegate extends ILoaderDelegate
//empty <- marker interface
interface IMediaPlayerConfigLoaderDelegate extends ILoaderDelegate
//empty <- marker interface
@creynders
creynders / gist:1133833
Created August 9, 2011 11:45
Use of parsers
//wherever you do your mapping
injector.mapSingletonOf( IConfigDataParser, XMLConfigDataParser )
//IConfigDataParser
function parseData( rawData : String ) : ConfigDataVO
//XMLConfigDataParser implements IConfigDataParser
public function parseConfigData( rawData : String ) : ConfigDataVO{
var output : ConfigDataVO = new ConfigDataVO();
var xmlData : XML = new XML( rawData );
@creynders
creynders / 1.obj.js
Created March 31, 2012 06:51
JavaScript generic inheritance methods
var Obj = {
createProxy : function( o ) {
var F = function () {
};
F.prototype = o;
return F;
},
createObject : function( o ){
//Crockford Object.create
var F = Obj.createProxy( o );
@creynders
creynders / gist:2281612
Created April 2, 2012 08:19
Media query overwrites
@media screen and (max-device-width: 480px){
#foo{
max-width: 270px;
}
}
/* wil overwrite previous rule if device resolution is bigger */
@media screen and (min-device-width: 481px){
#foo{
max-width: 540px;
@creynders
creynders / gist:2512838
Created April 27, 2012 20:35
grunt jasmine debug log
["debug","onResourceRequested","file:///Users/creynder/Dropbox/Work/Projects/CREY%20-%20grunt%20jasmine%20task/gfranko/test/SpecRunner.html"]
["debug","onResourceRequested","file:///Users/creynder/Dropbox/Work/Projects/CREY%20-%20grunt%20jasmine%20task/gfranko/stylesheets/SelectBoxIt/jQuery.selectBoxIt.css"]
["debug","onResourceRequested","file:///Users/creynder/Dropbox/Work/Projects/CREY%20-%20grunt%20jasmine%20task/gfranko/libs/jasmine/jasmine.css"]
["debug","onResourceRequested","file:///Users/creynder/Dropbox/Work/Projects/CREY%20-%20grunt%20jasmine%20task/gfranko/libs/jasmine/jasmine.js"]
["debug","onResourceRequested","file:///Users/creynder/Dropbox/Work/Projects/CREY%20-%20grunt%20jasmine%20task/gfranko/libs/jquery/jquery-1.7.2.min.js"]
["debug","onResourceRequested","file:///Users/creynder/Dropbox/Work/Projects/CREY%20-%20grunt%20jasmine%20task/gfranko/libs/jasmine/jasmine-jquery-1.3.1.js"]
["debug","onResourceRequested","file:///Users/creynder/Dropbox/Work/Projects/CREY%20-%20grunt%20jasmine%20task/g
class BaseService{
public function load():void{
this.onLoadComplete()
}
public function onLoadComplete():void{
}
}
@creynders
creynders / ParameterizedHandlerContainer.as
Created November 21, 2012 12:54
Maintains parameterized event handlers
/*
Copyright (c) 2012 Camille Reynders, http://www.creynders.be
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
@creynders
creynders / delete_referencing_nodes.php
Last active October 13, 2015 16:28
Drupal Snippets
/*
searches all nodes (of all nodetypes) that reference <code>target_nid</code> and deletes them
dependencies: Entity, EntityReference
*/
$conditions = array( 'type' => 'entityreference' );
$include_additional = array( 'include_inactive' => TRUE );
$fields = field_read_fields( $conditions, $include_additional );
foreach( $fields as $field ){
$query = new EntityFieldQuery();
function mymodule_pre_hook(){
register_hook( 'mymodule_form_foo_node_form_alter', 'mymodule_handle_nodetype_form_alter' );
register_hook( 'mymodule_form_baz_node_form_alter', 'mymodule_handle_nodetype_form_alter' );
}
function mymodule_handle_nodetype_form_alter( &$form, &$form_state, $form_id ){
//do what you need
}
package arraySort
{
import mx.utils.ObjectUtil;
public class ArraySort{
public function run() : void{
var i : int;
var n : int = 500;
var arr : Array = [];
for ( i = 0; i<n; i++ ){
arr.push( {