Skip to content

Instantly share code, notes, and snippets.

View scambier's full-sized avatar

Simon Cambier scambier

View GitHub Profile
@scambier
scambier / waitforseconds.lua
Last active August 29, 2015 14:21
waitForSeconds Lua function equivalent to "new WaitForSeconds()" from Unity
-- Heavily inspired by http://www.mohiji.org/2012/12/14/lua-coroutines/
require 'socket'
local WAITING_COROUTINES = {}
function waitForSeconds(seconds)
local milli = seconds * 1000
local co = coroutine.running()
assert(co ~= nil, "Cannot wait on main thread")
local wakeuptime = socket.gettime() * 1000 + milli
@scambier
scambier / init.lua
Last active February 26, 2016 22:05
shaders' class from mari0 updated for LÖVE 0.10.0
-- Licence: https://creativecommons.org/licenses/by-nc-sa/3.0/
-- This is the shaders/init.lua file from mari0, updated for 0.10.0
-- Original authors: Stabyourself.net - Maurice Guégan and Sašo Smolej
local supported = love.graphics.getSupported and love.graphics.getSupported("canvas") and love.graphics.getSupported("pixeleffect")
local supports_npo2 = love.graphics.getSupported and love.graphics.getSupported("npot") or false -- on the safe side
if not supported then
shaderssupported = false
print("post-processing shaders not supported")
end
@scambier
scambier / pyGitDiff.py
Created March 19, 2019 12:41
Copy all changed files between two git commits. Respects the folders structure.
#! /usr/bin/python
# Usage: python pyGitDiff.py hash1 hash2
# Help: python pyGitDiff.py -h
import subprocess
import os
import shutil
from datetime import datetime
import argparse
ignoreList = [".gitignore"]
@scambier
scambier / signalr.service.ts
Last active April 5, 2019 11:46
VueJS service for SignalR
import { HubConnectionBuilder, LogLevel } from '@aspnet/signalr'
async function wait(ms: number) {
return new Promise(resolve => {
setTimeout(resolve, ms)
})
}
const hubUrl = 'https://localhost:44360/testHub'
@scambier
scambier / userscriptTwitterMediaDownload.js
Created May 5, 2019 08:09
Userscript: Twitter Media Download
// ==UserScript==
// @name Twitter Video Download
// @namespace http://scambier.github.io/
// @version 0.1
// @description Adds an "Open video" link for tweets whith an embedded video
// @author Simon Cambier
// @match https://twitter.com/*
// @grant none
// @run-at document-idle
// ==/UserScript==

NeedL bot script, circa ~2005

For archive purposes

@scambier
scambier / boilerplate.lua
Last active March 30, 2021 16:02
PICO-8 boilerplate
-- gobals and tools
left,right,up,down,fire1,fire2=0,1,2,3,4,5
black,dark_blue,dark_purple,dark_green,brown,dark_gray,light_gray,white,red,orange,yellow,green,blue,indigo,pink,peach=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
--
-- simple ecs
-- https://github.com/namuol/pico8-ecs
--
local ecs = {}
function sunrect()
-- rainbow palette
pal({1,-15,-13,3,-5,11,-6,10,9,-7,8,-8},1)
-- origin x,y and radius
ox,oy,r=64,64,60
::_::
cls()
-- 12 points for the 12 colors
for i=1,12 do
-- the 12 points are equally spread on the circle's top half
function setting_sun()
-- set the palette with all the necessary color,
-- in the right order
pal({10,-7,8,-7,10,14,1},1)
-- circle radius
radius=40
-- start loop
::_::
@scambier
scambier / swept-aabb.lua
Last active July 9, 2022 08:56 — forked from tesselode/swept-aabb.lua
swept AABB collision detection implemented in Lua (commented)
--[[
moves rectangle A by (dx, dy) and checks for a collision
with rectangle B.
if no collision occurs, returns false.
if a collision does occur, returns:
- the time within the movement when the collision occurs (from 0-1)
- the x component of the normal vector
- the y component of the normal vector