Skip to content

Instantly share code, notes, and snippets.

@TheServer201
TheServer201 / btrh.h
Last active November 3, 2016 22:48
Bit Test Reset Jump
#define Btrj(x, y, z) asm goto("btr %0, %1\n\t" \
"jnc %l0 \n\t" \
: "+rm"(x) \
: "r"(y) \
: "cc" \
: z)
@TheServer201
TheServer201 / list.c
Last active January 16, 2017 13:25
Serialize with list
typedef struct node {
uint8_t *Elem;
uint16_t Size;
struct node *Next;
} node_t;
void Node_Push(node_t **Head, uint8_t *Elem, uint16_t Size){
node_t *Node = malloc(sizeof(node_t));
Node->Elem = Elem;
Node->Size = Size;
// gcc -Os -s -nostartfiles -nostdlib -e __main -Wl,-gc-sections win.c -o win -luser32 -lkernel32
#define UNICODE
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void _main(){
MSG msg = {0};
WNDCLASS wc = {0};
wc.lpfnWndProc = WndProc;
// gcc -Os -s -municode -nostartfiles -mfpmath=both -march=core2 -e __main -Wl,-gc-sections win.c -o win -luser32 -lkernel32 -lgdi32 -lopengl32
#include <windows.h>
#include <stdint.h>
#include <gl/gl.h>
#include <stdio.h>
#include <time.h>
typedef struct {
GLfloat x, y;
} Vector2;
@TheServer201
TheServer201 / serial.h
Last active September 7, 2018 04:52
Serialization Helper
/*
* serial.h - Serialization helper
*
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
* Version 2, December 2004
*
* Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
*
* Everyone is permitted to copy and distribute verbatim or modified
* copies of this license document, and changing it is allowed as long
@TheServer201
TheServer201 / vulkan.c
Created May 6, 2017 18:39
Simple vkCmdClearColorImage example
// gcc -Os -s -I. -L. -municode -nostartfiles -e _entry -Wl,--gc-sections vulkan.c -o vulkan -lvulkan-1
#define VK_USE_PLATFORM_WIN32_KHR
#include <vulkan/vulkan.h>
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
typedef struct
{
VkDevice Device;
@TheServer201
TheServer201 / yandex.java
Last active June 6, 2017 13:09
Simple yandex translator parser
import java.io.*;
import java.net.*;
import java.util.*;
import javax.net.*;
import javax.net.ssl.*;
public class Yandex {
private String pkey;
private InetAddress addr;
private SocketFactory fact;
@TheServer201
TheServer201 / crc32c.c
Created June 13, 2017 15:13
Use of SSE4.2 to compute crc32c
#include <nmmintrin.h>
#include <stdint.h>
#include <string.h>
uint32_t crc32(uint32_t len, uint8_t *msg) {
uint32_t pos = 0, hsh = -1;
while (1) {
uint32_t tmp = len - pos;
if (tmp >= 4) {
uint32_t val;
@TheServer201
TheServer201 / swf.c
Created July 22, 2017 19:49
Swf decompiler for RotMG
// gcc -Os -s -nostartfiles -e _entry -I. swf.c -o swf
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <tinf.h>
typedef struct {
uint32_t length, offset;
@TheServer201
TheServer201 / kyoubot.js
Last active July 28, 2017 23:33
Simple and powerfull Discord bot
const Discord = require("discord.js");
const client = new Discord.Client();
var news, count;
function reset() {
count = 0;
var today = new Date(),
time = today.getTime();
today.setHours(0);