tmux cheatsheet
As configured in my dotfiles.
start new:
tmux
start new with session name:
As configured in my dotfiles.
start new:
tmux
start new with session name:
module ClimateControlHelpers | |
# Usage: | |
# | |
# describe Foo do | |
# stub_envs( | |
# FOO: "bar", | |
# ) | |
# | |
# it "uses the ENVs" | |
# end |
#!/usr/bin/env osascript | |
# Required parameters: | |
# @raycast.schemaVersion 1 | |
# @raycast.title Send IM | |
# @raycast.mode silent | |
# Optional parameters: | |
# @raycast.icon 💬 | |
# @raycast.author Henrik Nyh |
def stub_env(key, value) | |
is_set_up_flag = "__stub_env_is_set_up" | |
unless ENV[is_set_up_flag] | |
allow(ENV).to receive(:[]).and_call_original | |
allow(ENV).to receive(:fetch).and_call_original | |
allow(ENV).to receive(:[]).with(is_set_up_flag).and_return(true) | |
end |
As determined by https://github.com/breunigs/bravia-auth-and-remote/.
Specifically, I followed the setup instructions in its README and then ran
curl --silent -XPOST http://192.168.0.131/sony/system -d '{"method":"getRemoteControllerInfo","params":[],"id":10,"version":"1.0"}' | pbcopy
(with the IP of the TV on my network).
I then ran its output through an online JSON prettifier.
Rails.stub!(:env).and_return(ActiveSupport::StringInquirer.new("production")) |
Get exchange rate as JSONP via YQL. | |
YQL Console: http://developer.yahoo.com/yql/console | |
Query (USD to SEK): select rate,name from csv where url='http://download.finance.yahoo.com/d/quotes?s=USDSEK%3DX&f=l1n' and columns='rate,name' | |
Example code: | |
<script type="text/javascript"> |
# Recursively diff two hashes, showing only the differing values. | |
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license. | |
# | |
# Example: | |
# | |
# a = { | |
# "same" => "same", | |
# "diff" => "a", | |
# "only a" => "a", | |
# "nest" => { |
Install ImageMagick for image conversion:
brew install imagemagick
Install tesseract for OCR:
brew install tesseract --all-languages
Or install without --all-languages
and install them manually as needed.
class Luhn | |
def self.checksum(number) | |
digits = number.to_s.reverse.scan(/\d/).map { |x| x.to_i } | |
digits = digits.each_with_index.map { |d, i| | |
d *= 2 if i.even? | |
d > 9 ? d - 9 : d | |
} | |
sum = digits.inject(0) { |m, x| m + x } | |
mod = 10 - sum % 10 | |
mod==10 ? 0 : mod |