Skip to content

Instantly share code, notes, and snippets.

View thevuuranusls's full-sized avatar

Nguyễn Vũ thevuuranusls

View GitHub Profile

Introduction to Kafka

Kafka acts as a kind of write-ahead log (WAL) that records messages to a persistent store (disk) and allows subscribers to read and apply these changes to their own stores in a system appropriate time-frame.

Terminology:

  • Producers send messages to brokers
  • Consumers read messages from brokers
  • Messages are sent to a topic
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)
@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
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tinydream</groupId>
<artifactId>hashtag</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
/**
* hello
*/
package com.tinydream.bigstats.view.test;
import com.gistlabs.mechanize.MechanizeAgent;
import java.io.IOException;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.util.Properties;
@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 / 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 / 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 / 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;
{
"collaborative":false,
"description":"Relax and indulge with some profoundly beautiful piano pieces.",
"externalUrls":{
"externalUrls":{
"spotify":"http://open.spotify.com/user/spotify/playlist/63dDpdoVHvx5RkK87g4LKk"
}
},
"followers":{
"total":1878226