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 / get-stacktrace.java
Created April 28, 2014 07:04
Get string of current stacktrace in Java
// Get current stack trace in Java
// - http://stackoverflow.com/questions/1069066/get-current-stack-trace-in-java
// - http://stackoverflow.com/questions/944991/is-there-a-way-to-dump-a-stack-trace-without-throwing-an-exception-in-java
// - http://javarevisited.blogspot.com/2013/04/how-to-get-current-stack-trace-in-java-thread.html
import org.apache.commons.lang.exception.ExceptionUtils;
public void testGetListElevesOfClassInEnclassmentForNonViecourante() {
String fullStackTrace = ExceptionUtils.getFullStackTrace(new Throwable("TKT Unit Test"));
System.out.println(fullStackTrace);
@tkt028
tkt028 / example-1-InheritanceType.JOINED
Created April 29, 2014 12:40
SpringJPA: map Java inheritance hierarchies to database tables
// @Note: Sample code from Broadleaf
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "BLC_CUSTOMER", uniqueConstraints = @UniqueConstraint(columnNames = { "USER_NAME" }))
public class CustomerImpl implements Customer, AdminMainEntity {
@Id
@Column(name = "CUSTOMER_ID")
protected Long id;
@tkt028
tkt028 / sample-autohotkey.ahk
Created June 5, 2014 12:18
Sample Autohotkey in Windows
; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
; semicolon, such as this one, are comments. They are not executed.
; This script has a special filename and path because it is automatically
; launched when you run the program directly. Also, any text file whose
; name ends in .ahk is associated with the program, which means that it
; can be launched simply by double-clicking it. You can have as many .ahk
; files as you want, located in any folder. You can also run more than
; one .ahk file simultaneously and each will get its own tray icon.
@tkt028
tkt028 / emacs-package-management.markdown
Created July 15, 2015 15:43
Emacs package management stuffs
  • To re-compile all packages in ELPA, type M-: (byte-recompile-directory package-user-dir nil 'force) - stackoverflow
@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: