Skip to content

Instantly share code, notes, and snippets.

View jforaker's full-sized avatar

Jake Foraker jforaker

View GitHub Profile
@jforaker
jforaker / 0_reuse_code.js
Created October 23, 2013 16:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
class Story < ActiveRecord::Base
validates :title, :link, :category, :upvotes, presence: true
scope :popular, -> { where('upvotes >= ?', 4)}
scope :recent, -> { where('created_at >= ?', Date.today)}
def self.search_for(query)
where('title LIKE :query OR category LIKE :query', query: "%#{query}%")
end
end
@jforaker
jforaker / devise_controller.rb
Created March 12, 2014 19:27
open gem file
export BUNDLER_EDITOR=mine
bundle open devise
@jforaker
jforaker / SeatingChart.js
Created April 7, 2014 15:11
Sencha Touch multiple listeners on XTemplate DOM elements
listeners:{
tap: {
element: 'element',
delegate: '.student-seat .doc-box, .bubble-holder',
fn: function(e){
var me = this;
var url = e.target.name
@jforaker
jforaker / FeedItemView.js
Created April 10, 2014 22:21
Multiple tap listeners
listeners: {
tap: {
element: 'element',
delegate: '.app-box, .doc-box, .bubble-holder',
fn: function(e){
var url = e.target.name
, name = e.delegatedTarget.textContent
, divClassName = e.delegatedTarget.className
@jforaker
jforaker / People.js
Created April 23, 2014 15:49
scrollable config
scrollable: {
fps: 'auto',
direction : 'vertical',
directionLock: true,
indicators: false,
momentumEasing: {
momentum: {
acceleration: 30, // how slowly it stops - high # = stops less
friction: 0.7 // stick factor
},
@jforaker
jforaker / gist:441c2eaf6ee0be326e96
Created June 20, 2014 14:59
clone_www.rb :: Clone and build - phonegap
#!env ruby
require 'optparse'
require 'yaml'
DESTINATION_DIRECTORY = './www'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: clone_www.rb [options]"
@jforaker
jforaker / FeedItemView.js
Created August 13, 2014 18:41
Multiple tap events Sencha Touch
tap: {
element: 'element',
delegate: '.app-box, .doc-box, .bubble-holder',
fn: function(e){
var url = e.target.name,
name = e.delegatedTarget.textContent,
divClassName = e.delegatedTarget.className,
appbox = "app-box",
docbox = "doc-box",
@jforaker
jforaker / FeedItemView.js
Created August 13, 2014 18:44
Parse due dates with moment.js
dues: function (expiresdate){
var now = moment(),
due = moment(expiresdate).format("YYYY-MM-DD"),
todayMoment = moment().format("YYYY-MM-DD"),
dueFormatted = moment(expiresdate).format("MMMM Do YYYY"),
tmrw, yest,
dueInfo = {
color: '',
text: ''
};
@jforaker
jforaker / FeedItemView.js
Last active August 29, 2015 14:05
Sencha Touch swipe to navigate
listeners: {
swipe: {
element: 'element',
fn: function (e) {
var direction = e.direction,
feednav = Ext.ComponentQuery.query('FeederNav')[0];
if (direction == 'right') {
feednav.reset();