Skip to content

Instantly share code, notes, and snippets.

View henkman's full-sized avatar
🌶️

henkman henkman

🌶️
View GitHub Profile
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
BasedOnStyle: Google
ColumnLimit: 80
TabWidth: 4
IndentWidth: 4
UseTab: Always
AllowShortIfStatementsOnASingleLine: false
AlwaysBreakTemplateDeclarations: true
BreakBeforeBraces: Linux
void SDL_RenderFillCircle(SDL_Renderer* rend, int x0, int y0, int radius)
{
// Uses the midpoint circle algorithm to draw a filled circle
// https://en.wikipedia.org/wiki/Midpoint_circle_algorithm
int x = radius;
int y = 0;
int radiusError = 1 - x;
while (x >= y) {
SDL_RenderDrawLine(rend, x + x0, y + y0, -x + x0, y + y0);
SDL_RenderDrawLine(rend, y + x0, x + y0, -y + x0, x + y0);
@henkman
henkman / snake.cc
Last active October 11, 2016 10:00
// unixoid:
// g++ -fno-ident -Wall -std=c++11 -s -O2 -o snake snake.cc $(sdl2-config --libs)
// win:
// windres snake.rc -O coff snake.res && g++ -fno-ident -Wall -std=c++11 -s -O2 -o snake snake.cc snake.res -static $(sdl2-config --static-libs)
#include <SDL2/SDL.h>
const auto WIDTH = 320, HEIGHT = 240, BLOCK = 16;
constexpr auto MAX_SEGS = ((WIDTH / BLOCK) * (HEIGHT / BLOCK));
constexpr auto MAX_DOTS = (MAX_SEGS / 100);
package main
import (
"flag"
"fmt"
"image"
_ "image/gif"
_ "image/jpeg"
_ "image/png"
"io"
@henkman
henkman / native_manual_memory_langs.txt
Last active April 8, 2020 09:24
native programming languages with manual memory management (C/C++ -likes)
=== released ===
Gentee - https://github.com/gentee/gentee
Rust - https://github.com/rust-lang/rust
Myrddin - https://github.com/oridb/mc
Free Pascal - http://www.freepascal.org/
Free Basic - https://github.com/freebasic/fbc
Terra - https://github.com/zdevito/terra
=== in development ===
Zig - https://github.com/andrewrk/zig
@henkman
henkman / unab.go
Created July 21, 2016 17:33
extract files from android backup
package main
import (
"compress/zlib"
"flag"
"io"
"log"
"os"
)
@henkman
henkman / msysunindent.go
Last active August 30, 2016 16:04
removes all occurences of ident strings (Built by...) in .o and .a files of a msys2 installation
package main
import (
"bytes"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
@henkman
henkman / libui.manifest
Last active July 1, 2016 12:25
testing libui
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="*"
name="CompanyName.ProductName.YourApplication"
type="win32"
/>
<description>Your application description here.</description>
<dependency>
@henkman
henkman / upchromium.go
Last active July 20, 2016 10:18
small util to update chromium.exe to latest snapshot version
package main
import (
"archive/zip"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"log"