Skip to content

Instantly share code, notes, and snippets.

@lostfictions
lostfictions / toggle-nightlight.sh
Created October 23, 2022 05:46
toggle gnome night light from shell or via keyboard shortcut
#!/usr/bin/env bash
set -euo pipefail
BUS_NAME="org.gnome.SettingsDaemon.Color"
OBJECT_PATH="/org/gnome/SettingsDaemon/Color"
TRUE="variant:boolean:true"
FALSE="variant:boolean:false"
set_disabled() {
@lostfictions
lostfictions / yt-clip.py
Last active March 12, 2024 08:21
clip a youtube video with yt-dlp and ffmpeg
#!/usr/bin/env python3
import subprocess
import argparse
from datetime import datetime
from urllib.parse import urlparse
from typing import List, Union
parser = argparse.ArgumentParser(
description="yt-clip: clip videos (from youtube, files, or other websites) by timestamp with the help of yt-dlp and ffmpeg."
)
@lostfictions
lostfictions / linux-streaming-setup.md
Last active April 16, 2023 02:22
Script to set up (and tear down) PulseAudio sinks for streaming to Discord or Twitch (including, optionally, via a capture device)

A Somewhat Better Setup for Streaming from Linux

I couldn't find a great way to set up streaming to Discord or Twitch from Linux, so I wrote this.

Intro

The script included below, streaming.sh, is meant to be used in tandem with the PulseAudio Volume Control application (pavucontrol, which is available in repositories for most distributions that use Pulse but might not be installed by default). It adds two PulseAudio "sinks" (destinations) that you can

@lostfictions
lostfictions / staticgen-notes.md
Last active March 22, 2019 21:45
Some Notes on Static Site Generators

(work in progress! notes will be updated as generators are re-evaluated.)

A Tale of Three Generators

Static site generators are far from a solved problem. It's a deceptively simple proposition: grab some data -- say, blog posts written in Markdown files -- stick them in templates, and spit out a set of HTML files, ready to be served as-is on something like GitHub Pages, no complex server code needed. And indeed, there have been hundreds of takes on the idea, running the gamut of pretty much every programming and templating language imaginable.

using UnityEngine;
using System;
using System.Collections.Generic;
using Debug = UnityEngine.Debug;
using Object = UnityEngine.Object;
using System.Linq;
using System.IO;
using UnityEditor;
@lostfictions
lostfictions / svg-to-css-clip-path-polygon.js
Created January 2, 2018 02:01
convert an svg to a css clip-path polygon
// why do this? clip-path accepts a `url` reference to an svg element, right?
// the difference is that anything defined as a `basic-shape` can be animated:
// https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path
const input = `121.151,20.761 170.165,55.885 200.872,3.816 231.145,55.884 280.592,20.762 286.854,80.687 346.526,68.666
327.657,126.005 387.276,139.247 346.502,184 395.796,220.302 340.127,244.647 370.611,297.814 309.636,297.457 316.076,358.381
260.303,333.3 241.622,391.529 200.655,345.979 160.121,391.53 141.008,333.302 85.666,358.381 91.673,297.456 31.131,297.813
61.183,244.647 5.947,220.302 54.81,184 14.466,139.248 73.652,126.004 55.216,68.667 114.457,80.688 `
const viewBoxScale = 4
@lostfictions
lostfictions / minitrace-2.js
Last active January 25, 2024 05:03
tiny tracery, take two
const randomInArray = arr => arr[Math.floor(Math.random() * arr.length)]
const isVowel = char => /^[aeiou]$/i.test(char)
const matcher = /\[([^\[\]]+)\]/g
export default function trace({concepts, concept, maxCycles = 10, seen = {}, modifierList = defaultModifiers}) {
const [resolvedConcept, ...modifierChunks] = concept.split('|')
const modifiers = modifierChunks
.map(chunk => {
const [modifierName, ...args] = chunk.split(' ')
@lostfictions
lostfictions / converter.js
Last active July 20, 2016 18:40
Node script to convert any type of file VLC can read into a Unity import-friendly .ogv format.
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
const efs = require('child_process').execFileSync
const vlcPath = path.resolve('C\:/Program\ Files/VideoLAN/VLC/vlc.exe')
const getVlcArgs = (inputFile, outputFile) =>
`"${inputFile}" :sout='#transcode{vcodec=theo,vb=800,scale=1,acodec=vorb,ab=128,channels=2,samplerate=44100}:file{dst="${outputFile}"}' vlc://quit --intf dummy`
@lostfictions
lostfictions / minitrace.js
Last active November 27, 2021 20:08
tiny tiny tracery-like
const matcher = /\[([^\[\]]+)\]/g
function randomInArray(arr) { return arr[Math.floor(Math.random() * arr.length)] }
export default function generate(concepts, concept, maxCycles = 10, seen = {}) {
if(!concepts[concept]) {
return `{error: unknown concept "${concept}"}`
}
return randomInArray(concepts[concept])
.replace(matcher, (_, nextConcept) => {
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>avre</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
.squiggle {