Skip to content

Instantly share code, notes, and snippets.

View vielhuber's full-sized avatar
🍐
❹❷

David Vielhuber vielhuber

🍐
❹❷
View GitHub Profile
@vielhuber
vielhuber / ..MD
Last active May 25, 2025 17:16
reveal.js markdown presentation #js

init

  • mkdir test
  • cd test
  • git clone git@github.com:vielhuber/test.git . # clone empty repository
  • create .gitignore, README.MD, index.html, index.md
  • follow README.MD

start

  • cd test
@vielhuber
vielhuber / style.css
Last active July 30, 2025 15:37
view transition smooth animated site transitions #css
@view-transition {
navigation: auto;
}
@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes fade-out {
@vielhuber
vielhuber / style.css
Created May 8, 2025 12:43
100% height on ios hidden elements svh lvh #css
div {
height:100svh; /* fixed, no jumps */
margin-bottom: calc(100lvh - 100svh); /* nice margin below, if nav is hidden */
}
@vielhuber
vielhuber / script.php
Created May 6, 2025 16:28
lock files prevent multiple duplicate script execution #php
<?php
$lock = fopen(sys_get_temp_dir() . '/' . md5(__FILE__) . '.lock', 'c');
if (!flock($lock, LOCK_EX | LOCK_NB)) {
echo 'current script already running...';
die();
}
echo 'script running...';
sleep(10);
@vielhuber
vielhuber / README.MD
Last active September 23, 2025 08:08
basics #python

virtual environments

setup

  • python -m venv venv

activate

  • source venv/bin/activate

deactivate

  • deactivate
@vielhuber
vielhuber / script.php
Created April 4, 2025 10:47
WP_REST_Response response immediately from inner function and die #wordpress
<?php
final class Test {
public function init() {
register_rest_route('v1', '/...', [
/* ... */
'callback' => function () {
// basic way
return new \WP_REST_Response([], 200);
// usage in inner functions
$this->fun1();
@vielhuber
vielhuber / README.MD
Last active April 1, 2025 13:44
gzip #php #server

enable in apache/php

  • this is done by default
  • check via cat /etc/apache2/mods-available/deflate.conf

enable in iis

  • Windows-Features aktivieren/deaktivieren
  • Webserver (IIS) > Webserver > Leistung > Komprimieren dynamischer Inhalte
  • IIS > nebro > Komprimierung > 2 Haken setzen
@vielhuber
vielhuber / .README.MD
Last active March 14, 2025 11:56
whatsapp js web api #js
  • node --version // >= 23
  • npm init -y
  • npm install whatsapp-web.js
  • npm install qrcode-terminal
  • node --no-deprecation script.js
@vielhuber
vielhuber / .htaccess
Last active October 24, 2025 07:16
echo output immediately in browser output buffering #php
<IfModule mod_deflate.c>
SetEnv no-gzip 1
</IfModule>
@vielhuber
vielhuber / final.py
Last active September 18, 2025 12:40
build llm from scratch #python #ai
import tiktoken
import torch
import torch.nn as nn
import urllib.request
import re
from torch.utils.data import Dataset, DataLoader
import numpy as np
import zipfile
import os
from pathlib import Path