Skip to content

Instantly share code, notes, and snippets.

View fluffy-critter's full-sized avatar

fluffy fluffy-critter

View GitHub Profile
@fluffy-critter
fluffy-critter / pngextract.cpp
Created October 18, 2015 03:51
Extract embedded .png files from an uncompressed container
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdint>
#include <iomanip>
#include <cctype>
const uint8_t magicnum[8] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a};
const std::string magicstr(reinterpret_cast<const char*>(magicnum), 8);
# Generate a list of popular names, sortable by their relative androgyny. Data is obtained
# from the SSA website at http://catalog.data.gov/dataset/baby-names-from-social-security-card-applications-national-level-data
#
# The expected input is a .csv file with columns of:
#
# name,assigned gender,count
#
# Some example uses of this program:
#
# Find the most androgynous names from 1978 beginning with Q:
@fluffy-critter
fluffy-critter / sillyhash.cpp
Created April 2, 2016 23:55
A really dumb genetic algorithm for optimizing hash coefficients
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <chrono>
#include <thread>
#include <mutex>
@fluffy-critter
fluffy-critter / namegen.py
Created April 12, 2016 03:16
Dissociator to generate names by example
#!/usr/bin/env python
#
# Silly thing to generate random names from examples. Uses the CSV files obtained from
# http://catalog.data.gov/dataset/baby-names-from-social-security-card-applications-national-level-data
#
# Any corpus will work if it's formatted like:
# Name,[ignored],weight
import csv
import sys
@fluffy-critter
fluffy-critter / Makefile
Last active February 24, 2017 19:34
Simple build system for building LÖVE games and deploying to itch.io, CD-style
# Simple-ish Makefile for building LOVE packages to multiple architectures and publishing to itch.io.
#
# Useful targets:
#
# all - build for Windows, OSX, and LOVE bundle
# publish - deploy the build to itch.io
# publish-status - print the itch.io status
#
# The itch publishing stuff uses itch's "butler" mechanism. Read more at https://itch.io/docs/butler/
#
@fluffy-critter
fluffy-critter / FixSourceEncodings.cs
Created March 26, 2018 21:16
A Unity editor plugin to automatically fix source file encodings to be UTF-8 with BOM
/*
Automatically fixes the character encoding of checked-in source files.
Put this file into your project's Assets/Editor directory, and reimport any
source files which aren't already UTF-8. This is especially useful if you use
git on Windows, where line-ending conversion can end up messing everything up.
Author: fluffy@beesbuzz.biz
Permission is hereby granted, free of charge, to any person obtaining a copy of
@fluffy-critter
fluffy-critter / vcard-telnorm.cpp
Created May 8, 2018 22:23
VCard phone number normalizer
/*! @brief Simple utility for normalizing phone numbers in VCard (.vcf) files
*
* @author fluffy <fluffy@beesbuzz.biz>
*
* Requires the Google libphonenumber (C++ version), available at:
*
* https://code.google.com/p/libphonenumber/
*
* Just build this with -lphonenumber (or whatever equivalent is
* necessary on your toolchain of choice), and pipe the VCard on
@fluffy-critter
fluffy-critter / README.md
Created January 3, 2019 20:45
simple git merge review tool

Simple code review tool thingy

  1. Put diff2html somewhere on your path
  2. Put this on your path too

Now you can quickly visualize a branch's code changes with e.g.

git cr

or

@fluffy-critter
fluffy-critter / xmousekeys.c
Created May 9, 2018 01:05
A simple program you can use to move the mouse in X11
/* XMouseKeys.c
*
* Move the mouse cursor by the specified vector, useful for keyboard
* bindings in pwm and other WMs which don't have this functionality
*
* contact: fluffy at beesbuzz dot biz
* Released into the public domain
*
* Compile with:
*
@fluffy-critter
fluffy-critter / wav2vid.sh
Created August 26, 2019 00:48
Make a music visualizer for twitter/mastodon/etc.
#!/bin/sh
# Converts an audio file to a smol .mp4 video with a basic spectrogram visualizer
ffmpeg -y -i "$1" -filter_complex "
[0:a]showcqt=s=320x80:text=0[v]
" -map [v] -map 0:a -b:a 320k "$1.mp4"