Skip to content

Instantly share code, notes, and snippets.

@ppoffice
ppoffice / Unicode_Garbled_Text_Decoder.js
Created April 25, 2016 14:56
Unicode Garbled Text Decoder
x = '\xE7\xBB\xBF\xE8\x89\xB2\xE5\x81\xA5\xE5\xBA\xB7\xE5\xB0\x8F\xE6\xB8\x85\xE6\x96\xB0';
x.split('').map(i => (j = i.charCodeAt(0).toString(2), i.charCodeAt(0) > 127 ? j : new Array((4 - (j.length % 4)) % 4).fill('0').join('') + j)).map((i, j, k) => (l = i.match(/^0|^1{2,4}0/), l ? m = new Array(l[0] === '0' ? 1 : l[0].length - 1).fill(0) : m = [], m.map((o, r) => r === 0 ? i.slice(l[0].length, i.length) : k[j + r].slice(2, k[j + r].length)))).filter(i => i.length).map(i => String.fromCharCode(parseInt(i.join(''), 2))).join('');
@ppoffice
ppoffice / cem_v1_to_v2.cpp
Created April 25, 2020 19:34
Convert Empire Earth CEM v1 model to v2 model
// Copyright 2020 ppoffice
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this softwareand 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 :
//
// The above copyright noticeand this permission notice shall be included in