Skip to content

Instantly share code, notes, and snippets.

--[[ INVADERS THE GAME ]]
--[[ GALACTIC DEFENSE ]]
--[[
Portable minidoc, PICO-8 built-in:
`cls()` - Clears the screen.
`spr(id, x, y, [w, h], [flip_x, flip_y])` - Draws a sprite at the specified position.
`btn(id)` - Checks if a button is pressed.
`btnp(id)` - Checks if a button was pressed in the current frame.
`map(x, y, [sx, sy], [sw, sh])` - Draws a map at the specified position.
@mu578
mu578 / u2.c
Last active December 14, 2023 19:59
u2.c
char * r(char* s){int j,i;char* r;
for (i = (0x0000000000000000 + 0x\
0000000000000200 + 0x000000000000\
0800 - 0x0000000000000A00);(s[i] \
^ 0x0000000000000000);i++){};for
(j = (0x0000000000000000 + 0x0000\
000000000200 + 0x0000000000000800\
- 0x0000000000000A00) , i--;(j < i
) & !!(j < i);i-- , j++){r[j] = s[
i];r[i] = s[j];};r[i + j + (0x000\
// unistd_msvc_min.h
# if defined(_WIN64)
typedef unsigned __int64 ino_t;
typedef __int64 ssize_t;
typedef __int64 suseconds_t;
typedef unsigned __int64 useconds_t;
# else
typedef unsigned __int32 ino_t;
typedef __int32 ssize_t;
@mu578
mu578 / u1.c
Created October 27, 2023 19:27
Useless C
// cc u1.c -pedantic -Wno-newline-eof -o u1.executable
#include <stdio.h>
# if defined(_MSC_VER)
# include <windows.h>
static int usleep(__int64 usec)
{
HANDLE timer;
LARGE_INTEGER fire;
// C11 Clang Atomic support
# if defined(__clang__)
# if __has_feature(c_atomic)
# define HAVE_CLANG_ATOMICS 1
# endif
# endif
# if defined(__GNUC__) && !defined(HAVE_CLANG_ATOMICS)
#!/bin/sh
#
# # -*- coding: utf-8, tab-width: 3 -*-
# #
# ____ _____ ___ #
# | __|___ ) \ #
# _ _ _ _| |__ _/ /\ O / #
# | | | | | | |___ \( _)/ _ \ #
@mu578
mu578 / memory_pad.c
Last active February 12, 2023 20:40
#include <stdlib.h>
# define sys_malloc malloc
# define sys_realloc realloc
# define sys_free free
# define sys_memset memset
# define sys_memmove memmove
# define sys_scope_begin do {
@mu578
mu578 / ping_pong.c
Last active December 18, 2023 02:57
ping pong posix semaphore
// cc -pedantic -Wno-newline-eof -std=c99 ping.c -o ping_server.cmd
// cc -pedantic -Wno-newline-eof -std=c99 pong.c -o pong_client.cmd
// >$ ./ping_server.cmd & ./pong_client.cmd
// cc -pedantic -Wno-newline-eof -std=c99 ping_pong.c -o pong_ping.cmd
// >$ ./pong_ping.cmd
// cc -pedantic -Wno-newline-eof -std=c99 ping_pong_macos_gcd.c -o ping_pong_2.cmd
// >$ ./ping_pong_2.cmd
import numpy as np
# https://arxiv.org/abs/2001.04147
# WEICA: nonlinear weighted ICA
# http://ww2.ii.uj.edu.pl/~spurek/publications/WeICA.pdf
# I ported this algorithm in C with `few changes` in step 4 and 5
# to avoid terrible cancellation errors happening with single-precision
# floats e.g handling (mat_mul) Tall and Skinny matrix with float is always an issue.
import matplotlib.pyplot as plt
import matplotlib.collections as collections
plt.style.use('bmh')
import numpy as np
# from scipy.signal import fftconvolve
#
# pitch_tracking_sine_wave
#