Skip to content

Instantly share code, notes, and snippets.

@k0f1sh
k0f1sh / helm-magit-log-all.el
Last active August 10, 2017 07:27
magit-log-allのhelm(未完成)
(defun magit-mode-setup-return-buffer (mode &rest args)
"Setup up a MODE buffer using ARGS to generate its content."
(let ((buffer (magit-mode-get-buffer mode t))
(section (magit-current-section)))
(with-current-buffer buffer
(setq magit-previous-section section)
(setq magit-refresh-args args)
(funcall mode))
(magit-display-buffer buffer)
(with-current-buffer buffer
! font
URxvt.allow_bold: false
URxvt*font: xft:RictyDiminishedDiscord-Regular:size=14:antialias=true
! Cursor
URxvt.cursorBlink: true
URxvt.cursorColor: #657b83
URxvt.cursorUnderline: false
! setting
@k0f1sh
k0f1sh / zone-pgm-rainbow
Last active April 27, 2018 15:51
虹色zone
;; zone-pgm-rainbow
(defun decimal->hex (n)
(format "%02X" n))
(defun hsv->rgb (h s v)
(let ((h (max 0 (min 360 h)))
(s (/ (max 0 (min 100 s)) 100.0))
(v (/ (max 0 (min 100 v)) 100.0)))
(if (= 0 s)
@k0f1sh
k0f1sh / core.clj
Created October 8, 2018 17:44
spandexでelasticsearch api叩いてみる
(ns hoge.core
(:require [qbits.spandex :as s]))
;; 参考: https://dev.classmethod.jp/server-side/elasticsearch-getting-started-07/
(def conn (s/client {:hosts ["http://localhost:9200"]}))
;; clusterの状態確認
(s/request conn {:url "/_cat/health?v"})
@k0f1sh
k0f1sh / 01.clj
Created May 10, 2020 09:51
第1章: 準備運動
;;; https://nlp100.github.io/ja/ch01.html
;; helper
(defn get-words [s]
(->> (clojure.string/split s #"[\., ]")
(filter #(not (empty? %)))))
(defn make-ngram [n coll]
(if (> n (count coll))
[]
@k0f1sh
k0f1sh / 02.sh
Created May 10, 2020 12:31
第2章: UNIXコマンド
#!/bin/bash
# https://nlp100.github.io/ja/ch02.html
# 10
cat popular-names.txt | bb -io "(count *input*)"
# 11
cat popular-names.txt | bb -i '(doseq [line *input*] (println (str/replace line #"\t" " ")))' > popular-names-spaces.txt
(ns gengo03
(:require [cheshire.core :as cheshire]
[clojure.java.io :as io]))
;; https://nlp100.github.io/ja/ch03.html
;; 20
(def r (io/reader (io/resource "jawiki-country.json")))
(def jsons (doall
(map (fn [line]
(ns gengo04
(:require [clojure.java.io :as io]
[incanter.core :as incanter-core]
[incanter.charts :as incanter-charts]
))
;; https://nlp100.github.io/ja/ch04.html
;; $ mecab neko.txt -o neko.txt.mecab
(ns gengo05
(:require [clojure.java.io :as io]
[incanter.core :as i-core]
[incanter.charts :as i-charts]
[dorothy.core :as dot]
[dorothy.jvm :refer (render save! show!)]))
;; https://nlp100.github.io/ja/ch05.html
;; $ cat neko.txt | cabocha -f1 > neko.txt.cabocha
@k0f1sh
k0f1sh / re-seq.el
Last active September 8, 2020 15:04
(defun re-seq (r s)
(let ((l)
(n 1)
(break nil))
(save-match-data
(string-match r s)
(while (null break)
(if-let ((m (match-string n s)))
(progn
(push m l)