Skip to content

Instantly share code, notes, and snippets.

View mathdroid's full-sized avatar
☢️
not good, not terrible

Odi mathdroid

☢️
not good, not terrible
View GitHub Profile
WEBVTT
00:00.000 --> 00:04.000
Jika Anda nonton film ini, saya punya pesan sederhana.
00:05.000 --> 00:15.000
Satu, tolong jadikan film ini sebagai landasan untuk Anda melakukan penghukuman.
00:16.000 --> 00:22.000
Saya mau terlibat dalam film ini karena banyak orang yang akan makin paham
@mathdroid
mathdroid / useCachedState.ts
Created September 20, 2021 09:26
useCachedState
import useSWR, { Key, useSWRConfig } from 'swr'
import { useEffect } from 'react'
export const useCachedState = <T>(key: Key, fallbackData?: T) => {
/// cache is used for subsequent uses
const { cache } = useSWRConfig()
/// if initial data is empty, use value from cache
const initialData = fallbackData ?? cache.get(key)
const { data, mutate } = useSWR(key, {
@mathdroid
mathdroid / absolute-to-relative.js
Created June 28, 2021 11:57 — forked from benmerckx/absolute-to-relative.js
jscodeshift codemod to change imports of internal modules using absolute path to relative path
//jscodeshift --rootDirs ./src --packageDir . --extensions ts --parser tsx -t abs.js src
/**
* This codemod expects 2 CLI arguments:
* - packageDir: the path of the directory containing the package.json. It's used to detect whether a path points
* to a dependency or an internal module.
* - rootDirs: root directory paths separated by a comma if you have more than one root.
* Let's say that you have two files:
* - src/component.js
* - src/index.js containing the import "import Component from 'component.js';"
@mathdroid
mathdroid / 1.windows-steps.ps1
Last active August 21, 2024 02:47
WSL2 Setup
# 0. open a PowerShell as administrator
# 1. Enable WSL
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
# 2. Enable VM Platform
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# 3. RESTART system, then open a PowerShell as administrator again
# MAKE SURE YOU HAVE RESTARTED BEFORE YOU CONTINUE
.card {
box-shadow: rgba(0, 0, 0, 0.01) 0px 0px 1px, rgba(0, 0, 0, 0.04) 0px 4px 8px, rgba(0, 0, 0, 0.04) 0px 16px 24px, rgba(0, 0, 0, 0.01) 0px 24px 32px;
}
@mathdroid
mathdroid / oop.js
Last active December 22, 2020 07:32
class
class Human {
constructor(arg1, arg2) {
this.name = arg1;
this.age = arg2;
}
login() {
console.log("logging in");
}
function main(callback1, callback2) {
callback1();
callback2();
callback2();
callback2();
}
function helloWorld() {
console.log("hello world");
@mathdroid
mathdroid / code.5.gif
Created November 3, 2019 09:04
Gist for code.5.gif. Generated by `crop-github-images-cli`.
Placeholder for code.5.gif.
@mathdroid
mathdroid / code.1.gif
Created November 3, 2019 09:04
Gist for code.1.gif. Generated by `crop-github-images-cli`.
Placeholder for code.1.gif.
@mathdroid
mathdroid / code.2.gif
Created November 3, 2019 09:04
Gist for code.2.gif. Generated by `crop-github-images-cli`.
Placeholder for code.2.gif.