Skip to content

Instantly share code, notes, and snippets.

#header < img[src="http://s55905.gridserver.com/banner3.png"] { display:none }
class Object
def send_chain(meths)
result = self
meths.each do |m|
return nil if result == nil
if result.respond_to?(m)
result = result.__send__(m)
elsif result.respond_to?(:[])
result = result[m]
else
@codekitchen
codekitchen / gfm.rb
Created January 5, 2011 15:56 — forked from mojombo/gfm.rb
require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end
@codekitchen
codekitchen / Object#vdiff method for ruby
Created January 19, 2011 16:16
view a diff of two ruby objects using pp and your difftool
$vdiff_difftool = 'ksdiff'
require 'pp'
class Object
def vdiff(other)
require 'tempfile'
t1 = Tempfile.new(['vdiff', '.rb'])
t2 = Tempfile.new(['vdiff', '.rb'])
PP.pp self, t1
PP.pp other, t2
@codekitchen
codekitchen / redmine_update_environment.rb
Created February 17, 2011 00:36
update redmine environment with a new staging/production ref
# requires redmine 1.1.x for the REST API fixes
require 'rubygems'
gem 'activeresource'
require 'active_resource'
env = ARGV.shift
new_commit = ARGV.shift
@codekitchen
codekitchen / .vimrc.local
Created June 9, 2011 20:17
vim surround commands for canvas i18n extraction
" i key
autocmd FileType eruby let b:surround_105 = "<%= t('\1key: \1', %{\r}) %>"
" o key
autocmd FileType eruby let b:surround_111 = "t('\1key: \1', \r)"
autocmd FileType ruby let b:surround_111 = "t('\1key: \1', \r)"
<% ot 'criterion_for_assignment', 'For %{assignment} users must %{select_criterion}', :assignment => capture { %>
<span style="padding: 0 4px;">
<select class="id assignment_picker">
</select>
</span>
<% }, :select_criterion => capture { %>
<span style="padding: 0 4px;">
<select class="type assignment_requirement_picker">
<option class="any" value="must_view"><%= t('', %{view the item}) %></option>
<option class="assignment wiki_page discussion_topic" value="must_contribute"><%= t('requirements.must_contribute', %{contribute to the page}) %></option>
--- jquery.1.7.1.js 2011-11-29 11:11:43.000000000 -0700
+++ jquery.1.7.1.patched.js 2011-11-29 11:11:21.000000000 -0700
@@ -560,6 +560,9 @@
// Make sure leading/trailing whitespace is removed (IE can't handle it)
data = jQuery.trim( data );
+ // Remove any prefixing while(1);, which is protection against CSRF
+ data = data.replace(/^while\(1\);/, "");
+
// Attempt to parse using the native JSON parser first
[ { a: 5, b: 6} ]
basically, POST to the lis_outcome_service_url URL with a XML body.
The sourcedId is the id passed to your tool, the resultScore is the score from 0.0 to 1.0. You'll need to set the content-type to application/xml, and sign the POST with your OAuth key and secret that you configured for the tool.
<?xml version = "1.0" encoding = "UTF-8"?>
<imsx_POXEnvelopeRequest xmlns = "http://www.imsglobal.org/lis/oms1p0/pox">
<imsx_POXHeader>
<imsx_POXRequestHeaderInfo>
<imsx_version>V1.0</imsx_version>