Skip to content

Instantly share code, notes, and snippets.

View salman0ansari's full-sized avatar
🟢
$ yay -S brain

Mohd Salman salman0ansari

🟢
$ yay -S brain
View GitHub Profile
@SwapnilSoni1999
SwapnilSoni1999 / libmagic.ts
Created May 30, 2024 05:57
Universal libmagic file validator, Multer Helper
import fs from 'fs'
import { FileMagic, MagicFlags } from '@npcz/magic'
import { extension } from 'mime-types'
import path from 'path'
import os from 'os'
FileMagic.magicFile = require.resolve(
'@npcz/magic/dist/magic.mgc'
)
@SwapnilSoni1999
SwapnilSoni1999 / validator.middleware.ts
Created May 30, 2024 05:54
Universal zod validator for express.js
import { AnyZodObject, ZodTypeAny } from 'zod'
import {
NextFunction,
Request,
RequestHandler,
Response
} from 'express'
import { HttpError } from '@/lib/errors.lib'
type RequestPayloadIn = 'body' | 'query' | 'params'
@cyco130
cyco130 / promises.js
Created December 26, 2023 17:52
Promise test
function fnThatReturnsPromiseOrValue() {
const random = Math.random();
if (random > 0.5) {
return Promise.resolve(random);
} else {
return random;
}
}
async function naive() {
@NeoHBz
NeoHBz / tampermoney-github_fork_status.js
Last active June 5, 2022 17:27
Tampermoney script to show Fork Status (fork x commits ahead, y commits behind)
// ==UserScript==
// @name GitHub Fork Details
// @namespace https://gist.github.com/NeoHBz/5028c5493fb68cb167235d2c074a138c
// @version 1.0
// @description Displays if GitHub forks are behind/ahead from the parent fork
// @author NeoHBz
// @include https://github.com/*/*/network/members
// @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant none
// ==/UserScript==
@bradtraversy
bradtraversy / node_nginx_ssl.md
Last active July 17, 2024 01:30
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@parmentf
parmentf / GitCommitEmoji.md
Last active July 19, 2024 04:00
Git Commit message Emoji
Byobu is a suite of enhancements to tmux, as a command line
tool providing live system status, dynamic window management,
and some convenient keybindings:
F1 * Used by X11 *
Shift-F1 Display this help
F2 Create a new window
Shift-F2 Create a horizontal split
Ctrl-F2 Create a vertical split
Ctrl-Shift-F2 Create a new session
@josephspurrier
josephspurrier / values_pointers.go
Last active July 15, 2024 16:04
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@jshaw
jshaw / byobuCommands
Last active July 4, 2024 10:58
Byobu Commands
Byobu Commands
==============
byobu Screen manager
Level 0 Commands (Quick Start)
------------------------------
<F2> Create a new window