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
#!/bin/sh | |
# Some things taken from here | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# Set the colours you can use | |
black='\033[0;30m' | |
white='\033[0;37m' | |
red='\033[0;31m' | |
green='\033[0;32m' |
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
javascript: var asin_elements, asin;asin_elements = document.getElementsByName('ASIN'); if (asin_elements.length == 0) { asin_elements = document.getElementsByName('ASIN.0'); };if (asin_elements.length == 0) { alert('Sorry, this doesn\'t appear to be an Amazon book page.'); }else { asin = asin_elements[0].value; if (asin.match(/\D/) === null) { var x = window.open('http://www.goodreads.com/review/isbn/'+ asin, 'add_review'); } else { var x = window.open('https://www.goodreads.com/search?q='+ asin); } x.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
#!/bin/sh | |
# get current branch and tag | |
branch=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3`; | |
tag=`git describe --tags`; | |
# if current tag has annotations showing number of commits since tagging, then use current branch | |
destination="$tag" | |
if [[ "$tag" == *-* ]] | |
then |
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
# A method signature such as: | |
def blah(file, underscore_to_hyphen=true) | |
# will be called like so: | |
blah(file, true) | |
# where true could also be false | |
# this is a code smell, since it is impossible to tell | |
# from the call what the boolean does |
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
# rather than | |
if some_condition | |
return true | |
else | |
return false | |
end | |
# you can use |
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
var ||= the_value |
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
many_elements.each do |foo| | |
dict[foo] ||= expensive_computation | |
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
# longer and harder to read, with redundant lines | |
facet_values_after = [] | |
facet_values.each do | facet_value | | |
facet_value = facet_value.gsub(/\_/, '\-') | |
facet_values_after << facet_value.gsub(/"/, '\"') | |
end | |
return facet_values_after | |
# can be turned into |
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
# instead of: | |
if retail_chains && retail_chains.size > 0 | |
return retail_chains[0] | |
end | |
# you could write: | |
retail_chains.first unless retail_chains.blank? |
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
# For Level 16 developers | |
# Instead of: | |
if !retailers.empty? | |
# Use this: | |
unless retailers.empty? |
NewerOlder