Skip to content

Instantly share code, notes, and snippets.

View LiamKarlMitchell's full-sized avatar

Liam Mitchell LiamKarlMitchell

View GitHub Profile
@ZeroGodForce
ZeroGodForce / HasUuid.php
Last active April 17, 2024 06:30
HasUuid Trait for Laravel
<?php
namespace App\Traits;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\App;
trait HasUuid
{
/**
@LiamKarlMitchell
LiamKarlMitchell / AsyncSingleInstance.js
Last active October 12, 2018 03:27
Javascript Async Patterns
// Given an Async Function (Not a promise) this class will ensure that the run method can only run 1 instance of that async operation at a time.
class AsyncSingleInstance {
// Soon we will have private fields? https://github.com/tc39/proposal-class-fields#private-fields
//#inProgress;
//#asyncFunction;
constructor(asyncFunction) {
this.inProgress = false;
this.asyncFunction = asyncFunction;
}
@LiamKarlMitchell
LiamKarlMitchell / MySQL Automated Backup Guide.md
Last active September 19, 2018 21:33
MySQL Backup and restore instructions

In the home directory make a .my.cnf file

touch ~/.my.cnf

Ensure it has your login details.

[mysqldump]
user=yourdbusername
password=yourdbpassword
@JohannesDeml
JohannesDeml / SceneViewFocusChangerWindow.cs
Last active January 20, 2020 08:53
Unity scene view focus changer
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SceneViewFocusChangerWindow.cs" company="Supyrb">
// Copyright (c) 2018 Supyrb. All rights reserved.
// </copyright>
// <author>
// Johannes Deml
// send@johannesdeml.com
// </author>
// --------------------------------------------------------------------------------------------------------------------
@LiamKarlMitchell
LiamKarlMitchell / HideVirtualBox.bat
Created February 3, 2018 12:11
Hide Virtual Machine.
@echo off
@reg copy HKLM\HARDWARE\ACPI\DSDT\VBOX__ HKLM\HARDWARE\ACPI\DSDT\NOBOX__ /s /f
@reg delete HKLM\HARDWARE\ACPI\DSDT\VBOX__ /f
@reg add HKLM\HARDWARE\DESCRIPTION\System /v SystemBiosVersion /t REG_MULTI_SZ /d "NOBOX - 1" /f
@reg add HKLM\HARDWARE\DESCRIPTION\System /v VideoBiosVersion /t REG_MULTI_SZ /d "NOBOX - 1" /f
@taskkill /f /im VBoxTray.exe
@exit
@LiamKarlMitchell
LiamKarlMitchell / downloadFile.js
Last active September 3, 2019 10:34
node.js download file outputs progress and does not re-download already downloaded file.
var fs = require('fs');
var http = require('http');
var forceredownload = false;
function downloadFile(url, file, callback, redirect_count, known_size) {
console.log('Attempting to download ' + url + ' to ' + file);
if (redirect_count) {
if (redirect_count > 5) {
callback('Max redirects reached', url);
return;
@fazlurr
fazlurr / noCache.js
Created August 1, 2016 04:31
No cache in Node.js Server - http://stackoverflow.com/a/30453242
// var app = express()
app.use(function (req, res, next) {
res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
res.header('Expires', '-1');
res.header('Pragma', 'no-cache');
next()
});
@petenelson
petenelson / wordpress-list-users.sql
Created May 3, 2016 18:00
WordPress: MySQL query to list user names, emails, and first & last name
SELECT wp_users.user_login, wp_users.user_email, firstmeta.meta_value as first_name, lastmeta.meta_value as last_name FROM wp_users left join wp_usermeta as firstmeta on wp_users.ID = firstmeta.user_id and firstmeta.meta_key = 'first_name' left join wp_usermeta as lastmeta on wp_users.ID = lastmeta.user_id and lastmeta.meta_key = 'last_name'
@shanebp
shanebp / bp-profile-tab-and-subnav.php
Last active June 28, 2023 18:11
BuddyPress add profile tab and subnav
function add_animal_tabs() {
global $bp;
bp_core_new_nav_item( array(
'name' => 'Animals',
'slug' => 'animals',
'parent_url' => $bp->displayed_user->domain,
'parent_slug' => $bp->profile->slug,
'screen_function' => 'animals_screen',
'position' => 200,
@haio
haio / Delete all queues in RabbitMQ
Created November 28, 2013 10:40
Delete all queues in RabbitMQ
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app