Skip to content

Instantly share code, notes, and snippets.

View drhayes's full-sized avatar
🐱

David Hayes drhayes

🐱
View GitHub Profile
@drhayes
drhayes / button.lua
Created April 3, 2020 01:30
The basic button control from my GUI lib in Gemini Rising
local Button = Control:extend()
Button:implement(EventEmitter)
function Button:new(text, x, y, w, h)
self.text = text
w = w or (ui.font:getWidth(text) + 20)
h = h or 20
Button.super.new(self, x, y, w or 40, h)
self.layout = fillLayout(0)
self.fill = self:add(Fill())
@drhayes
drhayes / release.sh
Created February 18, 2020 19:47
Gemini Rising release script as of 2020-02-18
#!/usr/bin/env bash
set -e
set -x
MY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MY_DIR=$(realpath "${MY_DIR}"/..)
GITHUB_WORKSPACE=${GITHUB_WORKSPACE:-$MY_DIR}
LOVEVERSION="11.2"
# From http://lua.space/general/assert-usage-caveat
function xassert(a, ...)
if a then return a, ... end
local f = ...
if type(f) == "function" then
local args = {...}
table.remove(args, 1)
error(f(unpack(args)), 2)
else
error(f or "assertion failed!", 2)
@drhayes
drhayes / query.graphql
Created January 13, 2020 16:51
GraphQL query for v4 GitHub API to find every user in an organization
query {
organization(login: "org-goes-here") {
samlIdentityProvider {
ssoUrl
externalIdentities(first: 100) {
edges {
node {
guid
samlIdentity {
nameId
@drhayes
drhayes / eventEmitter.lua
Last active September 9, 2019 20:31
`EventEmitter` in Lua (primarily) for my OOP-y, retained-mode, gamepad-friendly UI library.
local Object = require 'lib.classic'
local function push (t, ...)
local pushed = select('#', ...)
for i = 1, pushed do
t[t.n + i] = select(i, ...)
end
return t.n + pushed
@drhayes
drhayes / rexpaint.lua
Last active March 5, 2024 02:13
A lightweight REXPaint .xp file reader for LOVE2D.
--
-- A lightweight REXPaint .xp reader for LOVE2D.
-- By Vriska Serket / @arachonteur
-- Adapted by drhayes to not use self, make constants uppercase,
-- and updated to work with love 11.2.
-- From https://gist.github.com/vriska-serket/334bfcfa7dfe7265ddbe089e4a51e522
--
-- Output table looks like this.
--[[
{
@drhayes
drhayes / README.md
Created April 1, 2019 15:54
SCRIPT-8
@drhayes
drhayes / brain.lua
Created March 22, 2019 17:13
An old, busted version of coroutine-based AI
local Brain = {}
local currentTime = 0
local timeWaits = {}
local animWaits = {}
local yields = {}
local function yield()
local co = coroutine.running()
yields[co] = true
return coroutine.yield(co)
@drhayes
drhayes / brain.lua
Created March 22, 2019 17:11
An old coroutine-based AI
local lume = require 'lib/lume'
local Brain = {}
local currentTime = 0
local timeWaits = {}
local animWaits = {}
local function waitSeconds(secs)
local co = coroutine.running()
timeWaits[co] = currentTime + secs
@drhayes
drhayes / syncFacingSchemes.lua
Last active August 27, 2018 14:33
Slerp between rotations without doing the flippy thing.
local ax, ay = math.cos(fov.angle), math.sin(fov.angle)
local gx, gy = math.cos(goalAngle), math.sin(goalAngle)
ax, ay = ax + gx * 5 * dt, ay + gy * 5 * dt
fov.angle = math.atan2(ay, ax)