Skip to content

Instantly share code, notes, and snippets.

View DogLooksGood's full-sized avatar
🥌
Debugging

tianshu DogLooksGood

🥌
Debugging
View GitHub Profile
@DogLooksGood
DogLooksGood / nvim-terminal-edit.py
Last active April 6, 2016 12:27 — forked from tarruda/nvim-terminal-edit.py
Edit file in host Neovim instance from a :terminal buffer
#!/usr/bin/env python
"""Edit a file in the host nvim instance."""
import os
import sys
from neovim import attach
args = sys.argv[1:]
if not args:
print "Usage: {} <filename> ...".format(sys.argv[0])
@DogLooksGood
DogLooksGood / JsonPathHelper.java
Last active January 4, 2016 02:05
json generate helper
import org.codehaus.jettison.json.JSONObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* Created by DogLooksGood on 16/1/3.
*
@DogLooksGood
DogLooksGood / core.cljs
Last active January 8, 2016 05:57
Markdown edit demo for dynamic css reload with reagent & garden.
(ns mkd.core
(:require [reagent.core :as r :refer [atom]]
cljsjs.marked
[goog.style :as style]
[goog.dom :as dom]
[garden.core :refer [css]]
[garden.units :refer [percent px vh em]]))
(enable-console-print!)
@DogLooksGood
DogLooksGood / diff_and_apply.clj
Last active April 20, 2016 14:02
Vector items diff and apply.
(require '[clojure.set :refer [difference intersection]])
(defn diff [x y k]
(let [xks (set (map k x))
yks (set (map k y))
y-map (zipmap (map k y) y)
x-map (zipmap (map k x) x)
cancel (difference xks yks)
commit-ks (difference yks xks)
commit (vec (vals (select-keys y-map commit-ks)))
@DogLooksGood
DogLooksGood / init.el
Created October 12, 2016 17:37
My emacs config file.
;; Minimal setup for Clojure development & Org document.
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives
'(("gnu-cn" . "http://elpa.zilongshanren.com/gnu/")
("melpa-cn" . "http://elpa.zilongshanren.com/melpa/")
("melpa-stable-cn" . " http://elpa.zilongshanren.com/melpa-stable/")
("marmalade-cn" . "http://elpa.zilongshanren.com/marmalade/")
@DogLooksGood
DogLooksGood / lisp-colon-quote.el
Created July 18, 2019 22:06
Auto semicolon/colon and singlequote/doublequote
(defun user/lisp-semicolon ()
"Will insert a semicolon if we are at the beginning of the line,
otherwise will insert a colon."
(interactive)
(if (or (nth 3 (syntax-ppss))
(save-mark-and-excursion
(while (equal (char-before) 59)
(backward-char))
(equal (point) (line-beginning-position))))
(call-interactively 'paredit-semicolon)
@DogLooksGood
DogLooksGood / list_view.cljs
Last active August 14, 2019 03:28
SimpleListView
(ns demo.list-view
"A ListView provides:
1. Refresh control
2. Pagination"
(:require [reagent.core :as reagent]))
(def ^:private default-bounce-height 100)
;;; Event Handlers
@DogLooksGood
DogLooksGood / modal-edit-design.md
Last active October 17, 2019 22:17
A Modal Edit Design

模式编辑设计

最初的想法

  1. 减少RSI!避免control,也避免metashift.
  2. 尽量接近原始Emacs的按键绑定,减少学习的成本。
  3. 使用和位置无关的按键,这样在所有的键盘布局下都可以使用。
  4. 可以不需要hack就能方便的使用各个package。
  5. 可以高效的编辑文字。
  6. 指令序列尽量保持简短。
@DogLooksGood
DogLooksGood / clojure-comment.el
Created December 10, 2019 03:01
A command to comment clojure code
(defun user/clojure-comment ()
(interactive)
(cond
((not current-prefix-arg)
(save-mark-and-excursion
(if (equal "#_" (buffer-substring-no-properties (point) (+ 2 (point))))
(while (equal "#_" (buffer-substring-no-properties (point) (+ 2 (point))))
(delete-char 2))
(progn
(unless (or (equal (char-after) 40)
@DogLooksGood
DogLooksGood / rime.el
Created February 23, 2020 08:05
Try to implement a minimal emacs rime input method
(defface rime-preedit-face
'((((class color) (background dark))
(:underline t))
(((class color) (background light))
(:underline t)))
"Face for preedit string"
:group 'rime)
(defvar rime--preedit-overlay nil)
(defvar rime--backspace-fallback nil)