Skip to content

Instantly share code, notes, and snippets.

@AntonioCS
AntonioCS / HasEntityManager.php
Created January 10, 2022 14:56
A trait for symfony to simplify adding the EntityManager to a class
<?php
declare(strict_types=1);
namespace App\Traits;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ObjectRepository;
trait HasEntityManager
{
@AntonioCS
AntonioCS / mariadb_uuid_v4.sql
Created September 22, 2021 13:22
Functions for MariaDB to be able to convert to and from uuid v4 which is normally stored as BINARY(16)
DROP FUNCTION IF EXISTS uuid_v4;
DROP FUNCTION IF EXISTS BIN_TO_UUID;
DROP FUNCTION IF EXISTS UUID_TO_BIN;
-- Change delimiter so that the function body doesn't end the function declaration
DELIMITER //
CREATE FUNCTION uuid_v4()
RETURNS CHAR(36) NO SQL
BEGIN
@AntonioCS
AntonioCS / gist:83bccc7f6ecace2c3f3bcc4b9369d2ee
Last active February 11, 2021 12:37
Useful git alias for .bashrc
alias ga="git add"
alias gs="git status"
alias gc="git checkout"
alias gcb="git checkout -b"
alias gb="git branch"
alias gp="git pull"
alias gd="git diff"
alias gcom="git commit"
@echo off
REM Run this in Developer Command Prompt
REM https://docs.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-alphabetically?view=msvc-160
set file=%1
cl %file% /std:c++17 /EHsc
@AntonioCS
AntonioCS / backup_darksouls3.bat
Created November 14, 2020 00:00
Create a backup of the DS3 save file in the format DS30000.sl2_YEAR-MONTH-DAY_(hh-mm-ss)
@echo off
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set DateTime=%%a
set Yr=%DateTime:~0,4%
set Mon=%DateTime:~4,2%
set Day=%DateTime:~6,2%
set Hr=%DateTime:~8,2%
set Min=%DateTime:~10,2%
set Sec=%DateTime:~12,2%
@AntonioCS
AntonioCS / ds3_load_sl_133_backup_and_run_game.bat
Created November 13, 2020 23:53
A basic bat to load a Dark Souls 3 save file and then run DarkSouls 3
@echo off
set DS3_MAIN_PROGRAM=C:\\Program Files (x86)\\Steam\\steamapps\\common\\DARK SOULS III\\Game\\DarkSoulsIII.exe
set DS3_save_dir=%appdata%\DarkSoulsIII\\<YOUR_STEAM_ID>
set DS3_backups_dir=<DIRECTORY_OF_THE_SAVE_FILE>
set DS3_original_filename=DS30000.sl2
set DS3_backup_filename=<NAME_OF_BACKUP_FILE_TO_LOAD_NAME>
copy "%DS3_backups_dir%\\%DS3_backup_filename%" "%DS3_save_dir%\\%DS3_original_filename%"
@AntonioCS
AntonioCS / install_docker_and_docker_compose_linux.sh
Last active November 16, 2021 13:54
Install docker and docker-compose on linux host
#!/bin/bash
#RUN THIS SCRIPT AS ROOT
#https://docs.docker.com/engine/install/ubuntu/
apt-get remove docker docker-engine docker.io containerd runc
apt-get update
apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
@AntonioCS
AntonioCS / parameters.inc.dist
Created November 9, 2020 23:28
This is to be used in the Makefile
###### DO NOT EDIT THIS FILE
###### Use "make params" to create parameters.inc and do the changes there.
###### If you want to simply add something just do: var_name += new_data
###### Or if you want to overwrite you can just do: var_name = data
#Mysql data for logging
mysql_user=
#Only put the password in dev environment (if there is no password it will be asked)
mysql_pass=
mysql_log_file=//application/mysql_query.log
@AntonioCS
AntonioCS / create_table
Created November 5, 2020 14:25
Basic create table
CREATE TABLE `<table_name>` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`is_deleted` TINYINT(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
;
inotifywait -m -r /myfolder -e create -e moved_to -e modify -e delete |
while read path action file; do
echo "The file '$file' appeared in directory '$path' via '$action'"
done