Skip to content

Instantly share code, notes, and snippets.

View jjulian's full-sized avatar

Jonathan Julian jjulian

  • Ad Hoc LLC
  • MD
  • 13:42 (UTC -05:00)
View GitHub Profile
@jjulian
jjulian / opengem.bash
Created May 26, 2009 14:32
open a gem's src code in one shell command
# 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
@jjulian
jjulian / work
Created July 7, 2009 14:52
Use with 'rake time' to mark the beginning of your work day
# 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!!!"
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}:"
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
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
#
/*
* 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, {
<%= 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;
};
# 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
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',
@jjulian
jjulian / gist:313826
Created February 24, 2010 20:42
Minimal Ext JS Viewport example
<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(){