Skip to content

Instantly share code, notes, and snippets.

View jackboberg's full-sized avatar

Jack Boberg jackboberg

View GitHub Profile
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Feed Helper
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
*
* @author Jack Boberg
* @copyright ( coded by hand ) 2010-03
@jackboberg
jackboberg / gist:3625789
Created September 4, 2012 20:05
RVM & Rails setup

RVM & Rails setup

System Init

Set your .gemrc to not install docs by default

# ~/.gemrc
gem: --no-rdoc --no-ri

install: --no-rdoc --no-ri

@jackboberg
jackboberg / jquery.plugin.js.coffee
Created September 11, 2012 17:42
coffeescript boilerplate jQuery plugin
$ = jQuery
pluginName = 'test'
methods =
init: (opts)->
defaults =
foo: 'bar'
bar: 'foo'
options = $.extend defaults, opts
return @.each ->
@jackboberg
jackboberg / helper_task.rake
Created December 27, 2012 16:24
Accessing Rails Helpers in Rake Tasks
# lib/tasks/helper_task.rake
namespace :helper do
desc 'Access helper methods in rake tasks'
task :test => :environment do
include ActionView::Helpers
include ApplicationHelper
puts display_amount 2500 #=> "$2,500"
end
end
@jackboberg
jackboberg / wordpress.rake
Last active December 10, 2015 07:09
Convert wordpress.xml to rails models
@cache_dir = 'lib/assets/'
def hash_from_cache
xml = @cache_dir + 'published.xml'
cache = @cache_dir + 'published.cache.rb'
if ! File.exists?(cache)
data = File.read xml
hash = Hash.from_xml data
File.open(cache, "wb") {|io| Marshal.dump(hash, io)}
def template(from, to)
erb = File.read(File.expand_path("../../templates/#{from}", __FILE__))
put ERB.new(erb).result(binding), to
end
def set_default(name, *args, &block)
set(name, *args, &block) unless exists?(name)
end
def remote_file_exists?(path)
var mongoose = require('mongoose');
var ContactSchema = require('./contact');
var UserSchema = new mongoose.Schema({
email: {type: String},
name: {type: String},
//oauth: {},
profile: {type: Object},
contacts: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Contact' }]
});
@jackboberg
jackboberg / gist:5918466
Created July 3, 2013 14:33
Precompile assets locally and rsync
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :web, :except => { :no_release => true } do
system "RAILS_ENV=development bundle exec rake assets:precompile"
system "rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{host}:#{shared_path}"
system "RAILS_ENV=development bundle exec rake assets:clean"
end
task :update_asset_mtimes do
(function() {
Backtrace = {};
Backtrace.Router = (function() {
Router.prototype.optionalParam = /\((.*?)\)/g;
Router.prototype.namedParam = /:\w+/g;
#= require_tree ./
class App.Routers.Common extends App.Routers.Base
routes:
'*': 'global'
# ---------------------------------------------------------------------
global: (r)->
$(window).load @windowLoad