Skip to content

Instantly share code, notes, and snippets.

View jwreagor's full-sized avatar

J R jwreagor

  • New Gillington, WI
View GitHub Profile
function copyIntoClipboard(text) {
var flashId = 'flashId-HKxmj5';
/* Replace this with your clipboard.swf location */
//var clipboardSWF = 'http://appengine.bravo9.com/copy-into-clipboard/clipboard.swf';
var clipboardSWF = '/clipboard.swf';
if(!document.getElementById(flashId)) {
var div = document.createElement('div');
This is an example of using RVM's Project .rvmrc file
to have it automatically bootstrap your environment, including bundler.
This could be further expanded to do anything you require :)
The important thing to remember is that the purpose of these files is
to allow you to very easily have your 'project context' (aka 'environment')
loaded automatically for you when you enter the project in the shell (cd).
require 'machinist/datamapper'
# Let's say we have some really simple models for a blog. (I'm using
# DataMapper here, but Machinist works exactly the same way with ActiveRecord.)
class Person
include DataMapper::Resource
property :id, Serial
property :name, String
end
AK,61.3850,-152.2683
AL,32.7990,-86.8073
AR,34.9513,-92.3809
AS,14.2417,-170.7197
AZ,33.7712,-111.3877
CA,36.1700,-119.7462
CO,39.0646,-105.3272
CT,41.5834,-72.7622
DC,38.8964,-77.0262
DE,39.3498,-75.5148
<!-- Worse than RJS -->
= link_to_function("Add widget", :class => "new-widget", :id => "add_link") do |page|
- page << %Q{$(this).after('#{escape_javascript render(:partial => 'form', :object => Widget.new, :locals => { :thing => @thing, :that => @that})}').next().show();$(this).siblings('.no-information').remove(); return false;}
# For "Classic" style/top-level type of apps do something like:
#
# configure :development do
# require File.join(File.dirname(__FILE__), 'sinatra_reloader')
# set :reload_paths, [File.join(File.dirname(__FILE__), '**', '*.rb')]
# end
#
# For "Modular" style/Sinatra::Base subclasses:
#
# configure :development do
class Commit
attr_reader :id
lazy_reader :parents
lazy_reader :tree
lazy_reader :author
lazy_reader :authored_date
lazy_reader :committer
lazy_reader :committed_date
lazy_reader :message
lazy_reader :short_message
@jwreagor
jwreagor / jquery-easing-ext.js
Created October 25, 2010 04:08
Extends jQuery's easing functions with some homebrew lovin.
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend(jQuery.easing, {
def: 'easeOutQuad',
swing: function (x, t, b, c, d) {
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
},
easeInQuad: function (x, t, b, c, d) {
return c * (t /= d) * t + b;
},
"The secret to Ruby's success is its use of "convention over configuration," wherein naming a variable foo causes the corresponding column in the database to automatically be named foo as well."
http://infoworld.com/d/developer-world/7-programming-languages-the-rise-620?page=0,1
#
# Super tiny block configuration class, which is
# a great example of nested instance evaluation.
# All using a single class.
#
# Inspired by ...
# http://github.com/ahoward/configuration/blob/master/lib/configuration.rb
#
# Updated: More functionality, less lines of code (gem soon)
#