Skip to content

Instantly share code, notes, and snippets.

View roblabla's full-sized avatar
🌅
Kernel Dev'ing.

Robin Lambertz roblabla

🌅
Kernel Dev'ing.
View GitHub Profile
function findArgs(acc, v, k) {
if (typeof v === "string" && v[0] === '$')
acc.push({ "path": k, "val": v.subst(1) });
else if (Array.isArray(v) || typeof v === "object")
acc = acc.concat(_.map(_.reduce(v, findArgs, []), (v) => { "path": k + "." + v.path, "val": v.val }));
return acc;
}
function setField(path, val, into) {
var c = path.split('.').reverse();
@roblabla
roblabla / glpc.sh
Last active August 29, 2015 13:56
Screen Startup File
#!/bin/bash
# /etc/init.d/mcl
### BEGIN INIT INFO
# Provides: minecraft
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
@roblabla
roblabla / BytesBuffer.hx
Created April 4, 2014 15:14
nodejs length
/*
* Copyright (C)2005-2012 Haxe Foundation
*
* 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:
*
@roblabla
roblabla / Game.cs
Created May 5, 2014 20:07
XNA State Machine
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
@roblabla
roblabla / connect-via-proxy.js
Created February 28, 2015 15:38
HTTP proxy
var Http = require('http');
var proxy = {
address: '192.168.1.1',
port: 80
}
var server = {
host: "cmc.im",
port: 25565
}
@roblabla
roblabla / jarfile.js
Last active August 29, 2015 14:16
jarfile reader
var Protocols = require('../../index');
var fs = require("fs");
var yargs = require("yargs");
// Because the JVM is completely f***'d up, we can't simply use a normal 'array'.
// Pretty much, tag.value 5 & 6 requires you to increment the index by 2. Why ?
// Only god knows. Leads to super-dirty code.
var readConstantPool = function(buffer, offset, fieldInfo, context) {
var results = {
size: 0,
var mc = require('../');
var states = mc.protocol.states;
function print_help() {
console.log("usage: node proxy.js <target_srv> <user> [<password>]");
}
if (process.argv.length < 4) {
console.log("Too few arguments!");
print_help();
@roblabla
roblabla / gulpfile.js
Created May 4, 2015 14:25
Gulp modifying package version in prepublish script - Doesn't work
var gulp = require('gulp');
var jsonTransform = require("gulp-json-transform");
gulp.task('removeGH', function() {
gulp
.src('package.json')
.pipe(jsonTransform(function(data) {
if (data.version.indexOf("-GH") === data.version.length - 3)
data.version = data.version.substring(0, data.version.length - 3);
return data;
@roblabla
roblabla / framing.js
Created May 20, 2015 00:45
Packet framing transform stream
var readVarInt = require("../datatypes/utils").varint[0];
var Transform = require("stream").Transform;
module.exports.createSplitter = function() {
return new Splitter();
}
class Splitter extends Transform {
constructor() {
super();
function createServer({ host = '0.0.0.0',
port = 25565,
'online-mode' : onlineMode = true,
kickTimeout = 10 * 1000,
checkTimeoutInterval = 4 * 1000,
beforePing = null,
keepAlive = true,
motd = "A Minecraft server",
'max-players' : maxPlayers = 20,
} = {}) {