Skip to content

Instantly share code, notes, and snippets.

View vielhuber's full-sized avatar
🍐
❹❷

David Vielhuber vielhuber

🍐
❹❷
View GitHub Profile
@vielhuber
vielhuber / script.php
Last active November 15, 2024 16:07
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"]
}
@vielhuber
vielhuber / README.MD
Last active September 24, 2024 09:23
phpstan basics #php #laravel

installation

plain

composer require --dev phpstan/phpstan

phpstan.neon:

@vielhuber
vielhuber / !README.MD
Last active September 18, 2024 10:24
git: auto commit messages #git
modify git message
install
  • mkdir -p ~/git-template/hooks
  • nano ~/git-template/hooks/prepare-commit-msg
  • chmod +x ~/git-template/hooks/prepare-commit-msg
  • git config --global core.hooksPath ~/git-template/hooks
uninstall
  • git config --global --unset core.hooksPath
@vielhuber
vielhuber / !README.MD
Last active October 21, 2024 10:58
jobs queues #laravel

on every code change, don't forget to restart

  • php artisan queue:restart

production (normally used with supervisor)

  • php artisan queue:work --sleep=3 --tries=1 --memory=768 --timeout=10800

test queue locally

  • php artisan queue:work --env=production --sleep=3 --tries=1 --memory=768 --timeout=3600
  • php artisan queue:listen --env=production --sleep=3 --tries=1 --memory=768 --timeout=3600 # does not need restarts, but is less more efficient
@vielhuber
vielhuber / README.MD
Last active November 15, 2024 16:22
clean code best practices #php #laravel

prevent static classes

// bad
Example::calculate($obj)
  
// good
(new Example($obj))->calculate()