Skip to content

Instantly share code, notes, and snippets.

View Patrikgrinsvall's full-sized avatar

Patrik Grinsvall Patrikgrinsvall

View GitHub Profile
@Patrikgrinsvall
Patrikgrinsvall / composer7.4.sh
Last active April 27, 2021 18:29
Run composer with another PHP version
#!/bin/bash
# place in /usr/bin/composer7.4.sh
php7.4 /usr/bin/composer $@
[{"name":"zxc","color":"Red","position":{"x":294,"y":310},"increment":true,"timestamp":true,"softdelete":false,"column":[{"name":"id","type":"integer","length":"","defaultvalue":"","enumvalue":"","ai":true,"pk":false,"nu":false,"ui":false,"in":false,"un":false,"fillable":false,"guarded":false,"visible":false,"hidden":false,"colid":"c23","order":0},{"name":"asd_id","type":"integer","length":"","defaultvalue":"","enumvalue":"","ai":false,"pk":false,"nu":false,"ui":false,"in":false,"un":false,"fillable":false,"guarded":false,"visible":false,"hidden":false,"colid":"c34","order":1}],"relation":[{"extramethods":"","foreignkeys":"asd_id","name":"asd","relatedmodel":"asd","relationtype":"hasOne","usenamespace":""}],"seeding":[]},{"name":"asd","color":"Red","position":{"x":830,"y":290},"increment":true,"timestamp":true,"softdelete":false,"column":[],"relation":[],"seeding":[]}]
@Patrikgrinsvall
Patrikgrinsvall / windows-symlinks.md
Last active July 4, 2021 01:21
Composer Package - Symlinks on windows

MySQL common solutions to irritating problems

Creating users.

How to create remote root user from bash script.

export MYSQLPASSWORD="-ppassword" # with password to root user, include parameter switch
export MYSQLPASSWORD=""           # without any password set to root user
export NEWUSERPASSWORD=""         # new user password
@Patrikgrinsvall
Patrikgrinsvall / Regexp.md
Last active January 26, 2022 16:37
Regexp search replace patterns

Regexp search replace patterns

In this case using vs code

Simple example, from print "text" To print ("text")

print(.*?)\n

print ($1)
@Patrikgrinsvall
Patrikgrinsvall / BlenderAndVideoTips.md
Last active July 25, 2021 18:33
Blender And Video handy commands

FFMPEG

Image strip to video

Using cuda

When using h264_nvenc dont render in RGB or RGB24 color format since it only supports YUV444. png is rgb so dont follow example, use tiff

  • lossless ffmpeg.exe -framerate 25 -hwaccel cuda -hwaccel_output_format cuda -i 1%04d.png -c:v h264_nvenc -preset 10 grasscar.mp4
  • Lossy, since png with color conversion artifacts (but not bad) ffmpeg.exe -framerate 25 -hwaccel cuda -hwaccel_output_format cuda -i 1%04d.png -c:v h264_nvenc -preset 9 grasscar.mp4
@Patrikgrinsvall
Patrikgrinsvall / safephp
Created August 3, 2021 19:13
php function for http requests without dependencies
$path = "/absolute_path_to_your_files/"; // change the path to fit your websites document structure
$dl_file = preg_replace("([^\w\s\d\-_~,;:\[\]\(\).]|[\.]{2,})", '', $_GET['download_file']); // simple file name validation
$dl_file = filter_var($dl_file, FILTER_SANITIZE_URL); // Remove (more) invalid characters
$fullPath = $path.$dl_file;
if ($fd = fopen ($fullPath, "r")) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);

My current gear

i7-11gen
i7-11gen
i7-11gen
i7-11gen
i7-11gen
i7-11gen

@Patrikgrinsvall
Patrikgrinsvall / Dial_and_scale.py
Created October 10, 2021 18:12 — forked from tin2tin/Dial_and_scale.py
Dial_and_scale.py updated
bl_info = {
"name": "Dial and Scale",
"author": "stacker, sambler",
"version": (1, 2),
"blender": (2, 80, 0),
"location": "3DView > Add > Curve > Dial and Scale",
"description": "Add an array of text number objects or watch dials.",
"warning": "",
"wiki_url": "https://github.com/3dbug/blender/blob/master/DialScale.py",
"tracker_url": "https://github.com/3dbug/blender/issues",
@Patrikgrinsvall
Patrikgrinsvall / All-Loops-In-PHP.md
Last active March 20, 2022 20:34
Code snippets of all ways to loop through something in php.

All PHP Loops

Array iterator

getIterator(); while( $array_iterator->valid() ) { echo $array_iterator->current() . "\n";