Skip to content

Instantly share code, notes, and snippets.

local points = {}
local trails = {}
local N = 100
local w,h = love.graphics.getDimensions()
print(w,h)
local function color(x,y)
local th = (x+y)/20
return {(math.cos(th)+1)/2, (math.sin(th)+1)/2, (math.cos(th+math.pi/2+1))/2}
#!/bin/env bash
if [[ -f ~/unjscal ]]; then
echo "dont calibrate"
rm ~/unjscal
exit
fi
#---joydev cal---
jscal -s 8,1,0,135,135,11184469,20648251,1,0,116,116,13094012,14509581,1,0,126,126,5711218,5899500,1,0,28,28,107370905,2618802,1,0,30,30,178951509,2606089,1,0,127,127,5835375,5592234,1,0,0,0,536854528,536854528,1,0,0,0,536854528,536854528 /dev/input/js0
@lemon32767
lemon32767 / sdlthread.zig
Created November 23, 2019 14:08
thin wrapper around SDL_Thread's in zig
////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2019 lemon sherbet
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from
// the use of this software.
//
// Permission is granted to anyone to use this software
// for any purpose, including commercial applications, and to alter it
@lemon32767
lemon32767 / neocpkg
Last active December 22, 2019 17:19
neocities pkg archival tool
#!/bin/python
import sys, os, subprocess, re
if len(sys.argv) < 2:
print("""\
usage: neocpkg <command> [neocities website name | website/pkg]
commands:
init\t create a repo here
@lemon32767
lemon32767 / vd.c
Last active April 4, 2020 11:02
scanline based rendering with SDL2
#include <SDL2/SDL.h>
#include<math.h>
enum {FALSE ,TRUE};
enum {W=600,H=400};
int _SCROLLX = 0;
int _SCROLLY = 0;
SDL_Surface* screen;
@lemon32767
lemon32767 / fix32.cc
Last active April 28, 2020 14:10
16:16 fixed point
#include <stdint.h>
#include <cstdio>
#include <iostream>
#include <cmath>
typedef struct fix32 {
int32_t n;
static const int32_t FACTOR = (1<<16);
//constructor
@lemon32767
lemon32767 / mmacrofmt.py
Last active May 6, 2020 09:25
format C multiline macros
#!/bin/python
"""
usage: mmacrofmt.py [tabsize] < infile > outfile
formats something like:
#define X(a) \
whatever \
missing a backslash
//some comment
hmm\
#!/bin/env python
import subprocess, json, re, shutil, os
srcurl = "https://ziglang.org/download/index.json"
tmppath = "/tmp/zig-master.tar.xz"
print(" > downloading index...")
src = subprocess.check_output(["curl", "-L", srcurl])
@lemon32767
lemon32767 / bitreg.zig
Last active August 25, 2020 21:56
zig bitreg type
const std = @import("std");
const assert = std.debug.assert;
const trait = std.meta.trait;
//example:
// BitReg(u32, .{
// .{.first_4_bits, 0, 4},
// .{.next_7_bits, 4, 7},
// })
pub fn BitReg(comptime T: type, comptime fields: anytype) type {
const check_or = struct {
#!/bin/env python3
import sys, string
def str_findp(start, s, pred):
for i in range(start,len(s)):
if pred(s[i]):
return i
return None
#takes a list of lines as template for the ascii art; and a list of tokens (for example, words) to replace it with