Skip to content

Instantly share code, notes, and snippets.

View tkt028's full-sized avatar

Khon tkt028

  • home
  • Vietnam
View GitHub Profile
@tkt028
tkt028 / about.md
Created May 22, 2012 08:03 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@tkt028
tkt028 / my Arch Linux cheat-sheet
Created October 21, 2015 14:52 — forked from tungel/my Arch Linux cheat-sheet
I have kind of short term memory so I like to take note of what I've done. This cheat-sheet log some of the things I've done to my Arch Linux machine. Lots of these stuffs are based on my personal preference and may not be applicable to you. Also take note that: I'm not responsible if you break your machine by following any of the steps in this …
Installing Arch:
sudo vim /etc/pacman.conf
Update packages list: sudo pacman -Syy
run sudo pacman -Syu before installing any software (to update the repositories first)
* Timing issue:
- Change hardware clock to use UTC time:
sudo timedatectl set-local-rtc 0
@tkt028
tkt028 / .gitconfig
Created October 22, 2015 02:04 — forked from robmiller/.gitconfig
Some useful Git aliases that I use every day
#
# Working with branches
#
# Get the current branch name (not so useful in itself, but used in
# other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"
@tkt028
tkt028 / 1-securing-express.md
Created October 24, 2015 15:21 — forked from cerebrl/1-securing-express.md
Securing ExpressJS

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.
@tkt028
tkt028 / Secure Sessions Howto
Created October 29, 2015 01:00 — forked from nikmartin/A: Secure Sessions Howto
Secure sessions with Node.js, Connect, and Nginx as an SSL Proxy
Secure sessions are easy, but it's not very well documented, so I'm changing that.
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy:
The desired configuration for using NginX as an SSL proxy is to offload SSL processing
and to put a hardened web server in front of your Node.js application, like:
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [CLIENT]
To do this, here's what you need to do:
@tkt028
tkt028 / 00-about-search-api-examples.md
Created December 7, 2015 08:30 — forked from jasonrudolph/00-about-search-api-examples.md
5 entertaining things you can find with the GitHub Search API
@tkt028
tkt028 / storeImgInMongoWithMongoose.js
Created March 4, 2016 02:12 — forked from aheckmann/storeImgInMongoWithMongoose.js
store/display an image in mongodb using mongoose/express
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path
@tkt028
tkt028 / compile_emacs.sh
Created September 20, 2016 04:26 — forked from marcwebbie/compile_emacs.sh
Compile emacs 24 on Red Hat 6 workstations
# install needed libraries
sudo yum install texinfo libXpm-devel giflib-devel libtiff-devel libotf-devel
# compile autoconf
cd /tmp
wget ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.68.tar.bz2
tar xjvf autoconf-2.68.tar.bz2
cd autoconf-2.68/
./configure && make && sudo make install
@tkt028
tkt028 / postgres-cheatsheet.md
Created January 17, 2019 06:19 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@tkt028
tkt028 / nginx-tuning.md
Created March 20, 2020 17:23 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

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.