Skip to content

Instantly share code, notes, and snippets.

View ambrizals's full-sized avatar
⌨️
Typing....

Ambrizal Suryadinata ambrizals

⌨️
Typing....
View GitHub Profile
@ambrizals
ambrizals / contoh.tsx
Last active October 7, 2022 05:52
Resizable Sidebar
import { Button } from "antd";
import { FC, useState } from "react";
import { VscClose, VscRefresh } from "react-icons/vsc";
import { ButtonIconWrapper } from "../components/button_icon_wrapper";
import { NoData } from "../components/no_data";
// https://codepen.io/lukerazor/pen/GVBMZK
export const BonPage: FC = () => {
const [listDragging, setListDragging] = useState<boolean>(false);
@ambrizals
ambrizals / formula.ts
Created September 12, 2022 10:02
Nyoba buat formula di typescript
import { run } from "formula";
enum RumusType {
OPERATOR,
VARIABLE,
FIXEDVALUE,
}
interface Rumus {
urutan: number;
@ambrizals
ambrizals / object.ts
Created August 23, 2022 09:11
GraphQL Get Selected Field
export const getSelectedQueryGql = (obj: GraphQLResolveInfo) => {
let result: GQLSelectedField = {
field: [],
relationship: [],
}
const gqlObject: any = obj.returnType
const fields = gqlObject._fields
for (const key in fields) {
if (fields[key].type instanceof GraphQLScalarType) {
@ambrizals
ambrizals / App.tsx
Last active August 10, 2022 11:08
Simple Drag And Drop on React JS
// Demo : https://codesandbox.io/s/test-drag-with-handler-forked-vurlfx?file=/src/App.tsx
import React, { useEffect, useState } from "react";
interface model {
name: string;
hover: boolean;
}
interface category {
name: string;
@ambrizals
ambrizals / main.dart
Created July 29, 2022 14:46
Yeh Bisa Looping Ternyata
void main() {
Map<String, String> params = {
'test': 'test',
'siap': 'ready'
};
String url = 'http://domain.com';
int indexP = 0;
@ambrizals
ambrizals / ButtonPopupMenu.dart
Last active June 17, 2022 03:04
Create custom popup menu
import 'package:flutter/material.dart';
class ButtonPopupMenu extends StatefulWidget {
final Text label;
final Icon? icon;
final Widget content;
final double width;
final double height;
const ButtonPopupMenu(
@ambrizals
ambrizals / Repository.ts
Created February 16, 2022 14:05
hehehe pusing cuk
import {
ExtractModelRelations,
LucidModel,
ModelObject,
ModelQueryBuilderContract,
RelationQueryBuilderContract,
} from '@ioc:Adonis/Lucid/Orm'
import PaginationHelper from 'App/Helpers/PaginationHelpers'
import { ResponseContract } from '@ioc:Adonis/Core/Response'
// import Profile from 'App/Models/Profile'
@ambrizals
ambrizals / CacheService.ts
Created January 5, 2022 12:49
Create like some cache function with JSON file.
import Application from '@ioc:Adonis/Core/Application'
import fs from 'fs'
export default class CacheService {
private jsonPath: string
public static initialize(key: string): CacheService {
const instance = new CacheService()
instance.jsonPath = `${Application.tmpPath('cache')}/${key}.json`
return instance
@ambrizals
ambrizals / ExampleUI.dart
Created November 16, 2021 09:48
Some experiment to explore NestedScrollView widget & Sliver widget
import 'package:bbd_client_manager/components/Global/Tab.dart';
import 'package:bbd_client_manager/components/Transaksi/Detail/v2/header_component.dart';
import 'package:bbd_client_manager/components/Transaksi/Detail/v2/info_pengiriman_component.dart';
import 'package:bbd_client_manager/components/Transaksi/Detail/v2/info_pesanan_component.dart';
import 'package:bbd_client_manager/pages/transaksi/v2/detail/daftar_item_part.dart';
import 'package:bbd_client_manager/pages/transaksi/v2/detail/daftar_pembayaran_part.dart';
import 'package:bbd_client_manager/pages/transaksi/v2/detail/daftar_pengeluaran_part.dart';
import 'package:flutter/material.dart';
import 'dart:math' as math;
@ambrizals
ambrizals / Role.ts
Created September 5, 2021 09:25
CheckRole Decoration on Adonis 5
import { HttpContext } from '@adonisjs/http-server/build/standalone'
import UnAuthorized from 'App/Exceptions/UnAuthorizedException'
const message = 'You are not authorized'
const status = 403
const errorCode = 'E_UNAUTHORIZED'
function CheckRole(permitted: string[]) {
return function (target: Object, propertyKey: string, descriptor: PropertyDescriptor) {
const current = descriptor.value