Skip to content

Instantly share code, notes, and snippets.


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](

tupui /
Last active Apr 6, 2022
Halton Sequence in python
"""Halton low discrepancy sequence.
This snippet implements the Halton sequence following the generalization of
a sequence of *Van der Corput* in n-dimensions.
MIT License
Copyright (c) 2017 Pamphile Tupui ROY
t-abe /
Created Apr 28, 2017
Hook implementation to calculate roughly estimated computational cost of a given network for Chainer
from __future__ import print_function
import sys
import chainer
from chainer.utils import conv
class ComputationalCostHook(chainer.function.FunctionHook):
name = 'ComputationalCostHook'

Aligning images

left alignment

This is the code you need to align images to the left:

dcommander / Makefile
Last active Feb 7, 2022
Simple program to demonstrate OpenGL rendering without an X server
View Makefile
all: egltest
egltest: egltest.c
cc -O3 -Wall -Werror -I. -o $@ $^ -lOpenGL -lEGL
rm -f *.o egltest
pbugnion /
Last active Apr 24, 2022
Keeping IPython notebooks under Git version control

This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.

To use the script, follow the instructions given in the script's docstring.

For further details, read this blogpost.

The procedure outlined here is inspired by this answer on Stack Overflow.

eric-hu / Open iterm tab here
Last active Mar 11, 2022
Apple script to open an iterm2 tab from right-clicking on a file or folder in Finder. To use: (1) Open Automator (2) Create a new service (3) Change "Service receives selected" drop downs to "Files or folders" in "Finder" (4) Select "Run applescript" from the sidebar, then paste this script in and save
View Open iterm tab here
-- Adapted from these sources:
-- Modified to work with files as well, cd-ing to their container folder
on run {input, parameters}
tell application "Finder"
set my_file to first item of input
set filetype to (kind of (info for my_file))
-- Treats OS X applications as files. To treat them as folders, integrate this SO answer:
phette23 /
Last active May 6, 2022
Set the iTerm tab title to the current directory, not full path.
# put this in your .bash_profile
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
# Piece-by-Piece Explanation:
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too
# the $PROMPT_COMMAND environment variable is executed every time a command is run
# see:
View ec2-ssh
set -e
while [ $# -gt 0 ]; do
case $1 in
if [ -z "$2" ]; then
TotallyGatsby / gitignore Unity
Created Jun 18, 2012
Unity .gitignore file
View gitignore Unity
#This is the git ignore file used in Duck Hunted
#Note that ! negates an ignore. We ignore everything in Library then
#un-ignore the metadata folder and some specific files
#Use at your own risk, this may totally destroy your project, but it worked for us
#NOTE: this will cause your collaborators to re-import assets periodically