Skip to content

Instantly share code, notes, and snippets.

View vielhuber's full-sized avatar
🍐
❹❷

David Vielhuber vielhuber

🍐
❹❷
View GitHub Profile
@vielhuber
vielhuber / index.html
Last active January 17, 2024 12:12
confetti success animation #js
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5, minimum-scale=1" />
<title>.</title>
<script>
class Confetti {
constructor() {
this.confettiConfig = {
@vielhuber
vielhuber / index.php
Last active January 13, 2024 17:10
ical ics download #php
// composer require eluceo/ical
require_once(__DIR__ . '/vendor/autoload.php');
$date_begin = '2023-01-01 20:00:00';
$date_end = '2023-01-01 21:00:00';
$d = new \DateTime($date_end, new \DateTimeZone('Europe/Berlin'));
$d->setTimeZone(new \DateTimeZone('UTC'));
$date_begin = $d->format('Y-m-d H:i:s');
@vielhuber
vielhuber / 0.readme.md
Last active January 11, 2024 12:37
lottie lottiefiles animations dotlottie
@vielhuber
vielhuber / index.php
Last active January 4, 2024 16:54
logo headline h1 only on front page #html #php
<div class="logo">
<?= is_front_page() ? '<h1 class="logo__headline">' : '' ?>
<a class="logo__link" href="index.php">
<span class="logo__text" style="position:absolute;width:1px;height:1px;overflow:hidden;">h1 der Startseite</span>
<img class="logo__image" src="logo.svg" alt="h1 der Startseite">
</a>
<?= is_front_page() ? '</h1>' : '' ?>
</div>
<?= !is_front_page() ? '
@vielhuber
vielhuber / README.MD
Last active November 5, 2023 06:37
fix corrupt filenames natively or with detox #tools #linux

native search/replace of corrupt �

installation

  • sudo apt-get install rename perl libunicode-map8-perl

corrupt question marks

  • find . -exec rename 's/�/x/g' "{}" \;

corrupt umlauts

  • find ./ -type f -print0 | rename -v -0 'BEGIN { use Unicode::Map8; our $l1_map = Unicode::Map8-&gt;new("latin1") }; our $l1_map; $_ = $l1_map-&gt;tou($_)-&gt;utf8'
@vielhuber
vielhuber / script.php
Created November 3, 2023 14:49
get all laravel cached items by key (with redis enabled) #php #laravel
dd( \Illuminate\Support\Facades\Redis::connection('default')->keys('*') );
@vielhuber
vielhuber / script.sql
Created October 20, 2023 14:49
indexes #postgres
--SELECT to_tsquery('german', 'The & Fat & Rats');
--DROP INDEX IF EXISTS jo;
--DROP TABLE IF EXISTS foo;
CREATE TABLE IF EXISTS foo (
bar text,
baz text
);
@vielhuber
vielhuber / script.sh
Created October 13, 2023 11:02
send mail alert on quota #linux #server
#!/bin/bash
CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=80
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
mail -s 'Project XY: Disk Space Alert' email1@tld.com, email2@tld.com, email3@tld.com << EOF
Your root partition remaining free space is critically low. Used: $CURRENT%
EOF
fi
@vielhuber
vielhuber / index.js
Created October 8, 2023 09:41
destructuring spread arrays/objects in for loop #js
let arr = [['foo','bar'],['bar','baz']];
for(let [arr__value_1,arr__value_2] of arr) { console.log([val_a,val_b]); }
// ['foo','bar'], ['bar','baz']
@vielhuber
vielhuber / index.php
Created September 20, 2023 11:32
stream output pdf directly to browser #php
<?php
$file_abspath = '/foo/bar/baz.pdf';
$file_pseudoname = 'bazzz.pdf';
$content = file_get_contents($file_abspath);
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="' . $file_pseudoname . '"');
header('Content-Length: ' . strlen($file_abspath));
header('Cache-Control: private, max-age=0, must-revalidate');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');