Skip to content

Instantly share code, notes, and snippets.

View anhtranbk's full-sized avatar

Anh Tran Nhat anhtranbk

View GitHub Profile

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@anhtranbk
anhtranbk / kafka-cheat-sheet.md
Created August 21, 2021 09:53 — forked from ursuad/kafka-cheat-sheet.md
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

Features Java Scala Python Golang C++
Type Inference No Yes Yes Yes No
Function Must be in class Must be in class or object. Function is first-class object Can be at anywhere. Function is object Always outside struct. Function is object Can be at any where
Optional parameters No Yes Yes No No
Tuple No Full-features include unpack Full-features include unpack No No
Multiple return values No Support via tuple, must pack/unpack manually Support auto pack/unpack via tuple Support but return value is not first-class object like tuple in Scala/Python No
Class Support Support Missing scope-limit feature (private/protected), final method Do not have class, only have term struct, support ony some basic features when extends struct (updating...) Support
Class constructor Standard OOP Constructor is in the class signature, contructor overload via
@anhtranbk
anhtranbk / understanding-word-vectors.ipynb
Created November 27, 2019 08:43 — forked from aparrish/understanding-word-vectors.ipynb
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anhtranbk
anhtranbk / Dockerfile
Last active July 17, 2019 10:13
Dockerfile for OpenSSH + Anaconda3 with Jupyter at startup
FROM ubuntu:16.04
RUN apt-get update -y
RUN apt-get install -y openssh-server wget bzip2 htop net-tools tmux
RUN mkdir /var/run/sshd
RUN echo 'root:admin!2346' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
version: "3"
services:
vote:
build: ./vote
command: python app.py
volumes:
- ./vote:/app
ports:
- "5000:80"
@anhtranbk
anhtranbk / five9-spark-submit.sh
Last active October 24, 2018 04:45
Spark submit examples
#!/bin/bash
export SPARK_HOME=/usr/hdp/2.6.3.0-235/spark2
export OUTPUT_PATH=/user/anhtn/sampling/friends2
hdfs dfs -rm -r -f ${OUTPUT_PATH}
$SPARK_HOME/bin/spark-submit \
--master yarn \
--deploy-mode client \
--driver-memory 1g \
@anhtranbk
anhtranbk / limit-mongod
Last active July 27, 2018 02:40
Setup MongoDB on Centos 7
# /usr/lib/systemd/system/mongod.service
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
@anhtranbk
anhtranbk / pip-notes.md
Last active June 18, 2018 04:42
Python notes

Lỗi:

Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

khi gọi: sudo pip install trên Ubuntu sau khi update pip lên bản 10.x.

@anhtranbk
anhtranbk / hbase-shell.sh
Last active April 9, 2018 10:56
HBase configuration
create 'g3:edges', {NAME => 'cf', COMPRESSION => 'SNAPPY', BLOCKCACHE => 'true', IN_MEMORY => 'true'}, {SPLITS => ['012', '024', '036', '048', '060', '072', '084', '096', '108', '120', '132', '144', '156', '168', '180', '192', '204', '216', '228', '240', '252'], DURABILITY => 'ASYNC_WAL'}