Skip to content

Instantly share code, notes, and snippets.

@metaphore
metaphore / SecondOrderDynamics.java
Last active November 4, 2023 13:52
Second order dynamics 2D for Java. Inspired by https://youtu.be/KPoeNZZ6H4s
public class SecondOrderDynamics2D
{
// Dynamic constants.
private float k1, k2, k3;
// Previous dst.
private float pDstX, pDstY;
// State variables.
private float posX, posY;
private float accX, accY;
private float velX, velY;
@metaphore
metaphore / unity
Created January 9, 2023 15:42
Linux script to launch a Unity Editor (installed from Unity Hub) for the specific project.
#!/bin/bash
# Note that the shell option `nullglob` needs to be set. **It is not set by default.**
# It prevents an error in case the glob (or one of multiple globs) does not match any name.
shopt -s nullglob
PROJECT_DIR=$(realpath "$1")
if [ ! -d "$PROJECT_DIR" ]; then
echo "Project directory is not valid: $1" >&2 &&\
@metaphore
metaphore / images.thumbnailer
Last active January 1, 2023 15:56
Gnome | Better image thumbnails
[Thumbnailer Entry]
TryExec=/usr/bin/convert
Exec=/usr/bin/convert -colorspace sRGB %i'[0]' -background transparent -flatten -filter Point -thumbnail %sx%s -gravity center -extent %sx%s png32:%o
MimeType=image/png;image/bmp;image/x-bmp;image/x-MS-bmp;image/gif;image/x-icon;image/x-ico;image/x-win-bitmap;image/vnd.microsoft.icon;application/ico;image/ico;image/icon;text/ico;application/x-navi-animation;image/jpeg;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/tiff;image/x-xpixmap;image/x-xbitmap;image/x-tga;image/x-icns;image/jp2;image/jpeg2000;image/jpx;image/x-quicktime;image/qtif;image/vnd.adobe.photoshop;image/x-photoshop;image/x-psd;application/psd;application/x-psd;image/webp;
@metaphore
metaphore / aseprite-thumbnailer
Last active January 1, 2023 15:59
Gnome | Aseprite thumbnail generator
#!/usr/bin/sh
if [ $# -ge 2 -a $# -lt 4 ]; then
mkdir -p /tmp/Aseprite
filename="$(mktemp -d -p /tmp/Aseprite/).png"
if [ $# -eq 2 ]; then
aseprite -b --frame-range "0,0" $1 --trim --sheet $filename
elif [ $# -eq 3 ]; then
aseprite -b --frame-range "0,0" $1 --shrink-to "$3,$3" --trim --sheet $filename
@metaphore
metaphore / vid_remux_davinci.sh
Created November 2, 2022 17:52
Davinci Resolve Linux video transcode script.
#!/bin/bash
ABS_FILEPATH=$(realpath "$1")
ABS_DIR=$(dirname "$ABS_FILEPATH")
FILENAME=$(basename -- "$1")
EXTENSION="${FILENAME##*.}"
FILENAME="${FILENAME%.*}"
# echo "Filename is $FILENAME and the EXTENSION is $EXTENSION. Dir is $ABS_DIR"
@metaphore
metaphore / .tigrc
Last active July 10, 2022 17:32
My own tigrc with a few nifty perks.
bind status D !@?rm -r %(file)
bind status P !git push origin
bind status A !git add .
bind stage 1 stage-update-line
set blame-view = id:yes,color file-name:no author:abbreviated date:relative-compact line-number:yes,interval=1 text
set main-view = line-number:no,interval=5 id:no date:relative-compact author:abbreviated commit-title:yes,graph,refs,overflow=no
set tree-view = line-number:no,interval=5 mode author:abbreviated file-size date:relative-compact id:no file-name
@metaphore
metaphore / gdxtp-downloads.html
Last active October 16, 2021 17:43
Chrome bookmarklet to display latest release download count for https://github.com/crashinvaders/gdx-texture-packer-gui project.
data:text/html,<script>
fetch('https://api.github.com/repos/crashinvaders/gdx-texture-packer-gui/releases').then(response => {
response.text().then(responseText => {
let parsedResponse = JSON.parse(responseText);
let content = parsedResponse[0].assets.map(asset => ({
file: asset.name,
downloads: asset.download_count
}));
let htmlContent = JSON.stringify(content, null, 4);
alert(htmlContent);
@metaphore
metaphore / HqnxEffect.java
Last active September 7, 2023 10:05
[libGDX] HQX (HQ2X, HQ3X, HQ4X) upscaling filter implementation (Java and Kotlin) using GLSL shaders.
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.GdxRuntimeException;
/**
@metaphore
metaphore / PhotoshopToSpine.jsx
Last active February 11, 2020 09:22
EsotericSoftware Spine photoshop export script with parallax layers.
#target photoshop
app.bringToFront();
// This script exports Adobe Photoshop layers as individual PNGs. It also
// writes a JSON file which can be imported into Spine where the images
// will be displayed in the same positions and draw order.
// Copyright (c) 2012-2017, Esoteric Software
// All rights reserved.
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@metaphore
metaphore / PhotoshopToSpine.jsx
Created October 22, 2019 06:01
EsotericSoftware Spine photoshop export script with parallax layers.
#target photoshop
app.bringToFront();
// This script exports Adobe Photoshop layers as individual PNGs. It also
// writes a JSON file which can be imported into Spine where the images
// will be displayed in the same positions and draw order.
// Copyright (c) 2012-2017, Esoteric Software
// All rights reserved.
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: