Skip to content

Instantly share code, notes, and snippets.

root_dir = File.dirname(__FILE__)
if !defined?(Sinatra)
$:.unshift "#{root_dir}/vendor/sinatra/lib" if File.directory?("#{root_dir}/vendor/sinatra")
end
require 'rubygems'
require 'sinatra'
Sinatra::Application.default_options.merge!(
// testing serving javascript from a gist
alert("hello world");
// ==UserScript==
// @name Outlook Web Access Extensions
// @namespace http://www2.hawaii.edu/~dburger
// @description Extensions to using the bastard child Outlook Web Access
// @include https://mail.camber.com/exchange/*
// ==/UserScript==
(
function() {
def form_auth_token
(protect_against_forgery?) ? form_authenticity_token : ''
end
<%= javascript_tag "var FORM_AUTH_TOKEN = '#{form_auth_token}';" %>
new Ajax.Request(url, {parameters: 'authenticity_token=' + FORM_AUTH_TOKEN});
var store = new Ext.data.Store({
baseParams: {
authenticity_token: FORM_AUTH_TOKEN
},
...
class MondoController < ApplicationController
protect_from_forgery :except => [:action_one, :action_two]
# ...
namespace :minifier do
def minify(files)
files.each do |file|
cmd = "java -jar lib/yuicompressor-2.3.1.jar #{file} -o #{file}"
puts cmd
ret = system(cmd)
raise "Minification failed for #{file}" if !ret
end
end
task :after_update_code, :roles => :app do
run "cd #{release_path} && rake minifier:minify" if rails_env == :production
end