Skip to content

Snippet

A collection of helpful snippets to help you, including myself to spin up the development. Remember, Do Not Repeat Yourself.

Explore Them

I've put a collection of snippets that are available on my site. These snippets were created by me, as well as some awesome contributors on GitHub.

Axios HTTP Go Style

Make your HTTP request simple by using GO style in JavaScript

Read Your Mdx Files

Most dev use MDX as their storage to store content such as blog, well this site use mdx too, this snippet useful to read mdx files

Simple function to works with base64 encoding

This is simple function, it useful for base64 encoding

Check value exists in array

check is object value is exists in array

useToggle

Toggle boolean made easy with hooks

Observe Your HTML Element

Check whatever HTML element in viewport

Goroutine with Golang

Make multithreading program using goroutine

Modern Unique Array

get distinct values from an array of objects in JavaScript with modern solution

useArray

Array function made simple

Do Not Run First Mount

Prevent Side Effect to run when component did first mount, but when the next state changes, do something

useLocalStorage

Store a data to browser local storage using this hooks

Invalid Input Shake Animation

Simple shake animation when invalid input, very helpful for form validation

useClickOutside

Click outside element and run a callback, very helpful for element like dropdown

useKeyPressEnter

Hooks to help creating key press handler

useWindowScrollPosition

Get window scroll position of Y axis or X axis