Skip to content

Instantly share code, notes, and snippets.

View tobiasfabian's full-sized avatar

Tobias Wolf tobiasfabian

View GitHub Profile
@tobiasfabian
tobiasfabian / BookmarkPage.php
Last active March 17, 2024 18:45
Kirby bookmark
<?php
use Kirby\Http\Remote;
use Kirby\Cms\File;
use Kirby\Cms\Page;
use Kirby\Filesystem\F;
use Kirby\Filesystem\Mime;
use Kirby\Toolkit\Dom;
use Kirby\Toolkit\Str;
use Kirby\Toolkit\V;
@tobiasfabian
tobiasfabian / bash
Created April 26, 2023 09:40
Update composer dependencies with a specific php version (Homebrew)
/opt/homebrew/opt/php@8.0/bin/php $(which composer) update
@tobiasfabian
tobiasfabian / optimize-images
Created November 17, 2022 11:07
Optimize images with squoosh cli
cd ../content/; find . -name "*.png" -exec bash -c 'file="{}"; cd "$(dirname "$file")"; npx @squoosh/cli \
--oxipng '{"quality":90}' \
$(basename $file)' \
cd ../content/; find . -name "*.jpg" -exec bash -c 'file="{}"; cd "$(dirname "$file")"; npx @squoosh/cli \
--mozjpeg '{"quality":90}' \
$(basename $file)' \;
const svgPolygon = '12.034 19.674 10.634 18.28 14.309 14.61 2.125 14.61 2.125 12.572 14.309 12.572 10.634 8.897 12.034 7.508 18.117 13.591';
const viewBoxWidth = 25;
const viewBoxHeight = 25;
const array = [...svgPolygon.matchAll(/[\d.]+/g)];
let output = '';
array.forEach((item, key) => {
if (key % 2 === 0) {
output += `${(Math.round(((item / viewBoxWidth) * 100) * 1000)) / 1000}% `;
} else {
output += `${(Math.round(((item / viewBoxHeight) * 100) * 1000)) / 1000}%`;
@tobiasfabian
tobiasfabian / Yaml.php
Created January 3, 2019 11:04
Kirby Yaml Class with Symfony’s Yaml Component
<?php
namespace Kirby\Data;
use Exception;
use Spyc;
use \Symfony\Component\Yaml\Yaml as SymfonyYaml;
function array_map_recursive(callable $func, array $array) {
return filter_var($array, \FILTER_CALLBACK, ['options' => $func]);
@tobiasfabian
tobiasfabian / ce_image.css
Last active January 11, 2017 15:50 — forked from lucasdidthis/ce_image.css
Prevent Content-Shifting in Contao with automated proportion-calc (CSS)
figure > span:first-child{
display: block;
}
figure > span:first-child + img{
display: block;
transform: translateY(-100%);
}
@tobiasfabian
tobiasfabian / Panel Text
Last active October 2, 2015 14:21
kirbytext: email with subject
(email: name@domain.com subject: reserve tickets)
@tobiasfabian
tobiasfabian / drawing usb serial data
Last active August 29, 2015 14:11
Hands on EKG/EMG-Shield
import processing.serial.*;
Serial myPort;
int x = 0;
void setup() {
size(1200, 400);
println(Serial.list()); //list of available serial ports
String portName = Serial.list()[3]; //replace 0 with whatever port you want to use.
println(portName);