Skip to content

Instantly share code, notes, and snippets.

View LiamKarlMitchell's full-sized avatar

Liam Mitchell LiamKarlMitchell

View GitHub Profile
// Another thing I made ages ago feel free to use :)
// licensed under MIT / Public / do whatever.
#ifndef __MUTEX_H
#define __MUTEX_H
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// I license this as MIT do whatever you want with it basically.
// I can't be assed including the header you know what it is.
// If you don't want Mutex.h comment it out, check out my other gists for it if you need it.
#ifndef __CLOG_H
#define __CLOG_H
#include "Mutex.h"
#include <fstream>
// Sometimes when using Send and Recv API it will not send or recv all the data. You will notice your socket might have an error and gets disconnected.
// Such as the other end wont be able to recv the entire packet correctly or something. The bytes that were not sent are never sent.
// This is horrible of course, I did not read the fine print and just expected it to work -_- (okay I guess an error could happen half way through sending or receiving some data and thats why it works this way.
// Email: [email protected]
// License: MIT - do whatever you want with this code.
// Borrowed from UNIX Network Programming: Sockets Introduction
// By Andrew M. Rudoff, Bill Fenner, W. Richard Stevens Feb 27, 2004
// http://www.informit.com/articles/article.aspx?p=169505&seqNum=9
@LiamKarlMitchell
LiamKarlMitchell / ToggleRows.js
Created August 22, 2015 23:31
Google sheets toggle, hide, show rows.
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name: "Toggle Rows",
functionName: "toggleRows"
},{
name: "Hide Rows",
functionName: "hideRows"
},{
name: "Show Rows",
// Dump a bunch of things into it, it will queue them up and either send them when the queue is full or add more.
// Using some to call the callback function for the queued things.
// If you want you could view the array, process just the first or last thing and return true to break
// then no further execution would be done.
// Callback should expect value, index, array as arguments
function GroupOverTimeThenCall(callback, options) {
if (!(callback instanceof Function)) {
throw new Error('GroupOverTimeThenCall expects callback to be a function.');
}
@LiamKarlMitchell
LiamKarlMitchell / Quad-Tree-Implementation---Including-AI.markdown
Created February 27, 2015 23:05
Quad Tree Implementation - Including AI

Quad Tree Implementation - Including AI

We needed a Quad Tree to handle spartial positioning in our MMORPG server over at github.com/LiamKarlMitchell/InfiniteSky

So this was born. I have been wanting to implement it for a while anyway.

Using Pixi.js for rendering it so I can see what is going on.

Add a few moving objects by using the button or click in the quad area to add static ones.

@LiamKarlMitchell
LiamKarlMitchell / Clone keys of an object
Created December 11, 2014 22:13
Copies the keys from passed in object and returns a new object that references all the same kerys.
function Clone(o) {
var n = {};
for (var a in o) {
if (o.hasOwnProperty(a)) {
n[a] = o[a];
}
}
return n;
}