Skip to content

Instantly share code, notes, and snippets.

@andr-ew
andr-ew / ltc.py
Created August 27, 2020 16:53
lines python timechart
# usage:
# $ python3 ltc.py "America/Chicago" "8/27/2020 15:00"
# 01PM MST
# 01PM PDT
# ...
# 04:00 AWST
# 04:45 +0845
# ...
import pytz, datetime, argparse
@andr-ew
andr-ew / ztable.lua
Last active December 3, 2020 01:50
z sorted table (static)
ztable = { zsort = {} }
local function zcomp(a, b)
if type(a) == 'table' and type(b) == 'table' and a.z and b.z then
return a.z > b.z
else return false end
end
local function format(t, k, v)
if type(v) == "table" then
@andr-ew
andr-ew / binary-param-test.lua
Last active March 2, 2021 20:18
binary-param-test.lua
-- param test test
cs = require 'controlspec'
px = 48
py = 16
function init()
params:add{ type='binary', id='tog', behavior='toggle', action=function(v) print('tog: ' .. tostring(v)) end }
params:add{ type='binary', id='mom', behavior='momentary', action=function(v) print('mom: ' .. tostring(v)) end }
@andr-ew
andr-ew / syncolor.vim
Last active March 11, 2021 02:48
fix for changing a few syntax colors, replace /usr/share/vim/vim80/syntax/syncolor.vim
" Vim syntax support file
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2001 Sep 12
" This file sets up the default methods for highlighting.
" It is loaded from "synload.vim" and from Vim for ":syntax reset".
" Also used from init_highlight().
if !exists("syntax_cmd") || syntax_cmd == "on"
" ":syntax on" works like in Vim 5.7: set colors but keep links
@andr-ew
andr-ew / txtbox.lua
Created November 27, 2020 17:59
norns boxed text with alignment & placement options
local function txtbox(txt, x, y, x2, y2, xalign, yalign, font, size, lvl, border, fill, padding, font_headroom, font_leftroom)
font_headroom = font_headroom or 3/8
font_leftroom = font_leftroom or 1/16
screen.font_face(font)
screen.font_size(size)
local fixed = (x2 ~= nil) and (y2 ~= nil)
local width = screen.text_extents(txt)
local height = size * (1 - font_headroom)
#!/bin/bash
# This script takes a remote repository and merges it into
# the current one as a subdirectory
set -e
if [ -z "$1" ]
then
echo "Usage:"
@andr-ew
andr-ew / scales.lua
Created March 8, 2021 18:04
norns scale data
local root, et = 440, 12
local tonics = {
['D#'] = -6,
['C#'] = -8,
['A'] = 0,
['A#'] = 1,
['G'] = -2,
['B'] = 2,
['G#'] = -1,
@andr-ew
andr-ew / gendy-video.scd
Created May 27, 2021 15:19
gendy.kr() video
(
ServerOptions.devices;
s.options.device = "UMC404HD 192k";
s.boot;
)
(
~cc = Bus.control(s, 7);
MIDIIn.connectAll;
@andr-ew
andr-ew / fingers.lua
Created September 21, 2021 19:24
nest_ fingers demo
include 'nest_/lib/nest/core'
include 'nest_/lib/nest/norns'
include 'nest_/lib/nest/grid'
n = nest_ {
range = _grid.range {
x = { 1, 16 },
z = -1, --range shows up below tog
lvl = 4
},
@andr-ew
andr-ew / wrap.lua
Last active September 21, 2021 19:37
nest_ wrap example
include 'nest_/lib/nest/core'
include 'nest_/lib/nest/norns'
include 'nest_/lib/nest/grid'
n = nest_ {
num = _grid.number {
x = { 2, 14 }, y = 2,
wrap = 5, --wrap to the next line after 5 keys
level = { 4, 15 },
action = function(s, v) print(v) end --v is still range 1 - 13