Skip to content

Instantly share code, notes, and snippets.

@subimage
subimage / FullScreenTextArea.js
Created September 12, 2012 01:26
A fullscreen textarea for Sencha Touch 2
// The default TextAreaField in Sencha touch 2 is difficult to use
// on a mobile device.
//
// This when tapped to edit, this displays the text full screen, and allows
// for better reading and editing.
//
// Modified from 'BetterTextArea'
// http://colinramsay.co.uk/diary/2012/05/18/a-better-textareafield-for-sencha-touch-2/
Ext.define('Ext.ux.field.FullScreenTextArea', {
@subimage
subimage / ChildView.js
Created September 25, 2012 10:26
Sencha Touch 2 "child store" that keeps data sync'd from a parent Ext.data.Store
// A sub-store implementation that allows you to store local
// cached records in a 'parentStore', and then use this to present
// a view you can filter on for DataViews like List, etc.
//
// Dynamically selects data from parentStore, and refreshes itself
// when data in that store is changed.
//
// Allows passing a queryFunc to restrict selection of records
// from the parentStore.
Ext.define('CbMobile.store.ChildView', {
@subimage
subimage / sync.rb
Created November 2, 2012 14:17
Capistrano recipe to sync database with production machine
namespace :sync do
desc "Load production data into development database"
task :database, :roles => :db, :only => { :primary => true } do
require 'yaml'
# Gets db yml from server, because we don't store it on dev boxes!
get "#{current_path}/config/database.yml", "tmp/prod_database.yml"
prod_config = YAML::load_file('tmp/prod_database.yml')
local_config = YAML::load_file('config/database.yml')
@subimage
subimage / sync_database.rb
Created February 7, 2013 22:27
Capistrano task to import production database code locally.
namespace :db do
desc "Load production data into development database"
task :load_production_data, :roles => :db, :only => { :primary => true } do
require 'yaml'
# Gets db yml from server, because we don't store it on dev boxes!
get "#{current_path}/config/database.yml", "tmp/prod_database.yml"
prod_config = YAML::load_file('tmp/prod_database.yml')
local_config = YAML::load_file('config/database.yml')
@subimage
subimage / prince_xml.rb
Created February 7, 2013 22:58
Prince XML library I created in 2007
# Prince XML Ruby interface.
# http://www.princexml.com
#
# Library by Subimage Interactive - http://www.subimage.com
#
#
# USAGE
# -----------------------------------------------------------------------------
# prince = Prince.new()
# html_string = render_to_string(:template => 'some_document')
@subimage
subimage / pdf_helper.rb
Created February 7, 2013 23:00
Rails module that uses prince.rb to generate PDF files
# We use this chunk of controller code all over to generate PDF files.
#
# To stay DRY we placed it here instead of repeating it all over the place.
#
module PdfHelper
require 'prince'
private
# Makes a pdf, returns it as data...
def make_pdf(template_path, pdf_name, landscape=false)
@subimage
subimage / .autotest.rb
Created February 8, 2013 20:48
Autotest mapping file
Autotest.add_hook :initialize do |at|
# Ignore these files
%w{
.hg .git .svn stories tmtags Rakefile Capfile README .html
spec/spec.opts spec/rcov.opts vendor/gems autotest svn-commit .DS_Store
}.each {|exception|at.add_exception(exception)}
# Map concerned_with files properly.
# app/models/[model]/[concern].rb should map to
# test/unit/[model]/[concern]_test.rb
@subimage
subimage / backbone-cashboard_extensions.js
Created September 12, 2013 01:05
Extensions used in production for Cashboard (http://cashboardapp.com) that allow for serialized request queue, amongst other nice things. For use with backbone-prototype.js (https://gist.github.com/subimage/6532044) Used in production for Cashboard (http://cashboardapp.com)
// Overrides Backbone.js features for our specific use in Cashboard.
(function(){
// How many times do we try to re-contact the server
// if we're offline or the server is before erroring out?
var BACKBONE_RETRY_ATTEMPTS=99;
// Max timeout should be 10 seconds.
var MAX_TIMEOUT=10000;
// Helper function to get a value from a Backbone object as a property
// or as a function.
@subimage
subimage / backbone-prototype.js
Last active December 22, 2015 21:19
A Prototype.js => 1.7.1 compatible backbone.js 0.9.1 Used in production for Cashboard (http://cashboardapp.com)
// Backbone.js 0.9.1
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
//
// HACKED TO BE PROTOTYPE.JS COMPATIBLE BY [SUBIMAGE AT GMAIL DOT COM]
// REQUIRES PROTOTYPE >= 1.7.1
@subimage
subimage / jquery-2.1.1.min.js
Last active August 20, 2018 19:44
Refined version of @nbriz's "Leave Facebook" collection
/*! jQuery v2.1.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.1",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,