Skip to content

Instantly share code, notes, and snippets.

View amiel's full-sized avatar

Amiel Martin amiel

View GitHub Profile
noun_type_enable_disable = new CmdUtils.NounType( "Enable / Disable", ['enable', 'disable'] );
CmdUtils.CreateCommand({
name: "javascript",
synonyms: ['js'],
description: 'Enable or disable javascript for your browser. You will have to refresh the page for changes to take effect.',
author: {
name: 'Amiel Martin',
email: 'amiel@tatango.com'
CmdUtils.CreateCommand({
name: "hello-world",
execute: function() {
var doc = Application.activeWindow.activeTab.document;
// find div.foo in the body of that document
jQuery('#content', doc.body).html('woot');
displayMessage( "Hello, World!" );
@amiel
amiel / gist:69934
Created February 25, 2009 01:39
give it a value in seconds, and it will return a sentence
def length_of_time_in_words(seconds)
seconds = seconds.to_i
%w[ year month week day hour minute second ].collect do |unit|
unit_in_seconds = 1.send(unit).to_i
n = seconds / unit_in_seconds
seconds -= n * unit_in_seconds
module IncrementifyString
# Helps create a user friendly unique string
# For example, calling incrementify! repeatedly starting with
# 'string' would yield:
# 'string' => 'string1' => 'string2' => 'string3' ... 'string9' => 'string10' => 'string11' ... etc
def incrementify!
if match(/[0-8]$/)
succ! # this is faster than regex parse and to_i + 1 to_s
elsif ends_with?('9')
m = match(/(\d+)$/)
script_console_running = ENV.include?('RAILS_ENV') && IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers')
rails_running = ENV.include?('RAILS_ENV') && !(IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers'))
irb_standalone_running = !script_console_running && !rails_running
if script_console_running
require 'logger'
Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT))
end
$.fn.text_without_children = function(selector) {
var tmp = $("<div></div>").html(this.html()),
collection = (typeof selector == 'undefined') ? tmp.children() : tmp.find(selector);
collection.remove();
return tmp.text();
};
alias gb='for k in `git branch|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cblue%cr%Creset" $k|head -n 1`\\t$k;done'
# Output
# ------
# ~/Development/github(master)$ gb
# 4 weeks ago config-gem
# 9 days ago dropdown
# 5 weeks ago faucet
# 3 weeks ago health
export PATH="/usr/local/texlive/2008/bin/universal-darwin/:/opt/local/bin:/opt/local/sbin:$PATH:~/bin:/usr/local/mysql-5.0.67-osx10.5-x86/bin/:/usr/local/bin"
export MANPATH=/opt/local/share/man:$MANPATH
export LC_CTYPE=en_US.UTF-8
alias irb='irb --readline -r irb/completion'
# alias mate='open -a TextMate.app'
#define split =='/'-'%'?_=('+'+'+'+'('):'>'>'>')||(_
#define while main(_){while(((_=getchar())&&((_
while
#define while \
(@ a=
split
#ifndef __STRICT_ANSI__
//,<STDIN>){while(@a&&print(chr(($a=ord(shift@a))==10?126:$a
#endif
==126?
require_dependency 'will_paginate'
require_dependency 'will_paginate/finder'
unless Time.instance_methods.include? 'at_end_of_day'
Time.class_eval do
def at_end_of_day
self.at_beginning_of_day + 1.day
end
end