mongo shell
db.variousInstance.aggregate([
{
$match: {}
},
{
$sort: {createAt: -1},
},
{
| Object.create = function (obj) { | |
| var F = function () {}; //1.生成新的建構函數 | |
| F.prototype = obj; //2.連接新建構函數的prototype到obj | |
| return new F(); //3.返回用F製造出來的新物件, | |
| // F為沒有內容的空函數,返回物件的__proto__連接obj | |
| // 返回物件被設為空函數F的this綁定 | |
| }; |
| function Foo(){ | |
| this.testArr=[2,4]; | |
| }; | |
| Foo.prototype={ | |
| str:'test', | |
| num:1, | |
| arr:[1,2], | |
| obj:{a:2} | |
| }; |
| package main | |
| import ( | |
| "fmt" | |
| "net/http" | |
| "sync" | |
| ) | |
| var mu sync.Mutex | |
| var count int |
| //問題1用到的struct | |
| type IssuesSearchResult struct { | |
| TotalCount int `json:"total_count"` | |
| //為什麼使用 struct pointer 作內嵌欄位 | |
| //不能直接定義為 | |
| //Items []Issue ? | |
| Items []*Issue | |
| } | |
| //問題1用到的struct |
| type T struct { | |
| } | |
| var p *T | |
| func New() *T { | |
| if p == nil { | |
| p = new(T) | |
| } | |
| return p |
| function RabinKarpSet(string s[1~K], string patterns[1~N]) | |
| //用hash table or Cuckoo Filter 來儲存敏感詞彙相關資料 | |
| set hsSet := emptySet | |
| //前置處理 | |
| foreach p in patterns | |
| insert hash(p[1~M]) into hsSet | |
| hs := hash(s[1~M]) | |
| //匹配運算 |
| // main.go | |
| package main | |
| type Duck interface { | |
| Quack() | |
| } | |
| type Cat struct { | |
| Name string | |
| } |
mongo shell
db.variousInstance.aggregate([
{
$match: {}
},
{
$sort: {createAt: -1},
},
{
| from dataclasses import dataclass, field, ClassVar | |
| from typing import Callable, Union, Optional, Any | |
| from enum import Enum | |
| Pattern = Union[Enum, str, int] | |
| Message = Any | |
| MessageHandler = Callable[[Message], None] | |
| MessageDecorator = Callable[[MessageHandler], MessageHandler] |