Skip to content

Instantly share code, notes, and snippets.

View aaronksaunders's full-sized avatar

Aaron K Saunders aaronksaunders

View GitHub Profile
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active May 16, 2024 16:51
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@mschmulen
mschmulen / TableViewNeverending.js
Created February 1, 2011 02:07
Titanium tableView with a continuous amount of data.
//
// in this demo, we simply show how you could dynamically scroll
// with a continuous amount of data in the tableview by detecting
// when the user's scroll position gets near the end of the table
// and start a background fetch of new data and seamlessly append
// the new data to the table automatically
//
var win = Ti.UI.createWindow();
@dawsontoth
dawsontoth / InfiniteScrollableView.js
Created February 3, 2011 20:54
Infinite scrollable list.
/**
* We're going to create an infinite scrollable list. In this case, we're going to show a date. When you swipe left,
* you'll see yesterday. Then the day before yesterday, and so on. Swiping right shows you tomorrow, and so on.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var isAndroid = Ti.Platform.osname === 'android';
/**
* Track where we are in the infinite scrollable views, and define how large of a step goes between each view.
*/
var currentDate = new Date(), msIntervalBetweenViews = 1000/*ms*/ * 60/*s*/ * 60/*m*/ * 24/*h*/;
@dawsontoth
dawsontoth / InfiniteScrollingTableView.js
Created February 3, 2011 22:49
Infinite loading table view for iOS and Android.
/**
* We're going to create an infinite loading table view. Whenever you get close to the bottom, we'll load more rows.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var isAndroid = Ti.Platform.osname === 'android';
/**
* Create our UI elements.
*/
var table = Ti.UI.createTableView({ top: 0, right: 0, bottom: 0, left: 0 });
@dawsontoth
dawsontoth / app.js
Created February 4, 2011 23:21
CSS Injection on External Websites using Appcelerator Titanium
// create our web view
var win = Ti.UI.createWindow({ backgroundColor: "#fff" });
var web = Ti.UI.createWebView({ url: "http://chicago.craigslist.org/" });
// inject our css when the web view finishes loading (because we need to inject into the head element)
web.addEventListener('load', function () {
// first, specify the CSS file that we should load
var cssFileName = 'styles.css';
// read in the contents
var cssFromFile = Ti.Filesystem.getFile(cssFileName);
@dawsontoth
dawsontoth / LinksInWebViews.js
Created March 3, 2011 16:54
The following snippet takes over links in webviews, causing them to do nothing but Ti.App.fireEvent('linkClicked', { href: 'http://example.com' }). This lets you load in web pages, and control what should happen when a link is clicked.
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var html = '<html><body>'
+ '<a href="http://pedro.com">Pedro</a> '
+ '<a href="http://is.com">is</a> '
+ '<a href="http://a.com">a</a> '
+ '<a href="http://balla.com">balla!</a>.'
+ '</body></html>';
var web = Ti.UI.createWebView({
@pec1985
pec1985 / ResizingImages.js
Created March 10, 2011 23:04
Resize images from the Image Gallery
// testend on iOS
/*
Copyright 2011 Pedro Enrique
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
@kosso
kosso / background_demo.js
Created March 12, 2011 17:55
Background Service notification for Titanium
/* Kosso : March 12th 2011
This the only way I managed to do this without the app crashing on resume.
Done slightly differently to the KS example, since they unregister the service and
do not use a setInterval timer.
*/
//############ in app.js :
// test for iOS 4+
@dawsontoth
dawsontoth / LinksInExternalWebViews.js
Created March 21, 2011 16:51
The following snippet takes over links in a webview of a remote URL, causing them to do nothing but Ti.App.fireEvent('linkClicked', { href: 'http://example.com' }). This lets you load in web pages, and control what should happen when a link is clicked (li
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var web = Ti.UI.createWebView({
url: 'http://www.appcelerator.com/'
});
var linkJS = 'document.titaniumLinkQueue = [];'
+ '(function(){'
+ 'var links = document.getElementsByTagName("a");'
+ 'for(var i = 0, l = links.length; i < l; i++) {'
@jpurcell
jpurcell / pull-to-refresh(android).js
Created April 5, 2011 15:58
Tweetie-like pull to refresh and pull to load more. Note that it requries set heights for everything.
// This is the Android version of the Tweetie-like pull to refresh table:
// http://developer.appcelerator.com/blog/2010/05/how-to-create-a-tweetie-like-pull-to-refresh-table.html
var win = Ti.UI.currentWindow;
var alertDialog = Titanium.UI.createAlertDialog({
title: 'System Message',
buttonNames: ['OK']
});
var scrollView = Ti.UI.createScrollView({