Skip to content

Instantly share code, notes, and snippets.

@stilist
stilist / 0 README.markdown
Last active January 13, 2026 07:43
Extracting mood.camera’s film emulations

I like the look of mood.camera’s high-contrast black & white preset (the ‘Noir 800-C’ film stock), and would like to use it in other photo apps. Unlike most photo editors or camera apps with customizable looks, mood.camera doesn’t support LUT imports:

Why can't I import custom presets, instead of manually dialing in the settings?

This was actually an intentional choice. I didn't want people to just blindly import a bunch of presets, I wanted to them to understand the settings. I also didn't want users to be overwhelmed with choice, like the 1000s of Lightroom presets out there, it's so hard to settle on the "right one".

Instead, there’s twenty built-in ‘emulation’s (default iPhone colors + 19 simulations of film stocks), along with various sliders, allowing users to choose a look they like without having total control over the details. I was curious how this was implemented, and if it had anyth

@stilist
stilist / day1.rb
Last active December 4, 2024 02:24
Advent of Code 2024
File.read(File.expand_path('~/Downloads/day 1 input.txt'))
.split(/\n/)
.reduce([]) {|m,l|l.split.map(&:to_i).each_with_index.map {(m[_2]||[])<<_1}}
.map(&:sort)
.each_cons(2)
.map {_1.zip(_2)}
.flatten(1)
.map {(_1-_2).abs}
.sum
@stilist
stilist / monkeypatch.diff
Created July 10, 2024 18:31
Monkeypatch relations into Publify Blog model
diff --git a/config/initializers/model_extensions.rb b/config/initializers/model_extensions.rb
new file mode 100644
index 000000000..2db532ba9
--- /dev/null
+++ b/config/initializers/model_extensions.rb
@@ -0,0 +1 @@
+require "blog_extension"
diff --git a/lib/blog_extension.rb b/lib/blog_extension.rb
new file mode 100644
index 000000000..01fbcf5b3
@stilist
stilist / build-merge-branch.sh
Last active February 10, 2022 18:42
Script for creating a branch that combines multiple other branches
#!/usr/bin/env bash
set -euo pipefail
destination_branch_name="${1:-merge-pile}"
branch_list="${2:-branch-list.txt}"
if [[ ! -f "${branch_list}" ]] ; then
echo "ERROR: Branch list file (${branch_list}) doesn't exist" >&2
exit 1
@stilist
stilist / log-volume-by-date.sh
Created June 30, 2020 21:14
Count date-like strings in files in /var/log
#!/bin/bash
set -euo pipefail
log_directory="${1:-/var/log}"
year="20[[:digit:]]{2}"
day="[[:digit:]]{2}"
month_num="[[:digit:]]{1,2}"
month_alpha="[[:upper:]][[:lower:]]{2}"
@stilist
stilist / README.md
Last active April 24, 2020 04:47
Accurately count the number of lines from PS1, PS2, and the command the user entered.
@stilist
stilist / README.md
Created April 21, 2020 16:49
Correctly handle an arbitrary number of lines in PS0 rewriting

This is a small revision to the move_cursor_to_start_of_ps1 function described in ‘When did I run that command?’. The original relies on a specific number of lines in PS1; this works with an arbitrary number of lines.

The original code works correctly for the PS1 provided in the article, but my PS1 has an additional line, and I wanted to avoid using a magic number in case I change my PS1 in the future.

@stilist
stilist / netflix-ratings-to-json.js
Created February 8, 2019 00:32
Export Netflix ratings as JSON
// You can run this from your browser's JavaScript console.
console.log(JSON.stringify(Array.from(document.querySelectorAll('.retableRow')).map(node => {
let rating
const stars = node.querySelectorAll('.rating .personal')
if (stars.length) {
rating = stars.length
} else {
rating = node.querySelector('.rated-up') ? 'up' : 'down'
}
@stilist
stilist / dribbble-likes.js
Last active December 23, 2018 03:02
Scrape Dribbble likes into JSON that matches the real API's structure (but with some missing data)
// Copyright 2018 Jordan Cole
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@stilist
stilist / svn_log_to_json.rb
Created March 5, 2018 03:48
Extract Subversion log data
require 'fileutils'
require 'json'
# LOG = ARGF.read.freeze
LOG = File.read('log.txt')
COMMIT_PATTERN = /
\A
r(?<revision>\d+)
\s\|\s