Skip to content

Instantly share code, notes, and snippets.

View cakrads's full-sized avatar

Cakra Danu Sedayu cakrads

  • Mashara.id
  • Medan, North Sumatra, Indonesia
View GitHub Profile
@cakrads
cakrads / initial-sample-shoes-product.ts
Last active January 28, 2023 04:08
products-shoes-model.ts
import type { Product, Brand, Category, Price } from '@prisma/client';
interface TProduct extends Product {
category: Category;
brand: Brand;
price: Price[];
}
export const categories: Category[] = [
{
@cakrads
cakrads / simple-concept-of-js.js
Last active January 17, 2023 09:23
simple concept of javascript
/*
* 1. MUTABLE VS IMMUTABLE
*/
// CASE 1
let a = 1;
let b = a;
console.log(b); // No.1
b = 3;
console.log(a); // No.2
console.log(b) // No.3
@cakrads
cakrads / react-fetch-abort-controller.ts
Created January 8, 2023 15:59
Simple example how to implement abort controller in typescript react.js.
import { useRef } from "react";
function Component() {
const abortControllerRef = useRef<AbortController>(new AbortController());
const onAbortFetch = () => {
if (abortControllerRef.current) {
abortControllerRef.current.abort();
console.log("Download aborted");
// maksimum 2 angka setelah koma
const regex = [
{
"desc":"min. 0 dan max. Big. Int",
"value":"/^\s*([0-9])\d*(?:,\d{0,2})?\s*$/g",
},
{
"desc":"min. 0,01 dan max. 100",
"value":"/^(?:100(?:,00?)?|[1-9](?:,\d{1,2})?|[1-9]\d(?:,\d{1,2})?|0(?:,[1-9]?|,[0-9][1-9]))$/g",
},
@cakrads
cakrads / countries.sql
Created June 17, 2019 15:37 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;