This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my/get-yasnippet-content-by-name(snippet-name &optional mode) | |
(yas--template-content (yas--get-template-by-uuid (yas--table-get-create (or mode major-mode) ) snippet-name))) | |
(defun my/get-yasnippet-expansion-by-name(snippet-name &optional mode) | |
(let ((mode (or mode major-mode)) start-point snippet-expansion) | |
(save-excursion | |
;; (funcall mode) | |
(unless yas-minor-mode (yas-minor-mode)) | |
(goto-char (point-max)) | |
(insert "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my/get-yasnippet-snippet-name () | |
"Get the name of the Yasnippet defined in the current buffer." | |
(save-excursion | |
(goto-char (point-min)) | |
(forward-line) | |
(when (looking-at "# name: \\(.*\\)$") | |
(match-string-no-properties 1)))) | |
(defun my/get-yasnippet-mode () | |
(when (eq major-mode 'snippet-mode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.9 | |
import sxtwl | |
import argparse | |
import datetime as dt | |
DATE_FORMAT = "%Y-%m-%d" | |
parser = argparse.ArgumentParser(description='convert between lunar and solar calendar') | |
parser.add_argument('date', metavar='date', type=str, nargs='?', default=dt.datetime.today().strftime(DATE_FORMAT), | |
help='date to convert') | |
parser.add_argument('-s', dest='is_solar', action='store_const', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 去除代码块后面的% | |
$enter_code = 0; | |
while(<>) { | |
if(/\\begin\{langbox\}/) { | |
$enter_code = 1; | |
} elsif(/\\end\{langbox\}/) { | |
$enter_code = 0; | |
} | |
if($enter_code) { | |
s/%(\s*)$/$1/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AS = gcc | |
CC = gcc | |
LD = ld | |
ASFLAGS += -g -m32 | |
CFLAGS += -g -O0 | |
CFLAGS += -march=i386 -m32 -fno-stack-protector | |
CFLAGS += -fcf-protection=none # remove endbr32 in Ubuntu 20.04 with a CPU newer than Comet Lake | |
LDFLAGS += -melf_i386 | |
main: main.o memcpy.o | |
$(LD) $(LDFLAGS) -o main $^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cm2u () { | |
[email protected] | |
port=22 | |
# tmp_file_path=$(mktemp -t clipboard.XXXXXX) | |
tmp_file_path=/tmp/clipboard.m2h | |
pbpaste > $tmp_file_path | |
scp -q -P $port $tmp_file_path $hpc_host:/tmp/ | |
ssh -X -p $port $host "xclip -i -sel c < $tmp_file_path" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <pthread.h> | |
#include <semaphore.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#define CHAIR_NUM 3 | |
#define SOFA_NUM 4 | |
#define CAPACITY 20 | |
#define CUSTOMER_NUM 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 希望, jc a.ipynb, 得到a_ipynb.R, -f或者--format, 指定是得到md | |
# 反过来, jc a_ipynb.R能得到a.ipynb | |
# {{{1 全局变量 | |
format=python # 默认是python | |
target_filename="" | |
# {{{1 print_usage | |
print_usage() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include_dir=build | |
source=~/Downloads/100-gcc-tips/md/src/*.md | |
title='gcc-100' | |
filename='gcc-100' | |
all: html epub rtf pdf mobi | |
markdown: | |
awk 'FNR==1{print ""}{print}' $(source) > $(filename).md |
NewerOlder