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
/* | |
I only really use hanging-punctuation: first and only expect it to | |
work in blockquotes, which makes the usage extremely simple. And yet | |
for some reason I've never done a simple polyfill. Now I have. | |
*/ | |
(function() { | |
if ( !CSS.supports("hanging-punctuation", "first") ) { | |
document.querySelectorAll("p").forEach(e => { if ( e.innerText.trim()[0] == "“" ) { e.style.textIndent = "-0.725ch"; } }); | |
} | |
})(); |
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 | |
table = ARGF.read.chomp | |
parse_row = ->(row) { row.gsub(/^\||\|$/, "").split("|").map(&:strip) } | |
rows = table.each_line.map(&parse_row) | |
# Normalise column count | |
column_count = rows.map(&:length).max | |
rows = rows.map { |row| (row + ([""] * column_count)).take(column_count) } |
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 String | |
def pangram? | |
(("a".."z").to_a - self.downcase.chars.uniq).empty? | |
end | |
end | |
["The quick brown fox jumped over the lazy dogs!", "The slow dog didn't"].each do |text| | |
puts "#{text}: #{text.pangram?}" | |
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
class Kramdown::Converter::Html | |
def add_block_count(attr) | |
@block_count ||= 0 | |
@block_count += 1 | |
unless attr["id"] | |
attr["id"] = "b:#{@block_count}" | |
end | |
end | |
%i(format_as_block_html format_as_indented_block_html).each do |method| |
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 | |
# | |
# Play a command-line version of Wordle | |
# | |
# Original game by Josh Wardle: https://www.powerlanguage.co.uk/wordle/ | |
# | |
# Installation and usage: | |
# | |
# 1. Save this file somewhere as play-wordle.rb | |
# 2. Run `ruby play-wordle.rb` |
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 | |
# | |
# Trying to guess what the best first-choice word in Wordle might be. | |
# | |
# Author: Rob Miller <[email protected]> | |
# Boosts the score of a word that matches the first letter, with the | |
# rationale that getting the first letter makes the word easier for | |
# a human being to guess | |
FIRST_LETTER_WEIGHT = 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
#!/usr/bin/env ruby | |
gem "twitter", "~> 7.0" | |
gem "http", "~> 4.4" | |
require "twitter" | |
require "http" | |
require "json" | |
require "yaml" |
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
tell application "Skim" | |
repeat with n from (count of documents) to 1 by -1 | |
set doc to document n | |
if name of doc is "book-screen.pdf" then | |
revert doc | |
end if | |
end repeat | |
end tell |
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 macOS command line tools broke, so I had to reinstall them | |
# (I kept getting the error "Your CLT does not support macOS 11." | |
# when compiling packages from Homebrew.) | |
sudo rm -rf /Library/Developer/CommandLineTools | |
sudo xcode-select --install | |
# Homebrew had old x86 libraries and object files and god knows what | |
# else hanging around, which caused several packages to break during install | |
# (including Ruby) so I reinstalled Homebrew and all my packages | |
brew list > ~/homebrew.tmp.txt |
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 | |
# | |
# A "correct horse battery staple"-style password generator. Outputs | |
# four random, fairly common (among the 5,000 most common words) English | |
# words, contracted together with hyphens. | |
# | |
# Author: Rob Miller <[email protected]> | |
puts DATA.each_line.to_a.sample(4).map(&:chomp).join("-") |
NewerOlder