This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs").promises; | |
const buff = Buffer.alloc(100); | |
const header = Buffer.from("mvhd"); | |
async function length() { | |
const file = await fs.open("video.mp4", "r"); | |
const { buffer } = await file.read(buff, 0, 100, 0); | |
await file.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const useDebounce = () => { | |
let timeout = useRef<NodeJS.Timeout | null>(null); | |
return useCallback( | |
(fn: Function, wait: number) => (e: FormEvent) => { | |
e.preventDefault(); | |
timeout.current && clearTimeout(timeout.current); | |
timeout.current = setTimeout(() => { | |
fn(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This tmux statusbar config was created by tmuxline.vim | |
# on Sun, 09 Feb 2020 | |
set -g default-terminal "screen-256color" | |
set-option -ga terminal-overrides ",xterm-256color:Tc" | |
set -g status-justify "left" | |
set -g status "on" | |
set -g status-left-style "none" | |
set -g message-command-style "fg=#a89984,bg=#504945" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" For Plugins to work, copy this file into | |
" [For vim] --> ~/.vimrc | |
" [For neovim] --> ~/.config/nvim/init.vim | |
" | |
" Generating config with GUI | |
" https://vimconfig.com | |
" --- Required fonts --- | |
" powerline-fonts | |
" ttf-nerd-fonts-symbols |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I love super fast keyboard. Most of my friends and colleagues can't follow | |
# I use `atkbd.softrepeat=1` on the kernel command line. | |
# Even Visual Assist plugin in Visual Studio doubles keyboard repeat rate with _a reason_. | |
# I'm working on my laptop without X installed to avoid procrastination. | |
# I've spend a working day googling how to make `kbdrate` using slower delay than 250. | |
# Add this to your /etc/profile.d/kbdrate.sh: sudo kbdrate -r 82 -d 150 if you want it in console. | |
# Note that it will force you type password twice. I didn't find any workarounds. | |
xset r rate 150 82 | |
# When exiting from Vim, just type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Specify a directory for plugins | |
call plug#begin('~/.vim/plugged') | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'scrooloose/nerdtree' | |
"Plug 'tsony-tsonev/nerdtree-git-plugin' | |
Plug 'Xuyuanp/nerdtree-git-plugin' | |
Plug 'tiagofumo/vim-nerdtree-syntax-highlight' | |
Plug 'ryanoasis/vim-devicons' | |
Plug 'airblade/vim-gitgutter' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Types } = require("mongoose"); | |
const Joi = require("@hapi/joi"); | |
// custom validator | |
const customJoi = Joi.extend(joi => ({ | |
type: "objectId", | |
base: joi.string(), | |
messages: { | |
objectId: '"{{#label}}" must be a valid _id', | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const errorHandler = (error, event) => { | |
if (error) { | |
throw error; | |
} | |
throw new Error(`${event} caught`); | |
}; | |
process.on("beforeExit", () => errorHandler(null, "beforeExit")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"label": "Build React", | |
"type": "shell", | |
"command": "npm run build", | |
"presentation": { | |
"showReuseMessage": false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const http = require("http"); | |
// Port Environment variable | |
const PORT = process.env.PORT || 5000; | |
// Creating the node server | |
const SERVER = http.createServer(); |
NewerOlder