Skip to content

Instantly share code, notes, and snippets.

View tkt028's full-sized avatar

Khon tkt028

  • home
  • Vietnam
View GitHub Profile
@tkt028
tkt028 / brute-force-protection-by-ip.js
Created March 24, 2020 12:40 — forked from animir/brute-force-protection-by-ip.js
Node.js rate-limiter-flexible. Brute-force protection - Block source of requests by IP.
const http = require('http');
const express = require('express');
const redis = require('redis');
const { RateLimiterRedis } = require('rate-limiter-flexible');
const redisClient = redis.createClient({
enable_offline_queue: false,
});
const maxWrongAttemptsByIPperMinute = 5;
const maxWrongAttemptsByIPperDay = 100;
@tkt028
tkt028 / monit
Created March 29, 2020 16:09 — forked from roman01la/monit
Node.js + Nginx + Varnish + Upstart + Monit
check host localhost with address 127.0.0.1
start "/sbin/start myapp"
stop "/sbin/stop myapp"
if failed port 3000 protocol HTTP
request /
with timeout 5 seconds
then restart
@tkt028
tkt028 / apache-airflow.md
Created April 27, 2020 05:18 — forked from shravan-kuchkula/apache-airflow.md
Install apache-airflow locally on mac

Using Docker and docker-compose to manage Apache Airflow on mac

Using our beloved docker and docker-compose, we can very quickly bring up an Apache Airflow instance on our mac.

Contents of docker-compose.yml

About the only thing you need to customize in this docker-compose.yml file is the volumes section. This will tell docker to map the given directory containing your Airflow DAGs/plugins to container file system.

version: '3'
services:
@tkt028
tkt028 / mac-rabbitmq-setup.md
Created September 28, 2020 17:00 — forked from tomysmile/mac-rabbitmq-setup.md
Install RabbitMQ using Brew

Update Homebrew’s package database.

brew update

To install the MongoDB binaries, issue the following command in a system shell:

brew install rabbitmq
@tkt028
tkt028 / introrx.md
Created February 27, 2021 04:47 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@tkt028
tkt028 / reconnect.js
Created May 9, 2021 07:36 — forked from carlhoerberg/reconnect.js
How to build reconnect logic for amqplib
var amqp = require('amqplib/callback_api');
// if the connection is closed or fails to be established at all, we will reconnect
var amqpConn = null;
function start() {
amqp.connect(process.env.CLOUDAMQP_URL + "?heartbeat=60", function(err, conn) {
if (err) {
console.error("[AMQP]", err.message);
return setTimeout(start, 1000);
}
@tkt028
tkt028 / getOpenTabs.sh
Created June 17, 2021 06:03 — forked from NoahCardoza/getOpenTabs.sh
[OSX] Lists the URLs of all the open tabs in a specified browser.
#!/bin/bash
# args: browser
# example: ./getOpenTabs.sh "Brave Browser"
# credits:
# https://gist.github.com/samyk/65c12468686707b388ec43710430a421
# TODO:
# validate args
# don't open app if not already open
@tkt028
tkt028 / chrome_tabs.osa
Created June 17, 2021 06:03 — forked from samyk/chrome_tabs.osa
applescript to show all url+titles of Chrome tabs along with front window+tab url+title
# shows all url+titles of Chrome along with front window+tab url+title
set titleString to ""
tell application "Google Chrome"
set window_list to every window # get the windows
repeat with the_window in window_list # for every window
set tab_list to every tab in the_window # get the tabs
repeat with the_tab in tab_list # for every tab
@tkt028
tkt028 / install-rabbitmq-centos-7.md
Created December 8, 2021 03:28 — forked from fernandoaleman/install-rabbitmq-centos-7.md
Install RabbitMQ on CentOS 7

Install RabbitMQ on CentOS 7

sudo yum -y install epel-release
sudo yum -y update

Install Erlang

Download repository

@tkt028
tkt028 / ffmpeg-commands.sh
Created January 23, 2022 05:02 — forked from 44213/ffmpeg-commands.sh
ffmpeg commands.
# To extract the sound from a video and save it as MP3:
ffmpeg -i <video.mp4> -vn <sound>.mp3
# To convert frames from a video or GIF into individual numbered images:
ffmpeg -i <video.mpg|video.gif> <frame_%d.png>
# To combine numbered images (frame_1.jpg, frame_2.jpg, etc) into a video or GIF:
ffmpeg -i <frame_%d.jpg> -f image2 <video.mpg|video.gif>
# To quickly extract a single frame from a video at time mm:ss and save it as a 128x128 resolution image: