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
// Iterative depth-first search traversal as a partition. | |
// Start from startingPoint, and iteratively follow all neighbors. | |
// | |
// If inclusionCondition is true for a neighbor, include it, | |
// otherwise, exclude it. At the end, return two arrays: | |
// One for the included neighbors, another for the remaining | |
// neighbors. | |
// | |
// Example: Say you have a grid which contains certain points | |
// which are all adjacent-connected: |
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 prodssh { osascript -e 'tell application "Terminal" to set current settings of selected tab of window 1 to settings set "Red Sands"' && ssh "$@"; } | |
# prodssh yourserver |
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
class Symbol | |
def |(other) | |
self.to_proc | other | |
end | |
end | |
class Proc | |
def |(other) | |
proc { |arg| other.to_proc.call(self.call(arg)) } | |
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
# Delay Foo#method by 1 second before | |
# executing its original implementation. | |
def delay_method(klass, method) | |
sleeping_giant = Module.new do | |
define_method(method) do |*args, &block| | |
sleep 1 | |
super(*args, &block) | |
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
# Collect _spec.rb and .feature files under spec/ that are relevant to current work, one per line. Good for pipes. | |
# | |
# 1. Modified, staged git files. | |
# 2. Modified, unstaged git files. | |
# 3. Changes in any commits since master. | |
# 4. New, untracked files. | |
# | |
# $ specs | xargs rspec | |
cat <(git diff --name-only) <(git diff --staged --name-only) <(git diff master..@ --name-only) <(git ls-files --others --exclude-standard) | uniq | grep -e "^spec/" | grep -E "_spec\.rb$|\.feature$" |
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
# Demonstration showing that | |
# | |
# alias_method :bar, :foo | |
# | |
# is not equivalent to | |
# | |
# def bar | |
# foo | |
# 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
# place the contents of this file in, e.g., spec/re_run_friendly_formatter.rb | |
# | |
# and in .rspec: | |
# | |
# --format ReRunFriendlyFormatter | |
require "rspec/core/formatters/progress_formatter" | |
class ReRunFriendlyFormatter < RSpec::Core::Formatters::ProgressFormatter | |
RSpec::Core::Formatters.register self, :dump_summary |
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/bash | |
SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd -P )" | |
cd "$SCRIPT_DIR" | |
last_employee_count=$(cat last-employee-count) | |
last_employee_list="$(cat last-employee-list)" | |
employee_count=$(curl -s 'https://github.com/about/team' | grep -o '[0-9]* employees' | grep -o '[0-9]*') | |
employee_list="$(curl -s https://github.com/about/team | grep -e '<div class="employee">' -A 1 | grep -Po '(?<=<a href="/)[^"]+(?=">)')" |
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
# imgur redirecting direct image links from t.co on the first click ? | |
# A subsequent visit in the same browser seems to work fine, so maybe | |
# they remember it via the cookie. | |
# 1. See i.imgur.com/foo.jpg link in a tweet. | |
# 2. Visit it with a redirect through t.co. | |
# 3. See imgur.com/foo page instead of just the image. | |
# 4. Visit the same link from (1) again. | |
# 5. See the regular image at i.imgur.com/foo.jpg, as usual. |
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
/* | |
* Just a user stylesheet for yoleoreader.com. No affiliation. | |
* | |
* Author: Adam Prescott (aprescott.com) | |
* Copyright: CC BY-NC-SA - Creative Commons Attribution-NonCommercial-ShareAlike | |
*/ | |
.article-contents { | |
font-family: "Georgia", serif; | |
font-size: 1.1em; |
NewerOlder