Skip to content

Instantly share code, notes, and snippets.

🐱

David Hayes drhayes

🐱
Block or report user

Report or block drhayes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@drhayes
drhayes / release.sh
Created Feb 18, 2020
Gemini Rising release script as of 2020-02-18
View release.sh
#!/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"
View xassert.lua
# 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 Jan 13, 2020
GraphQL query for v4 GitHub API to find every user in an organization
View query.graphql
query {
organization(login: "org-goes-here") {
samlIdentityProvider {
ssoUrl
externalIdentities(first: 100) {
edges {
node {
guid
samlIdentity {
nameId
@drhayes
drhayes / eventEmitter.lua
Last active Sep 9, 2019
`EventEmitter` in Lua (primarily) for my OOP-y, retained-mode, gamepad-friendly UI library.
View eventEmitter.lua
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 May 15, 2019
A lightweight REXPaint .xp file reader for LOVE2D.
View rexpaint.lua
--
-- 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 / brain.lua
Created Mar 22, 2019
An old, busted version of coroutine-based AI
View brain.lua
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 Mar 22, 2019
An old coroutine-based AI
View brain.lua
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 Aug 27, 2018
Slerp between rotations without doing the flippy thing.
View syncFacingSchemes.lua
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)
@drhayes
drhayes / camera.lua
Created Mar 9, 2018
LÖVE camera shake
View camera.lua
self.noiseFactor = self.noiseFactor + dt
-- self.trauma = math.min(1, self.trauma) - dt * config.camera.traumaFactor
self.trauma = math.max(0, self.trauma - dt * config.camera.traumaFactor)
if self.cameraTarget then
self.x = self.x + (self.cameraTarget.pos.x - self.x) * dt * self.slideFactor
self.y = self.y + (self.cameraTarget.pos.y - self.y) * dt * self.slideFactor
end
-- Shake based on trauma
local shake = self.trauma ^ 2
local maxOffset, maxAngle = config.camera.shake.maxOffset, config.camera.shake.maxAngle
You can’t perform that action at this time.