Skip to content

Instantly share code, notes, and snippets.

View kulmajaba's full-sized avatar

Mika Kuitunen kulmajaba

  • Tampere, Finland
  • 11:52 (UTC +03:00)
View GitHub Profile
@kulmajaba
kulmajaba / Star Trails.jsx
Last active October 16, 2023 09:45
Stack layers and increment opacity to create a fading star trail effect.
// Create a file in the path "Adobe Photoshop 2022/Presets/Scripts/Star Trails.jsx" and paste the contents there to use
// Star Trails, author Mika Kuitunen
// DEBUGGING STUFF
function ConsoleLog() {
// Seeing logs: macOS: nc -lvk 8000, Win: install Ncat, then ncat -lk 8000
this.socket = new Socket();
this.hostPort = "127.0.0.1:8000";
}
@kulmajaba
kulmajaba / ffmpeg-cheatsheet.sh
Created June 9, 2023 10:58
Useful FFMPEG commands
# H.264 variable framerate screencap to constant framerate
ffmpeg -i input.mp4 -c:v libx264 -crf 0 -vsync cfr -filter:v fps=60 output.mp4
@kulmajaba
kulmajaba / figma-async-messaging.ts
Last active September 15, 2023 06:05
Messaging for Figma plugins using async/await
import manifest from '../manifest.json';
// Types
// Better Omit type for Discriminated Union types
// https://github.com/microsoft/TypeScript/issues/31501
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type OmitStrict<T, K extends keyof T> = T extends any ? Pick<T, Exclude<keyof T, K>> : never;
export enum PluginMessageType {
@kulmajaba
kulmajaba / color-sorter.py
Last active September 26, 2022 10:19
Python script to sort and display a list of colors
import numpy as np
from PIL import Image, ImageColor
from colorir import hue_sort_key
with open('colors hexed.txt', 'r') as file:
lines = file.readlines()
colors_sorted = [line.rstrip() for line in lines]
# The alphabetical sort helps grayscale values greatly
colors_sorted.sort()
@kulmajaba
kulmajaba / color-cleaner.py
Last active May 14, 2023 22:48
Python script to convert rgb, rgba, html color names and malformed hex colors to hex
import re
import colorsys
# HTML color names supported by browsers
color_lookup = {
'aliceblue': '#f0f8ff',
'antiquewhite': '#faebd7',
'aqua': '#00ffff',
'aquamarine': '#7fffd4',
'azure': '#f0ffff',
@kulmajaba
kulmajaba / color-regex.md
Last active September 20, 2022 07:59
Regex pattern to find all individually defined color codes in a codebase, for example with VS Code global search

Color finder

Find colors in your codebase.

1. Hex codes

Valid hex colors contain a hashbang followed by 3, 4, 6 or 8 hexadecimals, 0-9 or a-f. Negative lookahead to ensure further letters or digits follow to reduce false positives.

@kulmajaba
kulmajaba / Xpan.jsx
Last active September 8, 2022 10:39
PhotoShop ExtendScript file to Photomerge selected files in pairs using reposition
// Create a file in the path "Adobe Photoshop 2022/Presets/Scripts/Xpan.jsx" and paste the contents there to use
// Xpan Stitcher, author Mika Kuitunen
var runphotomergeFromScript = true; // must be before Photomerge include
//@include "Photomerge.jsx"
//@show include
// DEBUGGING STUFF
function ConsoleLog() {
@kulmajaba
kulmajaba / git_stats_csv.py
Last active April 11, 2022 07:43
Python script for parsing lines changed per commit for a git repository and saving as time-series data in a CSV file
import argparse
import subprocess
import re
import csv
from datetime import datetime
from zoneinfo import ZoneInfo
from enum import Enum
from operator import add
@kulmajaba
kulmajaba / android-screencast
Created February 24, 2021 08:25
Mirroring Android screen to a computer via USB with command line
adb exec-out screenrecord --bit-rate=16m --output-format=h264 --size 1920x1080 - | ffplay -framerate 60 -framedrop -bufsize 16M -
# Or with scrcpy
brew install scrcpy
scrcpy
@kulmajaba
kulmajaba / pltosheets.py
Last active August 6, 2017 19:04
Convert Adobe Prelude subclip markers exported as CSV to a better format.
"""Convert subclip marker CSV file exported from Prelude to a more user-friendly format."""
import argparse
import csv
import platform
# Add your category abbreviations here
CATS = {
'ha': 'Haastis',
'fi': 'Fiilis',