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
# copy/paste in ~/.bash_profile and invoke it by typing "gh" in commandline | |
# Opens the github page for the current git repo/branch in your browser | |
function gh() { | |
giturl=$(git config --get remote.origin.url) | |
if [ "$giturl" == "" ] | |
then | |
echo "Not a git repository or no remote.origin.url set" | |
exit 1; |
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
# copy/paste into ~/.bash_profile and invoke it by typing "bb" in commandline | |
# Opens the bitbucket page for the current git repo/branch in your browser | |
function bb() { | |
giturl=$(git config --get remote.origin.url) | |
if [ "$giturl" == "" ] | |
then | |
echo "Not a git repository or no remote.origin.url set" | |
exit 1; |
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
" Use Vim settings, rather then Vi settings (much better!). | |
" This must be first, because it changes other options as a side effect. | |
set nocompatible | |
runtime autoload/pathogen.vim | |
call pathogen#infect() | |
call pathogen#helptags() | |
" EDITOR SETTINGS ======================================================== | |
" ======================================================================== |
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
# this adds an additional `user_ids` array to each of the `organizations` collection | |
json.organizations do |json| | |
json.array! @organizations do |org| | |
json.merge! org.attributes | |
json.user_ids org.users.pluck(:id) | |
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
# add associated object's IDs as arrays for each record in collection | |
Organization.joins(:users) | |
.select("organizations.*, '#{User.joins(:organization).pluck(:id)}' as user_ids") | |
.group('organizations.id') | |
# => { organizations: [{ id: 1, name: 'some name',... user_ids:[1,2,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
// focus first form field element matching these criteria | |
$(':input:visible:enabled:not(.no-focus, | |
select, input[readonly=readonly], | |
input[type=checkbox], | |
input[type=radio], | |
input[type=submit]):first').focus(); |
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
http://stackoverflow.com/questions/3458553/javascript-passing-parameters-to-a-callback-function | |
function tryMe (param1, param2) { | |
alert(param1 + " and " + param2); | |
} | |
function callbackTester (callback) { | |
callback (arguments[1], arguments[2]); | |
} | |
callbackTester (tryMe, "hello", "goodbye"); |
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
# ==================== | |
# Spell: Dynamic Proxy | |
# ==================== | |
# Forward to another object any messages that don’t match a method. | |
class MyDynamicProxy | |
def initialize(target) | |
@target = target | |
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
/* Have padding and border that cut into the element's width instead expanding it. */ | |
textarea { | |
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ | |
-moz-box-sizing: border-box; /* Firefox, other Gecko */ | |
box-sizing: border-box; /* Opera/IE 8+ */ | |
} | |
/* reference: http://css-tricks.com/box-sizing/ */ |
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
namespace :pg do | |
namespace :structure do | |
# Does exactly the same as db:structure:dump but with one important | |
# difference. It tries to use a compatible version of pg_dump. If you see | |
# the following error message, use pg:structure:dump instead. | |
# | |
# pg_dump: server version: 9.1.0; pg_dump version: 9.0.4 | |
# pg_dump: aborting because of server version mismatch | |
# rake aborted! | |
# Error dumping database |
OlderNewer