Skip to content

Instantly share code, notes, and snippets.

View christophercrouzet's full-sized avatar

Christopher Crouzet christophercrouzet

View GitHub Profile
@christophercrouzet
christophercrouzet / atr-percent-indicator.md
Last active November 16, 2024 22:54
Alternative ATR% Formula

I'm seeing websites computing ATR% with (ATR / close) * 100, and I believe this yields unintuitive results.

Let's take the popular ADR indicator as a simpler example. Its absolute value, without accounting for the averaging, is the distance between high and low high - low. Its relative value, used for computing the ADR% indicator popularized by Kristjan Kullamägi, is (high / low - 1.0) * 100.0, which essentially represents how stretched a candle is.

If we were to apply the relative formula recommended for the ATR% to compute our ADR%, we'd get (high - low) / close * 100.0. This represents an awkward distance between the high and low relative to the candle's close. For two candles having the same height, their ADR% could vastly differ depending depending on where the close is located within that candle's range. This isn't really what we want, is it?

![image](https://camo.githubusercontent.com/e69f598cd0c92b15dce1bd0778f29aeb84d0a110d4fbcd00c11c25bc03413634/68747470733a2f2f692e696d6775722e636f6d2f673

@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()