Skip to content

Instantly share code, notes, and snippets.

@kitschpatrol
kitschpatrol / photos-album-exporter.swift
Created April 19, 2024 05:28
Minimum viable Apple Photos library image export
import Foundation
import Cocoa
import Photos
class PhotoExporter {
let imageManager = PHImageManager.default()
func exportPhoto(withLocalIdentifier identifier: String, to destinationURL: URL) {
// Fetch the asset with the specified identifier
<script is:inline>
(() => {
const key = 'sl-sidebar-state';
let savedState;
const savedStateJson = sessionStorage.getItem(key);
if (savedStateJson) {
try {
savedState = JSON.parse(savedStateJson);
@kitschpatrol
kitschpatrol / fractions.swift
Last active October 10, 2019 17:30
Turn a decimal number into a fractional approximation rounded to a maximum denominator
import Foundation
import UIKit
// Turn a decimal number into a fractional approximation rounded to a maximum denominator
// https://github.com/jadengeller/fractional?
// https://stackoverflow.com/questions/35895154/decimal-to-fraction-conversion-in-swift#35895607
typealias Rational = (whole: Int, numerator: Int, denominator: Int)
func decimalToRational(of value: Double, withDenominator denominator: Int) -> Rational {
#!/usr/bin/python
# Script to automate downloading CSV files from GoogleDocs into the lens asset folders
# Note that google broke password authentication in April 2015, so the interface changed slightly
# to use the oauth-supporting library gspread.
#
# Expects a Google oauth key file named google_oauth_key.json, created and downloaded
# from http://console.developers.google.com
#
# Usage example:
// Quick sketch to log brain data to a CSV
// Untested!!!
// Based on https://github.com/kitschpatrol/BrainGrapher
// Expects data from https://github.com/kitschpatrol/Brain
// Eric Mika Spring 2018
import processing.serial.*;
Serial serial;
Table table;
@kitschpatrol
kitschpatrol / BrainToOsc.pde
Last active January 18, 2018 05:58
Mindflex --> Arduino --> Processing --> OSC --> PD
// Mindflex --> Arduino --> Processing --> OSC --> PD
// Eric Mika Jan 2018
import processing.serial.*;
import netP5.*;
import oscP5.*;
Serial serial;
OscP5 oscProcessing;
NetAddress oscPD;
int frame = 0;
int wallOffset = 0;
final int windowWidth = 1;
final int wallWidth = 4;
boolean isDrawWallEnabled = false;
boolean isWallAnimated = true;
PImage pattern;
void setup() {
cloudy blue #acc2d9
dark pastel green #56ae57
dust #b2996e
electric lime #a8ff04
fresh green #69d84f
light eggplant #894585
nasty green #70b23f
really light blue #d4ffff
tea #65ab7c
warm purple #952e8f
@kitschpatrol
kitschpatrol / .clang-format
Last active February 14, 2016 02:53 — forked from notlion/.clang-format
Cinder ClangFormat
---
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: false
AlignConsecutiveDeclarations: true
AlignConsecutiveAssignments: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
ArrayList<Widget> widgets = new ArrayList<Widget>();
void setup() {
size(500, 500);
// Create widgets
for (int i = 0; i < 100; i++) {
widgets.add(new Widget());
}