Skip to content

Instantly share code, notes, and snippets.

View redguardtoo's full-sized avatar
⛸️
Focusing

Chen Bin redguardtoo

⛸️
Focusing
View GitHub Profile
@redguardtoo
redguardtoo / sort-chinese-word-list.el
Created May 24, 2020 13:16
Sort Chinese word list by pinyin
(defconst my-chinese-pinyin-order-hash
#s(hash-table size 30 test equal data (
"" 375
"" 381
"" 81
"" 293
"" 72
"" 35
"" 264
"" 20
@redguardtoo
redguardtoo / .bashrc
Last active May 8, 2021 00:50
My bash configuration
##
# Bash 4+ required
# FROM,
# 1. http://tldp.org/LDP/abs/html/sample-bashrc.html
# 2. git://github.com/chenkaie/DotFiles.git
##
# If not running interactively, don't do anything
case $- in
*i*) ;;
(defun narrow-or-widen-dwim (p)
;; fixed to behave correctly in org-src buffers; taken from:
;; https://lists.gnu.org/archive/html/emacs-orgmode/2019-09/msg00094.html
"Widen if buffer is narrowed, narrow-dwim otherwise.
Dwim means: region, org-src-block, org-fixed-width-region,
org-table-field, org-subtree, or defun, whichever applies
first. Narrowing to:
- org-src-block calls `org-edit-src-code'
@redguardtoo
redguardtoo / .emacs
Last active May 9, 2024 14:09
minimum emacs setup for Emacs plugin testing
;; A minimum .emacs to test Emacs plugins
(show-paren-mode 1)
(eval-when-compile (require 'cl))
;; test elisps download from internet here
(setq test-elisp-dir "~/test-elisp/")
(unless (file-exists-p (expand-file-name test-elisp-dir))
(make-directory (expand-file-name test-elisp-dir)))
(setq load-path
@gausby
gausby / advice-flyspell-auto-correct-word-to-read-out-loud.el
Last active November 14, 2017 15:41
Custom flyspell-insert-function that will read the word out loud
;; Read the inserted word out loud using the macOS speech synthesizer
;; when a misspelled word is corrected using the flyspell
;; `flyspell-auto-correct-word'-command.
;;
;; Note this only work on macOS. It should be fairly easy to change to
;; work with other command line interface speech synthesize systems.
;;
;; In a previous version this used to be a defadvice, but I've changed
;; it to implementing a custom flyspell insert function. This seems to
;; work a bit more reliably.
@anachronic
anachronic / init-javascript.el
Last active August 24, 2022 13:07
A hydra for js2-refactor in emacs
(defhydra js2-refactor-hydra (:color blue :hint nil)
"
^Functions^ ^Variables^ ^Buffer^ ^sexp^ ^Debugging^
------------------------------------------------------------------------------------------------------------------------------
[_lp_] Localize Parameter [_ev_] Extract variable [_wi_] Wrap buffer in IIFE [_k_] js2 kill [_lt_] log this
[_ef_] Extract function [_iv_] Inline variable [_ig_] Inject global in IIFE [_ss_] split string [_dt_] debug this
[_ip_] Introduce parameter [_rv_] Rename variable [_ee_] Expand node at point [_sl_] forward slurp
[_em_] Extract method [_vt_] Var to this [_cc_] Contract node at point [_ba_] forward barf
[_ao_] Arguments to object [_sv_] Split var decl. [_uw_] unwrap
[_tf_] Toggle fun exp and decl [_ag_] Add var to globals
@jackrusher
jackrusher / giraffe.el
Created April 28, 2017 14:25
An example elisp function presented at Emacs Berlin
(defun giraffe ()
"Passes a the active region (highlighted text in non-emacs
speak) to an external command that produces an SVG graph of the
data, which is then placed in a buffer called *giraffe* and
viewed as an image."
;; Declare that this is an interactive command. Whenever a function
;; starts this way emacs will make it available to be called with
;; M-x or bound to a key.
(interactive)
@bsuh
bsuh / faster_readbyte_from_file.diff
Created September 11, 2015 20:54
Faster reading of bytes from files in Emacs
diff --git a/src/lread.c b/src/lread.c
index e1a4b33..4f17e39 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -467,7 +467,7 @@ readbyte_from_file (int c, Lisp_Object readcharfun)
}
block_input ();
- c = getc (instream);
+ c = getc_unlocked (instream);
@druska
druska / native_js_drag_and_drop_helper.js
Created August 26, 2015 03:56
Create the `simulateDragDrop` function which can be used to simulate clicking and dragging one DOM Node onto another
function simulateDragDrop(sourceNode, destinationNode) {
var EVENT_TYPES = {
DRAG_END: 'dragend',
DRAG_START: 'dragstart',
DROP: 'drop'
}
function createCustomEvent(type) {
var event = new CustomEvent("CustomEvent")
event.initCustomEvent(type, true, true, null)
@redguardtoo
redguardtoo / .ctags.sample
Last active January 20, 2025 03:43
my ~/.ctags. Please note this is configuration for Exuberant Ctags. If you use Universal Ctags, you need run `ctags --options="$HOME/.ctags" -e -R` in shell at least once and fix all the warnings.
--c++-kinds=+p
--fields=+iaS
--extra=+q
--exclude=*/.hg/*
--exclude=.hg/*
--exclude=*/.cvs/*
--exclude=.cvs/*
--exclude=*/.svn/*
--exclude=.svn/*
--exclude=*/.git/*