Skip to content

Instantly share code, notes, and snippets.

View euforic's full-sized avatar

Christian Sullivan euforic

View GitHub Profile
@euforic
euforic / script.js
Created October 29, 2011 06:52
tublr page as home page hack
if(location.pathname.slice(1) == "" && location.hash !== '#blog') {
location.href='http://mysite.tumblr.com/home'
}
@euforic
euforic / app.js
Created April 24, 2012 23:31
Easy Evented Titanium Forms With Shimmy
//Requires [Shimmy](https://github.com/Xogix/TiLibrary/tree/master/Shimmy)
//Simple forms with Shimmy
var shimmy = require('/Shimmy')
, ui = shimmy.UI
, _ = shimmy._;
var win = ui.Window();
var form = ui.Form({
@euforic
euforic / app.js
Created May 11, 2012 04:35
Quick dirty hack for Node.js like modules with package.json and node_module directory for Titanium
require('require_patch')(this);
/**
* Loads "myModule" from your applications "Resources/titan_modules" directory if package.json is present.
* If "main" is set in package.json module will be loaded from that file else defaults to "index.js"
*/
var myModule = require('myModule');
myModule.someFunction();
@euforic
euforic / ti.socket.io.js
Created June 5, 2012 17:02
Socket.io-client Titanium
/*! Socket.IO.js build:0.9.6, development. Copyright(c) 2011 LearnBoost <[email protected]> MIT Licensed */
/**
* Originally Ported to titanium by Jordi Domenech <[email protected]>
* source: https://github.com/iamyellow/socket.io-client
*/
this.io = {};
module.exports = this.io;
/**
@euforic
euforic / app.js
Created June 13, 2012 21:48
Chatty Logger
var logger = require('lib/socket.io-client').connect({id:'MyAppName', channel:'MyAppChannel'});
var window = Ti.UI.Window();
window.open();
var jsonTest = {'test':'testparam'};
//String Example
logger.log('test message');
@euforic
euforic / apibuilder.js
Created September 18, 2012 04:02
API Builder
/*!
* apibuilder
* Copyright (c) 2012 Christian Sullivan <[email protected]>
* MIT Licensed
*/
var request = require('superagent');
/**
* Module Exports
@euforic
euforic / view.js
Created October 22, 2012 06:10
MVC Breakout - VIEW
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// Module Exports
var self = module.export = {};
// create tab group
self.tabGroup = Titanium.UI.createTabGroup();
/File generated Using psd2ti
var self = Ti.UI.createWindow();
self.open();
var bg = Ti.UI.createImageView({
top: 0, left: 0,
height: 480, width:320,
backgroundImage: 'images/bg.png'
@euforic
euforic / git-ticket
Created December 4, 2012 01:26
Jira Ticket Git Shortcut Command
if test "$1" = "finish"; then
test -z $2 && echo "ticket <name> number." 1>&2 && exit 1
branch=timob-$2
git checkout master
git branch -D $branch && git push origin :$branch
else
test -z $1 && echo "ticket <name> required." && exit 1
branch=timob-$1
git checkout -b $branch &> /dev/null
git checkout $branch &> /dev/null
@euforic
euforic / battery.sh
Created December 10, 2012 18:32
Battery Health and Cycles
osascript -e 'set a to do shell script "ioreg -w0 -l | grep Capacity"' -e "set h to word 5 of a" -e "set z to word 33 of a" -e "set b to word 38 of a" -e "set c to 1000 * b / z" -e "set d to round c" -e "set f to d / 10" -e "set q to 1000 * h / b" -e "set w to round q" -e "set j to w / 10" -e '"Battery Health: " & j &"%"' | iconv -f utf-8 -t ucs-2-internal;