Skip to content

Instantly share code, notes, and snippets.

View nghinv's full-sized avatar

NGUYEN VAN Nghi nghinv

  • ONVN
  • Ha Noi, Viet Nam
View GitHub Profile
@nghinv
nghinv / installDockerAndDockerCompose.sh
Created May 26, 2019 22:44 — forked from nghinguyenvan/installDockerAndDockerCompose.sh
Install Docker 1.13 and Docker-compose on ubuntu 16.04
#1.Install packages to allow apt to use a repository over HTTPS:
sudo apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
#2.Add Docker official GPG key:
curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add -
@nghinv
nghinv / how-to-ssh-agent.md
Created June 5, 2019 08:37 — forked from nepsilon/how-to-ssh-agent.md
Remember passphrases with ssh-agent — First published in fullweb.io issue #31

How to use ssh-agent to cache your SSH credentials?

Contributed by Fabien Loudet, Linux SysAdmin at Rosetta Stone

Tired of always having to enter your SSH key passphrase when logging in to remote machines? Here comes ssh-agent. Enter the passphrase once and it will keep it in memory for you

Using ssh-agent in your shell session:

@nghinv
nghinv / gitlogxml.sh
Created July 16, 2019 21:09 — forked from rhochreiter/gitlogxml.sh
Shell script to emulate the output of "svn log --verbose --xml" for git based on http://stackoverflow.com/questions/11093911/git-log-pretty-with-list-of-files?answertab=active#tab-top
#!/bin/sh
revlist=$(git rev-list HEAD)
(
echo '<?xml version="1.0"?>'
echo '<log>'
for rev in $revlist
do
echo "$(git log -1 --date=iso --pretty=format:"<logentry revision=\"%h\">%n<author>%an</author>%n<date>%ad</date>%n<msg>%s</msg>%n" $rev)"
files=$(git log -1 --pretty="format:" --name-only $rev)
echo '<paths>'
@nghinv
nghinv / postgres_queries_and_commands.sql
Created October 16, 2019 11:25 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@nghinv
nghinv / nginx.conf
Created February 14, 2020 05:05 — forked from morhekil/nginx.conf
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '
@nghinv
nghinv / nginx.conf
Created February 24, 2020 08:33 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@nghinv
nghinv / cas-auth.js
Created February 25, 2020 03:20 — forked from tfcporciuncula/cas-auth.js
CAS authentication script for OWASP Zed Attack Proxy (ZAP or ZAProxy)
/*
* This script is intended to handle CAS (http://jasig.github.io/cas) authentication via ZAP.
*
* When working with CAS, a single POST request with the credentials is not enough to trigger the authentication.
* When we GET the login page, some input values used by CAS are generated (the login ticket and some Spring Web
* Flow related parameters), and they must be included in the POST request for the authentication to work. So
* this script basically sends a GET to the login page, parses its response looking for the values generated by
* CAS, and sends a POST request with these values and the credentials.
*
* This is enough to trigger the authentication, but it's not enough to enable a successfull authenticated scan
@nghinv
nghinv / nginx.conf
Created February 25, 2020 07:58 — forked from baskaran-md/nginx.conf
NginX allow POST on static pages.
# ...
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
@nghinv
nghinv / install-openvpn-24.sh
Created February 28, 2020 11:02 — forked from tienthanh2509/install-openvpn-24.sh
Install OpenVPN 2.4.x on Ubuntu 16.04 Xenial
curl -s https://swupdate.openvpn.net/repos/repo-public.gpg | apt-key add -
echo "deb http://build.openvpn.net/debian/openvpn/stable xenial main" > /etc/apt/sources.list.d/openvpn-aptrepo.list
apt update
apt install -y openvpn
@nghinv
nghinv / config-git-proxy.txt
Created April 9, 2020 10:42 — forked from bynil/config-git-proxy.txt
Use git over socks5 proxy
Port: 1080
1. Create a file /YOUR PATH/gitproxy.sh with content:
#!/bin/sh
nc -X 5 -x 127.0.0.1:1080 "$@"
2. Edit your ~/.gitconfig
# For git://