Skip to content

Instantly share code, notes, and snippets.


Pham Cong Dinh pcdinh

View GitHub Profile
pcdinh /
Created Dec 30, 2019 — forked from maxwelleite/
Script to install Microsoft Vista TrueType Fonts (TTF) aka Microsoft’s ClearType fonts on Ubuntu distros
# Author: Maxwel Leite
# Website:
# Description: Script to install Microsoft Vista TrueType Fonts (TTF) aka Microsoft’s ClearType fonts on Ubuntu distros
# Microsoft added a group of new "ClearType Fonts" to Windows with Windows Vista and Office 2007.
# These fonts are named Constantia, Corbel, Calibri, Cambria (and Cambria Math), Candara, and Consolas.
# Calibri became the default font on Microsoft Word 2007, and it’s still the default font on Word 2016 today.
# Dependencies: wget, fontforge and cabextract
# Note: Microsoft no longer provides the PowerPoint Viewer 2007 (v12.0.4518.1014) or any version anymore for download
# Tested: Ubuntu Saucy/Trusty/Xenial/Bionic
pcdinh /
Created Aug 10, 2018 — forked from sergeyklay/
Install Nginx with Nchan
#!/usr/bin/env bash
# Works fine on Ubuntu 14.0.4 LTS
pcdinh / about.txt
Created Jul 5, 2018 — forked from jessejlt/about.txt
nginx, flask, and file downloads
View about.txt
Okay so here's the setup:
[-] The primary server API is exposed via Flask (Python) and all static files, including all html, css, js is served by nginx.
[-] Python is exposing an API at url<file_id>, where file_id is a database id for the file that we're interested in downloading.
1. User wants to download a file, so we spawn a new window with the url '/api/download/<file_id>'
2. Nginx intercepts the request, sees that it starts with /api/, and then forwards the request to Flask, which is being served on port 5000.
3. Flask routes the request to its download method, retrieves the pertinent data from the file_id, and constructs additional header settings to make nginx happy and to force the browser to see the file stream as a download request instead of the browser just trying to open the file in a new window. Flask then returns the modified header stream to nginx
4. Nginx is finally ready to do some work. While parsing the headers for the incoming request, it encounters "X
wget \
-O ngx_openresty-
tar xzvf ngx_openresty-
cd ngx_openresty-
sudo make install
wget \
pcdinh / nginx.conf
Created Jul 13, 2017 — forked from deltheil/nginx.conf
Hide sensitive GET parameters within nginx access logs thanks to the Lua module
View nginx.conf
http {
log_format filt '$remote_addr - $remote_user [$time_local] "$_request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server {
location /login {
# `set` is provided by the Rewrite module
set $filter "password|secret";
pcdinh / 100_base.conf
Created Jun 28, 2017 — forked from danackerson/100_base.conf
using nginx + lua + redis for redirects and rewrites
View 100_base.conf
# using such a setup requires `apt-get install lua-nginx-redis` under Ubuntu Trusty
# more info @
http {
lua_package_path "/etc/nginx/include.d/?.lua;;";
lua_socket_pool_size 100;
lua_socket_connect_timeout 10ms;
lua_socket_read_timeout 10ms;
server {
pcdinh /
Created Jun 27, 2017 — forked from tarcieri/
Ed25519-based semi-private keys

Semiprivate Keys

Semi-private keys are an expansion of the traditional idea of asymmetric keys, which have a public/private keypair, to N keys which can each represent a different capability level. In the degenerate case, a semi-private key system has 3 different types of keys. These are, to use the Tahoe terminology:

  • writecap: can publish new ciphertexts
  • readcap: can read/authenticate ciphertexts
pcdinh /
Created Dec 10, 2016 — forked from Spindel/
Direct IO in Python
#!/bin/env python3
import os
import mmap
import logging
import hashlib
import contextlib
log = logging.getLogger(__name__)
def directio_mmap(filename, readsize, offset):
View adding-HA-hack-to-all-children.css
.scrolling-element-class * {
-webkit-transform: translate3d(0,0,0);
You can’t perform that action at this time.