Skip to content

Instantly share code, notes, and snippets.

View cameronpriest's full-sized avatar

Cameron Priest cameronpriest

View GitHub Profile
# JSON-encoded error and redirect results for Devise controllers.
# This overrides an internal method of Devise, so be careful when updating Devise!
#
# Usage:
#
# class Users::RegistrationsController < Devise::RegistrationsController
# include DeviseJsonAdapter
# end
#
# devise_for :users, :controllers => { :registrations => "users/registrations" }
// RATER MODULE for Appcelerator Titanium
/*
WHAT IS IT:
Create a cycling reminder to go rate your app at the App Store. Tracks
the app launch count, and reminds the user every 20 launches (configurable) to
rate the app, with a click to launch the app page in the App Store.
Reminders stop if the user clicks the "Rate Now" or "Don't Remind Me" options.
USAGE:
@cameronpriest
cameronpriest / task.js
Created February 12, 2011 05:46 — forked from sr3d/task.js
(function() {
App.Models.Task = App.Models.Base.createModel('Task', 'tasks', {
name: 'TEXT',
note: 'TEXT',
due_at: 'DATE',
is_completed: 'TEXT',
completed_at: 'TEXT',
category_id: 'TEXT',
event_id: 'INTEGER',
has_reminders: 'TEXT',
# Copyright (c) Henry Poydar
# Modified from couchrest-rails
# A Rails plugin for connecting to and working with CouchDB via CouchRest
# https://github.com/hpoydar/couchrest-rails/
require 'sunspot_couch.rb'
begin
@cameronpriest
cameronpriest / app.js
Created September 26, 2011 23:22 — forked from dawsontoth/app.js
Loading images in @appcelerator #Titanium
/* The images for this example can be downloaded from http://j.mp/loadingimagesforti */
var win = Ti.UI.createWindow({ backgroundColor: '#f00'});
var loading = Ti.UI.createImageView({
images: [
'images/loading/00.png', 'images/loading/01.png', 'images/loading/02.png',
'images/loading/03.png', 'images/loading/04.png', 'images/loading/05.png',
'images/loading/06.png', 'images/loading/08.png', 'images/loading/09.png',
'images/loading/10.png', 'images/loading/11.png'
],
width: 33, height: 33
@cameronpriest
cameronpriest / app.js
Created September 26, 2011 23:22 — forked from dawsontoth/app.js
Simple remote on demand image caching.
var iconStore = Ti.Filesystem.applicationDataDirectory + '/CachedRemoteImages';
var dir = Ti.Filesystem.getFile(iconStore);
if (!dir.exists()) {
dir.createDirectory();
}
function cacheRemoteURL(image, imageURL) {
if (imageURL) {
var hashedSource = Ti.Utils.md5HexDigest(imageURL + '') + '.' + imageURL.split('.').pop();
var localIcon = Ti.Filesystem.getFile(iconStore, hashedSource);
if (localIcon.exists()) {
@cameronpriest
cameronpriest / app.js
Created September 26, 2011 23:22 — forked from dawsontoth/app.js
Sample tab group with an omnipresent bar at the top
/**
* Create a "container" window. This will house all of our high level UI elements
*/
var container = Ti.UI.createWindow({
backgroundColor: 'yellow'
});
/**
* Add some stuff to the top of the container. This will be visible everywhere in the app
*/
@cameronpriest
cameronpriest / app.js
Created September 26, 2011 23:22 — forked from dawsontoth/app.js
Tab within a Tab
var tabGroupOuter = Ti.UI.createTabGroup();
tabGroupOuter.addTab(Ti.UI.createTab({
title: 'app.js',
window: Ti.UI.createWindow({
title: 'app.js',
url: 'middle.js',
backgroundColor: 'red'
})
}));
tabGroupOuter.open();
@cameronpriest
cameronpriest / customTabsIniOS.js
Created September 26, 2011 23:22 — forked from dawsontoth/app.js
Customize the look of the tab bar in iOS Appcelerator Titanium
/**
* Override a tab group's tab bar on iOS.
*
* NOTE: Call this function on a tabGroup AFTER you have added all of your tabs to it! We'll look at the tabs that exist
* to generate the overriding tab bar view. If your tabs change, call this function again and we'll update the display.
*
* @param tabGroup The tab group to override
* @param backgroundOptions The options for the background view; use properties like backgroundColor, or backgroundImage.
* @param selectedOptions The options for a selected tab button.
* @param deselectedOptions The options for a deselected tab button.