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 ruby | |
# Find Homebrew formulas that are missing tests! | |
# Usage: run from checked out Homebrew repository root | |
# $ git clone git@github.com:Homebrew/homebrew.git && cd homebrew | |
# $ curl https://gist.githubusercontent.com/tedpennings/9148810/raw/ > missing_tests.rb | |
# $ chmod +x missing_tests.rb | |
# $ ./missing_tests.rb | |
min_commits = 25 |
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
export PATH=/usr/local/bin:$PATH:~/bin | |
eval "$(rbenv init -)" | |
export GREP_OPTIONS="--color=auto" | |
BREWDIR=$(brew --prefix) | |
if [ -f $BREWDIR/etc/bash_completion ]; then | |
source $BREWDIR/etc/bash_completion | |
fi |
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
// 1. Go to a page like https://untappd.com/user/thesleepyvegan/beers?filter_type=type&filter_id=all&sort= | |
// 2. Open the Javascript console (Mac Chrome: Apple+Option+J) | |
// 3. Run the following Javascript snippet: | |
$('#style_picker option').map(function(i,e) { return $(e).text() }).splice(1).map(function(s) { var item = /([A-z/\(\) ]+) \((\d+)\)/.exec(s); return [item[1], parseInt(item[2])]; }).sort(function(a,b) { return b[1] - a[1]; }); | |
// 4. Explore the resulting array and enjoy! | |
// Here are comments on what it does. Some browsers may require you to remove the comments for chaining | |
$('#style_picker option') // select the beer text from the style picker dropdown | |
.map(function(i,elem) { return $(elem).text() }) // take the text description of each |
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 ruby | |
# The challenge: | |
# Given a dollar amount, determine which bills to dispense, optimizing for fewest bills, using a greedy algorithm | |
# Ted Pennings, 2015, License: http://choosealicense.com/licenses/unlicense/ | |
AVAILABLE_BILLS = [100, 50, 20, 10, 5, 1] # nobody wants $2 bills |
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 decorates Handlebars.js with the ability to load | |
* templates from an external source, with light caching. | |
* | |
* To render a template, pass a closure that will receive the | |
* template as a function parameter, eg, | |
* T.render('template-name', function(t) { | |
* $('#somediv').html( t() ); | |
* }); | |
*/ |
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
<p>Modifying version ${dto.versionToExpire}. Currently, effective | |
${feature.featureVersions[dto.versionToExpire].effectiveRange.startDate} to | |
${feature.featureVersions[dto.versionToExpire].effectiveRange.endDate}</p> |
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
(defn power-of? [power number] | |
"Returns true if a number is a power of another number, eg, | |
(power-of? 5 25) => true | |
(power-of? 5 26) => false" | |
(= | |
(mod | |
(/ | |
(Math/log number) | |
(Math/log power) ) | |
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
(def certainty 5) | |
(defn prime? [n] | |
(if (= n 1) | |
true | |
(.isProbablePrime (BigInteger/valueOf n) certainty))) | |
(take 10001 | |
(filter prime? | |
(take-nth 2 |
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
(ns algorithms.hashtable) | |
; This is a programming assignment from my CS algorithms class. | |
(defn create-table [size] | |
(let [empty-table (hash-map)] | |
(loop [current 0 | |
table empty-table] | |
(if (> size current) | |
(recur (inc current) |
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
import java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.math.BigDecimal; | |
import java.math.RoundingMode; | |
import java.util.ArrayList; |
OlderNewer