- Fetch: [GET] -> /news/:id
- List: [GET] -> /news/list
- Add: [POST] -> /news
- Update: [POST] -> /news/:id
- Remove: [DELETE] -> /news/:id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tiktoken | |
| import langdetect | |
| T = tiktoken.get_encoding("o200k_base") | |
| length_dict = {} | |
| for i in range(T.n_vocab): | |
| try: | |
| length_dict[i] = len(T.decode([i])) | |
| except: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ref: https://gitlab.com/manning-fpcpp-book/code-examples/-/blob/master/chapter-01/count-lines-transform/main.cpp | |
| #include <iostream> | |
| #include <string> | |
| #include <vector> | |
| #include <unordered_map> | |
| #include <fstream> | |
| #include <algorithm> | |
| #include <iterator> | |
| #include <ranges> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| this.query = (filter: Filter) => | |
| Observable.from( | |
| this.api.getData(filter).switchMap((res) => { | |
| this.setData(res) | |
| }) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var alphabetBoardPath=function(f){var g=new Map(Array.from("abcdefghijklmnopqrstuvwxyz").map(function(a,c){return[a,{x:c/5|0,y:c%5|0}]})),d=function(a,c){return 0>=c?"":a.repeat(c)},a={x:0,y:0};return Array.from(f).reduce(function(e,c){var b=g.get(c);e.push(b.y<a.y?d("L",a.y-b.y):"",b.x<a.x?d("U",a.x-b.x):"",b.x>a.x?d("D",b.x-a.x):"",b.y>a.y?d("R",b.y-a.y):"","!");a=b;return e},[]).join("")}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const alphabetBoardPath = (target) => { | |
| const layout = 5 | |
| const hashMap = new Map(Array.from("abcdefghijklmnopqrstuvwxyz").map((c, i) => [ c, {x: (i / layout) | 0, y: i % layout | 0}])) | |
| const repeat = (s, n) => (n <= 0 ? '' : s.repeat(n)) | |
| let p0 = { x: 0, y: 0 } | |
| return Array.from(target).reduce((ret, t) => { | |
| const p = hashMap.get(t) | |
| ret.push(p.y < p0.y ? repeat('L', p0.y - p.y) : '', p.x < p0.x ? repeat('U', p0.x - p.x) : '', p.x > p0.x ? repeat('D', p.x - p0.x) : '', p.y > p0.y ? repeat('R', p.y - p0.y) : '', '!') | |
| p0 = p | |
| return ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const alphabetBoardPath = (target) => { | |
| const layout = 5 | |
| const hashMap = new Map(Array.from("abcdefghijklmnopqrstuvwxyz") | |
| .map((c, i) => [ c, {x: (i / layout) | 0, y: i % layout | 0}])) | |
| const repeat = (s, n) => (n <= 0 ? '' : s.repeat(n)) | |
| let p0 = { x: 0, y: 0 } | |
| const ret = Array.from(target).reduce((ret, t) => { | |
| const p = hashMap.get(t) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const delay = (delay) => () => new Promise((resolve, reject) => setTimeout(resolve, delay)) | |
| const main = () => f1().then(f2).catch(f3) | |
| const f1 = () => new Promise((resolve, reject) => ret ? resolve() : reject()) | |
| const f2 = () => Promise.resolve('f2') | |
| const f3 = () => Promise.resolve('f3') | |
| let ret = true | |
| const next = () => ret = !ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "compilerOptions": { | |
| "allowSyntheticDefaultImports": true, | |
| "declaration": false, | |
| "emitDecoratorMetadata": true, | |
| "experimentalDecorators": true, | |
| "lib": ["dom", "es2015"], | |
| "module": "es2015", | |
| "moduleResolution": "node", | |
| "sourceMap": true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let user = new User(filterByProps(form, [ | |
| 'username', | |
| 'displayname' | |
| ])) | |
| function filterByProps(obj: any, props: string[]): any { | |
| if (!props) return obj | |
| let ret = {} | |
| Object.keys(obj).forEach(key => { | |
| if (props.some(prop => prop === key)) { |
NewerOlder