Skip to content

Instantly share code, notes, and snippets.

View pablomayobre's full-sized avatar
📖
Learning new technologies

Pablo Ariel Mayobre pablomayobre

📖
Learning new technologies
  • NewCombin
  • Trelew, Chubut, Argentina
View GitHub Profile
@pablomayobre
pablomayobre / PushId.php
Last active August 14, 2021 22:51 — forked from jbroadway/PushId.php
Firebase Push ID, in PHP
<?php
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
@pablomayobre
pablomayobre / useAnimationFrame.js
Created March 2, 2020 20:38
useAnimationFrame React Hook, for requestAnimationFrame, with Delta Time and no re-rendering. Uses useLayoutEffect so it can be used before the canvas has been rendered to screen,
import { useState, useRef, useLayoutEffect } from "react";
const useAnimationFrame = (callback) => {
const callbackRef = useRef(callback);
const frameRef = useRef();
const timerRef = useRef();
useLayoutEffect(() => {
callbackRef.current = callback;
}, [callback]);
@pablomayobre
pablomayobre / eventEmitter.lua
Last active September 9, 2019 21:44 — forked from drhayes/eventEmitter.lua
`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
@pablomayobre
pablomayobre / Forum Post.bbcode
Last active February 17, 2023 21:16
LÖVE Jam
[url=https://itch.io/jam/love2d-jam-2019][img=https://i.imgur.com/OI9haBh.png]LÖVE Jam Banner[/img][/url]
Hey folks! I'll be hosting a new [url=https://itch.io/jam/love2d-jam-2019]LÖVE Jam[/url]!
Jam starts on [b][color=#004080]February 15th 23PM GMT+0[/color][/b] and ends on [b][color=#004080]February 18th 23PM GMT+0[/color][/b].
[size=150]Rules[/size][list]
[*][b]Your game needs to be made with the LÖVE framework[/b]
[*]The game must be made during the jam — existing basecode and libraries can be used
[*]Assets must be made during the jam — exceptions are logo/intro/fonts
@pablomayobre
pablomayobre / wyss.lua
Created July 9, 2018 17:28
WYSS - What're Your System Specs? Gather all the specs from a system into a neat table
local wyss = {
--OS detected by LÖVE
os = love.system.getOS(),
--Current LÖVE version (>= 11.0)
love = table.concat({love.getVersion()}, '.', 1, 3),
--Lua version (in case it was changed)
lua = _VERSION,
processor = {
--Number of threads/processors
@pablomayobre
pablomayobre / steady.lua
Last active May 22, 2020 07:37
Fixed time step love.run
--MIT License
--Copyright (c) 2019 Arvid Gerstmann, Jake Besworth, Max Cahill, Pablo Mayobre, LÖVE Developers
--Original author: https://github.com/Leandros
--Max frame skip: https://github.com/jakebesworth
--Manual garbage collection: https://github.com/Geti
--Put it all together: https://github.com/Positive07
--Original love.run: LÖVE Developers
local conf = {

Keybase proof

I hereby claim:

  • I am positive07 on github.
  • I am positive07 (https://keybase.io/positive07) on keybase.
  • I have a public key ASCj8HKT36qB0IvK6bq2R0BANGLVDTBAuksOIVUO_JGFBAo

To claim this, I am signing this object:

@pablomayobre
pablomayobre / Dialog.cpp
Last active December 14, 2017 22:07
Add NativeFileDialogs to LÖVE filesystem API (https://github.com/mlabbe/nativefiledialog)
enum DialogType
{
DIALOG_SAVE,
DIALOG_OPEN,
DIALOG_FOLDER,
DIALOG_MULTIPLE;
DIALOG_MAX_ENUM
};
#import <nfd.h>
@pablomayobre
pablomayobre / miniclass.lua
Last active January 11, 2023 22:09
Minimal class approach for Lua based on Tjakka5 code https://github.com/tjakka5/Babble/blob/master/babble/src/class.lua
local function new (self, ...)
local obj = setmetatable({}, self)
if self.initialize then self.initialize(obj, ...) end
return obj
end
local mt = { __call = function (self, ...)
return self:new(...)
end }
@pablomayobre
pablomayobre / bidirectional.ts
Created November 16, 2017 09:55
Bidirectional Map implemented in TypeScript. Designed for efficiency and performance
interface Callback <A, B> {
(key: A, value: B, map: BidirectionalMap <A, B>): void
}
const remove = <A, B> (item: A, from: A[], pair: B[]) => {
let index = from.indexOf(item)
if (index !== -1) {
from.splice(index, 1)
pair.splice(index, 1)