Skip to content

Instantly share code, notes, and snippets.

View romelperez's full-sized avatar
:electron:
Creating epic shit!

Romel Perez romelperez

:electron:
Creating epic shit!
View GitHub Profile
function checkGameIndex (checkedIndexesCache, list, index) {
const offset = list[index];
const is0 = list[index] === 0;
const is0ToLeft = list[index - offset] === 0;
const is0ToRight = list[index + offset] === 0;
if (is0 || is0ToLeft || is0ToRight) {
return true;
}
@romelperez
romelperez / arwesAnimationSystemExample.tsx
Created March 9, 2022 23:21
Arwes animation system example.
/** @jsxImportSource @emotion/react */
import { jsx } from '@emotion/react';
import { ReactElement, useState, useEffect } from 'react';
import { Animator, AnimatorGeneralProvider } from '@arwes/animator';
import { Animated } from '@arwes/animated';
const AnimatedItem = (props: { color: string }): ReactElement => {
return (
<Animated
@romelperez
romelperez / createTOScheduler.ts
Created February 26, 2022 04:55
Timeout Task Scheduler
import { isBrowser } from './browser';
type TOSchedulerId = number | string;
type TOSchedulerCallback = () => unknown;
const timeoutTask = (delay: number, callback: TOSchedulerCallback): () => void => {
const scheduleId = setTimeout(() => callback(), delay);
return () => clearTimeout(scheduleId);
};
@romelperez
romelperez / react-production-profiler.js
Last active April 7, 2021 23:11
Simple React profiler for mount phase for production environment.
import React, { useEffect, useState } from 'react';
import { render } from 'react-dom';
const ProductionProfiler = ({ children }) => {
const [mount, setMount] = useState(false);
useEffect(() => {
if (!mount) {
console.time('profile');
setMount(true);
}
@romelperez
romelperez / createRAFScheduler.ts
Last active February 26, 2022 04:54
Request Animation Frame Task Scheduler
import { isBrowser } from './browser';
type RAFSchedulerId = number | string;
type RAFSchedulerCallback = () => unknown;
// TODO: How to handle suspended schedules on suspended window?
const raf = (delay: number, callback: RAFSchedulerCallback): () => void => {
let scheduleId: number | undefined;
import React, { useState, useEffect } from 'react';
import { render, act, cleanup } from '@testing-library/react';
import { EXITED, EXITING, ENTERED, ENTERING } from '../constants';
import { useAnimator } from '../useAnimator';
import { Component as Animator } from './Animator.component';
jest.useFakeTimers();
afterEach(cleanup);
@romelperez
romelperez / validator.js
Created March 11, 2018 05:19
Quick validation library
import isLength from 'validator/lib/isLength';
import isEmail from 'validator/lib/isEmail';
import isInt from 'validator/lib/isInt';
import isFloat from 'validator/lib/isFloat';
import matches from 'validator/lib/matches';
const required = value => !!value;
const isLengthMin = (value, min) => isLength(value, { min });
const isLengthMax = (value, max) => isLength(value, { max });
# backup
mongodump --db=mydb --archive=./backups/mydb.mongodump --authenticationDatabase=mydb -u username -p
# restore
mongorestore --drop --archive=./backups/mydb.mongodump --authenticationDatabase=mydb -u username -p
# export
mongoexport --db mydb --collection users --out ./test/fixtures/users.json --pretty --jsonArray
# import
@romelperez
romelperez / demos.html
Last active June 25, 2017 00:05 — forked from demonio/kuwy.css
KuWy from KumbiaPHP developers
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Kuwy</title>
<link rel="stylesheet" href="./kuwy.css">
<style>
body { margin: 20px; font-family: sans-serif; }
@romelperez
romelperez / atom.keymap.cson
Last active February 5, 2017 00:16
Atom keybinding map
# Your keymap
#
# Atom keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Atom keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#