Skip to content

Instantly share code, notes, and snippets.

@1bardesign
1bardesign / conf.lua
Last active February 23, 2021 14:08
A little self-contained pomodoro timer for love2d
function love.conf(t)
t.window.width, t.window.height = 200, 60
t.window.x, t.window.y = 10, 10
t.window.borderless = true
t.window.title = "Pomodoro!"
end
@mnemnion
mnemnion / curry.lua
Created November 7, 2020 05:16
Simple currying in Lua, partial application
-- Simple currying module
--
-- With a bit of extra complexity, so that
-- currying several times gives only one
-- level of function indirection for up to
-- five parameters.
-- weak table to store a reference to the curried
-- function, with the parameters and original function
local _curried = setmetatable({}, { __mode = 'k' })
@mnemnion
mnemnion / sparse.lua
Last active February 17, 2021 17:55
Sparse multidimensional tables in Lua
local Sparse = {}
local function new(dimension)
local sparse = {}
sparse._dimension = dimension
return setmetatable(sparse, Sparse)
end
function Sparse.__index(sparse, key)
if sparse._dimension == 1 then
@Eiyeron
Eiyeron / reflect.glsl
Created October 1, 2017 14:20
Love2D shader for realtime palette swap + EB-like sine-based distorsions
#define PALETTE_SIZE 4
uniform float time = 0;
// Good old wave effect
uniform vec2 amplitude = vec2(0 / 128., 8/128.);
uniform vec2 speed = vec2(1., 2.);
uniform vec2 frequency = vec2(1, 3);
uniform float sampling_factor = 0.5;
uniform vec3 palette[PALETTE_SIZE+1];
uniform bool inverse = false;
@TannerRogalsky
TannerRogalsky / main.lua
Created January 23, 2017 13:55
Fast vertex setting in Love using ImageData and the FFI
local num_verts = 100000
local vertices = {}
for i=1,num_verts do
vertices[i] = {0, 0, 0, 0, 255, 255, 255, 255}
end
local ffi = require('ffi')
ffi.cdef[[
typedef struct {
float x, y;
@ertseyhan
ertseyhan / remount.sh
Created February 2, 2016 20:51
Temporarily increase size of tmp folder on Arch linux
#!/bin/bash
sudo mount -o remount,size=10G,noatime /tmp
echo "Done. Please use 'df -h' to make sure folder size is increased."
@stakira
stakira / luajit_mat2d.c
Last active September 26, 2021 12:08
LuaJIT FFI 2D matrix with continuously allocated data array.
#include <cinttypes>
extern "C" {
__declspec(dllexport) void array_to_mat2d_byte(unsigned char* data, unsigned char** mat, size_t w, size_t h) {
for (size_t i = 0; i < w; ++i) {
mat[i] = data + h * i;
}
}
@yufengwng
yufengwng / arch_cheatsheet.txt
Last active July 17, 2024 16:34
Arch Linux Commands Cheatsheet
pacman
======
view logs: /var/log/pacman.log
update system
# pacman -Syu
list installed packages
# pacman -Q
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class BezierCurveScript : MonoBehaviour {
public class BezierPath
{
public List<Vector3> pathPoints;
private int segments;
@yi
yi / gist:01e3ab762838d567e65d
Created July 24, 2014 18:52
lua hex <= => string
function string.fromhex(str)
return (str:gsub('..', function (cc)
return string.char(tonumber(cc, 16))
end))
end
function string.tohex(str)
return (str:gsub('.', function (c)
return string.format('%02X', string.byte(c))
end))