Skip to content

Instantly share code, notes, and snippets.

View ox's full-sized avatar
👹
what is this, AIM?

Artem Titoulenko ox

👹
what is this, AIM?
View GitHub Profile
@ox
ox / go-docs.optic
Last active February 8, 2024 16:39
Optic for Stract search engine to boost golang docs for queries that start with go or golang
Rule {
Matches {
Domain("pkg.go.dev")
}
Action(Boost(10))
}
@ox
ox / react_form_reducer_proxy.jsx
Created January 9, 2023 20:56
Experimenting with using a reducer and a proxy to make controlled from inputs in React. A little messy, maybe too much?
import React, {useState, useReducer} from 'react';
const CHANGE_VALUE = 'change_value';
function formReducer(state, action) {
switch(action.type) {
case CHANGE_VALUE:
return {...state, [action.name]: action.value};
default:
return state;
@ox
ox / TasksController.mjs
Last active January 5, 2023 23:32
Example Lit data store using immer and ulid
import produce from "https://cdn.jsdelivr.net/npm/immer/+esm";
import { ulid } from "https://unpkg.com/ulid@2.3.0/dist/index.esm.js";
// BaseStore is responsible for managing subscribers to the store and
// notifying them of changes.
class BaseStore {
constructor() {
this.subscribers = new Set([]);
}
@ox
ox / uxnemu.c.diff
Created August 14, 2021 21:15
Patch to toggle full-screen mode
diff --git a/projects/examples/demos/font.tal b/projects/examples/demos/font.tal
index 512ba5d..1513a6f 100644
--- a/projects/examples/demos/font.tal
+++ b/projects/examples/demos/font.tal
@@ -188,4 +188,4 @@ RTN
@font-path-small
"projects/fonts/atari8.uf1 $1
-@font-data
\ No newline at end of file
@ox
ox / guess-number.tal
Created August 13, 2021 22:26
Classic guess the number game written in Uxntal
( guess-number.tal )
%RTN { JMP2r }
%PRINT { ;print JSR2 }
%BR { #0a .Console/write DEO }
%BREAKPOINT { #0101 #0e DEO2 }
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
@ox
ox / to-mp3.sh
Created May 22, 2020 17:47
Converts any audio/video source to a 320kbps MP3 file in the same directory using ffmpeg.
#!/bin/bash
if [[ "$#" -ne 1 ]]; then
echo "Usage: to-mp3.sh <input source>"
exit 1
fi
set -ex
ffmpeg -hide_banner -loglevel warning -i "${1}" -b:a 320k "${1%.*}.mp3"
@ox
ox / to-gif.sh
Created May 22, 2020 17:46
Converts videos to gifs using ffmpeg. It creates a color palette to keep gif sizes low; hard-coded 15fps.
#!/bin/bash
if [[ "$#" -ne 2 ]]; then
echo "Usage: to-gif.sh <input video> <output gif>"
exit 1
fi
set -ex
# Generate a palette to cut down on space
@ox
ox / min-heap.py
Created March 17, 2020 05:11
MinHeap implementation in python3
from random import shuffle
class MinHeap:
def __init__(self):
self.arr = []
def __len__(self):
return len(self.arr)
def __nth_child(self, i, n):
@ox
ox / errata.md
Last active July 2, 2019 01:06
Computational Drawing, First Edition Errata

Computational Drawing Errata

Chapter 1

  • p37.: The variablyThickLine function has an argument named thinMoments but the code body uses thickMoments
  • There was another missing word I had found in Chapter 1, but I failed to mark it down. It was before p37 is all I remember.

Chapter 2

  • p80.: "relishes in ambiguity and has made ^a design computation career..."
@ox
ox / base.css
Last active June 16, 2019 22:33
Starter CSS template, based on https://every-layout.dev/
:root {
/* Modular Scale */
--ratio: 1.5;
--s-5: calc(var(--s-4) / var(--ratio));
--s-4: calc(var(--s-3) / var(--ratio));
--s-3: calc(var(--s-2) / var(--ratio));
--s-2: calc(var(--s-1) / var(--ratio));
--s-1: calc(var(--s0) / var(--ratio));
--s0: 1rem;
--s1: calc(var(--s0) * var(--ratio));