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 ApplicationHelper | |
def grid_for(collection, options={}, &block) | |
options[:columns] ||= 4 | |
options[:class] ||= '' | |
content_tag :table, :class => options[:class] do | |
content_tag :tbody do | |
collection.to_a.in_groups_of(options[:columns]).collect {|row| | |
content_tag :tr do | |
row.collect{|col| content_tag :td, (capture(col, &block) unless col.nil?) }.reduce(:+) | |
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
$.ajax | |
# ... | |
beforeSend: (xhr) => | |
if xhr.upload? | |
xhr.upload.onprogress = => | |
console.log arguments... |
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 Enumerable | |
def in_groups_of(*args, &block) | |
to_a.in_groups_of(*args, &block) | |
end | |
def in_groups(*args, &block) | |
to_a.in_groups(*args, &block) | |
end | |
def split(*args, &block) |
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
CREATE OR REPLACE TYPE Multiplication | |
AS OBJECT ( | |
runningProduct NUMBER, | |
STATIC FUNCTION ODCIAggregateInitialize | |
( actx IN OUT Multiplication | |
) RETURN NUMBER, | |
MEMBER FUNCTION ODCIAggregateIterate | |
( self IN OUT Multiplication, |
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
#!/usr/bin/env bash | |
# Backup and modify .zshrc | |
cp $HOME/.zshrc $HOME/.zshrc_ | |
sed -i "s/^ZSH_THEME=/\# \0/" $HOME/.zshrc | |
echo >> $HOME/.zshrc | |
echo "echo \"\\n\\n\\033[1;31m\$ZSH_THEME\\033[0m\\n\\n\"" >> $HOME/.zshrc | |
# Using xterm | |
CMD="xterm -ls -e /usr/bin/env zsh" |
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
# Create a class method (anyone, anywhere) | |
User.stub :save | |
# Save original constructor | |
new_method = User.method(:new) | |
# Stub constructor | |
User.stub(:new).and_return do |*args| | |
# Call original constructor | |
instance = new_method.call(*args) | |
# Save original save method | |
save_method = instance.method(:save) |
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
function _exec_with | |
set -l shell $argv[1] | |
set -l file $argv[2] | |
set -l code $argv[3] | |
set -l source | |
switch "$shell" | |
case bash zsh ksh | |
set source . | |
case '*' |
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
_bash_exec () { | |
file="$1" | |
code="$2" | |
function_names="typeset -f | sed '/^{\s*\\\$/,/^}\s*\\\$/d' | sed 's/\s*[(][)]\s*\\\$//' | sort" | |
variable_names="env | grep -v '^_|PIPESTATUS|COLUMNS|SHLVL\\\$' | sort" | |
# Create temp files to catch the change of variables and functions | |
functions_before=$(mktemp) | |
functions_after=$(mktemp) |
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
#!/usr/bin/env fish | |
for tool in ack rename perl | |
if not which $tool >/dev/null | |
echo You need $tool to run this tool >&2 | |
exit 1 | |
end | |
end | |
if [ (count $argv) != 3 ] |
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
// ==UserScript== | |
// @name Google Translate Keyboard Everywhere | |
// @description 25 keyboard shortcuts (with on-screen help) to use GT at rapid pace. | |
// @icon http://translate.google.com/favicon.ico | |
// @version 1.0-20130224 | |
// @namespace http://jakub-g.github.com | |
// @author http://jakub-g.github.com | |
// @license Apache 2.0 | |
// @downloadURL https://raw.github.com/jakub-g/greasemonkey-userscripts/master/googleTranslate/keyboardEverywhere.js | |
// @userscriptsOrg http://userscripts.org/scripts/show/... |
OlderNewer