Skip to content

Instantly share code, notes, and snippets.

View Artforge's full-sized avatar

Adam Artforge

View GitHub Profile
onRender: function() {
var filter = this.options.filter || this.filter;
var view= new ListView({collection: TitanFile.channelList, filter: filter});
var contentPromise = this.content.show(view);
return contentPromise;
}
Backbone.serverSync = Backbone.sync;
Backbone.pingUrl = '/Ping';
Backbone.localID = function() {
var localID = (localStorage.localID ? parseInt(localStorage.localID) : 0);
localID++;
localStorage.localID = localID.toString()
return -localID;
}
<!DOCTYPE html>
<html>
<head>
<title>Capture Photo</title>
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1"/>
<script type="text/javascript" charset="utf-8" src="js/phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
var pictureSource; // picture source
var destinationType; // sets the format of returned value
@Artforge
Artforge / gist:4612034
Created January 23, 2013 19:37
login session controller for devise receiver from mobile (phonegap) client
class Api::SessionsController < Devise::SessionsController
# include Devise::Controllers::InternalHelpers
prepend_before_filter :require_no_authentication, :only => [:new, :create]
def new
super
end
def create
sign_out(current_user) if current_user
@Artforge
Artforge / locations.js.coffee
Created August 7, 2012 15:24 — forked from nathancolgate/locations.js.coffee
CoffeeScript and HAML Pagination in Backbone.js
class IamConnect.Collections.Locations extends Backbone.Collection
url: '/api/locations'
model: IamConnect.Models.Location
_.extend IamConnect.Collections.Locations.prototype, IamConnect.Mixins.PaginationCollectionMethods.prototype
# Install PostgreSQL and PostGIS Via Homebrew
# One click installer seems to fail to get PostGIS installed.
# Download GISGraphy Binaries from http://www.gisgraphy.com/download/
# Move unzipped directory into /src/gisgraphy
# INITIALIZE TABLES
psql -U postgres -d gisgraphy -h 127.0.0.1 -f /src/gisgraphy/sql/create_tables.sql
@Artforge
Artforge / install_postgis_osx.sh
Created March 7, 2012 16:02 — forked from lucasallan/install_postgis_osx.sh
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@Artforge
Artforge / coupons
Created January 26, 2012 20:02 — forked from resistorsoftware/coupons
Discount Coupons
require 'rubygems'
require 'mechanize'
BASE = 'http://manure.myshopify.com/admin'
LOGIN = '/auth/login'
USER = 'paddy@cow.com'
PWD = 'moo-moo'
agent = Mechanize.new
page = agent.get(BASE+LOGIN)
form = page.forms.first
form.login = USER
@Artforge
Artforge / paperclip_migration.rake
Created December 12, 2011 00:03 — forked from louisgillies/paperclip_migration.rake
Quick and dirty one off migration task for paperclip plugin to move files from local filesystem to Amazon S3.
# First configure your models to use Amazon s3 as storage option and setup the associated S3 config.
# Then add the classes your want to migrate in the klasses array below.
# Then run rake paperclip_migration:migrate_to_s3
# Should work but this is untested and may need some tweaking - but it did the job for me.
namespace :paperclip_migration do
desc "migrate files from filesystem to s3"
task :migrate_to_s3 => :environment do
klasses = [:model_1, :model_2] # Replace with your real model names. If anyone wants to this could be picked up from args or from configuration.
klasses.each do |klass_key|
@Artforge
Artforge / gist:931912
Created April 20, 2011 16:58
Patch to add css class based on page title (in order to support background images)
<%
if menu_branch.title.nil?
css = "class='nil'"
elsif !!local_assigns[:apply_css] and (classes = css_for_menu_branch(menu_branch, menu_branch_counter, sibling_count||=nil, collection, selected_item ||= nil)).any?
css = "class='#{menu_branch.title.underscore.gsub(" ","_")} #{classes.join(' ')}'"
else
css = "class='#{menu_branch.title.underscore.gsub(" ","_")}'"
end
dom_id = ("id='item_#{menu_branch_counter}'" if menu_branch.parent_id.nil? and menu_branch.title.present?)