Skip to content

Instantly share code, notes, and snippets.

View LiamKarlMitchell's full-sized avatar

Liam Mitchell LiamKarlMitchell

View GitHub Profile
@LiamKarlMitchell
LiamKarlMitchell / Find log files.md
Created November 7, 2018 20:47
Find the appropriate log files

Find log files modified in last 5 min.

find / -cmin -5 -type f -name "*.log"

For example I used this to find the Akeneo daemon log so I could tail it for debugging.

tail -100f /var/log/akeneo_daemon.err.log
@LiamKarlMitchell
LiamKarlMitchell / refcontainer.php
Created March 1, 2019 06:20
Dumps container, referenceContainer, block and referenceBlock names and locations from Magento2 site.
<?php
$instructions = array("container", "referenceContainer", "block", "referenceBlock");
foreach ($instructions as $instruction) {
$containers = array();
$fp = fopen('debug_'.$instruction.'.txt', 'w');
$command = 'egrep -r -i --include \*.xml "<'.$instruction.'".*?"name=" *';
exec($command, $output);
@LiamKarlMitchell
LiamKarlMitchell / json-file.php
Last active April 2, 2019 22:20
Load data from and save it to a JSON file on php shutdown exit close.
<?php
namespace LiamKarlMitchell\File;
class JSONFile
{
public $filename;
private $data = array();
public function __construct($filename, $defaults = array())
{
$this->filename = $filename;
@LiamKarlMitchell
LiamKarlMitchell / shell.bat
Created May 10, 2019 13:34
Set location to current directory set path enviroment variable and start a shell Windows PowerShell if available otherwise cmd Command Prompt is used.
@echo off
cd /D "%~dp0"
title Your - Shell
set PATH="%~dp0Your\bin";%PATH%
REM Start powershell if available otherwise use cmd.
for %%i in (powershell.exe) do if "%%~$path:i"=="" (cmd) else start powershell -NoLogo -NoExit -Command "& { $env:Path = \"%PATH%\" }"
@LiamKarlMitchell
LiamKarlMitchell / Changes.md
Created September 11, 2019 23:57
Fix vTiger on mysql that requires set options.

You can change the mysql config to apply the set options.

sql_mode = 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

However this is not always desireable on shared hosting you don't know the follow on effects.

So far, I've found I can simply set this in the installer and the db connection class.

include/database/PearDatabase.php

@LiamKarlMitchell
LiamKarlMitchell / PearDatabase-fix.php
Last active September 30, 2019 00:54
Fix vtiger not able to save field changes.
<?php
if ($this->dbType === 'mysql' || $this->dbType === 'mysqli') {
$this->database->Execute("SET SESSION sql_mode = 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'");
}
// Either in the mysql config or if you don't want to touch it there you can edit the include/database/PearDatabase.php and put that statement at the bottom of the function connect.
// And for setup
// Edit the
@LiamKarlMitchell
LiamKarlMitchell / capitalize.js
Last active October 4, 2019 05:13
Capitalize peoples names jQuery snippet.
// Scenario:
// Users enter name in all lowercase or all uppercase it fixes the case.
// This isn't 100% suitable for all names but eh whatever!
// Attempts to resepect intentional ' and " and intentional multiple case.
$.fn.capitalize = function() {
$(this).blur(function(event) {
var box = event.target;
var txt = $(this).val();
var lc = txt.toLocaleLowerCase();
#!/bin/bash
SENDGRID_API_KEY="SG.YOUR_SENDGRID_API_KEY_HERE"
EMAIL_TO="[email protected]"
FROM_EMAIL="[email protected]"
FROM_NAME="SomeServer"
SUBJECT="Low Disk Space Email"
bodyHTML="<p>Testing sending email using sendgrid from sh.</p>"
maildata='{"personalizations": [{"to": [{"email": "'${EMAIL_TO}'"}]}],"cc":[{"email": "[email protected]"}],"from": {"email": "'${FROM_EMAIL}'",
@LiamKarlMitchell
LiamKarlMitchell / mysql-backup-windows.bat
Created November 17, 2019 04:04 — forked from sindresorhus/mysql-backup-windows.bat
Backup MySQL databases in separate gzipped sql files on Windows
@echo off
set dbUser=root
set dbPassword=password
set backupDir="C:\Documents and Settings\user\Desktop\backup\mysql"
set mysqldump="C:\Program Files\MySQL\MySQL Workbench 5.2 CE\mysqldump.exe"
set mysqlDataDir="C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.1\data"
set zip="C:\Program Files\7-Zip\7z.exe"
:: get date
@LiamKarlMitchell
LiamKarlMitchell / leagueoflegendsminionsai.md
Last active June 11, 2020 08:25
League of Legends interesting things.

Archived from http://web.archive.org/web/20200308182225/https://boards.na.leagueoflegends.com/en/c/developer-corner/qRHotV9k-minion-ai-rules-documentation and converted to markdown/niceness to read.

Found archived topic on here: https://www.reddit.com/r/summonerschool/comments/99d6my/riot_minion_ai_behavior_documentation/

Hello! I’m Riot Reinboom and I’m here to drop some Sweet minion AI game documentation on you all.

What? We’re sharing our understanding of how a bunch of weird behaviors of how lane minions work internally and figured it would be informative for you all as well.

So, documentation. Exciting stuff.