Skip to content

Instantly share code, notes, and snippets.

View CodeOfficer's full-sized avatar

Russell Jones CodeOfficer

View GitHub Profile
javascript:if(!document.getElementById('download-youtube-video')){var%20video_id=null;var%20video_hash=null;var%20video_player=document.getElementById('movie_player');if(video_player){var%20flash_variables=video_player.attributes.getNamedItem('flashvars');if(flash_variables){var%20flash_values=flash_variables.value;if(flash_values){var%20video_id_match=flash_values.match(/[^a-z]video_id=([^(\&|$)]*)/);if(video_id_match!=null)video_id=video_id_match[1];var%20video_hash_match=flash_values.match(/[^a-z]t=([^(\&|$)]*)/);if(video_hash_match!=null)video_hash=video_hash_match[1]}}}if(video_id==null||video_hash==null){var%20args=null;try{args=yt.getConfig('SWF_ARGS')}catch(e){}if(args){video_id=args['video_id'];video_hash=args['t']}}if(video_id!=null&&video_hash!=null){var%20div_embed=document.getElementById('watch-embed-div');if(div_embed){var%20div_download=document.createElement('div');var%20div_download_code='%3Cbr%20/%3E%3Cspan%20id=\'download-youtube-video\'%3E%3Ca%20href=\''+'http://www.youtube.com/get_video?f
require 'rubygems' rescue nil
require 'wirble'
require 'pp'
# load wirble
Wirble.init
Wirble.colorize
IRB.conf[:AUTO_INDENT] = true
# In Rails 3, I wanted to include some additional json values in my data for
# the jquery ui autocomplete plugin. Overriding to_json() at the model level
# seemed to work on a specific model instance, but not for a collection of
# model instances. (pretty sure that worked in prior Rails versions)
# Here's the working code:
class PostsController < ApplicationController
def index
@posts = Post.all
# mac specific aliases ------------------------------------------
alias o='open . &'
alias ff='open -a Firefox'
alias m='mate'
# other aliases ------------------------------------------
# utility
alias c='clear'
var data = [1,2,3,4]
var template = (<r><![CDATA[
<% for ( var i = 0; i < data.length; i++ ) { %>
<% if(data[i] != 2 ){ %>
<li><%= data[i] %></li>
<% } %>
<% } %>
]]></r>).toString();
console.log($.srender(template, data));
$.sammy(function() {
this.helpers({
showModal: function() {
$('.modal').show('slow');
},
hideModal: function() {
$('.modal').show('slow');
}
});
#!/usr/bin/env ruby
# Usage: gemspec [-s] GEMNAME
#
# Prints a basic gemspec for GEMNAME based on your git-config info.
# If -s is passed, saves it as a GEMNAME.gemspec in the current
# directory. Otherwise prints to standard output.
#
# Once you check this gemspec into your project, releasing a new gem
# is dead simple:
#
file 'Gemfile', <<-GEMS
source 'http://gemcutter.org'
gem "rails", "3.0.0.beta3"
gem "bson_ext"
gem "mongoid", "2.0.0.beta4"
gem "haml", "3.0.0.rc.2"
gem "compass", "0.10.0.rc4"
gem "inherited_resources"
group :test do
;(function($) {
$(function() {
$('body').bind('confirm', function(event) {
console.log('confirm', event);
});
$('body').bind('ajax:before', function(event) {
console.log('ajax:before', event);
// return false; works here to cancel the chain
(function ($) {
$.event.special.textchange = {
setup: function (data, namespaces) {
$(this).bind('keyup', $.event.special.textchange.handler);
$(this).bind('cut paste input', $.event.special.textchange.delayedHandler);
},
teardown: function (namespaces) {