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
# Example ~/.ssh/config for dealing with JSch problems regarding | |
# ssh public key authentication with encrypted (password protected) keys. | |
# | |
# First, a problem description and a couple of solutions that worked for me, | |
# (in March 2018 on MacOS High Sierra) and in the bottom youäll find an example | |
# config that doesn't interfere with JSch's use of the ssh-agent. | |
# | |
# | |
# Problem description: | |
# -------------------- |
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
# The equation | |
def equation(a, b, c, d, e, f, g, h, i) | |
a + 13 * b / c + d + 12 * e - f - 11 + g * h / i - 10 | |
end | |
# The brute force | |
def solutions(*numbers) | |
numbers. | |
permutation. | |
map { |nums| [nums, equation(*nums)] }. |
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
require 'clean_assert' | |
def add_drinking_person(name, age) | |
assert / "name != nil" / "not name.empty?" / "age >= 21" | |
puts "Adding '#{name}' of age #{age} to the list of drinkers" | |
# And some code to do it... | |
end | |
add_drinking_person("Niclas", 17) | |
# Gives: |
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
:: running ssh -i /home/deploy/.ssh/internal -o StrictHostKeyChecking=no -o PasswordAuthentication=no [email protected] '/usr/local/ey_resin/ruby/bin/gem list engineyard-serverside | grep "engineyard-serverside" | egrep -q '\''1\.4\.16[,)]'\' | |
:: running git clone -q https://github.com/engineyard/todo.git /data/todo/shared/cached-copy 2>&1 | |
~> Deploying revision 00fa4e7 Another temp model. | |
:: running git checkout -q '00fa4e7297f99b3a096c0f7b02ec03800aa21eff' | |
:: running git submodule sync | |
:: running git submodule update --init | |
:: running git clean -dfq | |
~> Pushing code to all servers | |
:: running ssh -i /home/deploy/.ssh/internal -o StrictHostKeyChecking=no -o PasswordAuthentication=no [email protected] 'mkdir -p /data/todo/shared/cached-copy' | |
:: running rsync --delete -aq -e "ssh -i /home/deploy/.ssh/internal -o StrictHostKeyChecking=no -o PasswordAuthentication=no" /data/todo/shared/cached-copy/ [email protected]:/data/todo/sha |
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
$cache = {} | |
def shorten(s, ws) | |
$cache[s] ||= ws.flat_map { |w| | |
a = s.split(w, -1) | |
(0..a.size-1).map { |p| | |
ns = a[0..p].join(w) + a[p+1..-1].join(w) | |
ns.size < s.size ? shorten(ns, ws) : s | |
} | |
}.min_by { |s| s.size } |