Skip to content

Instantly share code, notes, and snippets.

View rimzzlabs's full-sized avatar
🛵
Riding ...

Rizki Citra (rimzzlabs) rimzzlabs

🛵
Riding ...
View GitHub Profile
[
{
"base_asset": "audf",
"best_ask": "0",
"best_bid": "0",
"change_24hours": "0",
"exchange": null,
"forbidden_country": "US",
"incremental_price": "1",
"instrument": "audf_jidr_spot",
import { axios } from 'axios'
import type { AxiosError } from 'axios'
const asyncFetch = async <T = unknown>(url: string, config?: ExtendConfig) => {
try {
const res = await axios<T>({
url,
...config,
})
@rimzzlabs
rimzzlabs / tailwind.css
Created December 30, 2022 16:15
Tailwind Base style for font
@tailwind base;
@tailwind utilities;
@tailwind components;
@layer base {
h1 {
@apply text-4xl font-bold text-theme-800 dark:text-theme-100 md:text-5xl;
}
h2 {
import Axios, { AxiosRequestConfig } from 'axios'
import type { AxiosError } from 'axios'
type Method = 'GET' | 'POST' | 'DELETE' | 'PATCH' | 'PUT' | 'OPTIONS'
type HttpReturn<T> = Promise<[T | null, null | AxiosError<T, T>]>
export const httpInstance = Axios.create({
baseURL: import.meta.env.VITE_APP_API_URL
})
type Value = Record<string, unknown>
export const arrayObjSearch = <T extends Value>(arr: Array<T>, key: keyof Array<T>[0], target: string): T | null => {
if (!key) throw new TypeError('You should provide what key to find')
if (arr.length === 0) return null
let i = 0
do {
const source = arr[i][key]
@rimzzlabs
rimzzlabs / .prettierrc.js
Created October 2, 2022 19:05
Prettier Config
module.exports = {
semi: false,
tabWidth: 2,
printWidth: 120,
singleQuote: true,
jsxSingleQuote: true,
trailingComma: 'none',
arrowParens: 'always',
endOfLine: 'auto',
}
@rimzzlabs
rimzzlabs / extensions.json
Last active October 2, 2022 19:04
My Personal VS Code Extension
{
"recommendations": [
"bradlc.vscode-tailwindcss",
"eamodio.gitlens",
"dbaeumer.vscode-eslint",
"usernamehw.errorlens",
"vscode-icons-team.vscode-icons",
"mintlify.document",
"esbenp.prettier-vscode",
"mikestead.dotenv",
@rimzzlabs
rimzzlabs / toElipsis.ts
Last active September 26, 2022 07:45
given number length, make the string ellipsis
export const toElipsis = (str: string, range?: = 10): string => {
return str.slice(0, range) + '...'
}
// usage
const elipsis = toElipsis("Please mister, call me Robin, I will be your company while at your trip to Mongo Island", 44)
console.info(elipsis) // -> 'Please mister, call me robin, I will be your...'
@rimzzlabs
rimzzlabs / httpreq.ts
Last active October 7, 2022 16:03
Avoid async / await try - catch hell
export async function httpreq(fn: () => Promise<any>): Promise<[any, any]> {
try {
const res = await fn()
return [res, null]
} catch(err) {
return [null, err]
}
}
@rimzzlabs
rimzzlabs / Image.tsx
Last active September 26, 2022 07:29
next/image without explicit height and width
import Image from "next/image"
export function ImageComponent(){
return (
<figure className="relative w-40 h-40 md:w-80 md:h-80">
<Image lazy layout="fill" />
</figure>
)
}