Skip to content

Instantly share code, notes, and snippets.

View zaguiini's full-sized avatar
🏠
Working from home

Luis Felipe Zaguini zaguiini

🏠
Working from home
View GitHub Profile

Smooth Scroller for React

It's a port of Sooth Scroller for Svelte for React.

Actually, it requires GSAP, TypeScript & Tailwindcss are optional.

To remove TypeScript, just remove the type marks. To remove Tailwindcss, remove tailwindclasses but don't forget to reproduce the same styles in the elements with pure CSS.

Dependencies:

import React from "react";
import { useFormik } from "formik";
const initialValues = {
name: "",
email: "",
address: {
street: "",
number: "",
city: ""
open Belt;
let person = Js.Nullable.return({ "name": "marcos"})->Js.Nullable.toOption;
person
->Option.map(person => person##name)
-> Option.getWithDefault("");
let (>=) = (maybe, func) => maybe->Option.map(func);
let (>?) = (maybe, defaultValue) => maybe->Option.getWithDefault(defaultValue);
@jancassio
jancassio / README.md
Last active March 6, 2020 11:26
React Hooks

React Hooks

useImage

Provides an image from a respective URL

Usage

const Component = ({ src, alt, width = 320, height = 240, fallback }) => {
////////////////////////////////////////////////////////////// Array utilities
type Length<T extends any[]> = T["length"];
type Head<T extends any[]> = T[0];
type Tail<T extends any[]> = ((...xs: T) => any) extends ((_x: any, ...xs: infer R) => any) ? R : [];
type AllTrue<Ts extends any[]> = {
0: true,
1: false,
2: AllTrue<Tail<Ts>>
}[Length<Ts> extends 0 ? 0 : Head<Ts> extends false ? 1 : 2]
@jesstelford
jesstelford / 01-shape-up-to-kindle.md
Last active January 10, 2024 20:08
Read SHAPE UP by basecamp on a Kindle / reMarkable / eReader

Read Shape Up by basecamp on a kindle / reMarkable / eReader

Basecamp's new book Shape Up is now available online (https://basecamp.com/shapeup) to read page-by-page.

There is a .pdf version, but that's not the best format for Kindle / other eReaders. Instead, we can convert the page-by-page into an eReader friendly format.

Part 1: Convert to a single page

NOTE: This has only been tested on Chrome

@jeremyben
jeremyben / ts-build-api.ts
Last active April 6, 2024 19:38
Typescript programmatic build with tsconfig.json (run with `ts-node -T`)
import * as path from 'path'
import ts from 'typescript'
function build(
override: {
compilerOptions?: ts.CompilerOptions
include?: string[]
exclude?: string[]
files?: string[]
extends?: string
@sibelius
sibelius / usePrompt.tsx
Last active October 27, 2022 19:05
Prompt user before leaving route or reload
import { useEffect, useRef } from 'react';
import { useHistory } from 'react-router-dom';
export const usePrompt = (when: boolean, message: string = 'Are you sure you want to quit without saving your changes?') => {
const history = useHistory();
const self = useRef(null);
const onWindowOrTabClose = event => {
if (!when) {
@jordanmkoncz
jordanmkoncz / .react-navigation iOS 11 Navigation Bar with Large Title
Last active May 9, 2022 16:21
react-navigation iOS 11 Navigation Bar with Large Title
#
@tpae
tpae / graph.js
Last active February 14, 2024 23:29
JavaScript implementation of Graph Data Structure
// Implement a Graph
// basic operations:
// - add vertex (node)
// - add edge (node -> node)
function GraphNode(val) {
this.val = val;
this.edges = {};
}