Skip to content

Instantly share code, notes, and snippets.

View matiaskorhonen's full-sized avatar

Matias Korhonen matiaskorhonen

View GitHub Profile
@matiaskorhonen
matiaskorhonen / two-oceans-csv.rb
Created April 18, 2024 15:00
A rough script to get the Two Oceans 2024 half marathon results as a CSV
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source "https://rubygems.org"
gem "csv"
@matiaskorhonen
matiaskorhonen / acegist.user.js
Created April 10, 2012 13:55 — forked from abernier/acegist.user.js
ACE editor for editing your gists
// ==UserScript==
// @id acegist
// @name ACEgist
// @author Antoine BERNIER (abernier)
// @version 0.1.1
// @description ACE editor in your gists
// @match https://gist.github.com/gists/*/edit
// ==/UserScript==
(function (d, cb) {
@matiaskorhonen
matiaskorhonen / ffmpeg-pad-and-overlay.sh
Last active March 12, 2024 08:57
Add a device frame to an iOS screen recording (specifically an iPhone 12 Pro)
# 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 / HDCP MASTER KEY
Created September 14, 2010 16:18
HDCP MASTER KEY
HDCP MASTER KEY (MIRROR THIS TEXT!)
This is a forty times forty element matrix of fifty-six bit
hexadecimal numbers.
To generate a source key, take a forty-bit number that (in
binary) consists of twenty ones and twenty zeroes; this is
the source KSV. Add together those twenty rows of the matrix
that correspond to the ones in the KSV (with the lowest bit
in the KSV corresponding to the first row), taking all elements
@matiaskorhonen
matiaskorhonen / CustomPhotoImport.swift
Last active September 5, 2023 00:38
Custom image import into Photos.app using PhotoKit. Import an original JPEG plus an edited version of it. Proof of concept.
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 / espoo.json
Last active August 21, 2023 19:35
Espoo Rantamaraton / Rantapuolikas / Espoo Half Marathon
{
"setarea": false,
"count": 170,
"searchtext": "currentarea: category: \"Espoo Rantapuolikas\"",
"categories": [
"Espoo Rantapuolikas"
],
"results": [
{
"name": "Espoo Rantapuolikas",
@matiaskorhonen
matiaskorhonen / sign-pdf.rb
Last active May 25, 2023 10:58
Quick and dirty PDF signing in Ruby (using Origami)
#!/usr/bin/env ruby
require "openssl"
require "time"
begin
require "origami"
rescue LoadError
abort "origami not installed: gem install origami"
end
@matiaskorhonen
matiaskorhonen / simlang.sh
Created March 3, 2023 10:20
A hacked together script to change iOS simulator languages and locales. Use at your own peril.
#!/usr/bin/env bash
set -e -o pipefail
checkRequirements() {
requiredCommands=("jq" "xargs" "xcrun")
for cmd in "${requiredCommands[@]}"; do
if ! command -v "$cmd" &> /dev/null
then
@matiaskorhonen
matiaskorhonen / speaker.md
Last active November 8, 2022 21:28
Frozen Rails Talk Proposal Template (http://2014.frozenrails.eu/). If you want to submit multiple talks, just duplicate the talk.md file. If you don't want your proposal to be public, create a private gist.
@matiaskorhonen
matiaskorhonen / midnight-run.geojson
Last active September 7, 2022 08:39
Helsinki Midnight Run 10K (2022)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.