fzf is a general-purpose command-line fuzzy finder. Let’s install and make you 10 times more productive!

install fzf

# clone into ~/.fzf
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
# run install command
~/.fzf/install

output: answer “y” to enable auto-completion and key bindings

Cloning into '/home/naoko/.fzf'...
remote: Enumerating objects: 101, done.
remote: Counting objects: 100% (101/101), done.
remote: Compressing objects: 100% (94/94), done.
remote: Total 101 (delta 4), reused 28 (delta 2), pack-reused 0
Receiving objects: 100% (101/101), 180.78 KiB | 1.83 MiB/s, done.
Resolving deltas: 100% (4/4), done.
Downloading bin/fzf ...
  - Found in $PATH
  - Creating symlink: bin/fzf -> /usr/bin/fzf
  - Checking fzf executable ... 0.20.0 != 0.21.1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   637  100   637    0     0   1750      0 --:--:-- --:--:-- --:--:--  1750
100 1127k  100 1127k    0     0   991k      0  0:00:01  0:00:01 --:--:-- 2597k
  - Checking fzf executable ... 0.21.1
Do you want to enable fuzzy auto-completion? ([y]/n) y
Do you want to enable key bindings? ([y]/n) y

Generate /home/naoko/.fzf.bash ... OK
Generate /home/naoko/.fzf.zsh ... OK

Do you want to update your shell configuration files? ([y]/n) y

Update /home/naoko/.bashrc:
  - [ -f ~/.fzf.bash ] && source ~/.fzf.bash
    + Added

Update /home/naoko/.zshrc:
  - [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
    + Added

Finished. Restart your shell or reload config file.
   source ~/.bashrc  # bash
   source ~/.zshrc   # zsh

Use uninstall script to remove fzf.

For more information, see: https://github.com/junegunn/fzf

Let’s play

Key Binidngs

  • ctl + r: fuzzy find thorugh your command history
  • ctl + t: fuzzy find through the current directory

** trigger command + tab

It understand context and list only relative stuff. eg:

  • cd ** + tab
  • ssh ** + tab

Cheers!

I’ve been using JSONLint for every JSON prettifier needs. This site is super because it even format invalid JSON. For example, standard JSON prettifier won’t prettify JSON with key or value enclosed in single quote but this site does but having your local editor do quick prettifier if you have valid JSON or willing to quickly fix with find and replace.

Sublime is my go to text editor - taking note, prettify JSON etc. So let’s do that real quick.

Install Pretty JSON package. Assuming you are using Linux. If you are using other OS, key combination is different.

CTL + SHIFT + P > type “Install package” > Select Install package > Search for Pretty JSON > select it (this will install the package)

Okay now the package is installed, copy and paste into this UGLY JSON

[{"fav_fruit": "banana","fav_color":"red?","age":29}]

then hit CTL + ALT + J it will re-format to

[
  {
    "fav_fruit": "banana",
    "fav_color": "red?",
    "age": 29
  }
]

Whoohoo!

Cheers!

I tested out Stanza. English tokenizer and definately works. I ran quick test with Japanese lang and output was somewhat unexpected.

import stanza

# japanese "ja", for english model "en"

stanza.download("ja")
nlp = stanza.Pipeline("ja")
doc = nlp("皆さんおはようございます! ご機嫌いかがですか?")

for i, sentence in enumerate(doc.sentences):
    print(f"===== Sentence {i+1} tokens =====")
    print(*[f"word: {word.text}\t upos: {word.upos} xpos: {word.xpos}" for word in  sentence.words], sep="\n")

The output is:

===== Sentence 1 tokens =====
word: 皆さん	 upos: PRON xpos: NP
word: おは	 upos: VERB xpos: VV
word: よう	 upos: AUX xpos: AV
word: ござい	 upos: VERB xpos: VV
word: ます	 upos: AUX xpos: AV
word: !	 upos: PUNCT xpos: SYM
===== Sentence 2 tokens =====
word: ご	 upos: NOUN xpos: XP
word: 機	 upos: NOUN xpos: XS
word: 嫌い	 upos: NOUN xpos: NN
word: か	 upos: PART xpos: PF
word: が	 upos: ADP xpos: PS
word: です	 upos: AUX xpos: AV
word: か	 upos: PART xpos: PE
word: ?	 upos: PUNCT xpos: SYM

I’m not qualified to evaluate accuracy of POS etc but at least as far as tokenization goes, I would expect

["皆さん", "おはよう", "ござい", "ます", "!"]

and

["ご", "機嫌", "いかが", "です", "か". "?"]

Cheers!

See Useful keyboard shortcuts

Addition to the above:

  • Super + Space: Change input keyboard

  • Ctl + Q: Close an application window

  • Super + ↑ : Maxmize the application window.
  • Super → or ← : Move the application window to left right

```

Cheers!

Kafka is super popular and powerful data streaming platform but I’m surprised by lack of easy cli tool.

To find out version, there is no such thing as kafka --version you do:

$ find /opt/kafka/libs/ -name kafka_\* | head -1
/opt/kafka/libs/kafka_2.13-2.4.0-test-sources.jar

where 2.13 is scala version and 2.4.0 is kafka version.

One tool that I played with is lovely called kaf, “Modern CLI for Kafka”.

to list topics, you do:

sudo bin/kafka-topics.sh --list --bootstrap-server localhost:9092

whereas with kaf you do:

$ kaf topics  

to consume on console you do:

sudo bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test_topic

whereas with kaf you do:

kaf consume test_topic

just be able to omit –bootstrap-server etc makes you type less thus productive ;)

To install

go get github.com/birdayz/kaf/cmd/kaf

set auto-complete for zsh

echo 'source <(kaf completion zsh)' >> ~/.zshrc

for shell

echo 'source <(kaf completion bash)' >> ~/.bashrc

ADD and SELECT cluster ADD config for local

kaf config add-cluster local -b localhost:9092

This will create config file here:

~/.kaf/config 

Then you can SELECT to use this config

kaf config select-cluster 
Use the arrow keys to navigate: ↓ ↑ → ← 
? Select cluster: 
  ▸ local
    prod-kafka
    dev-kafka

LIST Kafka node

kaf node ls

LIST Kafka topics

kaf topics

Describe a topic

kaf topic describe ${topic}

List groups

kaf groups

Describe a group

You can see offset etc.

kaf group describe ${group}

LIST Kafka send message

echo '{"a": 123}' | kaf produce test_topic

LIST Kafka consume message

kaf consume test_topic --offset oldest|newest

Easy to install, easy to use, less typing and cluster def in yaml config. So why not use this!

Cheers!