diff options
| author | Michal Hanus <hanus.michal@divelit.cz> | 2024-03-02 18:49:55 +0100 |
|---|---|---|
| committer | Michal Hanus <hanus.michal@divelit.cz> | 2024-03-02 18:49:55 +0100 |
| commit | aab38f32e0a02e43565a554d0a76ff65636499b8 (patch) | |
| tree | f3f00df05c63228c69a338e80fd0e7d02986e8cf /my_snippets | |
| parent | 99353a355321d68ef4fb3c26291084b23e8f4978 (diff) | |
Diffstat (limited to 'my_snippets')
| -rw-r--r-- | my_snippets/all.snippets | 7 | ||||
| -rw-r--r-- | my_snippets/cpp.snippets | 187 | ||||
| -rw-r--r-- | my_snippets/markdown.snippets | 168 | ||||
| -rw-r--r-- | my_snippets/python.snippets | 30 | ||||
| -rw-r--r-- | my_snippets/snippets.snippets | 6 | ||||
| -rw-r--r-- | my_snippets/tex.snippets | 9 | ||||
| -rw-r--r-- | my_snippets/vim.snippets | 14 |
7 files changed, 0 insertions, 421 deletions
diff --git a/my_snippets/all.snippets b/my_snippets/all.snippets deleted file mode 100644 index efe5ada..0000000 --- a/my_snippets/all.snippets +++ /dev/null @@ -1,7 +0,0 @@ -snippet "(?<!\w)ltx" "LaTeX symbol" r -LaTeX -endsnippet - -snippet arw "Right-pointed arrow" ---> $1 -endsnippet diff --git a/my_snippets/cpp.snippets b/my_snippets/cpp.snippets deleted file mode 100644 index 148c8d0..0000000 --- a/my_snippets/cpp.snippets +++ /dev/null @@ -1,187 +0,0 @@ -snippet bare "barebone code template" -#include <iostream> -#include <vector> -#include <string> -#include <map> -#include <unordered_map> -#include <set> -#include <unordered_set> -#include <stack> -#include <queue> -#include <numeric> - -using std::cout; -using std::endl; -using std::vector; -using std::string; -using std::map; -using std::unordered_map; -using std::set; -using std::unordered_set; -using std::stack; -using std::queue; -using std::pair; -using std::make_pair; - - - -int main() -{ - - return 0; -} -endsnippet - -snippet icd "#include directive" b -#include <$1> -$0 -endsnippet - -snippet plist "print vector" w -template <class T> -void printList(const T& arr, const string& desc){ - std::cout << desc << ": ["; - - for (auto it = arr.begin(); it != arr.end(); it++){ - std::cout << *it << ((std::next(it) != arr.end()) ? ", " : ""); - } - std::cout << "]\n"; -} -endsnippet - -snippet pmat "print list of list" w -template <class T> -void printMat(const vector<vector<T>>& mat, const string& desc){ - cout << desc << ": " << endl; - - for (auto it1 = mat.begin(); it1 != mat.end(); it1++){ - auto cur_vec = *it1; - cout << "["; - for (auto it2 = cur_vec.begin(); it2 != cur_vec.end(); it2++){ - cout << *it2 << ((std::next(it2) != cur_vec.end()) ? ", " : "]\n"); - } - } -} -endsnippet - -snippet pqueue "print queue" -template <class T> -void printQueue(T q){ - while(!q.empty()){ - std::cout << q.top() << " "; - q.pop(); - } - std::cout << '\n'; -} -endsnippet - -snippet cout "print a variable" w -cout << "$1: " << $2 << endl; -endsnippet - -snippet random "Generate a random list" b -// Generate a random sequence of length len, in range(low, high) (inclusive). -// need to #include<random> -vector<int> genRandom(int low, int high, int len){ - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_int_distribution<int> distribution(low, high); - - vector<int> arr(len, 0); - for (int i = 0; i != len; ++i){ - arr[i] = distribution(gen); - } - - return arr; -} -endsnippet - -snippet incset "Use set" b -#include <set> - -using std::set; -endsnippet - -snippet incmap "Use map" b -#include <map> - -using std::map; -endsnippet - -snippet incqueue "Use queue" b -#include <queue> - -using std::queue; -endsnippet - -snippet incstr "Use string" b -#include <string> - -using std::string; -endsnippet - -snippet incvec "Use vector" b -#include <vector> - -using std::vector; -endsnippet - -snippet incstack "Use stack" b -#include <stack> - -using std::stack; -endsnippet - -snippet vec "std::vector" w -vector<$1> ${2:vec} -endsnippet - -snippet map "std::map" w -map<$1, $2> ${3:mymap} -endsnippet - -snippet umap "std::unordered_map" -unordered_map<$1, $2> ${3:mymap} -endsnippet - -snippet set "std::set" w -set<$1> ${2:myset} -endsnippet - -snippet uset "std::unordered_set" w -unordered_set<$1> ${2:myset} -endsnippet - -snippet queue "std::queue" w -queue<$1> ${2:q} -endsnippet - -snippet stack "std::stack" w -stack<$1> ${2:mystack} -endsnippet - -snippet sol "solution" w -auto solution = Solution(); -$0 -endsnippet - -snippet for "for loop" w -for ($1; $2; $3){ - $4 -} -endsnippet - -snippet if "if condition" w -if ($1){ - $2 -} -$0 -endsnippet - -snippet ifelse "if else condition" -if ($1){ - $2 -}else{ - -} -endsnippet diff --git a/my_snippets/markdown.snippets b/my_snippets/markdown.snippets deleted file mode 100644 index e00f538..0000000 --- a/my_snippets/markdown.snippets +++ /dev/null @@ -1,168 +0,0 @@ -global !p -def gen_header(snip): - placeholders_string = snip.buffer[snip.line].strip() - level = int(placeholders_string[0]) - - # erase current line - snip.buffer[snip.line] = "" - line_content = "#"*level + " ${1:Section Name}" - line_content += '\n$0' - - snip.expand_anon(line_content) -endglobal - -snippet "(k1|kbd)" "HTML kbd tag" rw -<kbd>${1:KEY}</kbd>$0 -endsnippet - -snippet k2 "Two key strokes shortcut" -<kbd>${1:KEY}</kbd> + <kbd>${2:KEY}</kbd> -endsnippet - -snippet k3 "Three key strokes shortcut" -<kbd>${1:KEY}</kbd> + <kbd>${2:KEY}</kbd> + <kbd>${3:KEY}</kbd> -endsnippet - -snippet meta "Markdown front matter (YAML format)" b ---- -title: "$1" -date: `!p from datetime import datetime -if not snip.c: - snip.rv=datetime.now().astimezone().strftime("%Y-%m-%d %H:%M:%S%z")` -tags: [$2] -categories: [$3] ---- -$0 -endsnippet - -snippet more "HTML more tag" -<!--more--> -endsnippet - -snippet img "Aligned image using HTML tag" -<p align="center"> -<img src="${1:URL}" width="${2:800}"> -</p> -$0 -endsnippet - -snippet font "HTML font tag" -<font color="${1:blue}">${2:TEXT}</font> -endsnippet - -snippet link "Markdown links" -[$1]($2)$0 -endsnippet - -post_jump "gen_header(snip)" -snippet "h([1-6])" "Markdown header" br -`!p snip.rv = match.group(1)` -endsnippet - -snippet detail "Clickable details" b -<details> -<summary><font size="2" color="red">${1:Click to show the code.}</font></summary> - -$2 -</details> -endsnippet - -snippet yh "直角引号" w -「$1」 -endsnippet - -snippet info "info box" -<style type="text/css"> -@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css'); - -.info-msg { - color: #059; - background-color: #BEF; - margin: 5px 0; - margin-bottom: 20px; - padding: 10px; - border-radius: 5px 5px 5px 5px; - border: 2px solid transparent; - border-color: transparent; -} -</style> - -<div class="info-msg"> - <i class="fa fa-info-circle"> Info</i></br> - ${1:info text} -</div> -$0 -endsnippet - -snippet warn "warning box" -<style type="text/css"> -@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css'); - -.warning-msg { - color: #9F6000; - background-color: #FEEFB3; - margin: 5px 0; - margin-bottom: 20px; - padding: 10px; - border-radius: 5px 5px 5px 5px; - border: 2px solid transparent; - border-color: transparent; -} -</style> - -<div class="warning-msg"> - <i class="fa fa-warning"> Warning</i></br> - ${1:warning text} -</div> -$0 -endsnippet - -snippet error "error box" -<style type="text/css"> -@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css'); - -.error-msg { - color: #D8000C; - background-color: #FFBABA; - margin: 5px 0; - margin-bottom: 20px; - padding: 10px; - border-radius: 5px 5px 5px 5px; - border: 2px solid transparent; - border-color: transparent; -} -</style> - -<div class="error-msg"> - <i class="fa fa-times-circle"> Error</i></br> - ${1:error text} -</div> -$0 -endsnippet - -snippet success "success box" -<style type="text/css"> -@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css'); - -.success-msg { - color: #270; - background-color: #DFF2BF; - margin: 5px 0; - margin-bottom: 20px; - padding: 10px; - border-radius: 5px 5px 5px 5px; - border: 2px solid transparent; - border-color: transparent; -} -</style> - -<div class="success-msg"> - <i class="fa fa-check"></i> - ${1:success text} -</div> -$0 -endsnippet - -snippet td "too long do not read" bw -tl;dr: $1 -endsnippet diff --git a/my_snippets/python.snippets b/my_snippets/python.snippets deleted file mode 100644 index fc3f355..0000000 --- a/my_snippets/python.snippets +++ /dev/null @@ -1,30 +0,0 @@ -snippet head "Python source file header" b -""" -Description: $1 -Author: Jie-dong Hao (jdhao@hotmail.com) -Created: `!v strftime("%Y-%m-%d %H:%M:%S%z")` -""" -$0 -endsnippet - -snippet print "Print value of some variable" -print("$1".format($2)) -$0 -endsnippet - -snippet impa "import FOO as BAR" b -import ${1:FOO} as ${2:BAR} -endsnippet - -snippet main "Main function boilerplate" b -def main(): - $0 - - -if __name__ == "__main__": - main() -endsnippet - -snippet sol "solution" b -solution = Solution() -endsnippet diff --git a/my_snippets/snippets.snippets b/my_snippets/snippets.snippets deleted file mode 100644 index 5473902..0000000 --- a/my_snippets/snippets.snippets +++ /dev/null @@ -1,6 +0,0 @@ -# copied from https://github.com/honza/vim-snippets/blob/master/UltiSnips/snippets.snippets -snippet snip "Ultisnips snippet definition" b -`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b} -${0:${VISUAL}} -`!p snip.rv = "endsnippet"` -endsnippet diff --git a/my_snippets/tex.snippets b/my_snippets/tex.snippets deleted file mode 100644 index 3b979f3..0000000 --- a/my_snippets/tex.snippets +++ /dev/null @@ -1,9 +0,0 @@ -snippet use "usepackage" b -\usepackage{${1:package}} -endsnippet - -snippet eqa "equation environment" b -\begin{equation}\label{$1} - $2 -\end{equation} -endsnippet diff --git a/my_snippets/vim.snippets b/my_snippets/vim.snippets deleted file mode 100644 index a2e0d3c..0000000 --- a/my_snippets/vim.snippets +++ /dev/null @@ -1,14 +0,0 @@ -snippet fun "vim function" -function! ${1:MyFunc}(${2}) abort - $3 -endfunction -$0 -endsnippet - -snippet aug "vim augroup" b -augroup ${1:GROUP_NAME} - autocmd! - autocmd ${2:EVENT} ${3:PATTERN} $4 -augroup END -$0 -endsnippet |
