Skip to content

Instantly share code, notes, and snippets.

View nickelpro's full-sized avatar
suzmarin

Vito Gamberini nickelpro

suzmarin
View GitHub Profile
@nickelpro
nickelpro / mcd2c.py
Created November 12, 2019 05:35
Generates a c parser for the minecraft protocol form minecraft_data
# Midway upon the journey of our life
# I found myself within a forest dark,
# For the straight-forward pathway had been lost.
import cfile as c
mcd_typemap = {}
def mc_data_name(typename):
def inner(cls):
mcd_typemap[typename] = cls
@nickelpro
nickelpro / cfile.py
Created November 12, 2019 05:34
C code generator in python
# Inspired by https://github.com/cogu/cfile
c_indent_char = '\t'
def set_indent_char(char):
global c_indent_char
c_indent_char = char
class blank:
@nickelpro
nickelpro / out.log
Created August 3, 2019 10:57
stdnoreturn.h build errors
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/nicke/source/repos/C11-Fibers/build/Debug --config Debug --target all -- -j 14
[build] [1/2 50% :: 0.042] Building C object CMakeFiles\main.dir\src\test.c.obj
[build] FAILED: CMakeFiles/main.dir/src/test.c.obj
[build] C:\PROGRA~1\LLVM\bin\clang-cl.exe /nologo -I..\..\include /DWIN32 /D_WINDOWS /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFiles\main.dir\src\test.c.obj /FdCMakeFiles\main.dir\ -c ..\..\src\test.c
[build] In file included from ..\..\src\test.c:2:
[build] In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\stdlib.h:12:
[build] In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\corecrt.h:10:
[build] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\vcruntime.h(326,20): error: __declspec attributes must be an identifier or string literal
[build] __declspec(noreturn) void __
# References:
# WHOI TECHNICAL MEMORANDUM 3-81
# Roark's Formulas for Stress and Strain, 7th Edition
mpa_per_foot_sw = 0.003033693
mpa_hy_steel_youngs_modulus = 207000
hy_steel_poissons_ratio = 0.30
mpa_hy80_yield_strength = 550
mpa_hy100_yield_strength = 900
in_ssn21_beam = 41 * 12
@nickelpro
nickelpro / build_and_copy_buf.c
Last active May 28, 2019 04:25
I hate Vulkan
//Basically this:
//https://github.com/KhronosGroup/Vulkan-Docs/wiki/Synchronization-Examples
//Holy shit this function got out of control
int build_and_copy_buf(
vk_buffer_t *local_buf,
void *data,
VkDeviceSize size,
VkBufferUsageFlags usage,
VkAccessFlags dst_access,
VmaAllocator allocator,
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <string.h>
#include <graphene-1.0/graphene.h>
#include "vgfx.h"
#include "logc/log.h"
#include "par/par_shapes.h"
#include "sds/sds.h"
#Midway upon the journey of our life
#I found myself within a forest dark,
#For the straight-forward pathway had been lost.
#This code is really bad
import cfile as c
import minecraft_data
import re
#This is not a real compiler, there is no IR or anything. Just walks the
char *enc_varint(char *dest, uint32_t source) {
for(; source >= 0x80; dest++, source >>= 7) {
*dest = 0x80 | (source & 0x7F);
}
*dest = source & 0x7F;
return ++dest;
}
char *dec_varint(int32_t *dest, char *source) {
for(; *(unsigned char *) source & 0x80; source++, *(uint32_t *) dest <<= 7) {
@nickelpro
nickelpro / nickfollow.py
Last active December 13, 2015 10:34
Example of movement with new pathfinding
from spockbot.plugins.tools.event import EVENT_UNREGISTER
from spockbot.plugins.base import PluginBase
from spockbot.vector import Vector3
class NickelproFollow(PluginBase):
requires = (
'Chat', 'ClientInfo', 'Entities', 'Event', 'Movement', 'Interact'
)
events = {
@nickelpro
nickelpro / mcvarint.py
Created November 5, 2013 02:20
Two python functions that implement the new Minecraft varint type (32-bit signed integers packed into Google protobuf varints). Packs varints into a byte string, unpacks varints from a buffer that has a read(bytes) method. Supports negative numbers even though they aren't used in the current protocol.
import struct
def pack_varint(val):
total = b''
if val < 0:
val = (1<<32)+val
while val>=0x80:
bits = val&0x7F
val >>= 7
total += struct.pack('B', (0x80|bits))