Skip to content

Instantly share code, notes, and snippets.

@aoba17
aoba17 / kindle_highlights.clj
Last active March 19, 2021 08:39
Mac版のKindleクライアントからコピーした情報を整形しorgファイルに貼り付けるbabashkaスクリプト
#!/usr/bin/env bb
(require '[clojure.java.shell :refer [sh]]
'[clojure.string :as string])
(def default-file "highlights.org")
;; (def test-text
;; "プリズム──本来の名称である「プラガ世界間通信機器」の頭字語をもじった呼び名──には、赤と青のLEDが一個ずつついている。
;; テッド チャン. 息吹 (Japanese Edition) (Kindle の位置No.4816-4818). Kindle 版. ")
@aoba17
aoba17 / treemacs-quick-look.el
Created August 29, 2020 10:04
TreemacsからQuickLookを呼び出す
(defun quick-look-dwim()
(interactive)
(call-process-shell-command
(format "qlmanage %s -p &>/dev/null"
(treemacs--nearest-path (treemacs-current-button)))
nil 0))
(with-eval-after-load "treemacs"
(define-key treemacs-mode-map (kbd "SPC") 'quick-look-dwim))
(def dt-a (js/Date. "2020-05-01"))
(def dt-b (js/Date. "2020-05-30"))
(def mills<->days (* 1000 60 60 24))
(defn get-duration
"2つの日付の差分(日数)を求める"
[dt-a dt-b]
(/ (- dt-b dt-a) mills<->days))
(get-duration dt-a dt-b) ;-> 29
@aoba17
aoba17 / memo.clj
Last active June 11, 2020 04:53
Clojureメモ
;; N-gram
(defn n-gram-index
"N-gram インデックスの作成"
[n s]
(map clojure.string/join (partition n 1 s)))
(def trigram-index (partial n-gram-index 3))
;; 2つの日付の差分(日数)を取得
(def dt-a #inst "2020-05-01")
@aoba17
aoba17 / yadm-command.md
Last active May 7, 2020 09:14
yadm (Yet Another Dotfiles Manager) 操作手順

リポジトリにファイルを追加

yadm add [filename]

リポジトリにコミット

yadm commit

リモートにプッシュ

yadm push -u origin master

yadmによって管理されているファイル一覧の表示

@aoba17
aoba17 / spacemacs-markdown.md
Last active May 4, 2020 06:05
spacemacsでMarkdownを書く
@aoba17
aoba17 / install-npm-on-ubuntu.md
Last active March 17, 2022 06:19
Ubuntu 18.04 (on WSL) にNPMをインストールしたときのメモ

インストール

sudo apt update
sudo apt install nodejs
sudo apt install npm

バージョンアップ