mirror of
https://github.com/Fechin/reference.git
synced 2026-11-21 05:24:10 +03:00
Merge branch 'main' of https://github.com/okolyachko/reference
This commit is contained in:
commit
875aa23766
22 files changed
+1789
-31
No files matched your search
@@ -0,0 +1,12 @@
|
||||
node_modules/
|
||||
test
|
||||
*.log
|
||||
Dockerfile*
|
||||
README.md
|
||||
LICENSE
|
||||
style.tailwindcss
|
||||
|
||||
.idea/
|
||||
.github/
|
||||
.travis.yml
|
||||
.eslintignore
|
||||
+13
-17
@@ -1,18 +1,14 @@
|
||||
# Stage 1: build the application
|
||||
FROM nginx:alpine AS build
|
||||
RUN rm -rf /etc/nginx/conf.d/*
|
||||
COPY nginx.conf /etc/nginx/
|
||||
COPY public /usr/share/nginx/html/
|
||||
EXPOSE 80
|
||||
|
||||
# Stage 2: final image
|
||||
FROM alpine:latest
|
||||
|
||||
# Install thttpd
|
||||
RUN apk add --no-cache thttpd
|
||||
|
||||
# Create a non-root user to own the files and run our server
|
||||
RUN adduser -D static
|
||||
USER static
|
||||
WORKDIR /home/static
|
||||
|
||||
# Copy the static website
|
||||
# Use the .dockerignore file to control what ends up inside the image!
|
||||
COPY public .
|
||||
|
||||
# Run thttpd
|
||||
CMD ["thttpd", "-D", "-h", "0.0.0.0", "-p", "3000", "-d", "/home/static", "-u", "static", "-l", "-", "-M", "60"]
|
||||
|
||||
EXPOSE 3000
|
||||
RUN apk add --no-cache nginx && mkdir -p /run/nginx
|
||||
COPY --from=build /usr/share/nginx/html/ /usr/share/nginx/html/
|
||||
COPY --from=build /etc/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
error_log /var/log/nginx/error.log notice;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
access_log /var/log/nginx/access.log ;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# error_page
|
||||
error_page 404 403 500 502 503 504 /assets/page/oops.htm;
|
||||
|
||||
# Rename cheatsheet
|
||||
rewrite ^/golang$ /go permanent;
|
||||
rewrite ^/css$ /css3 permanent;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ @html;
|
||||
}
|
||||
|
||||
location @html {
|
||||
# remove .html extension
|
||||
rewrite ^(.*)\.html$ $1 permanent;
|
||||
try_files $uri.html $uri/ =404;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -949,6 +949,7 @@ Getting Started
|
||||
|
||||
|
||||
### Education assistant
|
||||
- [ Brain Buddy](https://brain-buddy.com/)
|
||||
- [ Kobra](https://kobra.dev)
|
||||
- [ Boldvoice](https://boldvoice.com)
|
||||
- [ Prepai](https://prepai.in/us)
|
||||
|
||||
+133
-5
@@ -571,33 +571,161 @@ int main() {
|
||||
}
|
||||
```
|
||||
|
||||
C++ Classes & Objects
|
||||
C++ Classes & Objects {.cols-2}
|
||||
-----------------
|
||||
|
||||
### If statement
|
||||
### Defining a Class
|
||||
|
||||
```cpp
|
||||
class MyClass {
|
||||
public: // Access specifier
|
||||
int myNum; // Attribute (int variable)
|
||||
string myString; // Attribute (string variable)
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
### If statement
|
||||
### Creating an Object
|
||||
|
||||
```cpp
|
||||
MyClass myObj; // Create an object of MyClass
|
||||
|
||||
myObj.myNum = 15; // Set the value of myNum to 15
|
||||
myObj.myString = "Hello"; // Set the value of myString to "Hello"
|
||||
|
||||
cout << myObj.myNum << endl; // Output 15
|
||||
cout << myObj.myString << endl; // Output "Hello"
|
||||
|
||||
```
|
||||
|
||||
### If statement
|
||||
### Constructors
|
||||
|
||||
```cpp
|
||||
class MyClass {
|
||||
public:
|
||||
int myNum;
|
||||
string myString;
|
||||
MyClass() { // Constructor
|
||||
myNum = 0;
|
||||
myString = "";
|
||||
}
|
||||
};
|
||||
|
||||
MyClass myObj; // Create an object of MyClass
|
||||
|
||||
cout << myObj.myNum << endl; // Output 0
|
||||
cout << myObj.myString << endl; // Output ""
|
||||
|
||||
```
|
||||
|
||||
### If statement
|
||||
### Destructors
|
||||
|
||||
```cpp
|
||||
class MyClass {
|
||||
public:
|
||||
int myNum;
|
||||
string myString;
|
||||
MyClass() { // Constructor
|
||||
myNum = 0;
|
||||
myString = "";
|
||||
}
|
||||
~MyClass() { // Destructor
|
||||
cout << "Object destroyed." << endl;
|
||||
}
|
||||
};
|
||||
|
||||
MyClass myObj; // Create an object of MyClass
|
||||
|
||||
// Code here...
|
||||
|
||||
// Object is destroyed automatically when the program exits the scope
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Class Methods
|
||||
|
||||
```cpp
|
||||
class MyClass {
|
||||
public:
|
||||
int myNum;
|
||||
string myString;
|
||||
void myMethod() { // Method/function defined inside the class
|
||||
cout << "Hello World!" << endl;
|
||||
}
|
||||
};
|
||||
|
||||
MyClass myObj; // Create an object of MyClass
|
||||
myObj.myMethod(); // Call the method
|
||||
```
|
||||
|
||||
|
||||
### Access Modifiers
|
||||
|
||||
```cpp
|
||||
class MyClass {
|
||||
public: // Public access specifier
|
||||
int x; // Public attribute
|
||||
private: // Private access specifier
|
||||
int y; // Private attribute
|
||||
protected: // Protected access specifier
|
||||
int z; // Protected attribute
|
||||
};
|
||||
|
||||
MyClass myObj;
|
||||
myObj.x = 25; // Allowed (public)
|
||||
myObj.y = 50; // Not allowed (private)
|
||||
myObj.z = 75; // Not allowed (protected)
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Getters and Setters
|
||||
|
||||
```cpp
|
||||
class MyClass {
|
||||
private:
|
||||
int myNum;
|
||||
public:
|
||||
void setMyNum(int num) { // Setter
|
||||
myNum = num;
|
||||
}
|
||||
int getMyNum() { // Getter
|
||||
return myNum;
|
||||
}
|
||||
};
|
||||
|
||||
MyClass myObj;
|
||||
myObj.setMyNum(15); // Set the value of myNum to 15
|
||||
cout << myObj.getMyNum() << endl; // Output 15
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Inheritance
|
||||
|
||||
```cpp
|
||||
class Vehicle {
|
||||
public:
|
||||
string brand = "Ford";
|
||||
void honk() {
|
||||
cout << "Tuut, tuut!" << endl;
|
||||
}
|
||||
};
|
||||
|
||||
class Car : public Vehicle {
|
||||
public:
|
||||
string model = "Mustang";
|
||||
};
|
||||
|
||||
Car myCar;
|
||||
myCar.honk(); // Output "Tuut, tuut!"
|
||||
cout << myCar.brand + " " + myCar.model << endl; // Output "Ford Mustang"
|
||||
```
|
||||
|
||||
|
||||
|
||||
C++ Preprocessor
|
||||
------------
|
||||
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,327 @@
|
||||
---
|
||||
title: EJS
|
||||
date: 2023-04-07
|
||||
background: bg-[#b4ca65]
|
||||
tags:
|
||||
- EJS
|
||||
- Frontend
|
||||
- Framework
|
||||
categories:
|
||||
- Programming
|
||||
intro: EJS(Embedded JavaScript) is a simple templating language that lets you generate HTML markup with plain JavaScript.
|
||||
plugins:
|
||||
- copyCode
|
||||
---
|
||||
|
||||
Get Started { .cols-3 }
|
||||
-----------
|
||||
|
||||
### Hello world
|
||||
|
||||
#### install
|
||||
```
|
||||
npm install ejs
|
||||
```
|
||||
|
||||
#### hello.ejs
|
||||
```html
|
||||
<% if (user.email) { %>
|
||||
<h1><%= user.email %></h1>
|
||||
<% } %>
|
||||
```
|
||||
|
||||
#### CLI
|
||||
```shell
|
||||
$ ejs hello.ejs -o hello.html
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Render with Data
|
||||
|
||||
```
|
||||
let ejs = require('ejs');
|
||||
|
||||
let people = ['geddy', 'neil', 'alex'];
|
||||
let tpl = '<%= people.join(", "); %>';
|
||||
|
||||
let html = ejs.render(tpl, {people: people});
|
||||
console.log(html);
|
||||
```
|
||||
Pass EJS a template string and some data.
|
||||
|
||||
|
||||
|
||||
### Browser Support
|
||||
|
||||
```
|
||||
<script src="ejs.js"></script>
|
||||
<script>
|
||||
let people = ['geddy', 'neil', 'alex'];
|
||||
let html = ejs.render('<%= people.join(", "); %>', {people: people});
|
||||
</script>
|
||||
```
|
||||
Use ejs in a script tag.
|
||||
|
||||
|
||||
|
||||
### Variables
|
||||
| | |
|
||||
|--------------|----------------------------------|
|
||||
| `<%= var %>` | Prints the value of the variable |
|
||||
| `<%- var %>` | Prints without HTML escaping |
|
||||
|
||||
|
||||
### CLI
|
||||
|
||||
Render and specify an output file.
|
||||
```shell
|
||||
$ ejs hello.ejs -o hello.html
|
||||
```
|
||||
|
||||
Feed it a template file and a data file
|
||||
```shell
|
||||
$ ejs hello.ejs -f data.json -o hello.html
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Comments
|
||||
```html
|
||||
<%# This line will denote a comment %>
|
||||
```
|
||||
---------
|
||||
```html
|
||||
<%# This is a multi-line EJS comment.
|
||||
It can span multiple lines,
|
||||
but will not be displayed
|
||||
in the final HTML output.
|
||||
%>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
### Method
|
||||
|
||||
```
|
||||
let ejs = require('ejs');
|
||||
let template = ejs.compile(str, options);
|
||||
|
||||
template(data);
|
||||
// => Rendered HTML string
|
||||
|
||||
ejs.render(str, data, options);
|
||||
// => Rendered HTML string
|
||||
|
||||
ejs.renderFile(filename, data, options, function(err, str){
|
||||
// str => Rendered HTML string
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Including Files
|
||||
|
||||
```html
|
||||
<%- include('partials/navbar.ejs') %>
|
||||
```
|
||||
|
||||
Include a template with data:
|
||||
|
||||
```html
|
||||
<% include('header', { title: 'My Page' }) %>
|
||||
```
|
||||
------------
|
||||
|
||||
```html
|
||||
<ul>
|
||||
<% users.forEach(function(user){ %>
|
||||
<%- include('item', {user: user}); %>
|
||||
<% }); %>
|
||||
</ul>
|
||||
```
|
||||
|
||||
To include a template, needs a file name option, paths are relative
|
||||
|
||||
|
||||
|
||||
Docs {.cols-3}
|
||||
--------
|
||||
|
||||
|
||||
### Conditionals
|
||||
```html
|
||||
<% if (userLoggedIn) { %>
|
||||
<p>Welcome, <%= username %>!</p>
|
||||
<% } else { %>
|
||||
<p>Please log in.</p>
|
||||
<% } %>
|
||||
```
|
||||
|
||||
|
||||
### Using loops
|
||||
```html
|
||||
<% if (userLoggedIn) { %>
|
||||
<p>Welcome, <%= username %>!</p>
|
||||
<% } else { %>
|
||||
<p>Please log in.</p>
|
||||
<% } %>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Custom delimiters
|
||||
|
||||
```
|
||||
let ejs = require('ejs'),
|
||||
users = ['geddy', 'neil', 'alex'];
|
||||
|
||||
// Just one template
|
||||
ejs.render('<?= users.join(" | "); ?>',
|
||||
{users: users},
|
||||
{delimiter: '?'});
|
||||
// => 'geddy | neil | alex'
|
||||
|
||||
// Or globally
|
||||
ejs.delimiter = '$';
|
||||
ejs.render('<$= users.join(" | "); $>',
|
||||
{users: users});
|
||||
// => 'geddy | neil | alex'
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
### Caching
|
||||
|
||||
```
|
||||
let ejs = require('ejs'),
|
||||
LRU = require('lru-cache');
|
||||
|
||||
// LRU cache with 100-item limit
|
||||
ejs.cache = LRU(100);
|
||||
```
|
||||
|
||||
### Custom file loader
|
||||
|
||||
```
|
||||
let ejs = require('ejs');
|
||||
let myFileLoader = function (filePath) {
|
||||
return 'myFileLoader: ' + fs.readFileSync(filePath);
|
||||
};
|
||||
|
||||
ejs.fileLoader = myFileLoader;
|
||||
```
|
||||
|
||||
### Layouts
|
||||
|
||||
```
|
||||
<%- include('header'); -%>
|
||||
<h1>
|
||||
Title
|
||||
</h1>
|
||||
<p>
|
||||
My page
|
||||
</p>
|
||||
<%- include('footer'); -%>
|
||||
```
|
||||
|
||||
## Client-side support { .cols-2 }
|
||||
|
||||
### Example
|
||||
|
||||
```
|
||||
<div id="output"></div>
|
||||
<script src="ejs.min.js"></script>
|
||||
<script>
|
||||
let people = ['geddy', 'neil', 'alex'],
|
||||
html = ejs.render('<%= people.join(", "); %>', {people: people});
|
||||
// With jQuery:
|
||||
$('#output').html(html);
|
||||
// Vanilla JS:
|
||||
document.getElementById('output').innerHTML = html;
|
||||
</script>
|
||||
```
|
||||
|
||||
### Caveats
|
||||
|
||||
```
|
||||
let str = "Hello <%= include('file', {person: 'John'}); %>",
|
||||
fn = ejs.compile(str, {client: true});
|
||||
|
||||
fn(data, null, function(path, d){ // include callback
|
||||
// path -> 'file'
|
||||
// d -> {person: 'John'}
|
||||
// Put your code here
|
||||
// Return the contents of file as a string
|
||||
}); // returns rendered string
|
||||
```
|
||||
|
||||
|
||||
## Options { .cols-1 }
|
||||
|
||||
### Options list
|
||||
| Option | Description |
|
||||
|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| cache | Compiled functions are cached, requires filename |
|
||||
| filename | Used by cache to key caches, and for includes |
|
||||
| root | Set project root for includes with an absolute path (e.g., /file.ejs). Can be an array to try to resolve include from multiple directories. |
|
||||
| views | An array of paths to use when resolving includes with relative paths. |
|
||||
| context | Function execution context |
|
||||
| compileDebug | When false, no debug instrumentation is compiled |
|
||||
| client | Returns standalone compiled function |
|
||||
| delimiter | Character to use for inner delimiter, by default '%' |
|
||||
| openDelimiter | Character to use for opening delimiter, by default '<' |
|
||||
| closeDelimiter | Character to use for closing delimiter, by default '>' |
|
||||
| debug | Outputs generated function body |
|
||||
| strict | When set to `true`, generated function is in strict mode |
|
||||
| _with | Whether or not to use with() {} constructs. If false, then the locals will be stored in the locals object. (Implies `--strict`) |
|
||||
| localsName | Name to use for the object storing local variables when not using with Defaults to locals |
|
||||
| rmWhitespace | Remove all safe-to-remove whitespace, including leading and trailing whitespace. It also enables a safer version of -%> line slurping for all scriptlet tags (it does not strip new lines of tags in the middle of a line). |
|
||||
| escape | The escaping function used with <%= construct. It is used in rendering and is .toString()ed in the generation of client functions. (By default escapes XML). |
|
||||
| outputFunctionName| Set to a string (e.g., 'echo' or 'print') for a function to print output inside scriptlet tags. |
|
||||
| async | When true, EJS will use an async function for rendering. (Depends on async/await support in the JS runtime. |
|
||||
|
||||
## Tags { .cols-1 }
|
||||
|
||||
### Tags list
|
||||
| Tag | Description |
|
||||
|------|----------------------------------------------------------------------|
|
||||
| <% | 'Scriptlet' tag, for control-flow, no output |
|
||||
| <%_ | 'Whitespace Slurping' Scriptlet tag, strips all whitespace before it |
|
||||
| <%= | Outputs the value into the template (HTML escaped) |
|
||||
| <%- | Outputs the unescaped value into the template |
|
||||
| <%# | Comment tag, no execution, no output |
|
||||
| <%% | Outputs a literal '<%' |
|
||||
| %> | Plain ending tag |
|
||||
| -%> | Trim-mode ('newline slurp') tag, trims following newline |
|
||||
| _%> | 'Whitespace Slurping' ending tag, removes all whitespace after it |
|
||||
|
||||
## Cli { .cols-1 }
|
||||
|
||||
### Cli list
|
||||
| Option | Description |
|
||||
|----------------|-------------------------------------------------------------------------------------------------------------------------|
|
||||
| cache | Compiled functions are cached, requires filename |
|
||||
| -o / --output-file FILE | Write the rendered output to FILE rather than stdout. |
|
||||
| -f / --data-file FILE | Must be JSON-formatted. Use parsed input from FILE as data for rendering. |
|
||||
| -i / --data-input STRING | Must be JSON-formatted and URI-encoded. Use parsed input from STRING as data for rendering. |
|
||||
| -m / --delimiter CHARACTER | Use CHARACTER with angle brackets for open/close (defaults to %). |
|
||||
| -p / --open-delimiter CHARACTER | Use CHARACTER instead of left angle bracket to open. |
|
||||
| -c / --close-delimiter CHARACTER| Use CHARACTER instead of right angle bracket to close. |
|
||||
| -s / --strict | When set to `true`, generated function is in strict mode |
|
||||
| -n / --no-with | Use 'locals' object for vars rather than using `with` (implies --strict). |
|
||||
| -l / --locals-name | Name to use for the object storing local variables when not using `with`. |
|
||||
| -w / --rm-whitespace | Remove all safe-to-remove whitespace, including leading and trailing whitespace. |
|
||||
| -d / --debug | Outputs generated function body |
|
||||
| -h / --help | Display this help message. |
|
||||
| -V/v / --version | Display the EJS version. |
|
||||
|
||||
|
||||
Examples of use :
|
||||
```
|
||||
$ ejs -p [ -c ] ./template_file.ejs -o ./output.html
|
||||
$ ejs ./test/fixtures/user.ejs name=Lerxst
|
||||
$ ejs -n -l _ ./some_template.ejs -f ./data_file.json
|
||||
```
|
||||
@@ -0,0 +1,176 @@
|
||||
---
|
||||
title: Homebrew
|
||||
date: 2023-04-12
|
||||
background: bg-[#fbb041]
|
||||
tags:
|
||||
- packages manager
|
||||
- macos
|
||||
categories:
|
||||
- Toolkit
|
||||
intro: This is a quick reference cheat sheet to getting started with homebrew.
|
||||
plugins:
|
||||
- copyCode
|
||||
---
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Install
|
||||
|
||||
If not installed, instll Command Line Tools (CTL)
|
||||
|
||||
```
|
||||
xcode-select --install
|
||||
```
|
||||
|
||||
Install Homebrew :
|
||||
|
||||
```
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
```
|
||||
|
||||
### Commands
|
||||
|
||||
| | |
|
||||
|----------------------------------|----------------------------------------|
|
||||
| ``` brew install git ``` | Install a package |
|
||||
| ``` brew uninstall git ``` | Uninstall a package |
|
||||
| ``` brew upgrade git ``` | Upgrade package |
|
||||
| ``` brew unlink git ``` | Unlink |
|
||||
| ``` brew link git ``` | Link |
|
||||
| ``` brew switch git 1.0.0 ``` | Switch package version |
|
||||
| ``` brew list --versions git ``` | List the installed versions of package |
|
||||
|
||||
|
||||
### Help
|
||||
|
||||
Display the version of Homebrew.
|
||||
````
|
||||
brew --version
|
||||
````
|
||||
Print Help Information
|
||||
````
|
||||
brew help
|
||||
````
|
||||
Print Help Info for a brew command
|
||||
````
|
||||
brew help <sub-command>
|
||||
````
|
||||
Check system for potential problems.
|
||||
````
|
||||
brew doctor
|
||||
````
|
||||
|
||||
### Updates
|
||||
|
||||
Fetch latest version of homebrew and formula
|
||||
```
|
||||
brew update
|
||||
```
|
||||
Show formulae with an updated version available
|
||||
```
|
||||
brew outdated
|
||||
```
|
||||
Upgrade all outdated and unpinned brews
|
||||
```
|
||||
brew upgrade
|
||||
```
|
||||
Upgrade only the specified brew
|
||||
```
|
||||
brew upgrade <formula>
|
||||
```
|
||||
Prevent the specified formulae from being upgraded
|
||||
```
|
||||
brew pin <formula>
|
||||
```
|
||||
Allow the specified formulae to be upgraded.
|
||||
```
|
||||
brew unpin <formula>
|
||||
```
|
||||
|
||||
### Repositories
|
||||
|
||||
List all the current tapped repositories (taps)
|
||||
```
|
||||
brew tap
|
||||
```
|
||||
Tap a formula repository from Github using https for tap https://github.com/user/homebrew-repo
|
||||
```
|
||||
brew tap <user/repo>
|
||||
```
|
||||
Tap a formula repository from the specified URL
|
||||
```
|
||||
brew tap <user/repo> <URL>
|
||||
```
|
||||
Remove the given tap from the repository
|
||||
```
|
||||
brew untap <user/repo>
|
||||
```
|
||||
|
||||
### Cask
|
||||
|
||||
Tap the Cask repository from Github.
|
||||
```
|
||||
brew tap homebrew/cask
|
||||
```
|
||||
List all the installed casks .
|
||||
```
|
||||
brew cask list
|
||||
```
|
||||
Search all known casks based on the substring text.
|
||||
```
|
||||
brew search <text>
|
||||
```
|
||||
Install the given cask.
|
||||
```
|
||||
brew cask install <cask>
|
||||
```
|
||||
Reinstalls the given Cask
|
||||
```
|
||||
brew cask reinstall <cask>
|
||||
```
|
||||
Uninstall the given cask.
|
||||
```
|
||||
brew cask uninstall <cask>
|
||||
```
|
||||
|
||||
### Search, Install, Remove
|
||||
|
||||
List all the installed formulae.
|
||||
```
|
||||
brew list
|
||||
```
|
||||
Display all locally available formulae for brewing.
|
||||
```
|
||||
brew search
|
||||
```
|
||||
Perform a substring search of formulae names for brewing.
|
||||
```
|
||||
brew search <text>
|
||||
```
|
||||
Display information about the formula.
|
||||
```
|
||||
brew info <formula>
|
||||
```
|
||||
Install the formula.
|
||||
```
|
||||
brew install <formula>
|
||||
```
|
||||
Uninstall the formula.
|
||||
```
|
||||
brew uninstall <formula>
|
||||
```
|
||||
|
||||
### Cleanup
|
||||
|
||||
Remove older versions of installed formulae.
|
||||
```
|
||||
brew cleanup
|
||||
```
|
||||
Remove older versions of specified formula.
|
||||
```
|
||||
brew cleanup <formula>
|
||||
```
|
||||
Display all formula that will be removed (dry run)
|
||||
```
|
||||
brew cleanup -n
|
||||
```
|
||||
@@ -589,6 +589,92 @@ numbers.concat(newFirstNumber)
|
||||
if you want to avoid mutating your original array, you can use concat.
|
||||
|
||||
|
||||
JavaScipt Set
|
||||
------------
|
||||
|
||||
### Create Set
|
||||
|
||||
```javascript
|
||||
// Empty Set Object
|
||||
const emptySet = new Set()
|
||||
|
||||
// Set Object with values
|
||||
const setObj = new Set([1, true, "hi"])
|
||||
```
|
||||
|
||||
|
||||
### Add
|
||||
|
||||
```javascript
|
||||
const emptySet = new Set()
|
||||
|
||||
// add values
|
||||
emptySet.add('a') // 'a'
|
||||
emptySet.add(1) // 'a', 1
|
||||
emptySet.add(true) // 'a', 1, true
|
||||
emptySet.add('a') // 'a', 1, true
|
||||
```
|
||||
|
||||
|
||||
### Delete
|
||||
|
||||
```javascript
|
||||
const emptySet = new Set([1, true, 'a'])
|
||||
|
||||
// delete values
|
||||
emptySet.delete('a') // 1, true
|
||||
emptySet.delete(true) // 1
|
||||
emptySet.delete(1) //
|
||||
```
|
||||
|
||||
|
||||
### Has
|
||||
|
||||
```javascript
|
||||
const setObj = new Set([1, true, 'a'])
|
||||
|
||||
// returns true or false
|
||||
setObj.has('a') // true
|
||||
setObj.has(1) // true
|
||||
setObj.has(false) // false
|
||||
```
|
||||
|
||||
|
||||
### Clear
|
||||
|
||||
```javascript
|
||||
const setObj = new Set([1, true, 'a'])
|
||||
|
||||
// clears the set
|
||||
console.log(setObj) // 1, true, 'a'
|
||||
setObj.clear() //
|
||||
```
|
||||
|
||||
|
||||
### Size
|
||||
|
||||
```javascript
|
||||
const setObj = new Set([1, true, 'a'])
|
||||
|
||||
consoloe.log(setObj.size) // 3
|
||||
```
|
||||
|
||||
|
||||
### ForEach
|
||||
|
||||
```javascript
|
||||
const setObj = new Set([1, true, 'a'])
|
||||
|
||||
setObj.forEach(function(value){
|
||||
console.log(value)
|
||||
})
|
||||
|
||||
// 1
|
||||
// true
|
||||
// 'a'
|
||||
```
|
||||
|
||||
|
||||
JavaScript Loops
|
||||
------------
|
||||
|
||||
|
||||
@@ -54,6 +54,51 @@ h ◀ ─── + ─── ▶ l ││ page
|
||||
|
||||
|
||||
|
||||
### Copy to Clipboard
|
||||
|
||||
|
||||
Command Syntax:
|
||||
```
|
||||
:export.clip format flow
|
||||
```
|
||||
----------------
|
||||
Example:
|
||||
|
||||
| Description | Command Example |
|
||||
|--------------------------------|------------------------------------|
|
||||
| 1. Copy as a curl command | `:export.clip curl @focus` |
|
||||
| 2. Copy as a httpie | `:export.clip httpie @focus` |
|
||||
| 2. Copy as a raw | `:export.clip raw @focus` |
|
||||
| 2. Copy as a raw HTTP request | `:export.clip raw_request @focus` |
|
||||
| 2. Copy as a raw HTTP response | `:export.clip raw_response @focus` |
|
||||
{.style-list}
|
||||
|
||||
Export a flow to the system clipboard.
|
||||
|
||||
|
||||
|
||||
|
||||
### Save to File
|
||||
|
||||
Command Syntax:
|
||||
```
|
||||
:export.file format flow path
|
||||
```
|
||||
----------------
|
||||
Example:
|
||||
|
||||
| Description | Command Example |
|
||||
|------------------------------|----------------------------------------------------|
|
||||
| 1. Export to /tmp/a.curl | `:export.file curl @focus /tmp/a.curl` |
|
||||
| 2. Export to /tmp/a.httpie | `:export.file httpie @focus /tmp/a.httpie` |
|
||||
| 2. Export to /tmp/a.raw | `:export.file raw @focus /tmp/a.raw` |
|
||||
| 2. Export to /tmp/a.request | `:export.file raw_request @focus /tmp/a.request` |
|
||||
| 2. Export to /tmp/a.response | `:export.file raw_response @focus /tmp/a.response` |
|
||||
{.style-list}
|
||||
|
||||
Export a flow to the system clipboard.
|
||||
|
||||
|
||||
|
||||
### Common Keybindings
|
||||
| - | - |
|
||||
|
||||
@@ -0,0 +1,458 @@
|
||||
---
|
||||
title: MongoDB
|
||||
date: 2023-04-05
|
||||
background: bg-gradient-to-r from-green-900 via-green-600 to-green-400 hover:from-green-900 hover:via-green-700 hover:to-green-500
|
||||
tags:
|
||||
- NoSQL
|
||||
- DB
|
||||
categories:
|
||||
- Database
|
||||
intro: The MongoDB cheat sheet provides you with the most commonly used MongoDB commands and queries for your reference. the cheatsheet is from mongodb developers website
|
||||
plugins:
|
||||
- tooltip
|
||||
- copyCode
|
||||
---
|
||||
|
||||
## Getting Started {.cols-2}
|
||||
|
||||
### Connect MongoDB Shell
|
||||
|
||||
```mongosh
|
||||
mongo # connects to mongodb://127.0.0.1:27017 by default
|
||||
```
|
||||
|
||||
```mongosh
|
||||
mongo --host <host> --port <port> -u <user> -p <pwd> # omit the password if you want a prompt
|
||||
```
|
||||
|
||||
```mongosh
|
||||
mongo "mongodb://192.168.1.1:27017"
|
||||
```
|
||||
|
||||
```mongosh
|
||||
mongo "mongodb+srv://cluster-name.abcde.mongodb.net/<dbname>" --username <username> # MongoDB Atlas
|
||||
```
|
||||
|
||||
### Helpers
|
||||
|
||||
show dbs :
|
||||
|
||||
```mongosh
|
||||
db // prints the current database
|
||||
```
|
||||
|
||||
Switch database :
|
||||
|
||||
```mongosh
|
||||
use <database_name>
|
||||
```
|
||||
|
||||
Show collections :
|
||||
|
||||
```mongosh
|
||||
show collections
|
||||
```
|
||||
|
||||
Run JavaScript file :
|
||||
|
||||
```mongosh
|
||||
load("myScript.js")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Crud
|
||||
|
||||
### Create
|
||||
|
||||
```mongosh
|
||||
db.coll.insertOne({name: "Max"})
|
||||
db.coll.insert([{name: "Max"}, {name:"Alex"}]) // ordered bulk insert
|
||||
db.coll.insert([{name: "Max"}, {name:"Alex"}], {ordered: false}) // unordered bulk insert
|
||||
db.coll.insert({date: ISODate()})
|
||||
db.coll.insert({name: "Max"}, {"writeConcern": {"w": "majority", "wtimeout": 5000}})
|
||||
```
|
||||
|
||||
### Delete
|
||||
|
||||
```mongosh
|
||||
db.coll.remove({name: "Max"})
|
||||
db.coll.remove({name: "Max"}, {justOne: true})
|
||||
db.coll.remove({}) // WARNING! Deletes all the docs but not the collection itself and its index definitions
|
||||
db.coll.remove({name: "Max"}, {"writeConcern": {"w": "majority", "wtimeout": 5000}})
|
||||
db.coll.findOneAndDelete({"name": "Max"})
|
||||
```
|
||||
|
||||
### Update
|
||||
|
||||
```mongosh
|
||||
db.coll.update({"_id": 1}, {"year": 2016}) // WARNING! Replaces the entire document
|
||||
db.coll.update({"_id": 1}, {$set: {"year": 2016, name: "Max"}})
|
||||
db.coll.update({"_id": 1}, {$unset: {"year": 1}})
|
||||
db.coll.update({"_id": 1}, {$rename: {"year": "date"} })
|
||||
db.coll.update({"_id": 1}, {$inc: {"year": 5}})
|
||||
db.coll.update({"_id": 1}, {$mul: {price: NumberDecimal("1.25"), qty: 2}})
|
||||
db.coll.update({"_id": 1}, {$min: {"imdb": 5}})
|
||||
db.coll.update({"_id": 1}, {$max: {"imdb": 8}})
|
||||
db.coll.update({"_id": 1}, {$currentDate: {"lastModified": true}})
|
||||
db.coll.update({"_id": 1}, {$currentDate: {"lastModified": {$type: "timestamp"}}})
|
||||
```
|
||||
|
||||
### Array { .row-span-2 }
|
||||
|
||||
```mongosh
|
||||
db.coll.update({"_id": 1}, {$push :{"array": 1}})
|
||||
db.coll.update({"_id": 1}, {$pull :{"array": 1}})
|
||||
db.coll.update({"_id": 1}, {$addToSet :{"array": 2}})
|
||||
db.coll.update({"_id": 1}, {$pop: {"array": 1}}) // last element
|
||||
db.coll.update({"_id": 1}, {$pop: {"array": -1}}) // first element
|
||||
db.coll.update({"_id": 1}, {$pullAll: {"array" :[3, 4, 5]}})
|
||||
db.coll.update({"_id": 1}, {$push: {scores: {$each: [90, 92, 85]}}})
|
||||
db.coll.updateOne({"_id": 1, "grades": 80}, {$set: {"grades.$": 82}})
|
||||
db.coll.updateMany({}, {$inc: {"grades.$[]": 10}})
|
||||
db.coll.update({}, {$set: {"grades.$[element]": 100}}, {multi: true, arrayFilters: [{"element": {$gte: 100}}]})
|
||||
```
|
||||
|
||||
### Update many { .row-span-1 }
|
||||
|
||||
```mongosh
|
||||
db.coll.update({"year": 1999}, {$set: {"decade": "90's"}}, {"multi":true})
|
||||
db.coll.updateMany({"year": 1999}, {$set: {"decade": "90's"}})
|
||||
```
|
||||
|
||||
### FindOneAndUpdate { .row-span-1 }
|
||||
|
||||
```mongosh
|
||||
db.coll.findOneAndUpdate({"name": "Max"}, {$inc: {"points": 5}}, {returnNewDocument: true})
|
||||
```
|
||||
|
||||
### Upsert { .row-span-1 }
|
||||
|
||||
```mongosh
|
||||
db.coll.update({"_id": 1}, {$set: {item: "apple"}, $setOnInsert: {defaultQty: 100}}, {upsert: true})
|
||||
```
|
||||
|
||||
### Replace { .row-span-1 }
|
||||
|
||||
```mongosh
|
||||
db.coll.replaceOne({"name": "Max"}, {"firstname": "Maxime", "surname": "Beugnet"})
|
||||
```
|
||||
|
||||
### Save { .row-span-1 }
|
||||
|
||||
```mongosh
|
||||
db.coll.save({"item": "book", "qty": 40})
|
||||
```
|
||||
|
||||
### Write concern { .row-span-1 }
|
||||
|
||||
```mongosh
|
||||
db.coll.update({}, {$set: {"x": 1}}, {"writeConcern": {"w": "majority", "wtimeout": 5000}})
|
||||
```
|
||||
|
||||
### Find { .row-span-2 }
|
||||
|
||||
```mongosh
|
||||
db.coll.findOne() // returns a single document
|
||||
db.coll.find() // returns a cursor - show 20 results - "it" to display more
|
||||
db.coll.find().pretty()
|
||||
db.coll.find({name: "Max", age: 32}) // implicit logical "AND".
|
||||
db.coll.find({date: ISODate("2020-09-25T13:57:17.180Z")})
|
||||
db.coll.find({name: "Max", age: 32}).explain("executionStats") // or "queryPlanner" or "allPlansExecution"
|
||||
db.coll.distinct("name")
|
||||
```
|
||||
|
||||
### Count
|
||||
|
||||
```mongosh
|
||||
db.coll.count({age: 32}) // estimation based on collection metadata
|
||||
db.coll.estimatedDocumentCount() // estimation based on collection metadata
|
||||
db.coll.countDocuments({age: 32}) // alias for an aggregation pipeline - accurate count
|
||||
```
|
||||
|
||||
### Comparison
|
||||
|
||||
```mongosh
|
||||
db.coll.find({"year": {$gt: 1970}})
|
||||
db.coll.find({"year": {$gte: 1970}})
|
||||
db.coll.find({"year": {$lt: 1970}})
|
||||
db.coll.find({"year": {$lte: 1970}})
|
||||
db.coll.find({"year": {$ne: 1970}})
|
||||
db.coll.find({"year": {$in: [1958, 1959]}})
|
||||
db.coll.find({"year": {$nin: [1958, 1959]}})
|
||||
```
|
||||
|
||||
### Logical
|
||||
|
||||
```mongosh
|
||||
db.coll.find({name:{$not: {$eq: "Max"}}})
|
||||
db.coll.find({$or: [{"year" : 1958}, {"year" : 1959}]})
|
||||
db.coll.find({$nor: [{price: 1.99}, {sale: true}]})
|
||||
db.coll.find({
|
||||
$and: [
|
||||
{$or: [{qty: {$lt :10}}, {qty :{$gt: 50}}]},
|
||||
{$or: [{sale: true}, {price: {$lt: 5 }}]}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
### Element
|
||||
|
||||
```mongosh
|
||||
db.coll.find({name: {$exists: true}})
|
||||
db.coll.find({"zipCode": {$type: 2 }})
|
||||
db.coll.find({"zipCode": {$type: "string"}})
|
||||
```
|
||||
|
||||
### Aggregation Pipeline
|
||||
|
||||
```mongosh
|
||||
db.coll.aggregate([
|
||||
{$match: {status: "A"}},
|
||||
{$group: {_id: "$cust_id", total: {$sum: "$amount"}}},
|
||||
{$sort: {total: -1}}
|
||||
])
|
||||
```
|
||||
|
||||
### Text search with a "text" index
|
||||
|
||||
```mongosh
|
||||
db.coll.find({$text: {$search: "cake"}}, {score: {$meta: "textScore"}}).sort({score: {$meta: "textScore"}})
|
||||
```
|
||||
|
||||
### Regex
|
||||
|
||||
```mongosh
|
||||
db.coll.find({name: /^Max/}) // regex: starts by letter "M"
|
||||
db.coll.find({name: /^Max$/i}) // regex case insensitive
|
||||
```
|
||||
|
||||
### Array
|
||||
|
||||
```mongosh
|
||||
db.coll.find({tags: {$all: ["Realm", "Charts"]}})
|
||||
db.coll.find({field: {$size: 2}}) // impossible to index - prefer storing the size of the array & update it
|
||||
db.coll.find({results: {$elemMatch: {product: "xyz", score: {$gte: 8}}}})
|
||||
```
|
||||
|
||||
### Projections
|
||||
|
||||
```mongosh
|
||||
db.coll.find({"x": 1}, {"actors": 1}) // actors + \_id
|
||||
db.coll.find({"x": 1}, {"actors": 1, "\_id": 0}) // actors
|
||||
db.coll.find({"x": 1}, {"actors": 0, "summary": 0}) // all but "actors" and "summary"
|
||||
```
|
||||
|
||||
### Sort, skip, limit
|
||||
|
||||
```mongosh
|
||||
db.coll.find({}).sort({"year": 1, "rating": -1}).skip(10).limit(3)
|
||||
```
|
||||
|
||||
### Read Concern
|
||||
|
||||
```mongosh
|
||||
db.coll.find().readConcern("majority")
|
||||
```
|
||||
|
||||
|
||||
## Databases and Collections { .cols-2 }
|
||||
|
||||
### Drop { .row-span-1 }
|
||||
|
||||
```mongosh
|
||||
db.coll.drop() // removes the collection and its index definitions
|
||||
db.dropDatabase() // double check that you are *NOT* on the PROD cluster... :-)
|
||||
```
|
||||
|
||||
### Create Collection { .row-span-2}
|
||||
|
||||
```mongosh
|
||||
db.createCollection("contacts", {
|
||||
validator: {$jsonSchema: {
|
||||
bsonType: "object",
|
||||
required: ["phone"],
|
||||
properties: {
|
||||
phone: {
|
||||
bsonType: "string",
|
||||
description: "must be a string and is required"
|
||||
},
|
||||
email: {
|
||||
bsonType: "string",
|
||||
pattern: "@mongodb\.com$",
|
||||
description: "must be a string and match the regular expression pattern"
|
||||
},
|
||||
status: {
|
||||
enum: [ "Unknown", "Incomplete" ],
|
||||
description: "can only be one of the enum values"
|
||||
}
|
||||
}
|
||||
}}
|
||||
})
|
||||
```
|
||||
|
||||
### Other Collection Functions { .row-span-1}
|
||||
|
||||
```mongosh
|
||||
db.coll.stats()
|
||||
db.coll.storageSize()
|
||||
db.coll.totalIndexSize()
|
||||
db.coll.totalSize()
|
||||
db.coll.validate({full: true})
|
||||
db.coll.renameCollection("new_coll", true) // 2nd parameter to drop the target collection if exists
|
||||
```
|
||||
|
||||
|
||||
## Indexes {.cols-2}
|
||||
|
||||
### Basics
|
||||
|
||||
#### List
|
||||
|
||||
```mongosh
|
||||
db.coll.getIndexes()
|
||||
db.coll.getIndexKeys()
|
||||
```
|
||||
|
||||
#### Drop Indexes
|
||||
|
||||
```mongosh
|
||||
db.coll.dropIndex("name_1")
|
||||
```
|
||||
|
||||
#### Hide/Unhide Indexes
|
||||
|
||||
```mongosh
|
||||
db.coll.hideIndex("name_1")
|
||||
db.coll.unhideIndex("name_1")
|
||||
```
|
||||
|
||||
### Create Indexes
|
||||
|
||||
```mongosh
|
||||
// Index Types
|
||||
db.coll.createIndex({"name": 1}) // single field index
|
||||
db.coll.createIndex({"name": 1, "date": 1}) // compound index
|
||||
db.coll.createIndex({foo: "text", bar: "text"}) // text index
|
||||
db.coll.createIndex({"$**": "text"}) // wildcard text index
|
||||
db.coll.createIndex({"userMetadata.$**": 1}) // wildcard index
|
||||
db.coll.createIndex({"loc": "2d"}) // 2d index
|
||||
db.coll.createIndex({"loc": "2dsphere"}) // 2dsphere index
|
||||
db.coll.createIndex({"_id": "hashed"}) // hashed index
|
||||
|
||||
// Index Options
|
||||
db.coll.createIndex({"lastModifiedDate": 1}, {expireAfterSeconds: 3600}) // TTL index
|
||||
db.coll.createIndex({"name": 1}, {unique: true})
|
||||
db.coll.createIndex({"name": 1}, {partialFilterExpression: {age: {$gt: 18}}}) // partial index
|
||||
db.coll.createIndex({"name": 1}, {collation: {locale: 'en', strength: 1}}) // case insensitive index with strength = 1 or 2
|
||||
db.coll.createIndex({"name": 1 }, {sparse: true})
|
||||
```
|
||||
|
||||
## Others { .cols-2 }
|
||||
|
||||
### Handy commands { .row-span-3 }
|
||||
|
||||
```mongosh
|
||||
use admin
|
||||
db.createUser({"user": "root", "pwd": passwordPrompt(), "roles": ["root"]})
|
||||
db.dropUser("root")
|
||||
db.auth( "user", passwordPrompt() )
|
||||
|
||||
use test
|
||||
db.getSiblingDB("dbname")
|
||||
db.currentOp()
|
||||
db.killOp(123) // opid
|
||||
|
||||
db.fsyncLock()
|
||||
db.fsyncUnlock()
|
||||
|
||||
db.getCollectionNames()
|
||||
db.getCollectionInfos()
|
||||
db.printCollectionStats()
|
||||
db.stats()
|
||||
|
||||
db.getReplicationInfo()
|
||||
db.printReplicationInfo()
|
||||
db.isMaster()
|
||||
db.hostInfo()
|
||||
db.printShardingStatus()
|
||||
db.shutdownServer()
|
||||
db.serverStatus()
|
||||
|
||||
db.setSlaveOk()
|
||||
db.getSlaveOk()
|
||||
|
||||
db.getProfilingLevel()
|
||||
db.getProfilingStatus()
|
||||
db.setProfilingLevel(1, 200) // 0 == OFF, 1 == ON with slowms, 2 == ON
|
||||
|
||||
db.enableFreeMonitoring()
|
||||
db.disableFreeMonitoring()
|
||||
db.getFreeMonitoringStatus()
|
||||
|
||||
db.createView("viewName", "sourceColl", [{$project:{department: 1}}])
|
||||
```
|
||||
|
||||
### Replica Set { .row-span-2}
|
||||
|
||||
```mongosh
|
||||
rs.status()
|
||||
rs.initiate({"_id": "replicaTest",
|
||||
members: [
|
||||
{ _id: 0, host: "127.0.0.1:27017" },
|
||||
{ _id: 1, host: "127.0.0.1:27018" },
|
||||
{ _id: 2, host: "127.0.0.1:27019", arbiterOnly:true }]
|
||||
})
|
||||
rs.add("mongodbd1.example.net:27017")
|
||||
rs.addArb("mongodbd2.example.net:27017")
|
||||
rs.remove("mongodbd1.example.net:27017")
|
||||
rs.conf()
|
||||
rs.isMaster()
|
||||
rs.printReplicationInfo()
|
||||
rs.printSlaveReplicationInfo()
|
||||
rs.reconfig(<valid_conf>)
|
||||
rs.slaveOk()
|
||||
rs.stepDown(20, 5) // (stepDownSecs, secondaryCatchUpPeriodSecs)
|
||||
```
|
||||
|
||||
### Sharded Cluster { .row-span-2 }
|
||||
|
||||
```mongosh
|
||||
sh.status()
|
||||
sh.addShard("rs1/mongodbd1.example.net:27017")
|
||||
sh.shardCollection("mydb.coll", {zipcode: 1})
|
||||
|
||||
sh.moveChunk("mydb.coll", { zipcode: "53187" }, "shard0019")
|
||||
sh.splitAt("mydb.coll", {x: 70})
|
||||
sh.splitFind("mydb.coll", {x: 70})
|
||||
sh.disableAutoSplit()
|
||||
sh.enableAutoSplit()
|
||||
|
||||
sh.startBalancer()
|
||||
sh.stopBalancer()
|
||||
sh.disableBalancing("mydb.coll")
|
||||
sh.enableBalancing("mydb.coll")
|
||||
sh.getBalancerState()
|
||||
sh.setBalancerState(true/false)
|
||||
sh.isBalancerRunning()
|
||||
|
||||
sh.addTagRange("mydb.coll", {state: "NY", zip: MinKey }, { state: "NY", zip: MaxKey }, "NY")
|
||||
sh.removeTagRange("mydb.coll", {state: "NY", zip: MinKey }, { state: "NY", zip: MaxKey }, "NY")
|
||||
sh.addShardTag("shard0000", "NYC")
|
||||
sh.removeShardTag("shard0000", "NYC")
|
||||
|
||||
sh.addShardToZone("shard0000", "JFK")
|
||||
sh.removeShardFromZone("shard0000", "NYC")
|
||||
sh.removeRangeFromZone("mydb.coll", {a: 1, b: 1}, {a: 10, b: 10})
|
||||
```
|
||||
### Change Streams {.row-span-1 }
|
||||
|
||||
```mongosh
|
||||
watchCursor = db.coll.watch( [ { $match : {"operationType" : "insert" } } ] )
|
||||
|
||||
while (!watchCursor.isExhausted()){
|
||||
if (watchCursor.hasNext()){
|
||||
print(tojson(watchCursor.next()));
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,64 @@
|
||||
---
|
||||
title: Pandoc
|
||||
date: 2023-03-21 13:26:00
|
||||
background: bg-red-400
|
||||
tags:
|
||||
- convert
|
||||
- document
|
||||
- utility
|
||||
categories:
|
||||
- Linux Command
|
||||
intro: |
|
||||
[Pandoc](https://pandoc.org) is a document converter, this pandoc cheat sheet contains pandoc commands and some common pandoc tricks.
|
||||
plugins:
|
||||
- copyCode
|
||||
---
|
||||
|
||||
Getting Started
|
||||
---------------
|
||||
|
||||
### Pandoc Usage
|
||||
|
||||
Syntax
|
||||
```shell script
|
||||
$ pandoc -s [source file] -o [output file]
|
||||
```
|
||||
|
||||
|
||||
Pandoc examples
|
||||
----------
|
||||
|
||||
|
||||
### LaTeX to MS Word {.col-span-2}
|
||||
|
||||
Simple .tex to .docx
|
||||
```shell script
|
||||
$ pandoc -s file.tex -o file.docx
|
||||
```
|
||||
|
||||
.tex to .docx with default citations
|
||||
```shell script
|
||||
$ pandoc -s file.tex --citeproc --bibliography=bib_library.bib -o file.docx
|
||||
```
|
||||
|
||||
.tex to .docx with specific citations
|
||||
```shell script
|
||||
$ pandoc -s file.tex --citeproc --bibliography=bib_library.bib --csl=apa.csl -o file.docx
|
||||
```
|
||||
Get `.csl` file from [here](https://github.com/citation-style-language/styles)
|
||||
|
||||
.tex to .docx with cross references
|
||||
```shell script
|
||||
$ pandoc -s file.tex --filter pandoc-crossref -o file.docx
|
||||
```
|
||||
Get the filter `pandoc-crossref` from [here](https://github.com/lierdakil/pandoc-crossref/releases)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Also see {.cols-1}
|
||||
----------
|
||||
- [pandoc examples](https://pandoc.org/demos.html)
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ VALUES ( <value1>,<value2> );
|
||||
|
||||
|
||||
### Data
|
||||
[Select](http://www.postgresql.org/docs/current/static/sql-select.html] all data
|
||||
[Select](http://www.postgresql.org/docs/current/static/sql-select.html) all data
|
||||
```sql {.wrap}
|
||||
SELECT * FROM <table_name>;
|
||||
```
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
---
|
||||
title: PyTorch
|
||||
date: 2023-04-12
|
||||
background: bg-[#ee4c2c]
|
||||
tags:
|
||||
- AI
|
||||
- Python
|
||||
categories:
|
||||
- Other
|
||||
intro: This is a quick reference list of cheat sheets for PyTorch. See also [PyTorch website](https://pytorch.org/)
|
||||
---
|
||||
|
||||
## Imports { .cols-1 }
|
||||
|
||||
### General
|
||||
|
||||
```
|
||||
import torch # root package
|
||||
from torch.utils.data import Dataset, DataLoader # dataset representation and loading
|
||||
```
|
||||
|
||||
### Neural Network API
|
||||
|
||||
```
|
||||
import torch.autograd as autograd # computation graph
|
||||
from torch import Tensor # tensor node in the computation graph
|
||||
import torch.nn as nn # neural networks
|
||||
import torch.nn.functional as F # layers, activations and more
|
||||
import torch.optim as optim # optimizers e.g. gradient descent, ADAM, etc.
|
||||
from torch.jit import script, trace # hybrid frontend decorator and tracing jit
|
||||
```
|
||||
|
||||
### Torchscript and JIT
|
||||
|
||||
```
|
||||
torch.jit.trace() # takes your module or function and an example
|
||||
# data input, and traces the computational steps
|
||||
# that the data encounters as it progresses through the model
|
||||
|
||||
@script # decorator used to indicate data-dependent
|
||||
# control flow within the code being traced
|
||||
```
|
||||
|
||||
### ONNX
|
||||
|
||||
```
|
||||
torch.onnx.export(model, dummy data, xxxx.proto) # exports an ONNX formatted
|
||||
# model using a trained model, dummy
|
||||
# data and the desired file name
|
||||
|
||||
model = onnx.load("alexnet.proto") # load an ONNX model
|
||||
onnx.checker.check_model(model) # check that the model
|
||||
# IR is well formed
|
||||
|
||||
onnx.helper.printable_graph(model.graph) # print a human readable
|
||||
# representation of the graph
|
||||
```
|
||||
|
||||
### Vision
|
||||
|
||||
|
||||
```
|
||||
from torchvision import datasets, models, transforms # vision datasets,
|
||||
# architectures &
|
||||
# transforms
|
||||
|
||||
import torchvision.transforms as transforms # composable transforms
|
||||
```
|
||||
|
||||
### Distributed Training
|
||||
|
||||
```
|
||||
import torch.distributed as dist # distributed communication
|
||||
from torch.multiprocessing import Process # memory sharing processes
|
||||
```
|
||||
|
||||
## Tensors { .cols-1 }
|
||||
|
||||
### Creation
|
||||
|
||||
```
|
||||
x = torch.randn(*size) # tensor with independent N(0,1) entries
|
||||
x = torch.[ones|zeros](*size) # tensor with all 1's [or 0's]
|
||||
x = torch.tensor(L) # create tensor from [nested] list or ndarray L
|
||||
y = x.clone() # clone of x
|
||||
with torch.no_grad(): # code wrap that stops autograd from tracking tensor history
|
||||
requires_grad=True # arg, when set to True, tracks computation
|
||||
# history for future derivative calculations
|
||||
```
|
||||
|
||||
### Dimensionality
|
||||
|
||||
```
|
||||
x.size() # return tuple-like object of dimensions
|
||||
x = torch.cat(tensor_seq, dim=0) # concatenates tensors along dim
|
||||
y = x.view(a,b,...) # reshapes x into size (a,b,...)
|
||||
y = x.view(-1,a) # reshapes x into size (b,a) for some b
|
||||
y = x.transpose(a,b) # swaps dimensions a and b
|
||||
y = x.permute(*dims) # permutes dimensions
|
||||
y = x.unsqueeze(dim) # tensor with added axis
|
||||
y = x.unsqueeze(dim=2) # (a,b,c) tensor -> (a,b,1,c) tensor
|
||||
y = x.squeeze() # removes all dimensions of size 1 (a,1,b,1) -> (a,b)
|
||||
y = x.squeeze(dim=1) # removes specified dimension of size 1 (a,1,b,1) -> (a,b,1)
|
||||
```
|
||||
|
||||
### Algebra
|
||||
|
||||
```
|
||||
ret = A.mm(B) # matrix multiplication
|
||||
ret = A.mv(x) # matrix-vector multiplication
|
||||
x = x.t() # matrix transpose
|
||||
```
|
||||
|
||||
### GPU Usage
|
||||
|
||||
```
|
||||
torch.cuda.is_available # check for cuda
|
||||
x = x.cuda() # move x's data from
|
||||
# CPU to GPU and return new object
|
||||
|
||||
x = x.cpu() # move x's data from GPU to CPU
|
||||
# and return new object
|
||||
|
||||
if not args.disable_cuda and torch.cuda.is_available(): # device agnostic code
|
||||
args.device = torch.device('cuda') # and modularity
|
||||
else: #
|
||||
args.device = torch.device('cpu') #
|
||||
|
||||
net.to(device) # recursively convert their
|
||||
# parameters and buffers to
|
||||
# device specific tensors
|
||||
|
||||
x = x.to(device) # copy your tensors to a device
|
||||
# (gpu, cpu)
|
||||
```
|
||||
|
||||
### Deep Learning
|
||||
|
||||
```
|
||||
nn.Linear(m,n) # fully connected layer from
|
||||
# m to n units
|
||||
|
||||
nn.ConvXd(m,n,s) # X dimensional conv layer from
|
||||
# m to n channels where X⍷{1,2,3}
|
||||
# and the kernel size is s
|
||||
|
||||
nn.MaxPoolXd(s) # X dimension pooling layer
|
||||
# (notation as above)
|
||||
|
||||
nn.BatchNormXd # batch norm layer
|
||||
nn.RNN/LSTM/GRU # recurrent layers
|
||||
nn.Dropout(p=0.5, inplace=False) # dropout layer for any dimensional input
|
||||
nn.Dropout2d(p=0.5, inplace=False) # 2-dimensional channel-wise dropout
|
||||
nn.Embedding(num_embeddings, embedding_dim) # (tensor-wise) mapping from
|
||||
# indices to embedding vectors
|
||||
```
|
||||
|
||||
### Loss Functions
|
||||
|
||||
```
|
||||
nn.X # where X is L1Loss, MSELoss, CrossEntropyLoss
|
||||
# CTCLoss, NLLLoss, PoissonNLLLoss,
|
||||
# KLDivLoss, BCELoss, BCEWithLogitsLoss,
|
||||
# MarginRankingLoss, HingeEmbeddingLoss,
|
||||
# MultiLabelMarginLoss, SmoothL1Loss,
|
||||
# SoftMarginLoss, MultiLabelSoftMarginLoss,
|
||||
# CosineEmbeddingLoss, MultiMarginLoss,
|
||||
# or TripletMarginLoss
|
||||
```
|
||||
|
||||
### Activation Functions
|
||||
|
||||
```
|
||||
nn.X # where X is ReLU, ReLU6, ELU, SELU, PReLU, LeakyReLU,
|
||||
# RReLu, CELU, GELU, Threshold, Hardshrink, HardTanh,
|
||||
# Sigmoid, LogSigmoid, Softplus, SoftShrink,
|
||||
# Softsign, Tanh, TanhShrink, Softmin, Softmax,
|
||||
# Softmax2d, LogSoftmax or AdaptiveSoftmaxWithLoss
|
||||
```
|
||||
|
||||
### Optimizers
|
||||
|
||||
```
|
||||
opt = optim.x(model.parameters(), ...) # create optimizer
|
||||
opt.step() # update weights
|
||||
optim.X # where X is SGD, Adadelta, Adagrad, Adam,
|
||||
# AdamW, SparseAdam, Adamax, ASGD,
|
||||
# LBFGS, RMSprop or Rprop
|
||||
```
|
||||
|
||||
### Learning rate scheduling
|
||||
|
||||
```
|
||||
scheduler = optim.X(optimizer,...) # create lr scheduler
|
||||
scheduler.step() # update lr after optimizer updates weights
|
||||
optim.lr_scheduler.X # where X is LambdaLR, MultiplicativeLR,
|
||||
# StepLR, MultiStepLR, ExponentialLR,
|
||||
# CosineAnnealingLR, ReduceLROnPlateau, CyclicLR,
|
||||
# OneCycleLR, CosineAnnealingWarmRestarts,
|
||||
```
|
||||
|
||||
## Data Utilities { .cols-1 }
|
||||
|
||||
### Datasets
|
||||
|
||||
```
|
||||
Dataset # abstract class representing dataset
|
||||
TensorDataset # labelled dataset in the form of tensors
|
||||
Concat Dataset # concatenation of Datasets
|
||||
```
|
||||
|
||||
### Dataloaders and DataSamplers
|
||||
|
||||
```
|
||||
DataLoader(dataset, batch_size=1, ...) # loads data batches agnostic
|
||||
# of structure of individual data points
|
||||
|
||||
sampler.Sampler(dataset,...) # abstract class dealing with
|
||||
# ways to sample from dataset
|
||||
|
||||
sampler.XSampler where ... # Sequential, Random, SubsetRandom,
|
||||
# WeightedRandom, Batch, Distributed
|
||||
```
|
||||
@@ -910,7 +910,7 @@ print(setC) // print: ["D", "C"]
|
||||
```
|
||||
|
||||
|
||||
### .union() 合并去重
|
||||
### .union()
|
||||
|
||||
```swift
|
||||
var setA: Set = ["A", "B", "C", "D"]
|
||||
@@ -1275,7 +1275,7 @@ func season(month: Int, name: inout String) {
|
||||
name = "Unknown"
|
||||
}
|
||||
}
|
||||
season(monthNum: 4, name: ¤tSeason)
|
||||
season(month: 4, name: ¤tSeason)
|
||||
|
||||
print(currentSeason) // Spring 🌱
|
||||
```
|
||||
@@ -1369,7 +1369,7 @@ struct TV {
|
||||
var type: String
|
||||
|
||||
init(size: Int, type: String) {
|
||||
self. size = size
|
||||
self.size = size
|
||||
self.type = type
|
||||
}
|
||||
}
|
||||
@@ -1407,8 +1407,8 @@ Using the `Menu` class
|
||||
|
||||
```swift
|
||||
var dinerMenu = Menu()
|
||||
dinerMenu. addToMenu(dish: "Toast")
|
||||
print(dinerMenu. menuItems)
|
||||
dinerMenu.addToMenu(dish: "Toast")
|
||||
print(dinerMenu.menuItems)
|
||||
// prints: ["Fries", "Burgers", "Toast"]
|
||||
```
|
||||
|
||||
@@ -1633,7 +1633,7 @@ enum Season: CaseIterable {
|
||||
case falls
|
||||
}
|
||||
|
||||
for season in Season. allCases {
|
||||
for season in Season.allCases {
|
||||
print(season)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
---
|
||||
title: Taskset
|
||||
date: 2023-04-07 14:25:44
|
||||
background: bg-[#8bbb55]
|
||||
tags:
|
||||
- process
|
||||
- process manager
|
||||
categories:
|
||||
- Linux Command
|
||||
intro:
|
||||
The taskset command is used to set or retrieve the CPU affinity
|
||||
of a running process given its pid, or to launch a new command
|
||||
with a given CPU affinity.
|
||||
plugins:
|
||||
- copyCode
|
||||
---
|
||||
|
||||
Getting Started {.cols-3}
|
||||
--------
|
||||
|
||||
### Usage
|
||||
The default behavior is to run a new command with a given affinity mask
|
||||
```shell
|
||||
$ taskset [mask] [command] [arguments]
|
||||
```
|
||||
|
||||
#### Usage #2
|
||||
```shell
|
||||
$ taskset -p [pid]
|
||||
```
|
||||
---------
|
||||
```shell
|
||||
$ taskset -p [mask] [pid]
|
||||
```
|
||||
You can also retrieve the CPU affinity of an existing task
|
||||
|
||||
|
||||
### Common Options {.col-span-2}
|
||||
| Command | Alternavite | Meaning |
|
||||
|---------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `-a` | --all-tasks | Set or retrieve the CPU affinity of all the task (threads) for a given PID. |
|
||||
| `-c` | --cpu-list | Interpret mask as numerical list of processors instead of a bitmask.</br>Numbers are separated by commas and may include ranges. For example: `0,5,8-11` |
|
||||
| `-p` | --pid | Operate on an existing PID and do not launch a new task. |
|
||||
| `-h` | --help | Display help text and exit. |
|
||||
| `-v` | --version | Print version and exit. |
|
||||
{.show-header}
|
||||
|
||||
Example
|
||||
--------
|
||||
|
||||
### View CPU Affinity
|
||||
```shell
|
||||
$ taskset -cp 29523
|
||||
pid 29523's current affinity list: 0-15
|
||||
```
|
||||
That mean process with PID `29523` is active on CPU range from `[0,1,...,15]` which means `16` total.
|
||||
|
||||
**PID**: Process Identifier - is a unique numerical identifier given to each running process, you can view PID of processes in `top` or `htop` tools
|
||||
|
||||
_If you run the above command but get the message `bad usage`, try with PID = 1_
|
||||
|
||||
```shell
|
||||
$ taskset -cp 1
|
||||
```
|
||||
|
||||
### Set CPU Affinity
|
||||
Now let's try to set process in to a specify CPU. For example, we have a process has PID = 14846
|
||||
|
||||
Let's see the CPU affinity list of this process first:
|
||||
```shell
|
||||
$ taskset -cp 14846
|
||||
pid 14846's current affinity list: 0-15
|
||||
```
|
||||
|
||||
#### Change CPU affinity to 1:
|
||||
```shell
|
||||
$ taskset -cp 1 14846
|
||||
pid 14846's current affinity list: 0-15
|
||||
pid 14846's new affinity list: 1
|
||||
```
|
||||
As we see, CPU affinity was changed
|
||||
|
||||
### Set CPU Affinity with muliple value
|
||||
That mean new CPU affinity list is `[0,1,2,3]`
|
||||
```shell
|
||||
$ taskset -cp 0-3 14846
|
||||
pid 14846's current affinity list: 1
|
||||
pid 14846's new affinity list: 0-3
|
||||
```
|
||||
|
||||
You can set single CPU with the following command:
|
||||
|
||||
```shell
|
||||
$ taskset -cp 5,8,12 14846
|
||||
pid 14846's current affinity list: 0-3
|
||||
pid 14846's new affinity list: 5,8,12
|
||||
```
|
||||
That mean new CPU affinity list is `[5,8,12]`
|
||||
|
||||
### Other
|
||||
You can set affinity by range with other like a specify CPU
|
||||
```shell
|
||||
$ taskset -cp 1-3,12 14846
|
||||
```
|
||||
|
||||
Or
|
||||
|
||||
```shell
|
||||
$ taskset -cp 1-6:2 14846
|
||||
```
|
||||
The suffix ":N" specifies stride in the range, for example 0-10:3 is interpreted as 0,3,6,9 list.
|
||||
|
||||
|
||||
|
||||
Also see
|
||||
--------
|
||||
[taskset — Linux manual page](https://man7.org/linux/man-pages/man1/taskset.1.html) _(man7.org)_
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg height="1em" width="1em" viewBox="-46 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
||||
<g>
|
||||
<path d="M125.533525,84.856832 C126.234965,66.5716053 121.616725,59.190272 118.150485,53.9132587 C114.633045,48.9895253 106.195285,41.2532053 95.8272853,40.9289387 C86.0224853,40.6234453 83.663872,46.042112 74.6185387,46.369792 C73.1354453,29.8970453 85.5668053,20.8585387 85.5668053,20.8585387 C85.5668053,20.8585387 82.1671253,16.054272 79.3545387,14.881792 C76.1186987,17.7575253 68.360192,26.017792 66.701312,37.107712 C64.9536853,20.7732053 56.7872853,10.3266987 38.6829653,3.04605867 C33.5407787,21.0343253 50.5186987,37.839872 61.5488853,44.4770987 C55.7018453,42.5127253 50.6279253,39.9168853 43.8132053,41.2583253 C31.9023787,43.6032853 22.0839253,50.803712 16.4877653,66.6057387 C10.893312,82.4077653 18.4640853,100.843179 20.109312,106.108245 C21.7562453,111.378432 33.9367253,133.761365 43.4838187,137.053525 C53.0292053,140.349099 53.0326187,138.864299 58.135552,136.891392 C63.2384853,134.916779 70.9730987,131.293525 82.3343787,135.411712 C93.6871253,139.524779 95.168512,140.511232 102.244352,135.903232 C109.327019,131.295232 118.541312,116.976299 120.679765,112.859819 C122.819925,108.746752 123.971925,106.604885 124.634112,104.466432 C125.456725,98.2029653 124.902059,101.245952 125.533525,84.856832" fill="#D1D2D3">
|
||||
|
||||
</path>
|
||||
<path d="M126.214656,110.16192 L126.214656,119.103147 C126.214656,121.197227 127.912789,122.89536 130.006869,122.89536 L130.006869,122.89536 L144.076629,122.89536 C148.601003,122.89536 152.942763,124.694187 156.142763,127.894187 C159.344469,131.095893 161.143296,135.435947 161.143296,139.962027 L161.143296,139.962027 L161.142317,181.198985 C161.142285,181.658001 161.142252,182.115644 161.142219,182.571734 L161.141346,191.858973 C161.141296,192.284417 161.141245,192.707037 161.141192,193.126652 L161.140495,198.006133 C161.140432,198.398798 161.140367,198.78773 161.1403,199.17275 L161.139883,201.434453 C161.139883,205.970773 159.335936,210.321067 156.120576,213.522773 C152.906923,216.72448 148.549803,218.514773 144.013483,218.499413 C139.258709,218.51136 134.258176,218.502827 130.087083,218.4448 C129.066496,218.42432 128.081749,218.81344 127.353003,219.528533 C126.625963,220.24192 126.214656,221.218133 126.214656,222.235307 L126.214656,222.235307 L126.214339,226.749094 C126.214304,226.931737 126.214265,227.115473 126.214222,227.300091 L126.213464,229.544517 C126.213379,229.732856 126.213288,229.921242 126.213191,230.109466 L126.212523,231.2352 C126.210389,234.409813 126.206123,237.41696 126.197589,239.230293 C126.197589,240.35328 125.697536,241.41824 124.833963,242.13504 C120.487083,245.418667 105.301163,252.695893 71.3350827,252.695893 C38.0704427,252.695893 22.2291627,247.261867 17.286656,244.399787 C16.196096,243.705173 15.535616,242.500267 15.5322027,241.210027 C15.517184,233.835861 15.4611944,207.580048 15.4031959,180.486075 L15.3952782,176.787942 C15.3279344,145.338457 15.2602709,113.864788 15.2529605,110.46478 L15.2523093,110.16192 L126.214656,110.16192 Z M143.034197,138.088619 L130.954411,138.088619 C129.782044,138.088619 128.652792,138.525707 127.785893,139.305529 L127.604224,139.477845 C126.774329,140.309333 126.283401,141.412887 126.221632,142.580368 L126.214997,142.831445 L126.214997,197.999445 C126.214997,199.171812 126.650599,200.301064 127.43161,201.169351 L127.604224,201.351339 C128.432526,202.181234 129.538841,202.670675 130.703929,202.732246 L130.954411,202.738859 L143.034197,202.738859 C144.206564,202.738859 145.335816,202.304743 146.204103,201.52393 L146.386091,201.351339 C147.214393,200.521444 147.705215,199.415023 147.766977,198.249927 L147.773611,197.999445 L147.773611,142.831445 C147.773611,141.655893 147.338009,140.529402 146.558385,139.66011 L146.386091,139.477845 C145.556196,138.649543 144.449775,138.157234 143.284679,138.095274 L143.034197,138.088619 Z" fill="#FEFEFE">
|
||||
|
||||
</path>
|
||||
<path d="M26.191872,109.062656 L26.191872,226.619563 C26.191872,227.976363 26.9154987,229.229056 28.091392,229.906603 C32.888832,232.193536 46.810112,237.653163 71.217152,237.653163 C95.7846187,237.653163 109.291179,231.019349 113.815552,228.285269 C114.895872,227.590656 115.546112,226.392576 115.546112,225.109163 C115.556352,209.520469 115.556352,109.062656 115.556352,109.062656 L26.191872,109.062656 Z" fill="#FAAF41">
|
||||
|
||||
</path>
|
||||
<path d="M39.327744,123.713536 C42.128384,123.713536 44.4187307,125.903189 44.5791573,128.664576 L44.5876907,128.973483 L44.5876907,219.821056 C44.5876907,222.725803 42.2324907,225.081003 39.327744,225.081003 C36.5253973,225.081003 34.2367573,222.891349 34.0763307,220.131669 L34.0677973,219.821056 L34.0677973,128.973483 C34.0677973,126.068736 36.4229973,123.713536 39.327744,123.713536" fill="#FFDA95">
|
||||
|
||||
</path>
|
||||
<path d="M89.8184533,133.186048 C89.8184533,131.289941 88.7022933,129.025195 86.8693333,127.888555 C83.88608,126.084608 81.55648,123.316395 80.2884267,120.019115 C56.02304,120.834901 33.8773333,116.575061 22.7191467,113.566208 C19.85536,112.753835 16.9540267,112.079701 14.02368,111.547221 C7.3472,110.221141 2.27157333,104.357035 2.27157333,97.3067947 C2.27157333,89.5465813 8.42922667,83.240448 16.1211733,82.963968 C17.6042667,74.756608 24.7688533,68.525568 33.4045867,68.525568 C43.11552,68.525568 50.9883733,76.3984213 50.9883733,86.1093547 C50.9883733,88.1522347 50.6197333,90.1080747 49.9797333,91.934208 L50.0309333,91.9427413 C52.2001067,85.160448 58.5489067,80.245248 66.0514133,80.245248 C73.5044267,80.245248 79.8208,85.1024213 82.0258133,91.821568 C81.96096,91.2157013 81.9285333,90.5995947 81.9285333,89.9749547 C81.9285333,79.8749013 90.1154133,71.689728 100.21376,71.689728 C108.388693,71.689728 115.30752,77.055488 117.649067,84.453888 L119.241387,84.0374613 C121.326933,82.8632747 123.7248,82.1840213 126.288213,82.1840213 C134.224213,82.1840213 140.65664,88.6181547 140.653228,96.5507413 C140.653228,103.819435 135.258453,109.825195 128.254293,110.784341 C126.667093,111.007915 125.11232,111.412395 123.615573,111.989248 C119.451307,113.557675 115.19488,114.858155 110.895787,115.931648 C110.680747,118.051328 110.04928,120.048128 109.085013,121.840128 C107.3408,125.113515 106.559147,128.813568 106.8288,132.511915 C106.827093,132.735488 106.835627,133.909675 106.835627,134.134955 C106.835627,138.833408 103.026347,141.692075 98.3227733,141.692075 C93.6277333,141.692075 89.8184533,137.886208 89.8184533,133.186048" fill="#FEFEFE">
|
||||
|
||||
</path>
|
||||
<polygon fill="#010202" points="86.4017067 112.433152 86.5024 112.740352 86.4699733 112.433152">
|
||||
|
||||
</polygon>
|
||||
<path d="M37.19168,0 L39.5298133,0.938666667 C54.5570133,6.98197333 63.3053867,15.2814933 67.0993067,27.5182933 C69.49888,22.20032 73.1426133,17.4711467 77.3768533,13.6072533 L77.3768533,13.6072533 L78.9128533,12.2368 L80.2304,12.78464 C80.79872,13.0235733 81.3653333,13.3495467 81.9387733,13.75744 C82.8296533,14.3906133 83.73248,15.2132267 84.6472533,16.18432 C85.3418667,16.9198933 86.0040533,17.7015467 86.6167467,18.4814933 L86.6167467,18.4814933 L86.9546667,18.9166933 L87.33184,19.4235733 L88.7159467,21.3777067 L86.90176,22.69696 L86.6542933,22.8881067 L86.31296,23.168 L85.89312,23.5383467 L85.3998933,23.9940267 C84.2018133,25.1306667 82.9986133,26.4874667 81.8756267,28.05248 C78.7336533,32.43008 76.84608,37.4920533 76.7675733,43.2366933 L76.7675733,43.2366933 L76.7658667,43.9057067 L77.2573867,43.8254933 C78.9486933,43.5165867 80.5393067,42.9243733 82.8672,41.8645333 L82.8672,41.8645333 L84.1966933,41.2552533 C88.69376,39.2192 91.38688,38.5194667 95.8976,38.6594133 C105.47712,38.9597867 114.69312,45.1669333 120.04864,52.6677333 C120.168107,52.8503467 120.28928,53.03296 120.405333,53.21728 L120.405333,53.21728 L121.094827,54.3095467 L121.751893,55.3949867 C125.84448,62.34624 127.81568,69.0944 127.88736,79.99488 C136.326827,80.79872 142.928213,87.9035733 142.9248,96.5512533 C142.9248,104.89344 136.751787,111.91296 128.571733,113.032533 C128.54272,113.037653 128.515413,113.04448 128.484693,113.0496 L128.484693,113.0496 L128.484693,119.103147 C128.484693,119.942827 129.16736,120.625493 130.00704,120.625493 L130.00704,120.625493 L144.0768,120.625493 C149.205333,120.625493 154.123947,122.661547 157.750613,126.288213 C161.37728,129.916587 163.413333,134.8352 163.413333,139.962027 L163.413333,139.962027 L163.411627,201.434453 C163.411627,206.574933 161.365333,211.503787 157.723307,215.130453 C154.08128,218.758827 149.147307,220.788053 144.02048,220.76928 C143.296853,220.770987 142.58688,220.772693 141.888853,220.7744 L141.888853,220.7744 L137.751893,220.772693 L132.724053,220.745387 L130.039467,220.714667 C129.629867,220.706133 129.235627,220.863147 128.94208,221.149867 C128.65024,221.436587 128.484693,221.827413 128.484693,222.235307 L128.484693,222.235307 L128.479573,234.668373 L128.467627,239.230293 C128.467627,241.02912 127.6672,242.732373 126.201173,243.945813 C124.1344,245.507413 121.39008,246.985387 117.986987,248.323413 L117.986987,248.323413 L116.82816,248.762027 C115.053227,249.41568 113.114453,250.031787 111.015253,250.601813 L111.015253,250.601813 L109.590187,250.975573 L108.11904,251.33568 C106.624,251.68896 105.05728,252.02176 103.420587,252.330667 L103.420587,252.330667 L101.76,252.632747 L100.053333,252.91776 C98.6094933,253.14816 97.1195733,253.3632 95.5818667,253.55776 L95.5818667,253.55776 L93.71136,253.78304 L91.79648,253.991253 L89.83552,254.178987 L87.82848,254.349653 L85.77536,254.49984 L83.67616,254.629547 C83.32288,254.650027 82.9678933,254.6688 82.6112,254.687573 L82.6112,254.687573 L80.44544,254.78656 L78.2353067,254.865067 C77.4894933,254.885547 76.73856,254.906027 75.9790933,254.921387 L75.9790933,254.921387 L73.6785067,254.953813 C72.9053867,254.962347 72.1237333,254.96576 71.3352533,254.96576 L71.3352533,254.96576 L70.1354667,254.96576 C69.34016,254.96064 68.5499733,254.953813 67.76832,254.94528 L67.76832,254.94528 L65.4455467,254.907733 L63.1671467,254.85312 C62.4145067,254.83264 61.6704,254.80704 60.93312,254.78144 L60.93312,254.78144 L58.7451733,254.690987 C58.38336,254.67392 58.02496,254.65856 57.66656,254.639787 L57.66656,254.639787 L55.5451733,254.523733 L53.4698667,254.394027 L51.44064,254.245547 C51.1044267,254.221653 50.7733333,254.194347 50.44224,254.16704 L50.44224,254.16704 L48.48128,253.99808 C48.15872,253.96736 47.8378667,253.938347 47.51872,253.90592 L47.51872,253.90592 L45.6277333,253.714773 L43.7845333,253.508267 C43.4807467,253.472427 43.1786667,253.436587 42.88,253.39904 L42.88,253.39904 L41.1067733,253.170347 L39.3813333,252.931413 L37.7053867,252.67712 C36.87936,252.545707 36.0704,252.412587 35.2802133,252.27264 L35.2802133,252.27264 L33.72544,251.987627 C33.46944,251.93984 33.2168533,251.890347 32.9659733,251.840853 L32.9659733,251.840853 L31.48288,251.538773 L30.0509867,251.226453 L28.6685867,250.90048 L27.33568,250.56768 C26.0283733,250.228053 24.79616,249.873067 23.6424533,249.506133 L23.6424533,249.506133 L22.51264,249.13408 C21.95968,248.946347 21.4289067,248.7552 20.9152,248.558933 L20.9152,248.558933 L19.9150933,248.168107 C18.4541867,247.57248 17.1707733,246.95296 16.06656,246.314667 C14.3240533,245.203627 13.2676267,243.280213 13.2625067,241.21344 L13.2625067,241.21344 L12.98944,113.629867 C5.46474667,111.85152 0,105.14432 0,97.3073067 C0,89.66656 5.1712,83.2238933 12.2350933,81.29024 C12.1480533,78.96576 12.20096,76.672 12.4416,74.40896 C12.7624533,71.4154667 13.3888,68.5568 14.3479467,65.8466133 C19.8485333,50.3108267 29.6379733,41.73312 43.3749333,39.02976 C45.8274133,38.54848 48.07168,38.4938667 50.4302933,38.8113067 C48.6485333,37.143893Line truncated
|
||||
|
||||
</path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,47 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 128 128" id="mongodb">
|
||||
<path fill="#439934" fill-rule="evenodd"
|
||||
d="M88.038 42.812c1.605 4.643 2.761 9.383 3.141 14.296.472 6.095.256 12.147-1.029 18.142-.035.165-.109.32-.164.48-.403.001-.814-.049-1.208.012-3.329.523-6.655 1.065-9.981 1.604-3.438.557-6.881 1.092-10.313 1.687-1.216.21-2.721-.041-3.212 1.641-.014.046-.154.054-.235.08l.166-10.051c-.057-8.084-.113-16.168-.169-24.252l1.602-.275c2.62-.429 5.24-.864 7.862-1.281 3.129-.497 6.261-.98 9.392-1.465 1.381-.215 2.764-.412 4.148-.618z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#45A538" fill-rule="evenodd"
|
||||
d="M61.729 110.054c-1.69-1.453-3.439-2.842-5.059-4.37-8.717-8.222-15.093-17.899-18.233-29.566-.865-3.211-1.442-6.474-1.627-9.792-.13-2.322-.318-4.665-.154-6.975.437-6.144 1.325-12.229 3.127-18.147l.099-.138c.175.233.427.439.516.702 1.759 5.18 3.505 10.364 5.242 15.551 5.458 16.3 10.909 32.604 16.376 48.9.107.318.384.579.583.866l-.87 2.969z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#46A037" fill-rule="evenodd"
|
||||
d="M88.038 42.812c-1.384.206-2.768.403-4.149.616-3.131.485-6.263.968-9.392 1.465-2.622.417-5.242.852-7.862 1.281l-1.602.275-.012-1.045c-.053-.859-.144-1.717-.154-2.576-.069-5.478-.112-10.956-.18-16.434-.042-3.429-.105-6.857-.175-10.285-.043-2.13-.089-4.261-.185-6.388-.052-1.143-.236-2.28-.311-3.423-.042-.657.016-1.319.029-1.979.817 1.583 1.616 3.178 2.456 4.749 1.327 2.484 3.441 4.314 5.344 6.311 7.523 7.892 12.864 17.068 16.193 27.433z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#409433" fill-rule="evenodd"
|
||||
d="M65.036 80.753c.081-.026.222-.034.235-.08.491-1.682 1.996-1.431 3.212-1.641 3.432-.594 6.875-1.13 10.313-1.687 3.326-.539 6.652-1.081 9.981-1.604.394-.062.805-.011 1.208-.012-.622 2.22-1.112 4.488-1.901 6.647-.896 2.449-1.98 4.839-3.131 7.182-1.72 3.503-3.863 6.77-6.353 9.763-1.919 2.308-4.058 4.441-6.202 6.548-1.185 1.165-2.582 2.114-3.882 3.161l-.337-.23-1.214-1.038-1.256-2.753c-.865-3.223-1.319-6.504-1.394-9.838l.023-.561.171-2.426c.057-.828.133-1.655.168-2.485.129-2.982.241-5.964.359-8.946z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#4FAA41" fill-rule="evenodd"
|
||||
d="M65.036 80.753c-.118 2.982-.23 5.964-.357 8.947-.035.83-.111 1.657-.168 2.485l-.765.289c-1.699-5.002-3.399-9.951-5.062-14.913-2.75-8.209-5.467-16.431-8.213-24.642-2.217-6.628-4.452-13.249-6.7-19.867-.105-.31-.407-.552-.617-.826l4.896-9.002c.168.292.39.565.496.879 2.265 6.703 4.526 13.407 6.768 20.118 2.916 8.73 5.814 17.467 8.728 26.198.116.349.308.671.491 1.062l.67-.78c-.056 3.351-.112 6.701-.167 10.052z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#4AA73C" fill-rule="evenodd"
|
||||
d="M43.155 32.227c.21.274.511.516.617.826 2.248 6.618 4.483 13.239 6.7 19.867 2.746 8.211 5.463 16.433 8.213 24.642 1.662 4.961 3.362 9.911 5.062 14.913l.765-.289-.171 2.426-.155.559c-.266 2.656-.49 5.318-.814 7.968-.163 1.328-.509 2.632-.772 3.947-.198-.287-.476-.548-.583-.866-5.467-16.297-10.918-32.6-16.376-48.9-1.737-5.187-3.483-10.371-5.242-15.551-.089-.263-.34-.469-.516-.702 1.09-2.947 2.181-5.894 3.272-8.84z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#57AE47" fill-rule="evenodd"
|
||||
d="M65.202 70.702l-.67.78c-.183-.391-.375-.714-.491-1.062-2.913-8.731-5.812-17.468-8.728-26.198-2.242-6.711-4.503-13.415-6.768-20.118-.105-.314-.327-.588-.496-.879l6.055-7.965c.191.255.463.482.562.769 1.681 4.921 3.347 9.848 5.003 14.778 1.547 4.604 3.071 9.215 4.636 13.813.105.308.47.526.714.786l.012 1.045c.058 8.082.115 16.167.171 24.251z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#60B24F" fill-rule="evenodd"
|
||||
d="M65.021 45.404c-.244-.26-.609-.478-.714-.786-1.565-4.598-3.089-9.209-4.636-13.813-1.656-4.93-3.322-9.856-5.003-14.778-.099-.287-.371-.514-.562-.769 1.969-1.928 3.877-3.925 5.925-5.764 1.821-1.634 3.285-3.386 3.352-5.968.003-.107.059-.214.145-.514l.519 1.306c-.013.661-.072 1.322-.029 1.979.075 1.143.259 2.28.311 3.423.096 2.127.142 4.258.185 6.388.069 3.428.132 6.856.175 10.285.067 5.478.111 10.956.18 16.434.008.861.098 1.718.152 2.577z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#A9AA88" fill-rule="evenodd"
|
||||
d="M62.598 107.085c.263-1.315.609-2.62.772-3.947.325-2.649.548-5.312.814-7.968l.066-.01.066.011c.075 3.334.529 6.615 1.394 9.838-.176.232-.425.439-.518.701-.727 2.05-1.412 4.116-2.143 6.166-.1.28-.378.498-.574.744l-.747-2.566.87-2.969z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#B6B598" fill-rule="evenodd"
|
||||
d="M62.476 112.621c.196-.246.475-.464.574-.744.731-2.05 1.417-4.115 2.143-6.166.093-.262.341-.469.518-.701l1.255 2.754c-.248.352-.59.669-.728 1.061l-2.404 7.059c-.099.283-.437.483-.663.722l-.695-3.985z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#C2C1A7" fill-rule="evenodd"
|
||||
d="M63.171 116.605c.227-.238.564-.439.663-.722l2.404-7.059c.137-.391.48-.709.728-1.061l1.215 1.037c-.587.58-.913 1.25-.717 2.097l-.369 1.208c-.168.207-.411.387-.494.624-.839 2.403-1.64 4.819-2.485 7.222-.107.305-.404.544-.614.812-.109-1.387-.22-2.771-.331-4.158z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#CECDB7" fill-rule="evenodd"
|
||||
d="M63.503 120.763c.209-.269.506-.508.614-.812.845-2.402 1.646-4.818 2.485-7.222.083-.236.325-.417.494-.624l-.509 5.545c-.136.157-.333.294-.398.477-.575 1.614-1.117 3.24-1.694 4.854-.119.333-.347.627-.525.938-.158-.207-.441-.407-.454-.623-.051-.841-.016-1.688-.013-2.533z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#DBDAC7" fill-rule="evenodd"
|
||||
d="M63.969 123.919c.178-.312.406-.606.525-.938.578-1.613 1.119-3.239 1.694-4.854.065-.183.263-.319.398-.477l.012 3.64-1.218 3.124-1.411-.495z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#EBE9DC" fill-rule="evenodd" d="M65.38 124.415l1.218-3.124.251 3.696-1.469-.572z"
|
||||
clip-rule="evenodd"></path>
|
||||
<path fill="#CECDB7" fill-rule="evenodd"
|
||||
d="M67.464 110.898c-.196-.847.129-1.518.717-2.097l.337.23-1.054 1.867z" clip-rule="evenodd"></path>
|
||||
<path fill="#4FAA41" fill-rule="evenodd"
|
||||
d="M64.316 95.172l-.066-.011-.066.01.155-.559-.023.56z" clip-rule="evenodd"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6.0 KiB |
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg fill="#000000" height="1em" width="1em" viewBox="0 0 24 24" role="img" xmlns="http://www.w3.org/2000/svg"><title>PyTorch icon</title><path d="M12.005.04l-7.03 7.03a9.832 9.832 0 0 0 0 13.975 9.833 9.833 0 0 0 13.976 0c3.97-3.887 3.972-10.171.084-13.976l-1.738 1.737c2.895 2.895 2.895 7.608 0 10.503-2.894 2.894-7.608 2.894-10.503 0C3.9 16.414 3.9 11.7 6.794 8.806l4.632-4.631.58-.663zm3.556 3.886a1.323 1.323 0 0 0-1.323 1.323 1.323 1.323 0 0 0 1.323 1.323 1.323 1.323 0 0 0 1.323-1.323 1.323 1.323 0 0 0-1.323-1.323z"/></svg>
|
||||
|
After Width: | Height: | Size: 650 B |
File renamed without changes.
|
Before Width: | Height: | Size: 216 KiB After Width: | Height: | Size: 216 KiB |
@@ -15,7 +15,7 @@
|
||||
<div class="share mt-4">
|
||||
<a href="/zh-CN/">中文版</a>
|
||||
<% if (site.posts.filter(post => post.layout === "note").length > 0) { %>
|
||||
<a href="/notes">#Notes</a>
|
||||
<a href="/notes/">#Notes</a>
|
||||
<% } %>
|
||||
</div>
|
||||
<div class="share mt-8">
|
||||
|
||||
@@ -10,4 +10,4 @@ pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5p
|
||||
Updated for @stackoverflow/stacks v0.64.0
|
||||
Code Blocks: /blob/v0.64.0/lib/css/components/_stacks-code-blocks.less
|
||||
Colors: /blob/v0.64.0/lib/css/exports/_stacks-constants-colors.less
|
||||
*/.hljs{color:#2f3337;background:#f6f6f6}.hljs-subst{color:#2f3337}.hljs-comment{color:#656e77}.hljs-attr,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-section,.hljs-selector-tag{color:#015692}.hljs-attribute{color:#803378}.hljs-name,.hljs-number,.hljs-quote,.hljs-selector-id,.hljs-template-tag,.hljs-type{color:#b75501}.hljs-selector-class{color:#015692}.hljs-link,.hljs-regexp,.hljs-selector-attr,.hljs-string,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#54790d}.hljs-meta,.hljs-selector-pseudo{color:#015692}.hljs-built_in,.hljs-literal,.hljs-title{color:#b75501}.hljs-bullet,.hljs-code{color:#535a60}.hljs-meta .hljs-string{color:#54790d}.hljs-deletion{color:#c02d2e}.hljs-addition{color:#2f6f44}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}
|
||||
*/.hljs{color:#2f3337;background:#f6f6f6}.hljs-comment{color:#656e77}.hljs-attr,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-section,.hljs-selector-tag{color:#015692}.hljs-attribute{color:#803378}.hljs-name,.hljs-number,.hljs-quote,.hljs-selector-id,.hljs-template-tag,.hljs-type{color:#b75501}.hljs-selector-class{color:#015692}.hljs-link,.hljs-regexp,.hljs-selector-attr,.hljs-string,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#54790d}.hljs-meta,.hljs-selector-pseudo{color:#015692}.hljs-built_in,.hljs-literal,.hljs-title{color:#b75501}.hljs-bullet,.hljs-code{color:#535a60}.hljs-meta .hljs-string{color:#54790d}.hljs-deletion{color:#c02d2e}.hljs-addition{color:#2f6f44}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}
|
||||
Reference in new issue
Block a user