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 / make.sh
Last active February 17, 2018 18:59
OpenCV
#!/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++
# wget -nc https://zlib.net/zlib-1.2.11.tar.gz
# wget -nc ftp://ftp-osl.osuosl.org/pub/libpng/src/libpng16/libpng-1.6.34.tar.xz
# wget -nc -O libjpeg.tar.gz http://sourceforge.net/project/showfiles.php?group_id=159521
wget -nc https://github.com/opencv/opencv/archive/3.3.0.zip
/* ... */
template<size_t Dimen>
class NDMatrix
{
public:
/* this is imaginary, as of right now: */
$for(size_t i = 0; i < Dimen; ++i) {
/* Create one function definition for each dimen access:
* float &At(int x0, int x1, etc...) { return m_array[_At(...)]; }
@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>

Core Coding Standard

Coding practices are a source of a lot of arguments among programmers. Coding standards, to some degree, help us to put certain questions to bed and resolve stylistic debates. No coding standard makes everyone happy. (And even their existence is sure to make some unhappy.) What follows are the standards we put together on the Core team, which have become the general coding standard for all programming teams on new code development. We’ve tried to balance the need for creating a common, recognizable and readable code base with not unduly burdening the programmer with minor code formatting concerns.

Table Of Contents

@Leandros
Leandros / Swizzles.h
Created February 15, 2018 16:38 — forked from NocturnDragon/Swizzles.h
Swizzles in Clang, GCC, and Visual c++
#include <stdio.h>
// #define CLANG_OR_GCC
// Compile with -O3 -std=c++11 for Clang version
#define VS
// Compile with -O3 -fms-compatibility -std=c++11 for VS version
#if defined(CLANG_OR_GCC)
typedef float float2 __attribute__((ext_vector_type(2)));
@Leandros
Leandros / touch.cmd
Created February 16, 2018 10:03
*nix like touch on Windows
@echo off
setlocal enableextensions disabledelayedexpansion
(for %%a in (%*) do if exist "%%~a" (
pushd "%%~dpa" && ( copy /b "%%~nxa"+,, & popd )
) else (
type nul > "%%~fa"
)) >nul 2>&1
@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 / 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"
#include <stdio.h>
#include <string.h>
#include <math.h>
#define clamp(d, min, max) ((d) < (min) ? (min) : ((d) > (max) ? (max) : (d)))
float
sRGB_encode(float v)
{
#include <stdatomic.h>
#include <stdint.h>
#include <x86intrin.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/futex.h>
#include <sys/time.h>
#include <pthread.h>
static uint64_t