Skip to content

Instantly share code, notes, and snippets.

View LiamKarlMitchell's full-sized avatar

Liam Mitchell LiamKarlMitchell

View GitHub Profile
@unsetbit
unsetbit / Quadtree
Created February 4, 2013 04:37
Near-infinitely scaling quadtree
/* Quadtree by Ozan Turgut (ozanturgut@gmail.com)
A Quadtree is a structure for managing many nodes interacting in space by
organizing them within a tree, where each node contains elements which may
interact with other elements within the node. This is particularly useful in
collision detection, in which a brute-force algorithm requires the checking of
every element against every other element, regardless of their distance in space.
This quadtree handles object in 2d space by their bounding boxes. It splits
a node once it exceeds the object limit per-node. When a node is split, it's
@khigia
khigia / NumericUpDown MouseWheel
Created October 16, 2009 01:57
C# NumericUpDown MouseWheel event
class MyNumericUpDown : NumericUpDown
{
protected override void OnMouseWheel (MouseEventArgs e)
{
// remove scrolllines scaling, taking care of case scrolllines is 0
int delta = e.Delta / Math.Max (Math.Abs (SystemInformation.MouseWheelScrollLines), 1);
base.OnMouseWheel (new MouseEventArgs (e.Button, e.Clicks, e.X, e.Y, delta));
}
}
@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
@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
@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;
}
@jvsidler
jvsidler / gist:4610255
Created January 23, 2013 17:14
List all crontabs for all users on UNIX systems. Must be root. Credit: http://stackoverflow.com/questions/134906/how-do-i-list-all-cron-jobs-for-all-users
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done
@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;
@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>
// --------------------------------------------------------------------------------------------------------------------
@DerMitch
DerMitch / autoreload_supervisor.sh
Created October 31, 2013 15:33
auto-reload supervisord config on changes
#!/bin/sh
# auto-reload supervisor config on a config file change
# Licensed under Public Domain
# apt-get install inotify-tools
while true; do
inotifywait --quiet --recursive --event create,close_write /etc/supervisor/
supervisorctl reread
supervisorctl update
@sindresorhus
sindresorhus / mysql-backup-windows.bat
Created March 14, 2011 14:50
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