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 dayjs, { Dayjs } from 'dayjs'; | |
| import { get } from 'lodash'; | |
| type FormatOptions = { | |
| reliable: boolean; | |
| }; | |
| type BaseSchemaField = { | |
| type: SchemaFieldType; | |
| source?: ((parentSourceData: any, rootSourceData: any) => any) | string; |
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
| extends Node | |
| class_name ArrayUtils | |
| static func filter(arr: Array, prop: Dictionary) -> Array: | |
| var res = [] | |
| for item in arr: | |
| for key in prop.keys(): | |
| if prop[key] is Array and item[key] in prop[key]: | |
| res.push_back(item) | |
| elif (!prop[key] is Array) and prop[key] == item[key]: |
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
| float rect(vec2 uv, vec2 size) { | |
| float blur = 0.000; | |
| // 让 size 成正比 | |
| size = 0.5 - size * 0.5; | |
| // 先画一边 | |
| vec2 r = vec2(step(size.x, uv.x), step(size.y, uv.y)); | |
| // 再画相反的边,相乘得出相交位置就是对应的矩形 | |
| r *= vec2(step(size.x, 1.0 - uv.x), step(size.y, 1.0 - uv.y)); | |
| // x 和 y 相乘得出矩形的像素点值 | |
| return r.x * r.y; |
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
| function wrap_text(content,max_count) | |
| local lines={''}local wcount=0 | |
| for i=1,#content do | |
| local c=sub(content,i,i) | |
| lines[#lines]..=c | |
| wcount+=1 | |
| if (wcount>=max_count) | |
| then | |
| wcount=0 | |
| lines[#lines]..='\n' |
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
| [*] | |
| end_of_line = lf | |
| insert_final_newline = true | |
| charset = utf-8 | |
| indent_style = space | |
| indent_size = 2 | |
| [Makefile] | |
| indent_style = tab |
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
| function binarySearch(nums, target) { | |
| let i = 0, j = nums.length - 1; | |
| while (i <= j) { | |
| const mid = (i + j) >> 1; | |
| if (nums[mid] === target) return mid; | |
| else if (nums[mid] > target) j = mid; | |
| else i = mid + 1; | |
| } | |
| return -1; | |
| } |
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
| // the router should be sigleton | |
| class Router { | |
| constructor(routeMap) { | |
| this._routeMap = routeMap; | |
| this.bindEvent(); | |
| } | |
| init(url) { | |
| let fn = this._routeMap[url]; | |
| window.history.replaceState({url: url}, '', url); |
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
| function debounce(fn, delay) { | |
| let timer = setTimeout(fn, delay); | |
| return function(){ | |
| clearTimeout(timer); | |
| fn.apply(this, arguments); | |
| }; | |
| } | |
| function throttle(fn, delay) { | |
| let timer = setTimeout(fn, delay); |
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
| function duplicate(arr){ | |
| let set = new Set(); | |
| let result = []; | |
| for(let i = 0;i < arr.length; ++i) { | |
| if(!set.has(arr[i])) result.push(arr[i]); | |
| set.add(arr[i]); | |
| } | |
| return result; | |
| } |
NewerOlder