Skip to content

Instantly share code, notes, and snippets.

View khanhtc1202's full-sized avatar
💬
Someone is typing…

Khanh Tran khanhtc1202

💬
Someone is typing…
View GitHub Profile
@khanhtc1202
khanhtc1202 / dining_philosophers.rs
Created November 5, 2019 03:00
Dining Philosopher
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
struct Philosopher {
id: usize,
left: Arc<Mutex<Chopstick>>,
right: Arc<Mutex<Chopstick>>,
}
@khanhtc1202
khanhtc1202 / README.md
Created January 20, 2019 03:09 — forked from Lazza/README.md
VPNGate Python script

vpngate.py

This script allows to use the free VPN service provided by VPNGate in an easy way. The user just needs to provide the desidered output country, and the script automatically chooses the best server.

After this step, OpenVPN is launched with the proper configuration. The VPN can be terminated by pressing Ctrl+C.

Usage

Run the script by providing the desired output country:

@khanhtc1202
khanhtc1202 / benchmark.go
Created October 23, 2018 07:30
String concatenate
package main
import (
"bytes"
"strings"
"testing"
)
func BenchmarkConcat(b *testing.B) {
var str string
@khanhtc1202
khanhtc1202 / tmux.cheat
Created July 20, 2018 03:27 — forked from afair/tmux.cheat
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &
@khanhtc1202
khanhtc1202 / weather.sh
Created July 14, 2018 17:51
Check weather on terminal
#!/bin/bash
#
# khanhtc 08-11-2017
test -z "$1" && exit
BASEURL="http://wttr.in/"
method="curl -4"
# Run command get weather
@khanhtc1202
khanhtc1202 / promises.md
Created June 19, 2018 10:35 — forked from domenic/promises.md
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
#!/bin/sh
#
# author: khanhtc
#
# script for installing nodejs from source
#
VERSION=$1
OS=$(uname -s | awk '{print tolower($0)}')
ARCH=$(uname -m | sed 's/x86_/x/g')
@khanhtc1202
khanhtc1202 / di-container.go
Last active May 17, 2018 07:32
Sample Dependence Injection Container in GoLang
package main
import (
"fmt"
)
type UserRepository struct {
Description string
}
@khanhtc1202
khanhtc1202 / uzabase-niconico-attacker.py
Created May 17, 2018 03:43
Attacker to niconico comment & like system of Uzabase .inc
"""
just for fun beacause funthings are fun!!!
require: requests (install by using pip), python (2 or 3)
usage:
python sample.py {pool_size} {action_quantity}
=> for running in real life: pls uncomment this following line
108: requests.get(endpoint, headers=headers)