Skip to content

Instantly share code, notes, and snippets.

Christian Fillion cfillion

Block or report user

Report or block cfillion

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cfillion
cfillion / TLC591x_R-EXT.rb
Last active Sep 24, 2019
Calculate valid output current ranges for given R-EXT values [TLC5916/TLC5917 8-Channel Constant-Current LED Sink Driver]
View TLC591x_R-EXT.rb
#!/bin/env ruby
#
# TLC5916/TLC5917 8-Channel Constant-Current LED Sink Driver
# Calculate valid output current ranges for given R-EXT values
#
# Run with no arguments to print all valid ranges for common E12 and E96 values
# See ./TLC591x_R-EXT.rb --help for usage instructions and supported options.
#
# Example 1: ./TLC591x_R-EXT.rb 360 720
# Rext= 360Ω Imin= 4.375mA Imax= 52.090mA IΔ= 47.715mA
@cfillion
cfillion / mpasmx
Created Sep 21, 2019
Wrapper to make mpasmx output errors to stderr and fail with a proper exit code
View mpasmx
#!/bin/sh
errfile="$(mktemp)"
exit=0
/opt/microchip/mplabx/v*.*/mpasmx/mpasmx -e"$errfile" "$@"
if [ -s "$errfile" ]; then
cat "$errfile" >&2
exit=1
View cfillion_Save and compare opened project tabs.lua
-- @version 1.0beta
-- @author cfillion
local EXT_SECTION = 'cfillion_project_list'
local function makeKey(i)
return string.format('project%d', i)
end
local function enumOpenedProjects()
@cfillion
cfillion / orignal-poster.user.js
Last active Apr 25, 2019
Show an indicator beside an original poster's post on the REAPER forums https://i.imgur.com/oxUj5Ws.png
View orignal-poster.user.js
// ==UserScript==
// @name Original poster indicator
// @namespace https://cfillion.ca
// @version 1.1
// @author cfillion
// @include https://forum.cockos.com/showthread.php*
// ==/UserScript==
function getPosters(doc)
{
@cfillion
cfillion / reascript_vararg.hpp
Last active Apr 22, 2019
Compile-time ReaScript API vararg wrapper generator for REAPER extensions (C++17)
View reascript_vararg.hpp
// Extracted from ReaPack's source code (LGPL v3)
/* Usage example:
static int HelloWorld(int foo, int bar) { return foo * bar; }
extern "C" REAPER_PLUGIN_DLL_EXPORT int REAPER_PLUGIN_ENTRYPOINT(
REAPER_PLUGIN_HINSTANCE instance, reaper_plugin_info_t *rec)
{
// ...
// API_HelloWorld and APIdef_HelloWorld must also be registered as usual
@cfillion
cfillion / reaper_square.cpp
Last active Mar 18, 2019
A REAPER extension that draws a red square on the arrange view.
View reaper_square.cpp
#include <memory>
#ifdef _WIN32
# include <windows.h>
#else
# include <swell/swell.h>
# include <wdltypes.h> // GWLP_WNDPROC
#endif
#define REAPERAPI_IMPLEMENT
View reaper-keyboard-intercept.cpp
// Demo REAPER extension to intercept keyboard input
// https://i.imgur.com/xMSrqRr.gif
#include <cstdio>
#include <reaper_plugin.h>
static int (*plugin_register)(const char *name, void *infostruct);
static int HandleKey(MSG *, accelerator_register_t *);
static accelerator_register_t g_accel{HandleKey, true};
View Check whether js_ReascriptAPI is installed.lua
function checkJSAPI(requiredVersion)
if reaper.JS_ReaScriptAPI_Version and reaper.JS_ReaScriptAPI_Version() >= requiredVersion then
return true
end
local button = reaper.MB(string.format([[
This script requires js_ReaScriptAPI %s or newer. Do you want to install it now?
Choose [Yes] to open ReaPack's package browser.
]], requiredVersion), "js_ReaScriptAPI not found", 4)
@cfillion
cfillion / wav-parser.lua
Last active Oct 17, 2018
Lua WAV file reader (chunk parser)
View wav-parser.lua
-- http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
-- usage example at the end
local WavReader = {}
WavReader.__index = WavReader
function WavReader.new(fn)
local self = setmetatable({}, WavReader)
self.file, err = io.open(fn)
@cfillion
cfillion / fctest.cpp
Last active Aug 16, 2018
Font family matching with FontConfig demo
View fctest.cpp
// c++ -lfontconfig fctest.cpp
// ./a.out 'DejaVu Sans Mono' monospace 'Andale Mono' 'Ubuntu Mono' Lato
#include <cstdio>
#include <fontconfig/fontconfig.h>
class FontConfig {
public:
FontConfig() : m_config(FcInitLoadConfigAndFonts()) {}
FontConfig(const FontConfig &) = delete;
You can’t perform that action at this time.