Skip to content

Instantly share code, notes, and snippets.

View balanza's full-sized avatar

Emanuele De Cupis balanza

View GitHub Profile
//array of async resources to be loaded
var paths = ['file1.xml', 'file2.xml', 'file3.xml'];
//the callback for the ajax call
var callback = function(fileIndex){
alert('this is a callback for file ' + paths[fileIndex]);
};
//generates ajax calls
for(var i=0; i<=paths.length; i++){
@balanza
balanza / ti.android.events.js
Last active March 10, 2017 14:59 — forked from kristjanmik/ti.android.events.js
A proper way to handle pause and resume event in titanium for android
/**
* A little workaround to proper handle resume and paused events on Android
*/
var platformTools = require('bencoding.android.tools').createPlatform();
var wasInForeGround = true;
//to be executed on every activity staus change
//check if it's passing from foreground to background or viceversa
function checkStatusSwitch() {
var isInForeground = platformTools.isInForeground();
@commonFunctionalityX
@commonFunctionalityY
@commonFunctionalityZ
function myProcedure(arg1, arg2){
//procedure-specific code
}
var myProcedure = commonFunctionalityX(commonFunctionalityY(commonFunctionalityZ(function(arg1, arg2){
//procedure-specific code
})));
function commonFunctionalityX(fn){
return function retX() { //function name for didactical purpose only
//
// Here you write the commonFunctionalityX-specific code
//
var args = Array.prototype.slice.call(arguments);
return fn && fn.apply(this, args);
};
}
//navigation.js - centralized app navigation methods
exports.openHomePage = function(){ /* code for opening the Home page */ };
exports.openProfilePage = function(){ /* code for opening the Profile page */ };
exports.openDashboardPage = function(){ /* code for opening Dashboard page */ };
exports.openInsightsPage = function(){ /* code for opening Insights page */ };
//navigation.js - centralized app navigation methods
exports.openHomePage = function(){ /* code for opening the Home page */ };
@isLoggedIn
exports.openProfilePage = function(){ /* code for opening the Profile page */ };
@isLoggedIn
exports.openDashboardPage = function(){ /* code for opening Dashboard page */ };
//navigation.js - centralized app navigation methods
function isLoggedIn(fn){
return function() {
if( /* test if the user is logged in */ ){
/* redirect to login page */
} else {
var args = Array.prototype.slice.call(arguments);
return fn && fn.apply(this, args);
}
@balanza
balanza / mysite.conf
Last active November 8, 2018 09:05
Apache reverse proxy
<VirtualHost *:80>
ProxyPreserveHost On
ServerName mysite.com
<Location />
ProxyPass http://0.0.0.0:3000/
ProxyPassReverse http://0.0.0.0:3000/
RequestHeader set Connection ""
</Location>
@balanza
balanza / build.js
Created January 20, 2019 16:12
Snippet for supporting this: https://medium.com/p/36c950cd6f35
function compile() {
clean()
ensureDirectory('./dist')
compileCSS()
compileHTML()
compileAssets()
}