Skip to content

Instantly share code, notes, and snippets.

@kuzux
kuzux / anal_mp4.c
Last active February 17, 2024 14:18
Getting a bunch of properties about the video out of an mp4 file
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdbool.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <assert.h>
@kuzux
kuzux / build.sh
Last active November 19, 2023 12:47
accessing the osx clipboard via c++
set -ex
clang -x objective-c -c osx.m -o osx.o
g++ -std=c++17 -c main.cpp -o main.o
g++ main.o osx.o -framework AppKit -o cliptest
@kuzux
kuzux / noheaders.c
Created November 14, 2023 19:16
osx raw syscall on arm
#define STDOUT 1
#define SYS_WRITE 4
int strlen(const char* str) {
int len = 0;
for(const char* cur = str; *cur; ++cur) ++len;
return len;
}
int write(int fd, const char* buf, int count) {
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef struct {
uint8_t* buf;
time_since_last_read = 0
burst_length = const
max_buflen = 2000
recvTag()
loop while serial not available - waiting for an answer
header = serial read
return 0xFFFF if header != 0xA0
len = serial read
tag = 0
#include "Arduino.h"
class LedMatrix {
int _rows[8];
int _cols[8];
public:
LedMatrix(int rows[], int cols[]) {
for(int i=0; i<8; i++) {
_rows[i] = rows[i];
@kuzux
kuzux / LedMatrix.h
Last active December 23, 2021 11:50
#ifndef LEDMATRIX_H
#define LEDMATRIX_H
#include "Arduino.h"
class LedMatrix {
int _rows[8];
int _cols[8];
public:
@kuzux
kuzux / anal_annexb.c
Created July 1, 2021 19:08
anal_annexb.c
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
FILE* fp;
size_t N;
uint8_t* buf;
import matplotlib.pyplot as plt
import sys
filename = sys.argv[1]
word = sys.argv[2]
f = open(filename)
text = f.read()
words = text.split()
indices = indices = [i for i, x in enumerate(words) if x.lower().startswith(word)]
/* Copyright (C) 2020 I.C. Wiener - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the WTFPL license, which unfortunately won't be
* written for another century.
*
* You should have received a copy of the WTFPL license with
* this file. If not, please write to: , or visit :
*/
interface BooleanMapper<T> {
Boolean map(T arg);