Skip to content

Instantly share code, notes, and snippets.

View endel's full-sized avatar

Endel Dreyer endel

View GitHub Profile
@endel
endel / cpuinfo
Created November 28, 2025 20:07
Regular Compute: cat /proc/cpuinfo && lscpu
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 60
model name : Intel Core Processor (Haswell, no TSX, IBRS)
stepping : 1
microcode : 0x1
cpu MHz : 2394.454
cache size : 16384 KB
physical id : 0
@endel
endel / cpuinfo
Created November 28, 2025 19:41
High Performance: cat /proc/cpuinfo && lscpu
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 85
model name : Intel Xeon Processor (Cascadelake)
stepping : 6
microcode : 0x1
cpu MHz : 2893.194
cache size : 16384 KB
physical id : 0
@endel
endel / cpuinfo
Last active November 28, 2025 19:40
High Frequency: cat /proc/cpuinfo && lscpu
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 94
model name : Intel Core Processor (Skylake, IBRS)
stepping : 3
microcode : 0x1
cpu MHz : 3695.998
cache size : 16384 KB
physical id : 0
@endel
endel / index.ts
Created July 17, 2023 17:29
Colyseus Schema - Listen for all changes and print them as they come
room.onStateChange.once(function() {
function registerCallbacksOnStructure (schemaInstance, path) {
const schema = schemaInstance['_definition'].schema;
for (let field in schema) {
const schemaType = typeof(schema[field]);
if (schemaType === "object") {
// on item added to collection
schemaInstance[field].onAdd(function (item, key) {
onItemAdd([...path, field], item, key);
@endel
endel / README.md
Last active June 13, 2022 15:29
Node.js Package Authors: Please support both CJS and ESM: https://dev.to/endel/nodejs-package-authors-please-support-both-cjs-and-esm-1oj3
@endel
endel / SchemaCallbacks.md
Last active August 22, 2021 13:26
New Schema Callback API Proposal

Hi everybody! Regarding the possible new schema callback API, so far this is what I could came up so far, feedback highly appreciated! Do let me know if you feel I need to clarify anything!

I understand this may be long and hard to grasp, I can provide a side-by-side comparison between the new API and previous one so you can clearly see the difference.

The new API would allow to create all the callbacks at once, after the connection with the room has been established (even on deep structures) - rather than binding callbacks as Schema instances that are created on-demand on the client-side.

Structures:

class Point extends Schema {
@endel
endel / dungeon-generator.js
Created November 6, 2020 18:45
Simple Dungeon Generation Algorithm. Used in https://github.com/endel/mazmorra/
// Based on: http://breinygames.blogspot.com/2011/07/random-map-generation.html
// Needs improvment:
// - It is possible with small rooms for it to not be closed (i.e. a wall tile missing)
// - Walls often double up (more room spacing?)
var RoomMaze = srm = {
generate: function(gridSize, minRoomSize, maxRoomSize, maxRooms) {
// 1) Create the grid
var grid = [];
@endel
endel / lua-ternary-operator.lua
Created September 24, 2020 21:16
LUA Ternary Operator
local x = (y > 10) and "condition is true" or "condition is false"
@endel
endel / ecosystem.config.js
Last active June 28, 2020 00:30
Sample PM2 ecosystem file for deployment
module.exports = {
apps : [{
name : 'my-app',
script : 'lib/index.js',
watch : false,
instances : 1,
exec_mode : 'fork',
env: {
NODE_ENV: 'development'
}
@endel
endel / extract-parameters-typeof-typescript.ts
Created March 28, 2020 15:21
Extract parameters of an instance method using TypeScript
// Playground link: https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=19&pc=49#code/C4TwDgpgBAKuEB4YD4oF4oDsIHcoAoA6YgQwCcBzAZwC4oTMQBtAXQEp1UYBuAKF4DGAGxJUqUAEoB7KQFsk6eo1QBvXlChVgJYBAD8dHuqhTMAYTIQdEfFLDAAlqdpKQHNRoC+vb4JFioAFkQaTkoCAAPXUwAE3FQ+RUYhwAzFIhLTGAAcQhsMgcBOi0CzApPVWNTCytdW3snTBcVLBJZCGLgUooAGighCAA3CCE6TABXWQAjDKhPd29fFPHMAUdTKBiIFIdsBUjouNh4BATkZHxjMhlZOEhDHqqG5zoABXI2iF0yKgQASSa2lWEDuiBQTAA5NVLNYISxkEwAAwsXjuHz8LY7bD4YIJPotTCfOgAIj+wCgOCkZAA1lQAITEvoDYajKAARjmbG4QA
type Type<T> = new (...args: any[]) => T;
class Room<T = any> {
state?: T;
onCreate(options: any) {
}
}