Skip to content

Instantly share code, notes, and snippets.

@billywhizz
billywhizz / testloop.c
Created July 16, 2011 17:39
testing cpu write combining performance characteristics with loops
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
/*
This program tests the performance characteristics of write combining
On an intel CPU only 4 writes at a time will be combined so we should see
a big performance improvement if we only write to distinct memory locations
<=4 times per iteration of a loop
@rlane
rlane / matrix.glsl
Created September 17, 2011 01:12
GLSL matrix functions
mat4 translate(vec3 d)
{
return mat4(1, 0, 0, d.x,
0, 1, 0, d.y,
0, 0, 1, d.z,
0, 0, 0, 1);
}
mat4 scale(float c)
{
@eskil
eskil / ctassert.h
Created July 10, 2012 01:18
Example of how to implement static assert using template specialisation.
template<bool> struct _compile_time_assert;
template<> struct _compile_time_assert<true> {};
#define ctassert(expr) if (0) { int flaming_goat_sausage = sizeof(_compile_time_assert<(bool)(expr)>); flaming_goat_sausage++; }
int main (int argc, char *argv[]) {
ctassert (sizeof (int) == 4);
ctassert ((sizeof (int) == 5) == false);
//BLAM
ctassert (sizeof (int) == 5);
@ajdavis
ajdavis / start_process.py
Created August 13, 2013 15:47
Start a process and redirect its stdout and stderr to /dev/null.
try:
from subprocess import DEVNULL # Python 3.
except ImportError:
DEVNULL = open(os.devnull, 'wb')
def start_subprocess(cmd):
"""Run cmd (a list of strings) and return a Popen instance."""
return subprocess.Popen(cmd, stdout=DEVNULL, stderr=DEVNULL)
@tuxfight3r
tuxfight3r / vim-shortcuts.md
Last active May 27, 2025 09:33
VIM SHORTCUTS

VIM KEYBOARD SHORTCUTS

MOVEMENT

h        -   Move left
j        -   Move down
k        -   Move up
l        -   Move right
$        -   Move to end of line
0        -   Move to beginning of line (including whitespace)
@mbinna
mbinna / effective_modern_cmake.md
Last active June 18, 2025 08:43
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@mohanpedala
mohanpedala / bash_strict_mode.md
Last active June 29, 2025 11:00
set -e, -u, -o, -x pipefail explanation
@rylev
rylev / learn.md
Created March 5, 2019 10:50
How to Learn Rust

Learning Rust

The following is a list of resources for learning Rust as well as tips and tricks for learning the language faster.

Warning

Rust is not C or C++ so the way your accustomed to do things in those languages might not work in Rust. The best way to learn Rust is to embrace its best practices and see where that takes you.

The generally recommended path is to start by reading the books, and doing small coding exercises until the rules around borrow checking become intuitive. Once this happens, then you can expand to more real world projects. If you find yourself struggling hard with the borrow checker, seek help. It very well could be that you're trying to solve your problem in a way that goes against how Rust wants you to work.

@chaiyujin
chaiyujin / ubuntu_update_booting_kernel.md
Created December 8, 2020 12:42
Ubuntu: Install Kernel and Set GRUB Default Kernel

Ubuntu: Install Kernel and Set GRUB Default Kernel

Install Kernel

Install the default kernel:

sudo apt install linux-generic

Set GRUB Default Kernel

  1. Find entrance from /boot/grub/grub.cfg
    • Get the $menuentry_id_option: