Skip to content

Instantly share code, notes, and snippets.

View Leandros's full-sized avatar
🦀
Available for Rust contracting

Arvid Gerstmann Leandros

🦀
Available for Rust contracting
View GitHub Profile
@Leandros
Leandros / coroutine
Last active August 24, 2017 18:59
coroutine
// -*- C++ -*-
//===----------------------------- coroutine -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
$ dumpbin -symbols main.obj
Microsoft (R) COFF/PE Dumper Version 14.00.24213.1
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file main.obj
File Type: COFF OBJECT
COFF SYMBOL TABLE
@Leandros
Leandros / main.c
Created June 23, 2017 13:39
compile with clang: clang -x c -O3 main.c
#include <stdio.h>
#define 👉 ->
struct vec3 {
int x, y, z;
};
void print_vec(struct vec3 *v)
{
@Leandros
Leandros / nobom.c
Created May 19, 2017 08:15
remove bom. usage: gcc -o nobom nobom.c && ./nobom path/to/file
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
static char bom[3] = { 0xEF, 0xBB, 0xBF };
#define error(msg) error__(msg, __LINE__)
static int
error__(char const *msg, int line)
@Leandros
Leandros / windows.h
Created May 11, 2017 15:01
windows.h
#ifdef _MSC_VER
#pragma warning(push, 0)
#include <windows.h>
#pragma warning(pop)
#endif
@Leandros
Leandros / probe.sh
Created April 30, 2017 11:04
probe.sh
#!/bin/bash
WORDS=$(cat /usr/share/dict/words)
IFS=$'\n'
LC_ALL=C
echo "" > domains.txt
for word in $WORDS; do
if [[ $word =~ ^[A-Za-z]{4,12}$ ]]; then
@Leandros
Leandros / links.md
Last active November 24, 2025 08:08
Writing a Modern Rendering Engine
@Leandros
Leandros / tail.c
Created March 23, 2017 14:44
tail -1
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define BUF 4096
int main(int argc, char **argv)
{
FILE *f;
int i, n, nl;
@Leandros
Leandros / main.c
Last active December 3, 2018 12:01
Lua C preprocessor
/*
* Copyright (c) 2018 Arvid Gerstmann.
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#include <stdio.h>
/*lua!
local func = [[
@Leandros
Leandros / main.c
Created February 20, 2017 09:12
Error Checking
int
foo_can_fail(void)
{
bar_t bar;
if (bar_init(&bar))
return 1;
if (bar_do_stuff(&bar))