Skip to content

Instantly share code, notes, and snippets.

View hungdev's full-sized avatar
💭
I may be slow to respond.

Hung Vu hungdev

💭
I may be slow to respond.
View GitHub Profile
// App.js hoặc component của bạn
import React, { useState, useRef } from "react";
// import FunctionQueue from "./FunctionQueue"; // Import FunctionQueue
import { debounce } from "perfect-debounce";

// const queue = new FunctionQueue();

const App = () => {
  const [count, setCount] = useState(0);
@hungdev
hungdev / zustand simple.md
Created December 12, 2024 13:15
zustand simple

// Simple version of Zustand

zustand.js

import React from "react";
// Function to create store with core features
function createStore(createState) {
  // Store the current state
  let state;
@hungdev
hungdev / arr suite.md
Created December 1, 2024 04:16
arr suite
version: '3.8'

services:
  radarr: 
    image: linuxserver/radarr:4.1.0
    container_name: radarr
    restart: unless-stopped
    environment:
      - PUID=1000
@hungdev
hungdev / filebrowser rest api for nodejs.md
Last active November 2, 2024 07:10
filebrowser rest api for nodejs

Many programming projects need a quick and simple place to store some files which is currently way more difficult (and/or expensive) than it should be. FileBrowser has a lot of potential to be automated in the sense that it does one thing and does one thing well: Storing and retrieving files.

However, the documentation of the API is beyond lacking (i.e. it does not exist). Assuming people will only use the web interface is ignoring a massive possible userbase for this application. As a start, I have created a short example in nodejs on how to use the REST API to obtain a JWT token, and subsequently use it to upload a file, and then download a file. Please PLEASE just add ANY api documentation, this took me several hours...

I start the service using docker-compose (make sure you create the DATA_DIR beforehand):

version: '3'
services:
 filebrowser:
@hungdev
hungdev / params in axios.md
Created October 30, 2024 04:25
params in axios
const paramsMethod = (params: any) => ({
  get: { params },
  post: params,
  put: params,
  delete: { data: params },
});
@hungdev
hungdev / revert default theme raspberry pi 5.md
Created October 26, 2024 17:16
revert default theme raspberry pi 5
sudo apt reinstall raspberrypi-ui-mods
@hungdev
hungdev / dayjs different between 2 dates.md
Last active February 5, 2024 09:01
dayjs different between 2 dates

docs: https://day.js.org/docs/en/plugin/duration

https://replit.com/@hungdev/dayjs-diff#index.js


const dayjs = require('dayjs');
require('dayjs/locale/vi'); // Import locale để có các chuỗi ngôn ngữ Việt Nam
var durationExt = require('dayjs/plugin/duration')
dayjs.extend(durationExt)
@hungdev
hungdev / iso-language-codes.md
Last active October 6, 2023 04:07
iso-language-codes
@hungdev
hungdev / Node switcher version.md
Last active November 19, 2023 03:51
Node switcher version shellscript command

Node switcher:

How to use:

Create file name: node-swicher.sh and copy content below
give permission ( Only need to grant 1 time ): chmod +x node-swicher.sh
run it: ./node-swicher.sh $param
param: 
If no number is passed, it defaults to version 16.16.0.
If 14 is passed, it uses version 14.19.0.
@hungdev
hungdev / responsive.scss
Created June 1, 2023 08:34
a responsive mixin in SCSS
// SO responsive mixin
// a mixin is different from a function as it does not return a value but serves as placeholder for code
@mixin responsive( $breakpoint ) {
/*
breakpoints are viewport arbitrary values,
they are defined with the aim of allowing the SCSS/CSS code of your app' behave accordingly to your user's device width,
the breakpoints I used were inspired by Bootstrap =>
https://getbootstrap.com/docs/5.0/layout/breakpoints/
*/
@if $breakpoint == smartphone-portrait {