Skip to content

Instantly share code, notes, and snippets.

View ricardoalcocer's full-sized avatar
💭
making music at https://alcomusic.com

Alco ricardoalcocer

💭
making music at https://alcomusic.com
View GitHub Profile
@tonylukasavage
tonylukasavage / .bash_profile
Last active December 18, 2015 08:49
Shell script to create a new Titanium project, make it Alloy, and load it up in Sublime Text
# Here's how to add it to a shell profile
tialloy() {
ti create --id com.testing.$1 --name $1 --workspace-dir . --platforms \
android,blackberry,ios,ipad,iphone,mobileweb,tizen --no-prompt && \
cd $1 && alloy new . && subl .
}
@timanrebel
timanrebel / index.js
Created June 5, 2013 16:03
Did you know it is possible to create custom XML tags in Alloy and use them?
// <<MyElement> becomes Ti.UI.createMyElement, so that doesn't work
Ti.UI.createMyElement({
id: 'myId'
});
// But give it a namespace and all of a sudden, it is translated to:
Sc.UI.createMySecondElement({
id: 'mySecondId'
})
@FokkeZB
FokkeZB / ALLOY.md
Last active February 13, 2019 20:01
Alloy constants and helpers for non-Alloy Titanium projects.

If you want to your CommonJS modules to work in both Alloy and plain Titanium projects, you might need a way to detect if you're in Alloy. For instance, if you're in Alloy you would get Underscore from the alloy-module, while in plain Titanium you would require Underscore directly.

Well, you can:

var _ = require((typeof ENV_TEST === 'boolean') ? 'alloy' : 'underscore')._;

The above works by utilizing Alloy's optimization process. In this process, constants like ENV_TEST will be either TRUE or FALSE. The actual expressions in wich they are used will then be evaluated. If FALSE the code block will be removed. In plain Titanium projects the constants are undefined and this typeof ENV_TEST will be undefined, so the code block will be executed.

@FokkeZB
FokkeZB / app.js
Last active December 16, 2015 12:28
CommonJS module to spin a view in Titanium
var v = Ti.UI.createView();
var s = new require('spinner').Spinner(
v, // View to spin
30 // Degrees to spin per millisecond
); // Auto-starts
// Stop
s.stop();
@rblalock
rblalock / index.js
Last active December 15, 2015 09:28
/**
* Helper for opening / animating sidebar
*/
$.openSidebar = function() {
if(isOpen) {
var animateRight = Ti.UI.createAnimation({
left : 0,
curve : Ti.UI.ANIMATION_CURVE_EASE_OUT,
duration : 200
});
@FokkeZB
FokkeZB / index.tss
Last active January 16, 2023 09:35
Who said you can't do padding in Titanium (Alloy)?
"#wrapper": {
// Set wrapper to adjust it's size to it's contents
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
// Set stuff like borders and backgrounds on the wrapper
backgroundColor: "red"
}
@rblalock
rblalock / swipe.js
Last active December 14, 2015 00:59
// Custom swipe detection for table rows (since technically the "swipe"
// event doesn't apply to individual rows but rather the table. This way we
// don't have to assign a swipe event for each row. One event to manage
// them all is more performant.
var TOUCH_X = 0;
$.list.addEventListener("touchstart", function(e) {
TOUCH_X = e.x;
});
$.list.addEventListener("touchend", function(e) {
if(e.x > (TOUCH_X + 44)) {
@rampicos
rampicos / social.js
Last active January 10, 2019 10:10
Social.js is the Appcelerator Titanium's Alloy Widget at first it is used to connect with Twitter only, though twitter and linkedin uses OAuth for its authentication I made some changes on Social.js for multi-purpose to connect Twitter and LinkedIn
function hex_sha1(s) {
return binb2hex(core_sha1(str2binb(s), s.length * chrsz));
}
function b64_sha1(s) {
return binb2b64(core_sha1(str2binb(s), s.length * chrsz));
}
function str_sha1(s) {
return binb2str(core_sha1(str2binb(s), s.length * chrsz));
@CatTail
CatTail / htmlentity.js
Created November 30, 2012 08:27
Javascript: encode(decode) html text into html entity
// encode(decode) html text into html entity
var decodeHtmlEntity = function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
var encodeHtmlEntity = function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
@aaronksaunders
aaronksaunders / InstagramMgr.js
Created September 30, 2012 19:02
Titanium Appcelerator Instagram Code ... This code is almost two years old and I havent tested it in a while
/**
*
* this code was inspired by the work done by David Riccitelli
*
* Copyright 2011 Aaron K. Saunders, Clearly Innovative Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*