Skip to content

Instantly share code, notes, and snippets.

View sscholl's full-sized avatar

Simon Eric Scholl sscholl

View GitHub Profile
@sscholl
sscholl / engine.js
Last active June 6, 2016 17:21 — forked from avdg/engine.js
var global = self;
var Reflect = {
global: global
};
!function a(b, c, d) {
function e(g, h) {
if (!c[g]) {
if (!b[g]) {
@sscholl
sscholl / terrain.js
Created June 6, 2016 09:38 — forked from laverdet/terrain.js
parse terrain from screeps png
getPx('https://s3.amazonaws.com/static.screeps.com/map2/'+ roomName+ '.png', function(err, pixels) {
if (err) {
throw err;
}
let kyskip = 50 * 3 * 3 * 4;
let kxskip = 3 * 4;
for (let yy = 0; yy < 50; ++yy) {
for (let xx = 0; xx < 50; ++xx) {
let px = pixels.data[xx * kxskip + yy * kyskip] * 0x10000 + pixels.data[xx * kxskip + yy * kyskip + 1] * 0x100 + pixels.data[xx * kxskip + yy * kyskip + 2];
switch (px) {
@sscholl
sscholl / main.js
Created July 5, 2016 01:25
Game.loop
console.log('only once!');
var mod = require('mod');
Memory.ticks = 0;
var test = Game.time;
module.exports.loop = function() {
console.log('tick ' + (Memory.ticks ++) + '! (var test = ' + test + ')');
}
@sscholl
sscholl / main.js
Created July 5, 2016 01:27
Game.cpu
module.exports.loop = function() {
if (Game.cpu.tickLimit < 500) {
console.log("Execution of loop is not possible, because tick limit is " + Game.cpu.tickLimit + "<500");
return;
}
var time = Game.cpu.getUsed();
console.log("--> LOAD TIME " + time);
@sscholl
sscholl / Gitlab-RocketChat Integration
Created November 15, 2017 15:45
Gitlab-RocketChat IntegrationHinzuzufügen in RocketChat unter Integrationen->Incomming Webhook
/* eslint no-console:0, max-len:0 */
// see https://gitlab.com/help/web_hooks/web_hooks for full json posted by GitLab
const MENTION_ALL_ALLOWED = false; // <- check that bot permission allow has mention-all before passing this to true.
const NOTIF_COLOR = '#6498CC';
const refParser = (ref) => ref.replace(/^refs\/(?:tags|heads)\/(.+)$/, '$1');
const displayName = (name) => (name && name.toLowerCase().replace(/\s+/g, '.'));
const atName = (user) => (user && user.name ? '@' + displayName(user.name) : '');
const makeAttachment = (author, text) => {
return {
author_name: author ? displayName(author.name) : '',
@sscholl
sscholl / Gitlab-RocketChat Integration
Last active November 15, 2017 15:59
Gitlab-RocketChat Integration - Hinzuzufügen in RocketChat unter Integrationen->Incomming Webhook
/* eslint no-console:0, max-len:0 */
// see https://gitlab.com/help/web_hooks/web_hooks for full json posted by GitLab
const MENTION_ALL_ALLOWED = false; // <- check that bot permission allow has mention-all before passing this to true.
const NOTIF_COLOR = '#6498CC';
const refParser = (ref) => ref.replace(/^refs\/(?:tags|heads)\/(.+)$/, '$1');
const displayName = (name) => (name && name.toLowerCase().replace(/\s+/g, '.'));
const atName = (user) => (user && user.name ? '@' + displayName(user.name) : '');
const makeAttachment = (author, text) => {
if (author) {
text = displayName(author.name) + " " + text;