Skip to content

Instantly share code, notes, and snippets.

View joram77's full-sized avatar

Joram Declerck joram77

View GitHub Profile
# Powershell script to split large sql files to separate sql files per table - joram77
$inputFile = "c:\users\money\dumps\db_slimmed.sql"
$fileInfo = New-Object System.IO.FileInfo($inputFile)
$newDir = $fileInfo.Directory.ToString() + '\' + $fileInfo.BaseName.ToString()
New-Item -ItemType Directory -Force -Path $newDir
$outputFile = "$newDir\db_slimmed_start.sql"
$reader = New-Object System.IO.StreamReader($inputFile)
$count = 0
docker cp ./.ssh/id_ed25519 container-name:/root/.ssh/id_rsa ; docker exec container-name bash -c "chmod 700 /root/.ssh/id_rsa"
# B from C fromdomain D frompath E statuscode F to G rewriterule(formula below)
="if ($host = """&C8&""") { rewrite ^"&REGEXREPLACE(regexreplace(B8,"(.+)\?(.*)","$1"),"^(https://|http://)([^/]+)(.+)","$3")& "$ "& F8 &"? permanent; }"
# C fromdomain (formula below)
=index(split(B3,"/"),0,2)
sudo badblocks -sv /dev/sda > bad-blocks-result
sudo fsck -t ext4 -l bad-blocks-result /dev/sda1
----
sudo add-apt-repository universe
sudo apt-get install hfsprogs hfsplus
sudo fsck.hfsplus /dev/sda2
@joram77
joram77 / Makefile
Last active December 6, 2022 09:50
Xdebug makefile to quickly turn off and on xdebug extension in PHP-fpm container and reload service
DOCKER_CP_XDEBUG_ON=docker cp docker/php-fpm/docker-php-ext-xdebug-on.ini php-fpm_1:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
DOCKER_CP_XDEBUG_OFF=docker cp docker/php-fpm/docker-php-ext-xdebug.ini php-fpm_1:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
.PHONY: about xdebug-on xdebug-off
about:
echo "Xdebug Makefile https://github.com/joram77 - Joram Declerck"
echo "- Install: copy contents to Makefile in your project"
echo "- Usage: make xdebug-on or make xdebug-off"
%div.button
= render layout: 'folder/link_layout', locals: {link: link} do
= button_contents_variable
#folder/_link_layout.html.haml contents:
%a{href: link}
= yield # contents of button_contents_variable will be nested in the %a tag
# inspired by https://stackoverflow.com/questions/35933558/unexpected-error-using-yield-in-haml-nesting
zend_extension=xdebug
[xdebug]
xdebug.mode=debug # develop has impact on performance
xdebug.client_port = 9000
xdebug.idekey=PHPSTORM
xdebug.client_host=host.docker.internal
SELECT * FROM information_schema.tables
select schema_name as database_name from information_schema.schemata order by schema_name;
# copy current dir
cp -rv . ~/backup/$(basename "$PWD").bak.$(date '+%Y-%m-%d_%H-%M-%S')
# or tar current dir
tar -cvzf ~/backup/$(basename "$PWD").bak.$(date '+%Y-%m-%d_%H-%M-%S').tar.gz .
# tar current dir and exclude dot dirs/files in root to tar
tar --exclude="./.*" -cvzf /tmp/backup/$(basename "$PWD").bak.$(date '+%Y-%m-%d_%H-%M-%S').tar.gz .