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 / 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 / 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"
@AntonioCS
AntonioCS / Makefile
Last active December 17, 2020 14:42
Self documenting makefile template for docker (php)
#Parameters file, comment out if not used (will be needed for Mysql logging)
include parameters.inc.dist
-include parameters.inc
.DEFAULT_GOAL := help
.PHONY: help
compose_file_path = ./docker-compose.yml
dc = docker-compose --file $(compose_file_path)
service_php = php-fpm
service_mysql = mysql
@AntonioCS
AntonioCS / bcmake.bat
Last active November 22, 2020 07:56
Small bat file to create basic project. Will create src/ dir if not present (with dummy code). Will create tests/ folder if not present (with dummy test code). Will create build/ folder (if present with a .sln file ask if you want to delete). Check if there is a CMakeLists.txt and if there isn't create a generic one.
@echo off
@setlocal EnableExtensions EnableDelayedExpansion
:: This batch file will try to generate a minimalist project
:: It will create a src folder with a small cpp file^
:: It will create a test folder with some mock test files for catch2/catch
:: It will also ask if you want to enable testing
:: If a solution already exists (in the build folder) it will ask if you want to remove it and rebuild
:: NOTE: Run this in admin mode if it doesn't work
@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 / 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
;
@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%"