Skip to content

Instantly share code, notes, and snippets.

View balanza's full-sized avatar

Emanuele De Cupis balanza

View GitHub Profile
<!DOCTYPE HTML>
<html lang="it">
<head>
<script src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
<script>
(function($){
@balanza
balanza / gist:3753716
Created September 20, 2012 03:02
Let wordpress plugin being installed locally
#to show the apache running user, in a php file write
<?php echo(exec("whoami")); ?>
#Let's say it prints out XXX. now just run in your shell
$ sudo chown -R XXX:nogroup /path/to/wordpress/
@balanza
balanza / example.js
Last active August 29, 2015 14:12
A simple javascript function that implements truth tables, useful for handling multiple conditions
var TruthTable = require('truthtable');
var condition1 = true;
var condition2 = false;
var tt = new TruthTable(condition1, condition2)
.on('01', function() {
console.log('01');
})
.on('11', function() {
console.log('11');
})
@balanza
balanza / example.js
Created January 19, 2015 12:19
Show/Hide views when layout=vertical in Titanium
/*
* Snippet to solve a common problem in Titanium:
* hiding a view inside a vertical layout
* Tested with Alloy, will work on plain-vanilla Titanium too (just check underscore reference)
*/
/**
* hides a view nested into a layout=vertical container
@balanza
balanza / parseUrl
Created January 27, 2015 15:20
Parse URL (including HTTP validation)
var parseUrl = function(url) {
var r = /^((http[s]?|ftp):\/)?\/?(([\w\-\.]+):([\w\-\.\$]+)@)?([^:\/\s]+)((\/\w+)*?(:([0-9]+))\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/;
var tmp = r.exec(url);
return {
original: tmp[0],
protocol: tmp[2],
username: tmp[4],
password: tmp[5],
host: tmp[6],
@balanza
balanza / log
Created July 15, 2015 14:26
Error trace from console
[TRACE] error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can't move temporary file: /Users/emanuele/Documents/Workspace/titanium/kleur2/build/iphone/build/Debug-iphoneos/Kleur.app/Kleur to file: /Users/emanuele/Documents/Workspace/titanium/kleur2/build/iphone/build/Debug-iphoneos/Kleur.app/Kleur.lipo (Is a directory)
[TRACE] Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo emitted errors but did not return a nonzero exit code to indicate failure
[TRACE] GenerateDSYMFile build/Debug-iphoneos/Kleur.app.dSYM build/Debug-iphoneos/Kleur.app/Kleur
[TRACE] cd /Users/emanuele/Documents/Workspace/titanium/kleur2/build/iphone
[TRACE] export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/opt/local/bin:/opt/local/sbin:/Users/emanuele/.rvm/gems/ruby-2.1.2/bin:/Users/emanuele/.rvm/gems/ruby-2.1.2@global/bin:/Users/em
@balanza
balanza / alloyView.xml
Created July 27, 2015 15:04
Templated Alloy component
<!-- that's the pursued implementation -->
<Alloy>
<MyComponent ns="require('myui')" id="mc1" foo="bar">
<Label>That's my precious content!</Label>
</MyComponent>
<MyComponent ns="require('myui')" id="mc2" foo="bar">
<Label>Another precious content!</Label>
</MyComponent>
</Alloy>
"config": {
"localhost": "191.191.24.249",
"ts_port": "3000",
"geny_s4": "Samsung Galaxy S4 - 4.3 - API 18 - 1080x1920"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"android:s4": "appc ti build -p android --device-id \"$npm_package_config_geny_s4\"",
"android:s4:ts": "appc ti build -p android -d ./shadow/ --device-id \"$npm_package_config_geny_s4\"",
@balanza
balanza / alloy.jmk
Last active March 14, 2017 01:25
Alloy compile hook for reenginering file structure of a project
task("pre:compile", function(event, logger) {
//a decorator for path.join that consider arrays as arguments
function superJoin() {
var args = Array.prototype.slice.call(arguments);
var p = [];
_.each(args, function(e) {
_.each(['mario', 'luigi'], function(elem){
alert('Thanks ' + elem + ' but the princess is in another castle');
});