Skip to content

Instantly share code, notes, and snippets.

View rom1504's full-sized avatar

Romain Beaumont rom1504

View GitHub Profile
@rom1504
rom1504 / download_resize_when_necessary.py
Created June 12, 2021 14:51
download_resize_when_necessary.py
from multiprocessing import Pool
from tqdm import tqdm
import csv
import cv2
import os
import urllib.request
import hashlib
IMAGE_SIZE = 1280
@rom1504
rom1504 / download.py
Last active June 12, 2021 14:16
download
from multiprocessing import Pool
from tqdm import tqdm
import csv
import cv2
import os
import urllib.request
import hashlib
@rom1504
rom1504 / minecraft_helper.js
Last active March 13, 2021 02:42
mineflayer helpers
chat = (o) => bot.chat(JSON.stringify(o))
craft = (name, count=1) => {
let crafting_table = bot.findBlock({matching:mcData.blocksByName.crafting_table.id, maxDistance:5})
console.log(crafting_table)
let item = mcData.itemsByName[name]
console.log(item)
let recipes = bot.recipesFor(item.id, item.metadata, count, crafting_table)
console.log(recipes)
bot.craft(recipes[0], count, crafting_table)
@rom1504
rom1504 / model.gltf
Last active January 3, 2021 01:56
pviewer exports
This file has been truncated, but you can view the full file.
{"asset":{"version":"2.0","generator":"THREE.GLTFExporter"},"scenes":[{"nodes":[0,1,2,3,4,5,6,7,8,9,10,11]}],"scene":0,"nodes":[{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0.6666666666666666,0.6666666666666666,0.3333333333333333,1],"extensions":{"KHR_lights_punctual":{"light":0}}},{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,24,72,24,1],"mesh":0},{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,8,56,24,1],"mesh":1},{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,24,56,24,1],"mesh":2},{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,8,72,24,1],"mesh":3},{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,8,88,24,1],"mesh":4},{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,24,88,8,1],"mesh":5},{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,8,88,8,1],"mesh":6},{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,8,56,8,1],"mesh":7},{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,24,72,8,1],"mesh":8},{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,8,72,8,1],"mesh":9},{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,24,56,8,1],"mesh":10}],"extensions":{"KHR_lights_punctual":{"lights":[{"color":[1,1,1],"intensity":0.5,"type":"directional"}]}},"bufferViews":[{"buffer":0,"b
@rom1504
rom1504 / a.js
Created December 6, 2020 18:33
async function execution order
async function f() {
console.log('a')
await new Promise(resolve => setTimeout(resolve, 0))
}
f().then(() => console.log('c'))
console.log('b')
@rom1504
rom1504 / faiss_benchmark.py
Created November 6, 2020 09:31
faiss_benchmark
import faiss
import numpy as np
import re
import time
def index_factory(d: int, index_key: str, metric_type: int):
"""
custom index_factory that fix some issues of
faiss.index_factory with inner product metrics.
"""
if metric_type == faiss.METRIC_INNER_PRODUCT:
@rom1504
rom1504 / protocol_reverse_engineering.md
Created June 28, 2020 01:29
protocol_reverse_engineering

In general that's the procedure to follow for a new game :

  1. Check if somebody already did something even partially, if so read their code, take what you can, learn the general structure of things
  2. If nothing exists, boot up Wireshark, look if the protocol is encrypted, textual, binary, you might have some luck at this point
  3. If Wireshark failed, download the vanilla game binaries, identify what language it was, if java based (or c#) decompile, try to find the packet classes. If native you can try using idapro but it's going to be harder
  4. Assuming some of the above worked, document the protocol
  5. Implement the low level (tcp, udp, encryption, compression, splitting)
  6. Implement parsing and serialisation (we use protodef for this)
  7. Implement login sequence At this point you have something on the level of node-minecraft-protocol
@rom1504
rom1504 / 1.16-rc1_recipe_type_example.json
Last active June 23, 2020 02:04
1.16-rc1 recipe types
{
"minecraft:crafting_shaped": {
"type": "minecraft:crafting_shaped",
"group": "stained_terracotta",
"pattern": [
"###",
"#X#",
"###"
],
"key": {
@rom1504
rom1504 / nn.py
Created November 23, 2018 20:56
nn to solve house regression
from math import sqrt
from scipy import stats
from scipy.stats import norm, skew
from scipy.special import boxcox1p
import pandas as pd
train = pd.read_csv('train.csv')
test = pd.read_csv('test.csv')
train_ID = train['Id']
test_ID = test['Id']
# Nous retirons la colonne Id qui n'est pas utile pour l'entrainement
@rom1504
rom1504 / square.py
Created November 18, 2018 20:14
keras square function
import tensorflow as tf
from tensorflow import keras
import numpy as np
from keras.layers import Dense, Activation
from keras.models import Sequential
model = Sequential([
Dense(40, input_shape=(1,)),
Activation('relu'),
Dense(12),