Skip to content

Instantly share code, notes, and snippets.

View rom1504's full-sized avatar

Romain Beaumont rom1504

View GitHub Profile
@rom1504
rom1504 / simple_stringify.js
Created June 14, 2016 12:51
simple stringify
// model : https://github.com/rom1504/JsonConv/blob/master/source/json_to_json.ml
const p=require('./protocol.json');
const json_string_of_jarray=a => `[${(a.map(json_string_of_jvalue)).join(",")}]`;
const json_string_of_jobject=o => `{${Object.keys(o).map(k => '"'+k+'":'+json_string_of_jvalue(o[k])).join(",")}}`;
const json_string_of_jvalue=v => {
if(v===null)
return "NULL";
if(v.constructor===Array)
@rom1504
rom1504 / protocol-diff.js
Created June 5, 2016 22:16
script to make a diff between 2 protodef protocols
const equal = require('deep-equal');
if(process.argv.length != 4) {
console.log("Usage : node protocol-diff.js <protocol1.json> <protocol2.json>");
process.exit(1);
}
const p1File=process.argv[2];
const p2File=process.argv[3];
@rom1504
rom1504 / protocol-diff.json
Created June 5, 2016 22:09
diff example between 1.8 and 1.9.4
{
"play": {
"toClient": {
"oldTypes": {
"packet_login": [
"container",
[
{
"name": "entityId",
"type": "i32"
@rom1504
rom1504 / protocol-diff.json
Created June 5, 2016 22:07
diff example between 16w20a and 1.10-pre1
{
"play": {
"toServer": {
"oldTypes": {
"packet_resource_pack_receive": [
"container",
[
{
"name": "hash",
"type": "string"
@rom1504
rom1504 / level.json
Created April 3, 2016 22:33
mcpe level.dat
{
"type": "compound",
"name": "",
"value": {
"DayCycleStopTime": {
"type": "int",
"value": -1
},
"GameType": {
"type": "int",
@rom1504
rom1504 / convert.js
Created March 28, 2016 20:05
big endian to little endian in protodef tests
var numeric=require("./test/numeric");
var le=numeric.map(n => ({
"type":"l"+n.type,
"values":n.values.map(v => ({
"description":v.description,
"buffer":v.buffer.slice().reverse(),
"value":v.value
}))
}));
@rom1504
rom1504 / datapacket_4.json
Created March 27, 2016 22:16
datapacket_4
{
"name": "data_packet_4",
"params": {
"seqNumber": 0,
"encapsulatedPackets": [
{
"reliability": 2,
"hasSplit": 0,
"length": 33,
"messageIndex": 0,
@rom1504
rom1504 / regex.js
Last active March 7, 2016 13:01
regex
/<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>/
/(<link[^>]*(?:\s(?:type=[\"']?(application\/rss\+xml|application\/atom\+xml|application\/rss|application\/atom|application\/rdf\+xml|application\/rdf|text\/rss\+xml|text\/atom\+xml|text\/rss|text\/atom|text\/rdf\+xml|text\/rdf|text\/xml|application\/xml)[\"']?|rel=[\"']?(?:alternate)[\"']?))[^>]*>)/
@rom1504
rom1504 / keybase.md
Created March 6, 2016 14:59
keybase.md

Keybase proof

I hereby claim:

  • I am rom1504 on github.
  • I am rom1504 (https://keybase.io/rom1504) on keybase.
  • I have a public key ASB1Z9sbI8JRLzgvFg_Unf0luj8-SK7QKOGrCcpLDyZF-Qo

To claim this, I am signing this object:

@rom1504
rom1504 / mojang_position.md
Last active March 6, 2016 13:42
All the mojang position format

This will contain all mojang position formats:

Name Description Provenance Implementation example
bitfield a bitfield of x,y,z with x and z being 26 bits, y being 13 bits mcpc modern 1.8 mcdata
3 f64 x,y,z in f64 mcpc modern 1.8 mcdata
3 i32 : fixed-point x,y,z in i32 mcpc modern 1.8 mcdata
2 i32 and 1 i16 x,z in i32 and y in i16 mcpc modern 1.7 mcdata
2 i32 and 1 i8 x,z in i32 and y in i8 mcpc modern 1.7 [mcdata](https://github.com/Prismar