OSDN Git Service

Regular updates
authorErik <erikgronwal@users.osdn.me>
Mon, 27 Sep 2021 14:55:05 +0000 (23:55 +0900)
committerErik <erikgronwal@users.osdn.me>
Mon, 27 Sep 2021 14:55:05 +0000 (23:55 +0900)
cron.md
curl.md
grep.md [new file with mode: 0644]
jinja.md [new file with mode: 0644]
jinja2.md [new file with mode: 0644]
jsdoc.md
mako.md [new file with mode: 0644]
vimscript.md

diff --git a/cron.md b/cron.md
index b32ab60..401faba 100644 (file)
--- a/cron.md
+++ b/cron.md
@@ -47,7 +47,7 @@ Min  Hour Day  Mon  Weekday
 | `*/15 * * * *` | every 15 mins               |
 | `0 */2 * * *`  | every 2 hours               |
 | `0 18 * * 0-6` | every week Mon-Sat at 6pm   |
-| `10 2 * * 6,7` | every Sat and Thu on 2:10am |
+| `10 2 * * 6,7` | every Sat and Sun on 2:10am |
 | `0 0 * * 0`    | every Sunday midnight       |
 | ---            | ---                         |
 | `@reboot`      | every reboot                |
diff --git a/curl.md b/curl.md
index 419e3fb..ac63347 100644 (file)
--- a/curl.md
+++ b/curl.md
@@ -17,7 +17,8 @@ updated: 2020-03-09
 ```bash
 -v           # --verbose
 -vv          # Even more verbose
--s           # --silent
+-s           # --silent: don't show progress meter or errors
+-S           # --show-error: when used with --silent (-sS), show errors but no progress meter
 ```
 
 ```bash
diff --git a/grep.md b/grep.md
new file mode 100644 (file)
index 0000000..c9dc9b0
--- /dev/null
+++ b/grep.md
@@ -0,0 +1,102 @@
+---
+title: GNU grep
+category: CLI
+layout: 2017/sheet
+updated: 2021-08-23
+---
+
+### Usage
+{: .-prime}
+
+```bash
+grep <options> pattern <file...>
+```
+
+### Matching options
+
+```bash
+-e, --regexp=PATTERN
+-f, --file=FILE
+-i, --ignore-case
+-v, --invert-match
+-w, --word-regexp
+-x, --line-regexp
+```
+
+### Pattern options
+
+```bash
+-F, --fixed-strings   # list of fixed strings
+-G, --basic-regexp    # basic regular expression (default)
+-E, --extended-regexp # extended regular expression
+-P, --perl-regexp     # perl compatible regular expression
+```
+
+### Expressions
+
+#### Basic Regular Expressions (BRE)
+
+In BRE, these characters have a special meaning unless they are escaped with a backslash:
+
+`^ $ . * [ ] \`
+
+However, these characters do not have any special meaning unless they are escaped with a backslash:
+
+`? + { } | ( )`
+       
+#### Extended Regular Expressions (ERE)
+
+ERE gives all of these characters a special meaning unless they are escaped with a backslash:
+
+`^ $ . * + ? [ ] ( ) | { }`
+
+#### Perl Compatible Regular Expressions (PCRE)
+
+PCRE has even more options such as additional anchors and character classes, lookahead/lookbehind, conditional expressions, comments, and more. See the [regexp cheatsheet](/regexp).
+
+### Output Options
+
+```bash
+-c, --count           # print the count of matching lines. suppresses normal output
+    --color[=WHEN]    # applies color to the matches. WHEN is never, always, or auto
+-m, --max-count=NUM   # stop reading after max count is reached
+-o, --only-matching   # only print the matched part of a line
+-q, --quiet, --silent
+-s, --no-messages     # suppress error messages about nonexistent or unreadable files
+```
+
+### Context Options
+
+```bash
+-B NUM, --before-context=NUM  # print NUM lines before a match
+-A NUM, --after-context=NUM   # print NUM lines after a match
+-C NUM, -NUM, --context=NUM   # print NUM lines before and after a match
+```
+
+### Examples
+
+```bash
+# Case insensitive: match any line in foo.txt
+# that contains "bar"
+grep -i bar foo.txt
+
+#  match any line in bar.txt that contains
+# either "foo" or "oof"
+grep -E "foo|oof" bar.txt
+
+# match anything that resembles a URL in
+# foo.txt and only print out the match
+grep -oE "https?:\/\/((\w+[_-]?)+\.?)+" foo.txt
+
+# can also be used with pipes:
+# match any line that contains "export" in
+# .bash_profile, pipe to another grep that
+# matches any of the first set of matches
+# containing "PATH"
+grep "export" .bash_profile | grep "PATH"
+
+# follow the tail of server.log, pipe to grep
+# and print out any line that contains "error"
+# and include 5 lines of context
+tail -f server.log | grep -iC 5 error
+```
diff --git a/jinja.md b/jinja.md
new file mode 100644 (file)
index 0000000..63c857a
--- /dev/null
+++ b/jinja.md
@@ -0,0 +1,101 @@
+---
+title: jinja
+category: python
+layout: 2017/sheet
+---
+
+{% raw %}
+### Basic usage
+
+```
+- variable x has content: {{ x }}
+- expression: {{ x + 1 }}
+- escaped for HTML: {{ x | e }}
+```
+
+### Control structures
+
+```
+{% for x in range(5) %}
+    {% if x % 2 == 0 %}
+        {{ x }} is even!
+    {% else %}
+        {{ x }} is odd!
+    {% endif %}
+{% endfor %}
+```
+
+### Whitespace trimming
+
+```
+these are
+{{ "three" }}
+lines.
+
+this is conc
+{{- "at" -}}
+enated.
+```
+
+### Special blocks
+
+```
+{% filter e %}{% endraw %}
+{ {%- if 0 -%}{%- endif -%} % raw %}
+{%- raw -%}
+    This is a raw block where {{nothing is evaluated}}
+    {% not even this %}
+    and <html is escaped> too with "e" filter
+{% endraw %}
+{ {%- if 0 -%}{%- endif -%} % endraw %}{% raw %}
+{% endfilter %}
+
+{% macro myfunc(x) %}
+    this is a reusable macro, with arguments: {{x}}
+{% endmacro %}
+
+{{ myfunc(42) }}
+
+{#
+this is a comment
+#}
+```
+
+
+### Inheritance
+
+#### shared.html
+
+```
+<html>
+  <head>
+    <title>{%block title %}{% endblock %}</title>
+  </head>
+  <body>
+    <header><h1>{% block title %}{% endblock %}</h1></header>
+    <main>{% block content %}{% endblock %}</main>
+  </body>
+</html>
+```
+
+#### home.html
+
+```
+{% extends "shared.html" %}
+{% block title %}Welcome to my site{% endblock %}
+{% block content %}
+This is the body
+{% endblock %}
+```
+
+## Library
+
+### Basic usage
+
+```python
+from jinja2 import Template
+template = Template('Hello {{ name }}!')
+template.render(name='John Doe') == u'Hello John Doe!'
+```
+
+{% endraw %}
diff --git a/jinja2.md b/jinja2.md
new file mode 100644 (file)
index 0000000..5ec30e8
--- /dev/null
+++ b/jinja2.md
@@ -0,0 +1,5 @@
+---
+title: jinja
+category: python
+redirect_to: /jinja
+---
index 6171f0c..1eee7ce 100644 (file)
--- a/jsdoc.md
+++ b/jsdoc.md
@@ -13,6 +13,8 @@ weight: -1
  * This is a function.
  *
  * @param {string} n - A string param
+ * @param {string} [o] - A optional string param
+ * @param {string} [d=DefaultValue] - A optional string param
  * @return {string} A good string
  *
  * @example
@@ -20,7 +22,7 @@ weight: -1
  *     foo('hello')
  */
 
-function foo(n) {
+function foo(n, o, d) {
   return n
 }
 ```
diff --git a/mako.md b/mako.md
new file mode 100644 (file)
index 0000000..f4c9e0b
--- /dev/null
+++ b/mako.md
@@ -0,0 +1,114 @@
+---
+title: mako
+category: python
+layout: 2017/sheet
+---
+
+### Basic usage
+
+```
+Variable x has content: ${x}
+Expression: ${x + 1}
+Escaped for HTML: ${x | h}
+```
+
+### Control structures
+
+```html
+% for x in range(5):
+    % if x % 2 == 0:
+    ${x} is even!
+    % else:
+    ${x} is odd!
+    % endif
+% endfor
+```
+
+### Including Python code
+
+```python
+<%
+    greeting = "Hello world!"
+    # arbitrary python code
+%>
+
+<%!
+# arbitrary python code run at toplevel
+# cannot access variables!
+
+def sign_string(number):
+    if number > 0:
+        return "positive"
+    elif number < 0:
+        return "negative"
+    else:
+        return "zero"
+%>
+```
+
+### Special blocks
+
+```html
+<%text filter="h">
+    This is a raw block where ${nothing is evaluated}
+    <%
+        not even this
+    %>
+    and <html is escaped> too with "h" filter
+</%text>
+
+<%def name="myfunc(x)">
+    this is a reusable macro, with arguments: ${x}
+</%def>
+
+${myfunc(42)}
+
+<%doc>
+    this is a comment
+</%doc>
+```
+
+### Inheritance
+
+#### shared.html
+
+```html
+<html>
+  <head>
+    <title><%block name="title" /></title>
+  </head>
+  <body>
+    <header><h1><%block name="title" /></h1></header>
+    <main>${self.body()}</main>
+  </body>
+</html>
+```
+
+#### home.html
+
+```html
+<%inherit file="shared.html" />
+<%block name="title">Welcome to my site</%block>
+
+This is the body
+```
+
+#### article.html
+
+```html
+<%inherit file="shared.html" />
+<%block name="title">${post.title}</%block>
+
+${post.content}
+```
+
+## Library
+
+### Basic usage
+
+```python
+from mako.template import Template
+
+mytemplate = Template("hello, ${name}!")
+print(mytemplate.render(name="jack"))
+```
index 79c8e96..2174cea 100644 (file)
@@ -140,7 +140,7 @@ function! s:Initialize(cmd, args)
   " a: prefix for arguments
   echo "Command: " . a:cmd
 
-  return true
+  return 1
 endfunction
 ```