This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired by Gembox | |
function opengem { | |
mate $GEMDIR/gems/`ls $GEMDIR/gems/|grep $1|sort|tail -1`/ | |
} | |
_opengemcomplete() { | |
COMPREPLY=($(compgen -W '$(ls $GEMDIR/gems)' -- ${COMP_WORDS[COMP_CWORD]})) | |
return 0 | |
} | |
complete -o default -o nospace -F _opengemcomplete opengem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# save to script/work in a rails project | |
# run it once, you will get an error 'script/work.tracker' did not match any file(s) known to git | |
# run git add script/work.tracker, and you are ready to go | |
# script/work at the beginning of the day to log a commit that says "I've begun working" | |
# use with the time tracker rake task: http://gist.github.com/141886 | |
date "+%s" > script/work.tracker | |
git commit script/work.tracker -m "!!!starting work!!!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Check the JavaScript source with JSLint - exit with status 1 if any of the files fail." | |
task :jslint do | |
failed_files = [] | |
classpath = File.join(RAILS_ROOT, "vendor", "rhino.jar") | |
jslint_path = File.join(RAILS_ROOT, "vendor", "jslint.js") | |
Dir['public/**/*.js'].reject{|path| path =~ /public\/ext\//}.each do |fname| | |
cmd = "java -cp #{classpath} org.mozilla.javascript.tools.shell.Main #{jslint_path} #{fname}" | |
results = %x{#{cmd}} | |
unless results =~ /^jslint: No problems found in/ | |
puts "#{fname}:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module WillPaginate | |
module ViewHelpers | |
alias_method :original_page_entries_info, :page_entries_info | |
def page_entries_info(collection, options = {}) | |
"<div class=\"#{options[:class] || 'page_entries_info'}\">" + original_page_entries_info(collection, options) + '</div>' | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'time' | |
# | |
# Compute the average time from a list of times. | |
# | |
# http://rubylearning.com/blog/2009/10/08/rpcfn-average-arrival-time-for-a-flight-2/ | |
# | |
# ASSUMPTIONS | |
# * input error checking is left out. inputs are assumed to be in format h:m[am/pm], parsable by Time | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Extends PanelRowExpander to show an edit panel in the expansion instead of an ExtTemplate. | |
*/ | |
MyApp.MyRowExpander = function(config){ | |
Ext.apply(this, config); | |
MyApp.MyRowExpander.superclass.constructor.call(this); | |
}; | |
Ext.extend(MyApp.MyRowExpander, Ext.grid.PanelRowExpander, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= javascript_include_tag 'jquery-1.3.2.js' %> | |
<% javascript_tag do %> | |
jQuery(function(){ | |
window.onerror = function(msg, url, line) { | |
if (console && console.log) { | |
console.log("sending error: " + msg + "\n" + url + ":" + line); | |
} | |
$.post('/errors', {message: msg, url: url, line: line, form_authenticity_token: '<%= form_authenticity_token %>'}); | |
return true; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To rewrite server subdomains into directories: Capture the subdomains | |
# in a rewrite condition, then use backreferences to them in the rule. | |
# . run apache locally | |
# . add project.client.staging.domain.com to /etc/hosts | |
# . curl project.client.staging.domain.com | |
# . in rewrite_log, you'll see rewrite '/' -> '/root/staging/client/project' | |
RewriteLogLevel 3 | |
RewriteLog "rewrite_log" | |
RewriteEngine On | |
ServerName project.client.staging.domain.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ourStore = new Ext.data.JsonStore({ //change to JsonStore | |
url:'Chapter15Example.json', | |
root:'files', //add root here | |
fields: [ //add fields here | |
{name:'file_name',mapping:'name'}, | |
{name:'file_size',mapping:'size',type:'int'}, | |
'type', | |
{name:'lastmod',mapping:'datelastmodified',type:'date'}, | |
{name:'file_attributes',mapping:'attributes'}, //these last few fields are not in the source json | |
'mode', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link rel="stylesheet" href="ext-3.1.1/resources/css/ext-all.css" /> | |
<script src="ext-3.1.1/adapter/ext/ext-base.js"></script> | |
<script src="ext-3.1.1/ext-all-debug.js"></script> | |
<script> | |
Ext.BLANK_IMAGE_URL = 'ext-3.1.1/resources/images/default/s.gif'; | |
// ...your grid code... | |
//grid.render('grid-example'); <- do not render the grid, the viewport will do this for you | |
Ext.onReady(function(){ |
OlderNewer