Skip to content

Instantly share code, notes, and snippets.

View vielhuber's full-sized avatar
🍐
❹❷

David Vielhuber vielhuber

🍐
❹❷
View GitHub Profile
@vielhuber
vielhuber / script.js
Created November 29, 2024 14:08
console console.log overwrite #js
// overwrite
let console_backup = console;
console = {
log: msg => {},
info: msg => {},
warn: msg => {
// only show specific errors
if (msg !== 'hide this specific warning') {
console_backup.warn(e);
}
@vielhuber
vielhuber / README.MD
Last active November 28, 2024 12:26
crop resize scale pdf #tools #linux

crop

#!/usr/bin/env bash

# set this to point values (1pt = 25.4 mm)
cropLeft=0
cropRight=298
cropTop=421
cropBottom=0
@vielhuber
vielhuber / script.php
Last active November 25, 2024 13:12
output utc datetime in local time timezone #php
$date_in_utc = '2024-01-01 12:00:00';
// this both outputs "2024-01-01 13:00:00"
date('Y-m-d H:i:s', strtotime($date_in_utc . ' UTC'));
(new \DateTime($date_in_utc, new \DateTimeZone('UTC')))->setTimezone(new \DateTimeZone(date_default_timezone_get()))->format('Y-m-d H:i:s'));
Carbon::createFromFormat('Y-m-d H:i:s', $date_in_utc, 'UTC')->setTimezone(date_default_timezone_get())->toDateTimeString();
@vielhuber
vielhuber / script.php
Last active November 24, 2024 10:19
date 32-bit 64-bit overflow DateTime 2038 #php
// 32-bit
if (PHP_INT_SIZE == 4) {
echo date('Y-m-d',strtotime('2040-01-10T16:41:07+01:00'));
}
// 64-bit
if (PHP_INT_SIZE == 8) {
echo (new \DateTime('2040-01-10T16:41:07+01:00'))->format('Y-m-d');
}
@vielhuber
vielhuber / script.php
Last active November 25, 2024 13:10
carbon laravel date time #php #laravel
use Illuminate\Support\Carbon;
// create
Carbon::now();
Carbon::yesterday();
Carbon::today();
Carbon::now();
Carbon::now('Europe/London');
Carbon::tomorrow();
Carbon::createFromDate($year, $month, $day, $tz);
@vielhuber
vielhuber / README.MD
Last active October 29, 2024 12:38
tesseract ocr text recognition #server

show installed languages

tesseract --list-langs

input.jpg > output.txt

tesseract input.jpg output -l deu
@vielhuber
vielhuber / README.MD
Created October 21, 2024 20:30
EXPLAIN ANALYZE #sql
@vielhuber
vielhuber / README.MD
Last active October 16, 2024 09:52
query builder and or where #laravel
SELECT *
FROM table
WHERE
    col1 = 'foo'
    AND
    col2 = 'foo'
    AND (
      col3 = 'foo'
      OR
@vielhuber
vielhuber / launch.json
Last active October 21, 2024 09:56
xdebug launch.json wordpress laravel #php
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"ignore": ["**/vendor/**/*.php"]
}