Skip to content

Instantly share code, notes, and snippets.

View robstolarz's full-sized avatar

Rob Stolarz robstolarz

View GitHub Profile
@robstolarz
robstolarz / machine.js
Created October 12, 2020 01:15
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions

Keybase proof

I hereby claim:

  • I am robstolarz on github.
  • I am striking (https://keybase.io/striking) on keybase.
  • I have a public key ASCol8DHzbN9ZUAwFnObPSY7wBXxy4eHizAlpAQqmHB6Zgo

To claim this, I am signing this object:

local tdt = 0
function love.update(fdt)
tdt = tdt + fdt
--60 physics ticks per second
local dt = 1/60
while tdt > dt do
tdt = tdt - dt
//do something 60x a second
end
end
npm init;echo "var express = require('express'); var app = express(); app.use(express.static('public')); app.listen(9000);" > index.js; npm install --save express; mkdir public; echo "Hello, world" > public/index.html;node .
-- TODO: delete keys
return function(ttl, vendorString, font)
local ttl = ttl or 3
-- set font or use default
local font = font or love.graphics.newFont()
-- keep a private access to original table
local _t = {}
local taggedKeys = {
module.exports = function(app) {
var env = app.get('env');
app.set('views', config.root + '/server/views');
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use(compression());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(methodOverride());
@robstolarz
robstolarz / gist:c8a40f852f6e108750d9
Last active August 29, 2015 14:02
A lesson on when null/undefined/delete matters
[rob@Archie ~]$ node
> function kidresponse(kidname,favoriteFood){
... return kidname+" said: Man, I just love eating "+favoriteFood+"! :D"; //assume favoriteFood is always a string cause objects will only return strings
... }
undefined
> function iterateOverKids(kids){
... for (kid in kids)
... console.log(kidresponse(kid,kids[kid].favoriteFood))
... }
function(a){
this._speed=0; //who knows
var b=this.mbr(); //get the current mbr (minimum bound rectangle)
if(this._movement){
for(var i=0;i<a.length;++i){ //for every object we're touching
var a = a[i].obj.mbr(), //get the mbr of the object (sorry about that shadowing)
xl=Math.abs((a._x+a._w/2)-(b._x+b._w/2)), //get the x component of the difference in the origin of both objects
yl=Math.abs((a._y+a._h/2)-(b._y+b._h/2)); //ditto for y
if(xl>yl)this.x-=this._movement.x //if the distance is greater in the x direction don't move in the x direction
if(xl<yl)this.y-=this._movement.y //ditto for y (it lets us slide on one axis instead of stopping in both or neither)
Crafty.c('Bush',{
init:function(){
this.requires('Actor,WS,Color')
.color('#0F1')
}
});
Crafty.c('PlayerCharacter',{
init:function(){
this.requires('Actor,Fourway,Color,Collision')
.color('#F00')