Skip to content

Instantly share code, notes, and snippets.

@sr3d
sr3d / task.js
Created February 4, 2011 02:26
My own version of ActiveRecord that actually works on Titanium.
(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',
require File.expand_path('../boot', __FILE__)
require 'home_run'
Date::Format::STYLE[:slash] = :mdy # making sure 1.8.7 compatible
# for roo gem to parse XML
gem 'ruby-ole-patched-for-home_run'
gem 'rubyzip' # required for roo
gem 'spreadsheet' # require for roo
gem 'nokogiri'
gem 'roo', :git => 'http://github.com/sr3d/roo.git', :branch => 'nokogiri'
# gem 'roo' # for Excel parsing
ActiveRecord.executeScalar = function() {
// arguments.splice(0,1);
var rows = ActiveRecord.execute.apply(this, arguments);
var value = rows.isValidRow() ? rows.field(0) : null;
rows.close();
return value;
};
source ~/.bashrc
alias ll="ls -ll"
alias la="ls -la"
alias psgrep="ps aux | grep"
alias ss="script/server"
alias rr="rake routes > routes"
alias rs="rails server --debugger"
alias r="rails"
export EDITOR="mate"
Ti.include('../../lib/active_record.js');
Ti.include('../../lib/utils.js');
Ti.include('../../lib/models.js');
var guest = Model.Guest.find(win.guest.id),
gift = Model.Gift.find({ first: true, where: {guest_id: guest.id} }),
sections = [],
currentSection = 0,
yesNoBtn, amountInput, giftDescription,
tableView = Ti.UI.createTableView({ style: Titanium.UI.iPhone.TableViewStyle.GROUPED });
Ti.include('../../lib/active_record.js');
Ti.include('../../lib/utils.js');
Ti.include('../../lib/models.js');
win.title = 'Guests';
var
eventId = DB.get('event_id'),
guests = [],
/* Wrapper on top of the HTTP client */
function Request(url, options) {
if( !url ) { throw "Invalid URL"; };
options = _.extend({
method: 'GET',
async: true,
evalJSON: true,
parameters: {},
headers: [], // [ [key, value], [key, value] ]
onSuccess: function(){},
Ti.include('../../lib/active_record.js');
Ti.include('../../lib/utils.js');
Ti.include('../../lib/models.js');
win.orientationModes = [ Ti.UI.PORTRAIT, Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT ];
/* intermediate page to let quick refresh */
var tableView = Ti.UI.createTableView({style: Titanium.UI.iPhone.TableViewStyle.GROUPED});
@sr3d
sr3d / marrily_api.md
Last active September 23, 2015 17:28

Marrily's data can be accessed via a RESTful interface. Here are the documentation on how to access the API. Currently the data are represented via JSON format only.

  1. v1 API info =============== The current API is at v1, and the all API access is over HTTP, starting with

    http://api.marrily.com/api/v1/

If the subscription is expired, you will get a 402 error for non-GET requests (except for user's authentication).