Skip to content

Instantly share code, notes, and snippets.

Choice:
fields:
default: choice, question_id, question
form: choice, question_id, question
order_by:
relationships: question
filters: created_at, question
search:
application: survey
@donfrancisco
donfrancisco / cross_domain_proxy.js
Created May 30, 2012 17:36 — forked from ryankirkman/cross_domain_proxy.js
Call an external JSON API via a local cross domain proxy
// See: http://api.jquery.com/jQuery.ajaxPrefilter/
$.ajaxPrefilter( function( options ) {
if ( options.crossDomain ) {
var newData = {};
// Copy the options.data object to the newData.data property.
// We need to do this because javascript doesn't deep-copy variables by default.
newData.data = $.extend({}, options.data);
newData.url = options.url;
// Reset the options object - we'll re-populate in the following lines.
@donfrancisco
donfrancisco / fileapisample
Created May 31, 2012 22:40 — forked from alunny/file-api-sample.js
sample usage of the phonegap file api
var writeData = function (filename, data, callback) {
var writeOutData = function () {
var fw = new FileWriter();
fw.oncomplete = callback;
fw.onerror = function () {
alert("Failed to save update");
}
fw.writeAsText("myDir/" + filename, data);
}
@donfrancisco
donfrancisco / index.html
Created May 31, 2012 22:44 — forked from alunny/index.html
simple PhoneGap File API example
<html>
<body>
<form onsubmit="return saveText()">
<label for="name">Name</label><br>
<input id="name" /><br>
<label for="desc">Description</label><br>
<input id="desc" /><br>
<input type="submit" value="Save" />
@donfrancisco
donfrancisco / httpartyexample.rb
Created June 15, 2012 10:37
httparty example
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'httparty')
require 'pp'
config = YAML::load(File.read(File.join(ENV['HOME'], '.twitter')))
class Twitter
include HTTParty
base_uri 'twitter.com'
def initialize(u, p)
require 'HTTParty'
response = HTTParty.get("https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&screen_name=instagram&count=10")
puts result[0]['entities']['media'][0]['media_url']
@donfrancisco
donfrancisco / sublimesymlink.sh
Created June 16, 2012 07:49
Sublime 2 command line symlink OSX
require 'rubygems'
require 'sinatra'
require 'httparty'
class Representative
include HTTParty
end
get '/' do
erb :form
end
get '/:username' do
@donfrancisco
donfrancisco / gist:2940467
Created June 16, 2012 08:11
redis twitter datastore
require "httparty"
require "redis"
require_relative "../models/twitter_status" # some wrapper for a Twitter status
class TwitterStream
attr_reader :twitter_handle, :tweets
attr_reader :cache # a helper to the Redis database
attr_reader :cached_response # the actual response from a API call
that is put into the cache
@donfrancisco
donfrancisco / postgresapp_induction_rails.md
Created July 20, 2012 11:49 — forked from alexagui/postgresapp_induction_rails.md
Migrate a Rails project to Postgresql with Postgres.app and Induction

I had issues installing Postgres with the instructions in this Railscast. However I was able to get postgres running on my project with http://postgresapp.com/ and http://inductionapp.com/ (Hat tip to this stackoverflow thread).

  1. Download & install Postgres.app (documentation) Make sure to install in /Applications.
  2. Update your PATH
    In my case I added the following to ~/.bash_profile
    export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
    Check that Postgres.app is being loaded
$ which psql
/Applications/Postgres.app/Contents/MacOS/bin/psql