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
#!/usr/bin/env ruby | |
# | |
# enable-rs-db-root | |
# | |
# Enables the root account on a Rackspace cloud database instance. | |
# | |
# Usage: | |
# | |
# enable-rs-db-root name.of.your.instance.example.com | |
# |
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
db = SQLite3::Database.new ":memory:" | |
# A sample SQLite table; all that's necessary is the lat and log fields | |
db.execute <<-SQL | |
CREATE TABLE users ( | |
email VARCHAR(255), | |
lat FLOAT, | |
lon FLOAT | |
) | |
SQL |
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
<?php | |
function register() | |
{ | |
if (!empty($_POST)) { | |
$msg = ''; | |
if ($_POST['user_name']) { | |
if ($_POST['user_password_new']) { | |
if ($_POST['user_password_new'] === $_POST['user_password_repeat']) { | |
if (strlen($_POST['user_password_new']) > 5) { | |
if (strlen($_POST['user_name']) < 65 && strlen($_POST['user_name']) > 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
#!/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 <r@robm.me.uk> | |
puts DATA.each_line.to_a.sample(4).map(&:chomp).join("-") |
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 | |
# | |
# lightroom-groups.rb | |
# Author: Rob Miller <r@robm.me.uk> | |
# | |
# Mass organises presets into groups in Lightroom, based on their folder | |
# on disk. | |
# | |
# -- | |
# |
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
# `git merge-log` shows the commits that were introduced in a given merge | |
# `git merge-diff` shows the actual changes that were introduced by a given merge | |
# Both commands accept an optional commitish; if ommitted, the last merge commit is used | |
merge-span = "!f() { echo $(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f1)$1$(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f2); }; f" | |
merge-log = "!git log `git merge-span .. $1`" | |
merge-diff = "!git diff `git merge-span ... $1`" | |
merge-difftool = "!git difftool `git merge-span ... $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
/* reveals koalastothemax.com without needing to move your mouse */ | |
var mm = new Event("mousemove"); | |
function rand(min, max) { return Math.ceil(Math.random() * (max - min) + min); } | |
function sorter(c1, c2) { if ( c1[0] > c2[0] ) { return -1; } if ( c1[0] < c2[0] ) { return 1; } return 0 } | |
function getBiggestCircle() { | |
var circles = [...document.querySelectorAll("#dots circle")].map(c => [c.getBBox().width, c]).sort(sorter); | |
return circles[0][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
#!/usr/bin/env ruby | |
# | |
# Solutions to Diamond Geezer's "the digits of the year 2019 add up to twelve" puzzles: | |
# http://diamondgeezer.blogspot.com/2019/01/the-digits-of-year-2019-add-up-to-twelve.html | |
def main | |
# a) How many years ago did this last happen? | |
a = 2019 - 2018.downto(0).find { |year| sum_digits(year) == 12 } | |
# b) In what year? | |
b = 2018.downto(0).find { |year| sum_digits(year) == 12 } |