Skip to content

Instantly share code, notes, and snippets.

View christophercrouzet's full-sized avatar

Christopher Crouzet christophercrouzet

View GitHub Profile
@christophercrouzet
christophercrouzet / README.md
Last active January 14, 2022 07:50
Matching types with the Clang AST

Using the tmp.cpp snippet below and clang-query with the following query...

// single line:

match typeLoc(isExpansionInMainFile(), loc(qualType(hasDeclaration(decl(hasAncestor(namespaceDecl(hasName("std"))))))))


// prettified:
@christophercrouzet
christophercrouzet / usd.log
Created November 10, 2021 19:58
Profiling of Pixar's USD compilation time using ClangBuildAnalyzer
cmake \
-DCMAKE_INSTALL_PREFIX="$(BUILD_DIR)" \
-DCMAKE_PREFIX_PATH="$(DEPS_DIR)/dist" \
-DCMAKE_BUILD_TYPE=Release \
-DPXR_PREFER_SAFETY_OVER_SPEED=ON \
-DPXR_ENABLE_PYTHON_SUPPORT=ON \
-DPXR_USE_PYTHON_3=ON \
-DPXR_USE_DEBUG_PYTHON=OFF \
-DPYTHON_EXECUTABLE="/usr/bin/python3" \
-DPYTHON_LIBRARY="/usr/lib/x86_64-linux-gnu/libpython3.8.so" \
@christophercrouzet
christophercrouzet / main.c
Last active May 27, 2021 10:11
Linux's `mremap()`
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/mman.h>
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
_DIGIT_CHAR_OFFSET = ord('0')
_SIGN_TABLE = ('-', '')
@christophercrouzet
christophercrouzet / main.c
Created November 16, 2019 21:45
Designated Initializer Macro for C99 and C++
#include <stdio.h>
/* -------------------------------------------------------------------------- */
#define EXPAND(x) x
#define CONCAT_(a, b) a##b
#define CONCAT(a, b) CONCAT_(a, b)
#define ARG( \
@christophercrouzet
christophercrouzet / countargs.h
Created September 14, 2019 02:15
Counting Variadic Macro Arguments in C99 and C++
/*
Credits: Jens Gustedt
https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments
*/
#include <stdio.h>
#define EXPAND(x) x
#define CONCAT_(a, b) a##b
@christophercrouzet
christophercrouzet / mayabake.py
Created December 24, 2016 14:03
Quick and dirty prototype of a naive animation bake implementation for Autodesk Maya.
#!/usr/bin/env mayapy
import itertools
import math
import random
import timeit
from maya import cmds, OpenMaya, OpenMayaAnim
@christophercrouzet
christophercrouzet / google_foobar-3_1_find_the_access_codes.py
Last active June 12, 2023 23:41
Failed attempt at the exercise level 3.1 “Find the Access Codes“ from Google's Foobar challenge.
#!/usr/bin/env python2.7
"""Find the Access Codes
In order to destroy Commander Lambda's LAMBCHOP doomsday device, you'll need
access to it. But the only door leading to the LAMBCHOP chamber is secured with
a unique lock system whose number of passcodes changes daily. Commander Lambda
gets a report every day that includes the locks' access codes, but only she
knows how to figure out which of several lists contains the access codes. You
need to find a way to determine which list contains the access codes once
@christophercrouzet
christophercrouzet / mayaskin.py
Last active January 28, 2020 05:14
Quick and dirty Maya skin load/save
# Relies on https://github.com/christophercrouzet/banana.maya
import collections
import json
from maya import OpenMaya, OpenMayaAnim, cmds
import banana.maya
banana.maya.patch()
@christophercrouzet
christophercrouzet / multiprocessing.py
Created August 24, 2016 07:15
Python's asynchronous queues vs synchronous pipes.
#!/usr/bin/env python3
import logging
import multiprocessing
_LOGGER = multiprocessing.log_to_stderr()
_LOGGER.setLevel(logging.DEBUG)