Skip to content

Instantly share code, notes, and snippets.

View BonsaiDen's full-sized avatar

Ivo Worms BonsaiDen

View GitHub Profile

Asynchronous Ping Measurement

Below is a simple description of how to implement a two way ping measuring which calculates the values for both server -> client and client -> server, as these can differ on asymmetric routes.

To work around clock differences, the system uses the date and time of the initial connection as it's origin.

Each side will calculate their roundtrip to the respective remote, and will then transmit it to them in order to create a shared state of the roundtrip time information.

@BonsaiDen
BonsaiDen / require.js
Last active December 12, 2015 00:58
A straigtforward Node.js require() implementation for browsers
/**
* Copyright (c) 2013 Ivo Wetzel.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@BonsaiDen
BonsaiDen / DarkSoulsWeapons.js
Created November 17, 2012 15:41
Dark Souls Weapons Data in JSON form (scraped from: http://darksoulswiki.wikispaces.com/Weapons )
[{
"name": "Dagger",
"atk": {
"physical": 56,
"magic": 0,
"fire": 0,
"lightning": 0,
"bonus": 131
},
"def": {
@BonsaiDen
BonsaiDen / Twist.js
Created February 29, 2012 05:57
Update twist thing
/**
* Copyright (c) 2012 Ivo Wetzel.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@BonsaiDen
BonsaiDen / tokenize.js
Created February 12, 2012 21:15
Small, simple, JS tokenizer in JS.
/**
* Simple JavaScript tokenizer (not a full parser!!!)
*
* Portions taken from Narcissus by Brendan Eich <brendan@mozilla.org>.
*/
/*jshint evil: true, regexdash: false, regexp: false */
var KEYWORDS = [
'break',
@BonsaiDen
BonsaiDen / tokenizer.js
Created February 9, 2012 19:51
Tokenizer
/**
* Copyright (c) 2012 Ivo Wetzel.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@BonsaiDen
BonsaiDen / tokens.json
Created February 9, 2012 19:49
Stuffs
[{
"type": "comment.multi",
"value": "/**\n * Copyright (c) 2011 Ivo Wetzel.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n *
@BonsaiDen
BonsaiDen / class.js
Created February 2, 2012 23:38
Class in 394 bytes (minified).
/**
* Copyright (c) 2012 Ivo Wetzel.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@BonsaiDen
BonsaiDen / Class.js
Created February 1, 2012 23:30
Crazy stuff... still needs a way to get rid of Members and make it work via closure to keep encapsulation
/**
* Copyright (c) 2012 Ivo Wetzel.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@BonsaiDen
BonsaiDen / Twist.js
Created January 23, 2012 16:15
More enhancements for low fps situations
/**
* Copyright (c) 2011 Ivo Wetzel.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*