Skip to content

Instantly share code, notes, and snippets.

View Leandros's full-sized avatar

Arvid Gerstmann Leandros

View GitHub Profile
@Leandros
Leandros / random.h
Created July 2, 2018 05:22
C++ Pseudo Random Number Generators
/* Copyright (c) 2018 Arvid Gerstmann. */
/* This code is licensed under MIT license. */
#ifndef AG_RANDOM_H
#define AG_RANDOM_H
class splitmix
{
public:
using result_type = uint32_t;
static constexpr result_type (min)() { return 0; }
@Leandros
Leandros / links.md
Last active April 27, 2024 19:05
Writing a Modern Rendering Engine
@Leandros
Leandros / main.lua
Last active April 24, 2024 20:38
Love2D Fixed Timestep
local TICKRATE = 1/60
function love.update(dt)
end
function love.draw(dt)
end
function love.run()
if love.math then
@Leandros
Leandros / make.sh
Created February 24, 2018 17:09
Compile NASM
#!/bin/bash
export PATH=$PATH:$HOME/x86_64-linux-musl/bin
export CC=x86_64-linux-musl-gcc
export CXX=x86_64-linux-musl-g++
# If needed
export CC="$CC -static --static"
export CXX="$CXX -static --static"
@Leandros
Leandros / make.sh
Created February 17, 2018 19:51
Compile ccache
#!/bin/bash
export PATH=$PATH:$HOME/x86_64-linux-musl/bin
export CC=x86_64-linux-musl-gcc
export CXX=x86_64-linux-musl-g++
# If needed
export CC="$CC -static --static"
export CXX="$CXX -static --static"
@Leandros
Leandros / com.c
Created February 7, 2018 19:46
Compile any file
/*% cc -o # %
* com [-n] [file ...]
* looks for the sequence /*% in each file, and sends the rest of the
* line off to the shell, after replacing any instances of a `%' character
* with the filename, and any instances of `#' with the filename with its
* suffix removed. Used to allow information about how to compile a program
* to be stored with the program. The -n flag causes com not to
* act, but to print out the action it would have taken.
*/
#include <string.h>
@Leandros
Leandros / p4.py
Last active January 9, 2022 00:09
p4.py - p4 offline caching
#!/usr/bin/env python3
# p4.py - p4 offline caching
#
# Copyright (c) 2017 Arvid Gerstmann
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@Leandros
Leandros / gen_host.sh
Created April 26, 2016 16:27
Generate Hostfile
#!/bin/sh
#
# This code is GPLv3
# Taken from: http://chr4.org/blog/2016/04/26/homebrew-betrayed-us-all-to-google/
HOSTSFILE=hosts
TMPFILE=/tmp/aosp-hosts-file
echo "Updating adblocking hosts file..."
#!/bin/bash
#
# UPTIME MONITORING
# v1.0.0
#
### INSTALLATION
#
# 1. Install dependencies
#
# `apt-get install mailx curl openssl`
@Leandros
Leandros / compresspdf.sh
Created April 2, 2019 08:55
Compress PDF (requires ghostscript)
#!/bin/bash
readonly input="$1"
readonly output="$2"
readonly preset="$3"
if [ "$input" = "" ] || [ "$output" = "" ] || [ "$preset" = "" ]; then
echo "usage: $0 [input file] [output file] [screen|ebook|printer|prepress]"
exit 1
fi