Skip to content

Instantly share code, notes, and snippets.

@pablasso
pablasso / gist:1149747
Created August 16, 2011 18:07
ls on a dir with spaces
#!/bin/bash
IFS=$','
vals='./this is a test/,./test2 back'
for i in $vals; do echo $i; eval ls "\"$i\""; done
unset IFS
@pablasso
pablasso / gist:1184212
Created August 31, 2011 17:59
ScrollView with internal views
var tmpWindow = Titanium.UI.createWindow({
backgroundColor:'gray'
});
var tmpScrollView = Titanium.UI.createScrollView({
contentWidth:320,
contentHeight:'auto',
showVerticalScrollIndicator:'true'
});
@pablasso
pablasso / gist:1186885
Created September 1, 2011 18:33
NavigationController
exports.NavigationController = function() {
this.windowStack = [];
};
exports.NavigationController.prototype.open = function(/*Titanium.UI.Window*/windowToOpen) {
Titanium.API.info('nav OPEN triggered, old windowStack:' + this.windowStack.length);
this.windowStack.push(windowToOpen);
Titanium.API.info('nav OPEN triggered, new windowStack:' + this.windowStack.length);
var that = this;
@pablasso
pablasso / gist:1187076
Created September 1, 2011 19:43
NavigationController instance
var NavigationController = require('NavigationController').NavigationController;
var nav = new NavigationController();
var tmpWindow = Titanium.UI.createWindow({
backgroundColor:'white',
title:'1st Window'
});
var tmpButton = Titanium.UI.createButton({
title:'Touch me'
var obj = new Object();
var exampleWindow = Titanium.UI.createWindow({
url:'example.js',
title:"I'm an example",
backgroundColor:'red',
someVar:obj
});
@pablasso
pablasso / gist:1190578
Created September 3, 2011 04:45
Login script for Ubuntu: /etc/update-motd.d/00-stats
#!/bin/bash
echo " "
echo " ======================================="
echo " = Welcome to KENTAURUS. ="
echo " ======================================="
echo
btime=`who -b | sed -e 's/[^A-Z]*//'`
utime=`uptime | sed -e 's/ [0-9:]* up />/' -e 's/,.*//'`
echo " ==== BOOT TIME ==== ==== UPTIME ===="
echo " "$btime" " $utime
@pablasso
pablasso / gist:1276818
Created October 10, 2011 22:56
JSON stuff
{
"total":1,
"page":1,
"limit":1,
"artists":[
{
"id":"172032211301443675536147328123616447779",
"name":"I haz a band",
"avatar":"http://example.com/avatar.jpg",
"bio":"Some totally awesome description right here",
15090792207824914689299302111293390910
62195380455342808744906805393239021982
76096933698024536798268794263645478726
83669245350769490272343848448863138581
90732512097952169660801374000419937573
99227861950690058087894766853355604843
106231480191160623286572966105843398721
119825583003234372579297569500108407259
133700140834102615346582278965882197399
140391624674997358476491961477360973567
graph sample {
layout=neato
overlap=false
splines=true
tailclip=false
headclip=false
A -- I
A -- J
A -- B
A -- H
@pablasso
pablasso / gist:1690133
Created January 27, 2012 18:18
UIView animation
UIView *testView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];
[UIView animateWithDuration:1.0f
animations:^{
testView.transform = CGAffineTransformTranslate(testView.transform, 100.0f, 0.0f);
}
completion:^(BOOL finished){
if (finished) {
// Do some magic after the animation finishes
}