Skip to content

Instantly share code, notes, and snippets.

View T2Knock's full-sized avatar
🎩
Hats off to you sir

Knock Huynh T2Knock

🎩
Hats off to you sir
  • Saigon/Vietnam
  • 17:24 (UTC -12:00)
  • X @T2Knock
View GitHub Profile
@T2Knock
T2Knock / before-shutdown.js
Created May 16, 2023 10:57 — forked from nfantone/before-shutdown.js
Node.js graceful shutdown handler
'use strict';
/**
* @callback BeforeShutdownListener
* @param {string} [signalOrEvent] The exit signal or event name received on the process.
*/
/**
* System signals the app will listen to initiate shutdown.
* @const {string[]}
@T2Knock
T2Knock / streamer.js
Created July 11, 2023 05:55 — forked from montanaflynn/streamer.js
Streaming a response with Express.js
var express = require('express')
var app = express()
app.listen(1337)
app.all('/stream/:chunks', function (req, res, next) {
res.writeHead(200, {
'Content-Type': 'text/plain',
@T2Knock
T2Knock / load_dotenv.sh
Last active July 3, 2024 18:45 — forked from mihow/load_dotenv.sh
Load environment variables from dotenv / .env file in Bash
if [ -f .env ]
then
export $(grep -v '^#' .env | xargs)
fi
@T2Knock
T2Knock / postman_installation.md
Created October 1, 2023 11:08 — forked from Akhil-Suresh/postman_installation.md
Installing Postman on Ubuntu/Debian

Installing Postman

Step 1

If any version of postman is installed we need to remove it

sudo rm -rf /opt/Postman

Step 2

@T2Knock
T2Knock / zod-optional-null.ts
Created October 2, 2023 09:58 — forked from ciiqr/zod-optional-null.ts
zod optional/nullable/nullish differences
// zod schema
z.object({
// valid if string or:
optional: z.string().optional(), // field not provided, or explicitly `undefined`
nullable: z.string().nullable(), // field explicitly `null`
nullish: z.string().nullish(), // field not provided, explicitly `null`, or explicitly `undefined`
});
// type
{
@T2Knock
T2Knock / auto-wall
Created October 10, 2023 06:45 — forked from himalay/auto-wall
Sets random wallpaper every 30 minutes using feh(A lightweight and powerful image viewer).
#!/usr/bin/bash
img=(`find ~/pictures/wallpapers/ -name '*' -exec file {} \; | grep -o -P '^.+: \w+ image' | cut -d':' -f1`)
while true
do
feh --bg-scale "${img[$RANDOM % ${#img[@]} ]}"
sleep 30m
done
@T2Knock
T2Knock / Install-AWS-SAM.sh
Created January 5, 2024 07:43 — forked from singledigit/Install-AWS-SAM.sh
Install AWS SAM on Linux using the new Linux installer
curl -L https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip -o aws-sam-cli-linux-x86_64.zip
unzip aws-sam-cli-linux-x86_64.zip -d sam-installation
sudo ./sam-installation/install
where sam
sam --version