Skip to content

Instantly share code, notes, and snippets.

View oLaVanBac's full-sized avatar
🤣
Focusing

La Van Bac oLaVanBac

🤣
Focusing
  • Sun* Inc.
  • Vietnam
View GitHub Profile
@oLaVanBac
oLaVanBac / generate-nginx-cloudflare-allow.sh
Created November 18, 2019 06:27 — forked from mkg20001/generate-nginx-cloudflare-allow.sh
A script to generate a config to allow or additionally allow cloudflare addresses for a specific domain
#!/bin/bash
set -e
cf_ips() {
echo "# https://www.cloudflare.com/ips"
for type in v4 v6; do
echo "# IP$type"
curl -s "https://www.cloudflare.com/ips-$type" | sed "s|^|allow |g" | sed "s|\$|;|g"
@oLaVanBac
oLaVanBac / nginx-tuning.md
Created November 18, 2019 01:33 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

package security
import (
"encoding/base64"
"net/http"
"strings"
)
// BasicAuth Middleware with next handler in chain
type BasicAuth struct {
@oLaVanBac
oLaVanBac / watch.sh
Created November 6, 2019 10:01
simple golang live reload
#!/bin/sh
PID=0
stop() {
if ps -p $PID
then
echo "Stopping... $PID"
kill $PID
fi
@oLaVanBac
oLaVanBac / app.js
Created March 29, 2019 07:45 — forked from saiumesh535/app.js
error handling in express applicaiton
const express = require('express');
const http = require('http');
const app = express();
app.get('/', (req, res) => {
res.send('Hey!!');
});
app.post('/exceptionRoute', async (req, res) => {
@oLaVanBac
oLaVanBac / figaro-capistrano.rb
Created January 28, 2019 08:31 — forked from mhui/figaro-capistrano.rb
Capistrano recipe for deploying figaro's application.yml
namespace :figaro do
desc "SCP transfer figaro configuration to the shared folder"
task :setup do
transfer :up, "config/application.yml", "#{shared_path}/application.yml", :via => :scp
end
desc "Symlink application.yml to the release path"
task :symlink do
run "ln -sf #{shared_path}/application.yml #{current_path}/config/application.yml"
end