Skip to content

Instantly share code, notes, and snippets.

@matiaskorhonen
matiaskorhonen / crouton-to-mela.rb
Last active Dec 12, 2021
A rough Crouton (https://crouton.app) to Mela (https://mela.recipes) recipe converter. The imported recipes may require some clean-up…
View crouton-to-mela.rb
#!/usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "tty-logger", "~> 0.6"
gem "pry"
gem "dotiw"
@matiaskorhonen
matiaskorhonen / CustomPhotoImport.swift
Last active Jul 31, 2021
Custom image import into Photos.app using PhotoKit. Import an original JPEG plus an edited version of it. Proof of concept.
View CustomPhotoImport.swift
import Cocoa
import Photos
let original = URL(fileURLWithPath: "/Users/matt/Code/personal/PhotoKitPlayground/Test/DSC_6326.jpg")
let edited = URL(fileURLWithPath: "/Users/matt/Code/personal/PhotoKitPlayground/Test/DSC_6326-edit.jpg")
let status = PHPhotoLibrary.authorizationStatus(for: .readWrite)
if status != .authorized {
PHPhotoLibrary.requestAuthorization(for: .readWrite) { status in
@matiaskorhonen
matiaskorhonen / uusimaa.geojson
Last active Nov 20, 2021
Uusimaa postcode areas
View uusimaa.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matiaskorhonen
matiaskorhonen / statusbarmagic.sh
Created Jan 28, 2021
Override the iOS Simulator status bar in all running simulators
View statusbarmagic.sh
function statusbarmagic() {
usage="Usage: statusbarmagic apply|clear|help"
arg="$1"
requirements=( xcrun jq )
missing=0
for c in "${requirements[@]}"
do
if ! command -v "$c" &> /dev/null
then
@matiaskorhonen
matiaskorhonen / ffmpeg-pad-and-overlay.sh
Last active Dec 22, 2020
Add a device frame to an iOS screen recording (specifically an iPhone 12 Pro)
View ffmpeg-pad-and-overlay.sh
# Record screen from simulator:
xcrun simctl io booted recordVideo appVideo.mov
# Full size screen recording
ffmpeg -i screen-recording.mp4 -i iPhone12ProOverlay.png \
-filter_complex "scale=-1:2532,pad=width=3656:height=2057:x=(ow-iw)/2:y=(oh-ih)/2,overlay=x=0:y=0" \
output.mp4
# Screen recording resized to 1920px height
ffmpeg -i screen-recording.mp4 -i iPhone12ProOverlay-3656.png \
@matiaskorhonen
matiaskorhonen / librespot.service
Created Nov 20, 2020
Librespot (https://github.com/librespot-org/librespot) systemd config (/etc/systemd/system/librespot.service)
View librespot.service
[Unit]
Description=Librespot
Requires=network-online.target
After=network-online.target
[Service]
User=nobody
Group=audio
Restart=always
RestartSec=10
@matiaskorhonen
matiaskorhonen / ics.md
Created Nov 20, 2019
Add iCalendar/ICS feed to Google calendar
View ics.md

Link to add a iCalendar feed to Google Calendar

https://www.google.com/calendar/render?cid=http://example.org/index.ics

Note: cid must be a plain HTTP URL even if the feed is actually served over HTTPS

Source: https://stackoverflow.com/a/1479310

@matiaskorhonen
matiaskorhonen / rtl_433.rb
Created Aug 23, 2019
Parse streaming output from rtl_433
View rtl_433.rb
require "json"
IO.popen("./rtl_433 -F json") do |io|
while (line = io.gets) do
begin
puts JSON.parse(line).inspect
rescue JSON::ParserError
puts line
end
end
@matiaskorhonen
matiaskorhonen / eurukoshots.rb
Created Jul 8, 2019
Generate screenshots of all the Euruko sites
View eurukoshots.rb
#!/usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "down"
gem "pry"
end
@matiaskorhonen
matiaskorhonen / euruko-map.rb
Created Jul 8, 2019
Build a map of all the Euruko cities
View euruko-map.rb
#!/usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "addressable"
gem "nokogiri"
gem "pry"
end