Skip to content

Instantly share code, notes, and snippets.

View zilahir's full-sized avatar
🍺

Richard Zilahi zilahir

🍺
View GitHub Profile
@zilahir
zilahir / index.js
Created April 23, 2020 11:56
routeTransition
import React from 'react'
import { AnimatePresence } from 'framer-motion'
import { useSelector } from 'react-redux'
import { Route, Switch, useLocation, Redirect } from 'react-router-dom'
import { MountTransition } from '../MountTransition'
export const RouteTransition = ({
children,
exact = false,
path,
@zilahir
zilahir / form.js
Created March 3, 2020 22:04
form
import React, { useState } from 'react';
import { submitForm } from '../../store/actions/submitForm'
import Success from '../common/Success';
const ContactForm = () => {
const [name, setName] = useState('')
const [email, setEmail] = useState('')
const [message, setMessage] = useState('')
const [isAnimationHidden, showAnimation] = useState(true)
const [counter, setCounter] = useState(null)
@zilahir
zilahir / .releaserc
Created June 21, 2021 07:59
semantic-release
{
"repositoryUrl": "git+ssh://***",
"branches": [
{
"name": "master",
"prerelease": "true"
},
{
"name": "release",
"prerelease": "false"
@zilahir
zilahir / LoadAssets.tsx
Created December 26, 2020 08:00
expo loading assets custom wrapper
// some stuff here
export type FontSouce = Parameters<typeof Font.loadAsync>[0];
const usePromiseAll = (
promises: Promise<void | void[] | Asset[]>[],
cb: () => void
) =>
useEffect(() => {
(async () => {
await Promise.all(promises);
cb();
@zilahir
zilahir / docker-compose.yml
Created October 21, 2020 12:24
php docker
version: '2'
services:
web:
image: nginx:latest
ports:
- "80:80"
volumes:
- ./<path-to-folder/backend>:/code/Backend
- ./<path-to-folde/frontend>:/code/Frontend
@zilahir
zilahir / alpr-nodejs-raspberrypi.js
Created September 11, 2020 15:44 — forked from dataslayermedia/alpr-nodejs-raspberrypi.js
ALPR License Plate Detection for Raspberry PI written in Node.js
const PiCamera = require('pi-camera');
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
setInterval(function() {
var path = './' + getRandomInt(500) + '.jpg';
function handleTagClick(tag, thisLevel) {
reduxDispatch(getContentByTagId(tag.tag_id, authToken))
setLastClickedTag(tag)
const childTagIds = tag.relations.relation
const isRendered = tagState[thisLevel + 2]
if (isRendered) {
const tempTagState = tagState
Object.keys(tagState).map(curr => {
if (curr > thisLevel + 1) {
setTimeout(() => {
@zilahir
zilahir / guide.md
Last active May 18, 2020 09:51
guide

React Guide

Table Of Contents

  1. Components
  2. Development Environment
  3. Deployment
  4. General rules 4.1 Hooks 4.2 Project structure
@zilahir
zilahir / findInDeepArray.js
Created May 7, 2020 10:42
findInDeepArray
/**
* @param {number} tagId the id of the tags we are looking for it's child
* @param {Array} tags array of the level we are looking for the child tags
* @returns {object} object of the found child object
*/
function findTagById(tagId, tags) {
// console.debug("findTagById > Tags", tags);
const result = filter(tags, { item: [{ tag_id: tagId }] });
// console.debug("findTagById > result", result);
return result[0].item.filter(t => t.tag_id === tagId)[0];
import { useState, useCallback } from 'react'
import { useStore } from 'react-redux'
export const useStructure = param => {
const store = useStore()
const fetchedStructure = store.getState().fetchStructure.structure
return {
structure,
setStructure,
getParentTagList: useCallback(tagId => setStructure(