Skip to content

Instantly share code, notes, and snippets.

View RadicalTeapot's full-sized avatar

Mathias Capdet RadicalTeapot

View GitHub Profile
@RadicalTeapot
RadicalTeapot / new-periodic.lua
Last active May 2, 2024 08:42
Open daily / weekly / monthly note with predefined content
local M = {
config = {
root_dir = "01 Periodic notes",
extension = ".md",
day = {
subdirectory = "daily",
to_string = function(now)
return os.date("%Y-%m-%d", now)
end,
},
@RadicalTeapot
RadicalTeapot / send-to-pandoc.lua
Created April 30, 2024 10:22
Send to pandoc and clean result
vim.api.nvim_create_user_command("SendToPandoc", function(opts)
local start = (opts.line1 or 1) - 1
local last = opts.line2 or -1
local lines = vim.api.nvim_buf_get_lines(0, start, last, false)
local out = vim.system({"pandoc", "--columns=120", "-t", "gfm"}, {stdin=lines, text=true}):wait()
assert(out.code == 0, "An error occured "..(out.stderr or ""))
-- Remove extra pandoc markings
local cleaned = string.gsub(out.stdout, "\\%[", "[")
@RadicalTeapot
RadicalTeapot / planning-layout.lua
Created April 30, 2024 08:03
Open planning files in specific layout in Neovim
local M = {
root_dir = "01 Periodic notes",
suffix = {
day = "daily",
week = "weekly",
month = "monthly",
},
}
M.get_file_names = function()
@RadicalTeapot
RadicalTeapot / window-dimmer.lua
Last active April 29, 2024 12:32
Simple window dimmer for Neovim
local M = {
ns = vim.api.nvim_create_namespace("WindowDimmer"),
augrp_name = "WindowDimmerAuGroup",
hl_group = "Twilight", -- NOTE This supposes the `Twilight" group exists!
enabled = false,
enabled_buf = nil,
}
M.enable = function()
if not M.enabled then
@RadicalTeapot
RadicalTeapot / unit-test.lua
Created April 27, 2024 22:57
Quick and dirty Neovim unit-test runner
local M = {
buf_nr = nil,
suites = {},
window_title = "Results: ",
buffer_namespace = { name = "ResultWindowNS", id = nil },
}
M.clear_internal_buffer = function()
if M.buf_nr ~= nil and vim.fn.bufexists(M.buf_nr) then
vim.api.nvim_buf_delete(M.buf_nr, { force = true })
@RadicalTeapot
RadicalTeapot / main.cpp
Created March 26, 2023 20:35
Read values from analog in and send them out to touchdesigner using serial communication
const size_t count = 6;
const uint8_t pins[count] = {A0, A1, A2, A3, A4, A5};
size_t i;
void setup() {
Serial.begin(9600);
}
void loop() {
for (i = 0; i < count; i++)
@RadicalTeapot
RadicalTeapot / vcv bounds.lua
Created October 12, 2021 04:43
Lua file to load in Wrong People LUA module, inspired by JustMat's Bounds script for Monome Norns
-- Channels
INPUT_CHANNELS = {0, 1} -- Left and right audio input
SPEED_CHANNELS = {2, 3} -- Left and right speed change triggers
FLIP_CHANNELS = {4, 5} -- Left and right direction flip triggers
SKIP_CHANNELS = {6, 7} -- Left and right position skip triggers
OUTPUT_CHANNELS = {0, 1} -- Left and right audio outputs
-- Constants
DURATION = 8 -- Audio buffer duration in seconds
SPEEDS = {0.5, 0.6703, 1, 1.49831} -- Possible play head speed
@RadicalTeapot
RadicalTeapot / testAllocation.html
Created November 18, 2020 10:52
Test javascript allocation speed
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test allocation</title>
</head>
<body>
@RadicalTeapot
RadicalTeapot / CompressionTest.cs
Last active November 16, 2020 13:09
Test various data type arrays conversion to base64 encoded string and their resulting size
using System;
using System.Text;
namespace Test
{
class Program
{
public static readonly Random Rand = new Random();
public static readonly UTF8Encoding Encoding = new UTF8Encoding();
public static readonly int DataLength = ushort.MaxValue;
@RadicalTeapot
RadicalTeapot / Vargrantfile
Created July 8, 2020 13:08
Vagrant setup for Apache Cordova to build android app in Ubuntu 18.04 LTS
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at