Skip to content

Instantly share code, notes, and snippets.

Avatar

Amiel Martin amiel

View GitHub Profile
View gist:54772
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'
View using jQuery in a ubiquity command
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 Feb 25, 2009
give it a value in seconds, and it will return a sentence
View gist:69934
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
View gist:97387
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+)$/)
View .irbrc
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
View gist:110219
$.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();
};
View git-branch.sh
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
View .bashrc
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'
View gist:163455
#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?
View add_pagination_by_day_to_will_paginate.rb
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
You can’t perform that action at this time.