Skip to content

Instantly share code, notes, and snippets.

View MikuAuahDark's full-sized avatar

Miku AuahDark MikuAuahDark

View GitHub Profile
@MikuAuahDark
MikuAuahDark / honoka2.lua
Last active September 19, 2017 10:24
libhonoka2 Lua(JIT) FFI binding
-- libhonoka2 FFI binding
-- Copyright (c) 2038 Dark Energy Processor Corporation
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-- copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following conditions:
--
@MikuAuahDark
MikuAuahDark / lua52.lua
Created October 3, 2017 13:20
Lua 5.2 FFI Binding for Lua FFI library
-- A very basic Lua 5.2 FFI binding.
-- Tested under LuaJIT FFI, but should work under Facebook LuaFFI too
-- This assume:
-- - lua_Number is double
-- - lua_Integer is ptrdiff_t (equal to size_t?)
-- - lua_Unsigned is unsigned int
-- Released under public domain
local ffi = require("ffi")
local lua52 = ffi.load("lua52")
@MikuAuahDark
MikuAuahDark / crc16_ccitt.lua
Created January 9, 2018 12:33
CRC-16 CCITT in LuaJIT
-- Converted from https://gist.github.com/chitchcock/5112270
-- Requires LuaBitOp or LuaJIT (since LuaJIT comes with LuaBitOp)
local bit = require("bit")
local crcTable = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5,
0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b,
0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210,
0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c,
@MikuAuahDark
MikuAuahDark / crc16_ccitt.c
Created April 2, 2018 11:55
Another CRC16, but in C
/* CRC16-CCITT */
#include <stdlib.h>
const unsigned short crcTable[] = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5,
0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b,
0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210,
0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c,
0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401,
@MikuAuahDark
MikuAuahDark / makevis.lua
Created April 26, 2018 14:19
Rainmeter Circle Visualizer
-- Visualizer builder script
-- Copyright (c) 2018 MikuAuahDark
--
-- 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 and redistribute it
-- freely, subject to the following restrictions:
@MikuAuahDark
MikuAuahDark / clHCA.def
Created June 13, 2018 15:18
deHCA: LuaJIT FFI Binding to vgmstream's clHCA to play HCA audio in LOVE
; If you're using MSVC, use this DEF file or deHCA will complain
; about a nil value. Example command to build clHCA in Windows:
; > cl.exe /c /Ox /Ot /GL /arch:SSE2 /MD clHCA.c
; > link.exe /DLL /LTCG /DEF:clHCA.def /OUT:clHCA.dll clHCA.obj
; Then copy clHCA.dll to LOVE directory.
; The library name must be "clHCA" (clHCA.dll/libclHCA.so/libclHCA.dylib)
EXPORTS
clHCA_isOurFile0
clHCA_isOurFile1
clHCA_sizeof
@MikuAuahDark
MikuAuahDark / fragment.glsl
Last active June 29, 2018 06:30
LOVE 11.0 default shader (OpenGLES 3.x)
#version 300 es
#define PIXEL PIXEL
#if !defined(GL_ES) && __VERSION__ < 140
#define lowp
#define mediump
#define highp
#endif
#if defined(VERTEX) || __VERSION__ > 100 || defined(GL_FRAGMENT_PRECISION_HIGH)
@MikuAuahDark
MikuAuahDark / conf.lua
Created July 10, 2018 16:18
Play grayscale image as audio (really?)
--[[
Some notice:
1. This code is compatible with LOVE 0.10.0, and LOVE 11.0 (probably later version too)
2. Audio must have sample rate of 28224Hz
3. Audio is encoded to 8bit PCM (128 denotes 0) then converted to PNG
]]
local ffi = require("ffi")
function love.conf(t)
t.window = nil
@MikuAuahDark
MikuAuahDark / vec.lua
Last active July 28, 2018 03:01
Lua GLSL-like vector & matrix (with vector swizzle mask)
-- luagvect
-- GLSL-like vector & matrix function
local vec = {}
local math = require("math")
------------------
-- Vector class --
------------------
@MikuAuahDark
MikuAuahDark / Makefile
Created November 22, 2018 10:17
Simple makefile to zopflipng images from `old/` to`.`
SRC_FILES := $(wildcard old/*.png)
DST_FILES := $(patsubst old/%.png,%.png,$(SRC_FILES))
all: $(DST_FILES)
%.png: old/%.png
zopflipng $< --lossy_transparent --filters=01234mepb --iterations=10 $@