Skip to content

Instantly share code, notes, and snippets.

@lvm
lvm / plasma.py
Created January 27, 2024 04:39
plain text plasma p/raspi w/3.5 screen
import math
import time
s = math.sin
q = math.sqrt
i = lambda a, b, c: a in range(b, c)
def c(x, y):
# http://www.purplemath.com/modules/distform.htm
t = time.time() * 1000 / 74
;; mkdir -p $HOME/.emacs.d/themes \
;; && mkdir -p $HOME/.emacs.d/lisp \
;; && wget https://raw.githubusercontent.com/lvm/monochrome-theme.el/master/monochrome-transparent-theme.el -O $HOME/.emacs.d/themes/monochrome-transparent-theme.el
(require 'package)
(custom-set-variables
'(package-archives
(quote
(("gnu" . "http://elpa.gnu.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/")))))
@lvm
lvm / flatten.py
Created August 28, 2020 05:03
Flat nested dicts.
def flatten(dct: dict, , prefix="", glue: str = "__") -> dict:
flat = {}
prefix = f"{prefix}{glue}" if prefix else ""
def _flat(dct):
_dct = {}
for k, v in dct.items():
if not isinstance(v, list) and not isinstance(v, dict):
_dct[k] = v
@lvm
lvm / youtube-mp3
Last active August 19, 2020 22:54
#!/usr/bin/env python3
import re
import eyed3
import shlex
import string
import argparse
import youtube_dl
import subprocess as sp
from pathlib import Path
@lvm
lvm / youtube-slice
Last active August 18, 2020 01:23
youtube-dl a portion of a video.
#!/usr/bin/env python3
import shlex
import argparse
import youtube_dl
import subprocess as sp
from pathlib import Path
from youtube_dl.utils import sanitize_filename
@lvm
lvm / admin.py
Created February 11, 2020 22:04 — forked from mariocesar/admin.py
Django admin decorator to create a confirmation form action, like the default delete action works
from .models import Post, Category
from .decorators import action_form
class PostCategoryForm(forms.Form):
title = 'Update category for the selected posts'
category = forms.ModelChoiceField(queryset=Category.objects.all())
@admin.register(Post)
@lvm
lvm / ddupe
Created September 2, 2019 14:02
find dupe directories, only 1 level.
#!/usr/bin/env python3
import argparse
from pathlib import Path
def get_dirs(path):
return dict([(x.name,x.as_posix())
for x in path.iterdir()
if x.is_dir()])
@lvm
lvm / ageis.scd
Created April 30, 2019 22:57
ageispolis midi.scd
z = SimpleMIDIFile.read("/home/mauro/Downloads/General MIDIMan - Ageispolis.mid")
(
x = { |smf, channel, track|
var pending = IdentitySet.new, buf = MIDIRecBuf(\seq).absoluteOnsets_(true),
events = smf.noteEvents(channel, track).sort { |a, b|
if(a[1] == b[1]) {
a[2] > b[2] // equal time, put noteOn first
} {
a[1] < b[1] // earlier time first
}
@lvm
lvm / SynthDefExtras.sc
Created February 1, 2019 17:03
synthdef general helpers
+ Symbol {
args {
^SynthDescLib.global.at(this);
}
function {
^SynthDescLib.global.at(this).def.func;
}