Skip to content

Instantly share code, notes, and snippets.

View avdg's full-sized avatar

Anthony Van de Gejuchte avdg

View GitHub Profile
@avdg
avdg / gist:786f6c7ba9e1111c070f
Created September 18, 2014 09:39
keybase.md
### 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 August 29, 2015 14:13
Experimental script to fetch unicode chars for ecmascript 5
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 January 23, 2015 11:25
Tried to uglify this and it works fine for me
//! 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 August 29, 2015 14:21
Screeps dump
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 June 28, 2015 19:35
Some random uncompleted huffman tree implementation
// 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 August 29, 2015 14:24
Untested code!
'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;
@avdg
avdg / terrain.js
Created July 13, 2015 22:32
Just blah
'use strict';
// TODO use high performance array?
var types = {
plain: 0,
swamp: 1,
lava: 2,
wall: 3
};
@avdg
avdg / main.js
Last active August 29, 2015 14:26
Screeps fetch api
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",
"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();
}