Skip to content

Instantly share code, notes, and snippets.

@c02y
c02y / mpp.sh
Created July 25, 2018 08:09
list all the ips
alias mpp "ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'"
@c02y
c02y / config.fish
Created August 1, 2018 08:58
catt to wrap default cat
function catt
if test (count $argv) -gt 1
for i in $argv
echo -e "\\033[0;31m"\<$i\>
echo -e ------------------------------------------------- "\\033[0;39m"
cat $i
echo
end
else
cat $argv
@c02y
c02y / init.el
Created August 15, 2018 06:48
C-w/C-x w in emacs, edited: (delete-char 1) in the end
(defun delete-line-or-region-or-buffer ()
"Delete current line, or text selection.
When `universal-argument' is called first, delete whole buffer (respects `narrow-to-region')."
(interactive)
(if current-prefix-arg
(delete-region (point-min) (point-max))
(progn (if (use-region-p)
(delete-region (region-beginning) (region-end))
(progn
(if (current-line-empty-p)
@c02y
c02y / init.el
Last active August 15, 2018 07:01
edit mode in helm-swoop
(bind-keys :map helm-swoop-map
("C-x e" . helm-swoop-edit) ;; since builtin C-c C-e is already used
;;
)
@c02y
c02y / init.el
Created August 15, 2018 10:56
comment line or region
;; (setq comment-style 'extra-line)
(add-hook 'c-mode-hook
(lambda ()
(set (make-local-variable 'rebox-style-loop) '(241 243 111))
(rebox-mode 1)))
(add-hook 'c++-mode-hook
(lambda ()
(set (make-local-variable 'rebox-style-loop) '(21 23 111))
@c02y
c02y / config.fish
Last active August 23, 2018 03:25
tweak config.fish
in `function d`
change(type character/number without pressing Enter)
read -l -p 'echo "Goto: "' choice
to
read -n 1 -l -p 'echo "Goto: "' choice
change(echo path without /home/users)
if string match -q -r '^\d+$' $choice
@c02y
c02y / b2
Last active August 26, 2018 10:32
one base converter for all bin/oct/dec/hex
#!/usr/bin/perl
if (@ARGV < 2) {
printf("Convert numbers among bin/oct/dec/hex\n");
printf("\nUsage: b2 2/8/10/16 num num2 ... \n");
exit;
}
for ($i=1; $i<@ARGV; $i++) {
if ($ARGV[0] == 2) {
@c02y
c02y / init.el
Created September 3, 2018 09:42
C-w/C-x w
(defun delete-line-or-region-or-buffer ()
"Delete current line, or text selection.
When `universal-argument' is called first, delete whole buffer (respects `narrow-to-region')."
(interactive)
(if current-prefix-arg
(delete-region (point-min) (point-max))
(progn (if (use-region-p)
(delete-region (region-beginning) (region-end))
(progn
(if (current-line-empty-p)
@c02y
c02y / init.el
Created September 13, 2018 05:55
hydra in init.el
(autoload 'multiple-cursors "multiple-cursors" t)
(defhydra multiple-cursors-hydra (:hint nil)
"
^Up^ ^Down^ ^Other^
----------------------------------------------
[_p_] Next [_n_] Next [_l_] Edit lines
[_P_] Skip [_N_] Skip [_a_] Mark all
[_M-p_] Unmark [_M-n_] Unmark [_r_] Mark by regexp
^ ^ ^ ^ [_q_] Quit
"
@c02y
c02y / gist:a64e270c0089edbaf07e901f9c231afb
Created October 8, 2018 06:00
config of "simple=select+search" extension for Chrome
{"newTab":true,"newTabSelected":true,"newTabPosition":"Next","trackGA":true,"searchEverywhere":true,"searchEverywhereGroups":false,"searchEngines":[{"name":"Youtube","url":"http://www.youtube.com/results?search_query=%s&aq=f","incognito":false,"plus":false,"group":null,"$$hashKey":"object:161"},{"name":"Wikipedia","url":"http://en.wikipedia.org/w/index.php?title=Special:Search&search=%s","incognito":false,"plus":false,"group":null},{"name":"Chrome Extensions","url":"https://chrome.google.com/webstore/search?q=%s","incognito":false,"$$hashKey":"object:162"},{"name":"Google Images","url":"http://www.google.com/search?num=10&hl=en&site=imghp&tbm=isch&source=hp&q=%s","incognito":false},{"name":"Wikipedia","url":"http://en.wikipedia.org/w/index.php?title=Special:Search&search=%s","incognito":false},{"name":"Stackoverflow","url":"http://stackoverflow.com/search?q=%s","incognito":false},{"name":"Baidu","url":"https://www.baidu.com/s?wd=%s","incognito":false},{"name":"Github","url":"https://github.com/search?q=%s&ref