Skip to content

Instantly share code, notes, and snippets.

View jackliusr's full-sized avatar

Jack Liu Shurui jackliusr

View GitHub Profile
@dunderrrrrr
dunderrrrrr / GeoIP Block NGINX Ubuntu 20.04.md
Created April 19, 2021 08:28
Allow or block GeoIP in Nginx on Ubuntu 20.04

GeoIP Block NGINX Ubuntu 20.04

Block or filter IPs based on location in Nginx (tested on 1.18.0) on Ubuntu 20.04.

Install Nginx modules

To make use of the geographical filtering, we must first install the Nginx GeoIP module as well as the GeoIP database containing the mappings between visitors’ IP addresses and their respective countries. To do so, let’s execute:

$ sudo apt install libnginx-mod-http-geoip geoip-database
@estahn
estahn / !kubectl-secrets
Last active August 15, 2023 07:48
Simple shell function to read out Kubernetes secret in plain text
function kubectl-secrets () {
kubectl get secrets $@ -ojson | jq '{name: .metadata.name, data: .data | map_values(@base64d)}'
}
@FrankSpierings
FrankSpierings / README.md
Last active January 20, 2024 20:45
Linux Container Escapes and Hardening
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 7, 2024 22:55
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@dcode
dcode / GitHub Flavored Asciidoc (GFA).adoc
Last active May 21, 2024 20:07
Demo of some useful tips for using Asciidoc on GitHub

GitHub Flavored Asciidoc (GFA)

@alekseykulikov
alekseykulikov / index.md
Last active April 14, 2024 00:32
Principles we use to write CSS for modern browsers

Recently CSS has got a lot of negativity. But I would like to defend it and show, that with good naming convention CSS works pretty well.

My 3 developers team has just developed React.js application with 7668 lines of CSS (and just 2 !important). During one year of development we had 0 issues with CSS. No refactoring typos, no style leaks, no performance problems, possibly, it is the most stable part of our application.

Here are main principles we use to write CSS for modern (IE11+) browsers:

@dialogbox
dialogbox / oracle_first_without_groupby_to_postgresql.sql
Last active September 6, 2018 10:28
Example: Convert an Oracle FIRST/LAST query to EDB PAS/PostgreSQL
SELECT MAX(FCT_CODE) KEEP(DENSE_RANK FIRST ORDER BY FNL_UPD_DT desc, PRODC_MAGT_NO desc) AS FCT_CODE,
MAX(PLANT_CODE) KEEP(DENSE_RANK FIRST ORDER BY FNL_UPD_DT desc, PRODC_MAGT_NO desc) AS PLANT_CODE,
MAX(PRODC_MAGT_NO) KEEP(DENSE_RANK FIRST ORDER BY FNL_UPD_DT desc, PRODC_MAGT_NO desc) AS PRODC_MAGT_NO
FROM TBM_PM_PRODC_PRGS A
WHERE 1 = 1
AND (A.FCT_CODE, A.PLANT_CODE) IN (('C100A', 'P105'))
AND (A.PRODC_MAGT_NO = '0F5PH3AH700007H' OR A.PRODC_MAGT_NO LIKE '0F5PH3AH700007H'||'_')
AND ROWNUM = 1
-- ==>
@trungv0
trungv0 / haproxy.sh
Last active April 29, 2024 14:54
RabbitMQ cluster with HAProxy & Keepalived for high availability
# install haproxy
yum install -y haproxy
# config haproxy for rabbitmq
cat > /etc/haproxy/haproxy.cfg << "EOF"
global
log 127.0.0.1 local0 notice
maxconn 10000
user haproxy
@lewisd32
lewisd32 / iptableflip.sh
Created April 15, 2015 18:20
Snippet of Unbounce script for restarting HAProxy with zero downtime
echo "Flipping tables! (╯°□°)╯︵ ┻━┻"
num_rules=3
real=3 # exposed to the ELB as port 443
test=4 # used to install test certs for domain verification
health=5 # used by the ELB healthcheck
blue_prefix=855
green_prefix=866
@joyrexus
joyrexus / README.md
Last active June 8, 2023 07:45
form-data vs -urlencoded

Nice answer on stackoverflow to the question of when to use one or the other content-types for POSTing data, viz. application/x-www-form-urlencoded and multipart/form-data.

“The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data. Otherwise, use application/x-www-form-urlencoded.”


Matt Bridges' answer in full:

The MIME types you mention are the two Content-Type headers for HTTP POST requests that user-agents (browsers) must support. The purpose of both of those types of requests is to send a list of name/value pairs to the server. Depending on the type and amount of data being transmitted, one of the methods will be more efficient than the other. To understand why, you have to look at what each is doing