Skip to content

Instantly share code, notes, and snippets.

Avatar

Anthony Van de Gejuchte avdg

View GitHub Profile
View gist:786f6c7ba9e1111c070f
### Keybase proof
I hereby claim:
* I am avdg on github.
* I am anthonyvdg (https://keybase.io/anthonyvdg) on keybase.
* I have a public key whose fingerprint is AEAB D787 FD4A 0B8E CD9B D3B1 E296 08B0 FF0E 3964
To claim this, I am signing this object:
@avdg
avdg / ecmascript-unicode.js
Last active Aug 29, 2015
Experimental script to fetch unicode chars for ecmascript 5
View ecmascript-unicode.js
var fs = require('fs');
var http = require('http');
var path = require('path');
var useLocal = false; // Just to stop this script from fetching unicodeData all the time ;-)
var es6mode = false; // If false, we use es5 syntax and ommit some characters for now
// Format:
// 0000;<control>;Cc;0;BN;;;;;N;NULL;;;;
//
@avdg
avdg / moment-timezone-full.js
Created Jan 23, 2015
Tried to uglify this and it works fine for me
View moment-timezone-full.js
//! moment-timezone.js
//! version : 0.3.0
//! author : Tim Wood
//! license : MIT
//! github.com/moment/moment-timezone
var moment = (function (root, factory) {
"use strict";
/*global define*/
@avdg
avdg / roomPosition.js
Last active Aug 29, 2015
Screeps dump
View roomPosition.js
c.prototype.findClosest = function(b, c) {
var e = this;
c = d.clone(c || {});
var f = a.rooms[this.roomName];
if (!f) throw new Error("Could not access a room " + this.roomName);
if (d.isUndefined(b)) return null;
var g, j = null, k = f.getEndNodes(b, c);
if (!c.algorithm) {
var l, m = 0;
k.objects.forEach(function(a) {
@avdg
avdg / huffman.js
Created Jun 28, 2015
Some random uncompleted huffman tree implementation
View huffman.js
// Priority stack implementation over here https://github.com/avdg/screeps/blob/master/extensions/tools/library/priorityStack.js
// Assume AI.priorityStack = require(<path to priorityQueue>);
/**
* A basic huffman tree compression algorithm
*
* @param input String Input to convert
*
* @return string
*/
@avdg
avdg / room.js
Last active Aug 29, 2015
Untested code!
View room.js
'use strict';
function hasWall(list, returnValueDefaultsTrue) {
if (!Array.isArray(list)) {
return returnValueDefaultsTrue === undefined ? true : returnValueDefaultsTrue;
}
for (var i = 0; i < list.length; i++) {
if (list[i].type === "terrain" && list[i].terrain === "wall") {
return true;
View terrain.js
'use strict';
// TODO use high performance array?
var types = {
plain: 0,
swamp: 1,
lava: 2,
wall: 3
};
@avdg
avdg / main.js
Last active Aug 29, 2015
Screeps fetch api
View main.js
var writeApiData = function() {
var parseFunction = function(obj) {
// Note: Function.prototype.toString() is implementation defined, may not work on non-v8 or future v8 js engines
// See: http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.4.2
var args = obj.toString();
args = args.substr(0, args.indexOf(")"));
args = args.substr(args.indexOf("(") + 1);
args = args === "" ? [] : args.split(",");
var data = {
"_type": "function",
View screepsGet.js
"use strict";
var https = require("https");
var querystring = require("querystring");
// Display help if necessary
if ((process.argv[2] === "--help" || process.argv[2] === undefined) && process.argv[3] === undefined) {
console.log("Usage: " + process.argv[0] + " " + process.argv[1] + " <email> <password> [branch=default]");
process.exit();
}