Skip to content

Instantly share code, notes, and snippets.

View matiaskorhonen's full-sized avatar

Matias Korhonen matiaskorhonen

View GitHub Profile
@matiaskorhonen
matiaskorhonen / README.md
Created November 25, 2025 11:17
Google OAuth in a CLI script

Google API OAuth Client Setup Guide

This guide walks you through creating OAuth 2.0 credentials in the Google Cloud Console to use with the Google OAuth authentication script.

Prerequisites

Step 1: Create or Select a Google Cloud Project

@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 / 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 / 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 / midnight-run.geojson
Last active September 7, 2022 08:39
Helsinki Midnight Run 10K (2022)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matiaskorhonen
matiaskorhonen / crouton-to-mela.rb
Last active March 12, 2025 01:26
A rough Crouton (https://crouton.app) to Mela (https://mela.recipes) recipe converter. The imported recipes may require some clean-up…
#!/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 September 14, 2024 16:40
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 / uusimaa.geojson
Last active November 20, 2021 11:46
Uusimaa postcode areas
Loading
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 January 28, 2021 10:47
Override the iOS Simulator status bar in all running simulators
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 June 2, 2025 15:58
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 \