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 / toggle_comment_comick.js
Created August 14, 2024 13:48
Toggle comment on Comick
// ==UserScript==
// @name Toggle Comments Container on Comick
// @namespace http://tampermonkey.net/
// @version 1.0
// @description A very simple script to toggle Comments Container on Comick
// @author Dadangdut33
// @match *://*.comick.io/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=comick.io
// @grant none
// ==/UserScript==
@Dadangdut33
Dadangdut33 / add_pooler_connection_tembo.sql
Created August 11, 2024 17:43
Add pooler connection to newly created database in tembo
GRANT CONNECT ON DATABASE db_name_here TO cnpg_pooler_pgbouncer;
CREATE OR REPLACE FUNCTION user_search(uname TEXT)
RETURNS TABLE (usename name, passwd text)
LANGUAGE sql SECURITY DEFINER AS
'SELECT usename, passwd FROM pg_shadow WHERE usename=$1;';
REVOKE ALL ON FUNCTION user_search(text)
FROM public;
GRANT EXECUTE ON FUNCTION user_search(text)
@Dadangdut33
Dadangdut33 / run_thing_as_admin.bat
Last active August 11, 2024 17:44
A simple bat script to run thing as admin
@echo off
if "%1"=="runas" (
cd %~dp0
start "" "full_path_of.exe"
) else (
powershell Start -File "cmd '/K %~f0 runas'" -Verb RunAs
)
exit
@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