Skip to content

Instantly share code, notes, and snippets.

View jbasdf's full-sized avatar

Justin Ball jbasdf

View GitHub Profile
clean_snippet: function(snippet){
snippet = snippet.replace(/'/gi, "("); // single quote will cause javascript problems inline.
snippet = snippet.replace(/[\t\n\r]/gi, ""); // remove tabs, newlines, and return chars
return this.rewrite_links(snippet);
},
// Rewrite links in the snippets so they go back to the parent site.
rewrite_links: function(snippet){
var obj = jQuery(snippet);
obj.find('[href]').attr('href', function(){ return com.oerglue.browser.make_abs_url(this.href); });
clean_snippet: function(snippet){
snippet = snippet.replace(/'/gi, "("); // single quote will cause javascript problems inline.
snippet = snippet.replace(/[\t\n\r]/gi, ""); // remove tabs, newlines, and return chars
return this.rewrite_links(snippet);
},
// Rewrite links in the snippets so they go back to the parent site.
rewrite_links: function(snippet){
var obj = jQuery(snippet);
obj.find('[href]').attr('href', function(){ return com.oerglue.browser.make_abs_url(this.href); });
@jbasdf
jbasdf / jquery.outerhtml.js
Created February 8, 2011 22:59
An outerHtml method for jQuery
jQuery.fn.outerHtml = function(include_scripts) {
if(include_scripts === undefined){ include_scripts = false; }
var clone = this.clone();
var items = jQuery.map(clone, function(element){
if(jQuery.nodeName(element, "script")){
if(include_scripts){
var attributes;
if(element.attributes){
attributes = jQuery.map(element.attributes, function(attribute){
return attribute.name + '="' + attribute.value + '" ';
@jbasdf
jbasdf / gist:1512141
Created December 22, 2011 22:32
Output from build
node public/oerglue_js/app.build.js
/Users/jbasdf/projects/oerglue_proxy/public/oerglue_js/min-main-edit.js
----------------
/Users/jbasdf/projects/oerglue_proxy/public/oerglue_js/libs/require/almond.js
/Users/jbasdf/projects/oerglue_proxy/public/oerglue_js/libs/jquery/jquery.js
/Users/jbasdf/projects/oerglue_proxy/public/oerglue_js/libs/underscore/underscore.js
/Users/jbasdf/projects/oerglue_proxy/public/oerglue_js/libs/backbone/backbone.js
/Users/jbasdf/projects/oerglue_proxy/public/oerglue_js/libs/utils/common.js
/Users/jbasdf/projects/oerglue_proxy/public/oerglue_js/libs/cookies.js
@jbasdf
jbasdf / sessions.rb
Created January 30, 2012 21:45
Middleware for Sessions in Goliath Options [Click the star to watch this topic]
require 'rack/utils'
require 'rack/session/abstract/id'
require 'remcached'
require 'em-synchrony/em-remcached'
module Slurper
module Rack
class Session < ::Rack::Session::Abstract::ID
include Goliath::Rack::AsyncMiddleware
@jbasdf
jbasdf / sessions.rb
Created February 2, 2012 03:45
Goliath Session Middleware
require 'rack/utils'
require 'rack/session/abstract/id'
require 'remcached'
require 'em-synchrony/em-remcached'
module Slurper
module Rack
class Session < ::Rack::Session::Abstract::ID
include Goliath::Rack::AsyncMiddleware
@jbasdf
jbasdf / iterm2_customize
Created September 12, 2012 21:49
iTerm2 AppleScript
launch "iTerm"
tell application "iTerm"
activate
------------------------------------
-- create the Open Tapestry tabs
tell the first terminal
-- set terminal size
@jbasdf
jbasdf / scan_cameras.rb
Created June 24, 2013 00:00
Output Camera Models for iPhoto
#!/usr/bin/env ruby
require 'rubygems'
require 'exifr'
require 'fileutils'
require 'logger'
class PictureScanner
def self.scan_files(source_dir)
cameras = {}
@jbasdf
jbasdf / ember_models.rake
Created September 28, 2013 17:46
Create Ember.js models from Rails Schema
namespace :ember do
desc "Build ember models from schema"
task :models => :environment do
# Change these values to fit your project
namespace = 'App' # The Ember application's namespace.
output_dir = File.join(Rails.root, "app/assets/javascripts/common/models") # The directory where ember models will be written
schema_file = File.join(Rails.root, 'db/schema.rb')
@jbasdf
jbasdf / ember_models.rake
Created October 1, 2013 23:31
Generate models for Ember Data 1.0.0 beta using Ruby on Rails Schema.
namespace :ember do
desc "Build ember models from schema"
task :models => :environment do
# Change these values to fit your project
namespace = 'App' # The Ember application's namespace.
# The directory where ember models will be written. We drop them
# in the tmp directory since we might not want an ember model for every table in the