Skip to content

Instantly share code, notes, and snippets.

View thevuuranusls's full-sized avatar

Nguyễn Vũ thevuuranusls

View GitHub Profile
@thevuuranusls
thevuuranusls / db_test.go
Created September 14, 2019 04:54 — forked from void-main/db_test.go
Test Beego ORM with mocked sql driver
package db
import (
"testing"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
"time"
@thevuuranusls
thevuuranusls / latency.txt
Created May 30, 2019 17:07 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@thevuuranusls
thevuuranusls / difference.js
Created January 19, 2018 11:20 — forked from Yimiprod/difference.js
Deep diff between two object, using lodash
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
@thevuuranusls
thevuuranusls / gist:4b42814df649889624b96fb13769c5bc
Created March 12, 2017 14:17 — forked from THemming/gist:2173037
init.d script to launch Play framework under CentOS/RedHat
#!/bin/bash
# chkconfig: 345 20 80
# description: Play start/shutdown script
# processname: play
#
# Instalation:
# copy file to /etc/init.d
# chmod +x /etc/init.d/play
# chkconfig --add /etc/init.d/play
# chkconfig play on
@thevuuranusls
thevuuranusls / FTPExample.java
Created August 10, 2016 15:59 — forked from madan712/FTPExample.java
Java program to upload/download files from remote server
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
@thevuuranusls
thevuuranusls / ReadWriteExcelFile.java
Created August 10, 2016 15:55 — forked from madan712/ReadWriteExcelFile.java
Read / Write Excel file (.xls or .xlsx) using Apache POI
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@thevuuranusls
thevuuranusls / CacheMonitorBTrace.java
Created April 20, 2016 04:30 — forked from PiotrNowicki/CacheMonitorBTrace.java
BTrace script which monitors sample cache access application (https://github.com/PiotrNowicki/BTrace-Cache-access-app)
package com.piotrnowicki.btrace;
import static com.sun.btrace.BTraceUtils.printArray;
import static com.sun.btrace.BTraceUtils.println;
import static com.sun.btrace.BTraceUtils.strcat;
import java.lang.ref.WeakReference;
import com.sun.btrace.AnyType;
import com.sun.btrace.BTraceUtils.Aggregations;
@thevuuranusls
thevuuranusls / System Design.md
Created April 18, 2016 09:02 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@thevuuranusls
thevuuranusls / gist:79f90caf02c5275d03da
Last active August 30, 2015 09:59 — forked from sgergely/gist:3793166
Midnight Commander Keyboard Shortcuts for Mac OSX
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
package main
import "fmt"
type hash_function func (uint64, int32) int32
func main() {
for j := 1; j < 32; j++ {
simulate_rebalance("JumpConsistentHash", 32, int32(32 + j), JumpConsistentHash)
simulate_rebalance("ModConsistentHash", 32, int32(32 + j), ModConsistentHash)