Skip to content

Instantly share code, notes, and snippets.

View nikosantis's full-sized avatar
🏠
Working from home Chile

Nikolas Santis nikosantis

🏠
Working from home Chile
View GitHub Profile
@maykbrito
maykbrito / README.md
Created February 20, 2021 13:44
Generate PDF with NodeJS and Puppeteer. Using ExpressJS, EJS and TailwindCSS to create fake data server

Generate PDF

Using NodeJS and Puppeteer.

Creating a fake data server with ExpressJS, EJS and TailwindCSS.

How to use it.

  1. Add this files do any directory
  2. Run npm install
@christophemarois
christophemarois / use-map.tsx
Last active April 18, 2024 03:24
React hook for state using ES6 Map
import { useState } from 'react'
export default function useMap<K, V>(): [
Map<K, V>,
{
set: (key: K, value: V) => void
unset: (key: K) => void
clear: () => void
}
] {

Migrating @reach/router to React Router v6

Note: This document is still a work in progress! Please let us know where it lacks so we can make the migration as smooth as possible!

Introduction

When we set out to build React Router v6, from the perspective of @reach/router users, we had these goals:

  • Keep the bundle size low. Turns out we got it smaller than @reach/router
////////////////////////////////////////////////////////////////////////////////
// Welcome to @reach/tooltip!
//
// Quick definitions:
//
// - "on rest" or "rested on": describes when the element receives mouse hover
// after a short delay (and hopefully soon, touch longpress).
//
// - "activation": describes a mouse click, keyboard enter, or keyboard space.
//
// store-provider.js
import React, { createContext, useReducer, useContext } from 'react';
const defaultState = {
counter: 0,
};
function reducer(state = defaultState, action = {}) {
switch (action.type) {
@dreamorosi
dreamorosi / standardJS-in-CRA.md
Last active August 16, 2022 17:33
Add Standard JS to create-react-app project

Standard JS in create-react-app

I've been using create-react-app lately as I find it very useful to kick things off while starting a project. I almost always follow JavaScript Standard Style and I found myself googling it so I figured out I should write it down.

Get Standard JS

I really like keeping dependencies as local as possible but if you prefer you can install it globally.

yarn add standard --dev

or

@parmentf
parmentf / GitCommitEmoji.md
Last active May 26, 2024 20:53
Git Commit message Emoji
@kbastani
kbastani / CalendarDay.cql
Last active July 14, 2020 20:36
This gist is a Neo4j Cypher query for merging a calendar graph for a specific year. This query has 4 levels of indexes, consisting of year, month, day, hour.
// Enter the day you would like to create
WITH { day: 18, month: 1, year: 2014 } as dayMap
// Merge hours in a day
MERGE (thisDay:Day { day: dayMap.day, month: dayMap.month, year: dayMap.year })
MERGE (firstHour:Hour { day: dayMap.day, month: dayMap.month, year: dayMap.year, hour: 1 })
CREATE (thisDay)-[:FIRST]->(firstHour)
FOREACH (i IN tail(range(1, 24)) |
MERGE (thishour:Hour { day: dayMap.day, month: dayMap.month, year: dayMap.year, hour: i })
MERGE (lasthour:Hour { day: dayMap.day, month: dayMap.month, year: dayMap.year, hour: i - 1 })
@stongo
stongo / app.js
Last active January 23, 2024 18:48
Joi validation in a Mongoose model
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', function() {
return console.error.bind(console, 'connection error: ');
});