Skip to content

Instantly share code, notes, and snippets.

@TheServer201
TheServer201 / inet_addr.asm
Last active August 17, 2018 19:12
Implementation of inet_addr (~3-5x faster)
; Coded by CORRADI Q.
global inet_addr
inet_addr:
push rbx
push rsi
mov rsi, rcx
lodsb
sub al, '0'
mov dl, al
@TheServer201
TheServer201 / stdatomic.h
Last active July 12, 2018 21:41
Implementation of missing lockable instructions
#include <stdbool.h>
#include <stdint.h>
typedef __int128 int128_t;
typedef unsigned __int128 uint128_t;
#define atomic_fetch_adc(object, argument) \
({ \
asm("lock adc %0, %1" \
: "+m"(*(object)), "+r"(argument) \
@TheServer201
TheServer201 / xxhash.c
Created March 16, 2018 20:16
Implementation of xxHash for small input
#include <stdlib.h>
#include <intrin.h>
#define PRIME32_1 0x9E3779B1
#define PRIME32_2 0x85EBCA77
#define PRIME32_3 0xC2B2AE3D
#define PRIME32_4 0x27D4EB2F
#define PRIME32_5 0x165667B1
uint32_t xxHash(const char *input, size_t size, uint32_t seed) {
@TheServer201
TheServer201 / scroll.css
Created January 5, 2018 17:19
Scroll without a scrollbar
.scroll {
overflow: hidden;
cursor: move;
touch-action: none;
}
@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);
@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 / 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 / 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 / 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 / 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