Tuesday, September 01, 2020

learn about this book from applebot story:

Introduction to Information Retrieval

Sunday, September 06, 2020

playing with the Fennel programming language

$ brew install luarocks
$ luarocks --local install fennel
$ luarocks --local install readline

install fennel-mode for emacs

C-u M-x run-lisp RET to start a repl

  • C-c C-z - Start or switch to repl buffer
  • C-c C-e - Evaluate current top-level form
  • C-c C-r - Evaluate the region
  • C-c C-k - Reload the module for the current file (requires fennel.seacher)
  • C-c C-d - Ask for a value and show its docstring in the repl
  • C-c C-l - Display compilation output for the current file
  • M-. - Jump to the definition of the function at point
  • M-, - Jump back to where you were before jumping to definition
    (let [f (assert (io.open "a.txt"))]
      (print (f:read "*a"))
    (each [line (io.lines "a.txt")]
      (print line))
    (let [f (assert (io.open "a.txt"))]
      (each [line (f:lines)]
          (print line))

Monday, September 07, 2020

reading Python for DevOps

Wednesday, September 09, 2020

kind of finished Python for Devops, not much interesting stuffs in later chapters.

now reading Flask Web Development

Wednesday, September 16, 2020

read this thread I use WordPerfect 6.2 for DOS, not for any nostalgia or legacy reasons, just because ... and then this post: How to Use Classic Amiga for Word Processing Today (2 of 2)

so I started trying Amiga, it was fun and some links I collected:

things I wanna try:

I didn't read for so long, here's reading list I want to pick up:

  • Mastering Python Networking - Third Edition
  • 40 Algorithms Every Programmer Should Know
  • Practices of the Python Pro
  • Modern Python Cookbook - Second Edition
  • Black Hat Go
  • gRPC: Up and Running
  • Using Asyncio in Python
  • Container Security
  • Pandas 1.x Cookbook
  • Effective C
  • Codeless Data Structures and Algorithms : Learn DSA Without Writing a Single Line of Code
  • Building Event-Driven Microservices
  • Architecture Patterns with Python
  • Data Management at Scale
  • High Performance Python, 2nd Edition
  • Fundamentals of Software Architecture
  • Database Internals


special registers:

  • ": default register
  • %: current file path
  • :: most recently executed command
  • .: the last inserted text

insert mode to access registers: use ctrl-r [register]

can also run command using ctrl-r =:

ctrl-r = system('ls') <enter>

Thursday, September 17, 2020

trying Emacs Prelude

I'm kind of giving up on my personal emacs config and just kept the minimal, it's very nice that it comes with many language support.

$ curl -L https://github.com/bbatsov/prelude/raw/master/utils/installer.sh | sh

edit prelude-modules.el to enable language support, it's very simple

to update, just M-x prelude-update

keybindings for Prelude Mode

for custom setup, put snippets in personal/preload/

(setq prelude-flyspell nil)
(setq prelude-guru nil)
(setq prelude-minimalistic-ui t)
(setq prelude-theme nil)
(setq make-backup-files nil)
(setq prelude-whitespace nil)

it comes with some useful shortkeys too:

  • C-c f: Open recently visited file.
  • C-S-up: Move the current line or region up.
  • C-S-down: Move the current line or region down.
  • C-c d: Duplicate the current line (or region).
  • C-c k: Kill all open buffers except the one you're currently in.
  • C-c . +: Increment integer at point. Default is +1.
  • C-c s: Swap two active windows.
  • C-c i: Search for a symbol, only for buffers that contain code
  • C-c U: Search in Duckduckgo for the thing under point (or an interactive query).
  • Cmd-p: projectile prefix
  • Cmd-j: join line
  • Cmd-k: kill whole line
  • Cmd-o: Insert an empty line above the current line and indent it properly.
  • Cmd-RET: Insert an empty line and indent it properly
  • M-Z: Zap up to char.

Reveal: Read Eval Visualize Loop for Clojure is very cool, the best thing is I can navigate previous results via tabs, like pandas

to start is easy:

$ clj -Sdeps '{:deps {vlaaad/reveal {:mvn/version "1.0.128"}}}' -m vlaaad.reveal repl
  • Tab to switch between output and result
  • Ctrl ← and Ctrl → to switch tabs
  • Esc to close tab
    $ clj -A:reveal -J-Dvlaaad.reveal.prefs='{:theme :light}' -m vlaaad.reveal repl

or create an alias by add this block to ~/.clojure/deps.edn, under :aliases:

{:reveal {:extra-deps {vlaaad/reveal {:mvn/version "1.0.128"}}
         :main-opts ["-m" "vlaaad.reveal"]
         :jvm-opts ["-Dvlaaad.reveal.prefs={:theme,:light}"]}}

and then just simply run

$clj -A:reveal repl

to use it in an existing leiningen project is also easy, add the dependency to project.clj:

:profiles {:dev {:dependencies [[vlaaad/reveal "1.0.128" :exclusions [org.clojure/clojure]]]}}

to only show tapped value:

(ns myapp.core
  (:require [vlaaad.reveal :as reveal]))

(add-tap (reveal/ui))

(tap> {:foo 1})

to start nrepl with reveal (then can use cider-connect):

first create .nrepl.edn in project root:

{:middleware [vlaaad.reveal.nrepl/middleware

then start the nrepl server with

$ lein run -m nrepl.cmdline

(or build-in client)
$ lein run -m nrepl.cmdline -i

then can use emacs to connect to it.

Saturday, September 19, 2020

found this tool when browsing github:

borkdude/babashka: A Clojure babushka for the grey areas of Bash

introduction video: Babashka and Small Clojure Interpreter: Clojure in new contexts

I used to use single frame on emacs, now I'm more comfortable with multiple frames that I don't need to switch buffers all the time:

C-x 5 C-f       find-file-other-frame
C-x 5 C-o       display-buffer-other-frame
C-x 5 0         delete-frame
C-x 5 1         delete-other-frames
C-x 5 2         make-frame-command
C-x 5 d         dired-other-frame
C-x 5 f         find-file-other-frame
C-x 4 C-f       find-file-other-window
C-x 4 C-j       dired-jump-other-window
C-x 4 C-o       display-buffer
C-x 4 b         switch-to-buffer-other-window
C-x 4 d         dired-other-window
C-x 4 f         find-file-other-window

ace-window supports multiple frames (c-x o under Emacs Prelude)

  • c-x tab`, use arrows to move the region
  • c-x <left>: next buffer
  • c-c <right>: winner undeo

m-x package-install embrace, then use m-x embrace-change to change quote pairs

some notes on redis

$ sudo pip install redis fake2db
$ bin/redis-cli flushall
$ fake2db --rows 10000 --db redis> DBSIZE
(integer) 50000

// this takes a while> KEYS *

// use scan instead> scan 0> EXISTS "simple_registration:7681"
(integer) 1> TYPE "company:3859"

// rename key> RENAME "customer:6591" "customer:6591:renamed"

calling the KEYS command is dangerous, use SCAN, HSCAN or SSCAN

If the key to be deleted is a data type other than string, you may encounter server latency when the number of elements in the key is large. Use UNLINK instead of DEL. It will perform the deletion in another thread rather than the main event loop thread, so it won't block the event handling.

RENAME will delete the target key if it has already existed. Therefore, the best practice for renaming is to UNLINK the target key if it exists, and then do the renaming.

The command DUMP/RESTORE can be used for serialization and deserialization. You can use these two commands to make partial backups for Redis.

read Introducing Deno, I'll re-visit deno later.

didn't use paredit for a long time:

M-( wrap around`

moving right parenthese in/out

C-S-left / C-S-right M-} / M-)

moving left parenthese in/out

C-M-left / C-M-right M-{ / M-(

M-s kill parenthese

Sunday, September 20, 2020

almost forgot how to start a *cider-scratch* looks like nrepl still easier in emacs

make sure ~/.lein/profiles.clj has:

{:user {:dependencies [[org.clojure/tools.nrepl "0.2.13"]]
        :plugins [[cider/cider-nrepl "0.25.3"]]}}

I like to start server in termnial instead of inside emacs start a nrepl server anywhere even without a project:

$ lein repl :headless &

start *cider-scratch* and cider-connect to it

I would like to use prepl too, I was using it under vim and with conjure but need to research is there an easy way to do it in emacs ...k

I also updated the reveal alias:

:aliases {:reveal {:extra-deps {nrepl {:mvn/version "0.8.2"}
                                org.clojure/tools.nrepl {:mvn/version"0.2.13"}                                 
                                cider/cider-nrepl {:mvn/version "0.25.3"}
                                vlaaad/reveal {:mvn/version "1.0.128"}}
                   :main-opts ["-m" "nrepl.cmdline"
                   :jvm-opts ["-Dvlaaad.reveal.prefs={:theme,:light,:font-size,16}"]}

Monday, September 21, 2020

finally reading Programming Clojure 3rd edition, I read 2nd edition before, this time focus on spec

Blog Archives

Search Blog: