Skip to content

Instantly share code, notes, and snippets.

View Dadangdut33's full-sized avatar
🦕
Frog

Fauzan F A Dadangdut33

🦕
Frog
View GitHub Profile
@Dadangdut33
Dadangdut33 / EditorJS_Mantine_darkmode_support.md
Created April 3, 2024 04:58
Editor js with dark mode and mantine support

Here is how i managed to use and style editorjs for my use.

Some notes:

  • To obtain the content we pass setRef, so a higher component can get the content easily
  • You might not need to style the .dark style yourself if you are using mantine's TypographyStylesProvider because it should do the color just fine. (i styled it in my css because i forgot that it exists)
  • I use this component for both editing and rendering results, that's why there is editable and not-editable class
  • To improve ssr i render the results plainly in server side using editorjs-parser
@Dadangdut33
Dadangdut33 / Next js custom server with express + dynamic local or public file upload serving.md
Last active April 1, 2024 11:41
Snippets to serve dynamically uploaded public folder file in next js 14

If you want to serve files using public folder in next js and you want to have upload ability you should use this custom server because next js wont serve dynamically created or uploaded images.

To counter this, we can use express' static method.

Package needed:

  • express
  • cross-env (optional, you might be able to use other lib like dotnev)

(methods tested on next js 14 using nextjs app)

@Dadangdut33
Dadangdut33 / PasswordWithStrength.tsx
Created March 8, 2024 16:28
Mantine UI Password Input With Password Confirmation and Strength Indicator
import { passRequirements } from "@/lib/constant";
// example
/*
export const passRequirements = [
{ re: /[0-9]/, label: "Number" },
{ re: /[a-z]/, label: "lowercase letter" },
{ re: /[A-Z]/, label: "Uppercase letter" },
{ re: /[$&+,:;=?@#|'<>.^*()%!-]/, label: "Special symbol" },
];
*/
@Dadangdut33
Dadangdut33 / PhoneNumber.tsx
Created March 8, 2024 16:26
Mantine UI Phone Number Input with react-phone-number-input
import { Input as MantineInput, TextInput } from "@mantine/core";
import { UseFormReturnType } from "@mantine/form";
import { LegacyRef, forwardRef } from "react";
import PhoneInput, { DefaultInputComponentProps, Value } from "react-phone-number-input";
import "react-phone-number-input/style.css";
// eslint-disable-next-line react/display-name
const CustomInput = forwardRef((inputProps: DefaultInputComponentProps, ref: LegacyRef<HTMLInputElement>) => {
const { error, ...rest } = inputProps;
return (
@Dadangdut33
Dadangdut33 / Get_Checksum.md
Created November 28, 2023 08:52
Function to Get Checksum of File with Powershell and write it (SHA1, SHA256, SHA384, SHA512, MD5)

About

Powershell support the following hashing algorithm:

  • SHA1
  • SHA256
  • SHA384
  • SHA512
  • MD5

I created simple script that you can add to your powershell $PROFILE

  1. Install CUDA 11.8 first
$ wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
$ sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
$ wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
$ sudo dpkg -i cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
$ sudo cp /var/cuda-repo-wsl-ubuntu-11-8-local/cuda-*-keyring.gpg /usr/share/keyrings/
$ sudo apt-get update
$ sudo apt-get -y install cuda
@Dadangdut33
Dadangdut33 / Install CUDA for TensorFlow in WSL2 (Win 10).md
Created September 13, 2023 16:22 — forked from adwellj/Install CUDA for TensorFlow in WSL2 (Win 10).md
Instructions for installing CUDA for TensorFlow 2.8 in Ubuntu 20.04 in WSL2 (Win 10 - 02/2022)

Confirm GPU access in WSL

In an Ubuntu terminal, enter nvidia-smi. If that fails, make sure your Nvidia drivers are up-to-date (current version: 511.23). Win10 version also needs to be at least 21H2 (Winkey + R then winver in Windows to check version).

Current versions of TF use CUDA 11.2 and cuDNN 8.1. Tested build configurations Run the below commands in a terminal:

wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.2.2/local_installers/cuda-repo-wsl-ubuntu-11-2-local_11.2.2-1_amd64.deb
@Dadangdut33
Dadangdut33 / type_hint_in_circular_import.py
Last active July 21, 2023 15:28
Type hint / type checking in a circular import loop in python
# GlobalClass.py
from typing import Optional, TYPE_CHECKING
if TYPE_CHECKING:
from MainWindow import MainWindow # Forward declaration for type hinting
class GlobalClass:
def __init__(self):
self.mw: Optional[MainWindow] = None
self.x = 1
@Dadangdut33
Dadangdut33 / git_uppercase_change.txt
Created July 21, 2023 10:38
Dont Ignore case changes in git
# Global
git config --global core.ignorecase false
# local
git config --local core.ignorecase false
@Dadangdut33
Dadangdut33 / toggle_terminal.py
Last active February 21, 2023 17:59
Toggling hide console/terminal including windows terminal in python
import ctypes
import win32.lib.win32con as win32con
import win32gui # pip install pywin32
from time import sleep
kernel32 = ctypes.WinDLL('kernel32')
user32 = ctypes.WinDLL('user32')
a = input('Input value here:')