Skip to content

Instantly share code, notes, and snippets.

View Leandros's full-sized avatar

Arvid Gerstmann Leandros

View GitHub Profile

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 / 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>
/* ... */
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 / 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
@Leandros
Leandros / build.bat
Last active November 29, 2021 07:45
Compile LLVM
@echo off
del /s /q build/*
rmdir /s /q build
mkdir build
cd build
cmake .. -G"Visual Studio 16 2019" -A x64 -Thost=x64^
-DCMAKE_BUILD_TYPE:STRING="Release"^
-DCMAKE_INSTALL_PREFIX:STRING="output"^
#!/bin/bash
ROOT=output
CC=x86_64-linux-musl-g++
CFLAGS="
-nostdinc
-isystem $ROOT/x86_64-linux-musl/include/c++/7.2.0
-isystem $ROOT/x86_64-linux-musl/include/c++/7.2.0/x86_64-linux-musl
-isystem $ROOT/x86_64-linux-musl/include/c++/7.2.0/backward
-isystem $ROOT/x86_64-linux-musl/include/
@Leandros
Leandros / fix.sh
Last active January 17, 2018 11:41
Rewrite git author
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
VERSION=$(git --version | cut -b13- | sed -n 's/.*[0-9]*\.\([0-9]*\)\.[0-9]*.*/\1/p')
if [ "$VERSION" -lt 15 ]; then
echo "git version 2.15.0 or higher required"
echo "please upgrade your git: brew upgrade git"
exit 1
fi
@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
auto PtrLiteral = new (S.Context) CXXNullPtrLiteralExpr(
S.Context.NullPtrTy, NTTP->getLocation());
Expr *Value =
S.ImpCastExprToType(PtrLiteral, NullPtrType, CK_NullToPointer)
.get();
DeducedTemplateArgument NewDeduced(S.Context.getCanonicalTemplateName(Arg));
DeducedTemplateArgument Result = checkDeducedTemplateArguments(
S.Context,
@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.
//
//===----------------------------------------------------------------------===//