Skip to content

Instantly share code, notes, and snippets.

var bacon = (function () {
var bacon = {},
defaultBase = 2;
function getEncodedWidth(alphabet, base) {
var width = 1 + Math.floor(Math.log(alphabet.length) / Math.log(base));
return width;
}
function hasIndex(array, index) {
return array.splice(index, 1).reduce(function () {
return true;
}, false);
}
var array = [];
hasIndex(array, 0); // => false
array[0] = 1;
@vermie
vermie / gist:9818c441d261ccf6219a
Created August 15, 2014 17:35
create worker form <script> blob url
function makeWorker(fn, args, callback) {
var fnString = 'self.addEventListener("message", function (e) {self.postMessage((' + fn.toString() + ').apply(this, e.data))});',
blob = new Blob([fnString], { type: 'text/javascript' }),
url = URL.createObjectURL(blob),
worker = new Worker(url);
worker.postMessage(args);
worker.addEventListener('message', function (e) {
URL.revokeObjectURL(url);
callback(e.data);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
namespace Expressions
{
public static class Coalesce
{
@vermie
vermie / gist:3021844
Created June 30, 2012 02:17
linear spline offset
diff --git a/src/game/movement/packet_builder.cpp b/src/game/movement/packet_builder.cpp
index 2e7b4f9..50a93b4 100644
--- a/src/game/movement/packet_builder.cpp
+++ b/src/game/movement/packet_builder.cpp
@@ -99,16 +99,16 @@ namespace Movement
uint32 last_idx = spline.getPointCount() - 3;
const Vector3 * real_path = &spline.getPoint(1);
+ Vector3 dest = real_path[last_idx];
data << last_idx;
commit 8f235b728ee99be69656ec7674fe160dab64feaf
Author: faramir118 <[email protected]>
Date: Sat Feb 4 13:59:54 2012 -0600
guard against concurrent read/write access to navMesh
Need to add -DMMAP_CONCURRENCY=1 to cmake
visual studio support coming later
diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt
############## details ################
============== structure ================
repository
a tree of objects which are under version control
objects are any of the following:
blob: binary data (usually a file)
tree: points to blobs (files) and other trees (subdirectories)
commit: points to a tree (your projects root directory), and points to the parent commit(s)
@vermie
vermie / gist:1371164
Created November 16, 2011 20:01
more debugging
diff --git a/Client/World/Network/WorldSocket.cs b/Client/World/Network/WorldSocket.cs
index 6c3df10..0d6cbd8 100644
--- a/Client/World/Network/WorldSocket.cs
+++ b/Client/World/Network/WorldSocket.cs
@@ -8,6 +8,7 @@ using Client.Authentication;
using Client.UI;
using Client.Chat;
using Client.Chat.Definitions;
+using System.Diagnostics;
@vermie
vermie / gist:1332816
Created November 2, 2011 03:55
path diagram
A @
XXXXXXXXXXXXXXXXXX
X
X Z
B C#
monster = @, player = #, obstacle = X
nice path: @ -> A -> B -> C
actual path: @ -> A -> B -> Z
@vermie
vermie / profile.xml
Created May 13, 2011 01:56
Profiling for mangos
<region name="default">
<scope name="World::Update" count="153" recurses="0" time="23036000">
<region name="default">
<scope name="World::UpdateSessions" count="153" recurses="0" time="922000"/>
</region>
</scope>
</region>