Skip to content

Instantly share code, notes, and snippets.

@codephi
codephi / background.css
Created March 14, 2024 16:56
Background
html {
font: 5vmin/1.3 Serif;
overflow: hidden;
background: #123; }
body, head {
display: block;
font-size: 52px;
color: transparent; }
@codephi
codephi / usePromise.js
Created December 6, 2019 06:51
usePromise is a React hook. It ensures that you will not experience memory leak after unmont component. See it working at: https://codesandbox.io/embed/youthful-wilbur-eu9bb?expanddevtools=1&fontsize=14&hidenavigation=1&theme=dark
import { useCallback, useRef, useEffect } from 'react'
export function usePromise (promiseFn) {
const mountedRef = useRef(false)
const isMounted = useCallback(() => mountedRef.current, [])
useEffect(() => {
mountedRef.current = true
return () => {
{
//O client e env ID é para saber sobre que marketplace o ec será cadastrado.
client_id: client_id,
env_id: env_id,
email: email do usuario,
password: senha,
name: Nome Completo,
ein: CPF do Usuário,
cellphone: Numero de telefone da empresa ou pessoa fisica,
@codephi
codephi / getAllRoutesPHPSlim
Last active March 16, 2018 17:37
Lista todas as rotas slim php a partir de um diretório
#!/usr/bin/python3
'''
Author: assis@pagzoop.com
Usage: getAllRoutes.py [options] path
Options:
-h, --help show this help message and exit
--quote=QUOTE Quotation marks
'''
import os, sys
import re
@codephi
codephi / Nodejs: Teste de loop e callback's
Last active May 16, 2017 14:42
O resultado final deve ser 550, independente o index da iteração. Online test: https://runkit.com/philippeassis/591b0f3ae1482900125159b9
var Promise = require("promise-with-queue"),
val = 0, position = 0;
var loop = (index, callback) => {
setTimeout(() => {
val += index * 10;
console.log("loop | index:", index, "val:", val)
++position;
callback(val)
}, Math.floor(Math.random() * (500 - 2000) + 500))
alias mongorestart="sudo rm /var/lib/mongodb/mongod.lock && sudo service mongod restart"
alias bashrc="source ~/.bashrc"
gitall(){
if [ -z "$1" ]; then
git add --all && git commit -m all && git push origin master
else
git add --all && git commit -m \"$1\" && git push origin master
fi
}
@codephi
codephi / keystone-express-vhost.js
Created July 20, 2016 21:48
Using KeystoneJs with Express-vhost to work with multiple sites on the same port.
var path = require('path'),
evh = require('express-vhost'),
express = require('express'),
server = express();
/**
* express-vhost
**/
server.use(evh.vhost(server.enabled('trust proxy')));
server.listen(3000); //port 3000
#!/bin/bash
LD_PRELOAD=/lib/x86_64-linux-gnu/libresolv.so.2 /opt/Unity/Editor/Unity
using UnityEngine;
using System.Collections;
public static class SpritePivotAlignment
{
public static SpriteAlignment GetSpriteAlignment(GameObject SpriteObject)
{
BoxCollider2D MyBoxCollider = SpriteObject.AddComponent<BoxCollider2D>();
float colX = MyBoxCollider.offset.x;
float colY = MyBoxCollider.offset.y;
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(SpriteRenderer))]
public class RepeatSpriteBoundary : MonoBehaviour
{
SpriteRenderer sprite;
void Awake()
{