Skip to content

Instantly share code, notes, and snippets.

View dongyuwei's full-sized avatar
💭
天天听儿歌

dongyuwei dongyuwei

💭
天天听儿歌
View GitHub Profile
@dongyuwei
dongyuwei / cacheable-ng-for.directive.ts
Last active September 18, 2023 01:19
cacheable-ng-for.directive. It's buggy now. Don't use it. I'm testing it.
import {
ChangeDetectorRef,
Directive,
DoCheck, Injector,
Input, OnChanges, SimpleChanges,
TemplateRef,
TrackByFunction,
ViewContainerRef
} from "@angular/core";
@Directive({
@dongyuwei
dongyuwei / PIME.md
Last active October 7, 2023 13:39
PIME dev/debug log

build and compile with Visual Studio 2019(same with the Appveyor CI)

test build in vs studio 2022

  1. mkdir /d/dyw-code/PIME-Cmake-build
  2. cd /d/dyw-code/PIME-Cmake-build
  3. cmake -G "Visual Studio 17 2022" -A x64 ../PIME
  4. open PIME.sln in vs studio 2022
/**
1. 有@3x的优先取@3x, 如 add@3x.png
2. 没有@3x的优先取@2x,如 add@2x.png
3. 没有@3x和@2x的,取图片名称本身,如 add.png
*/
const path = require("path");
const shell = require("shelljs");
const files = {};
@dongyuwei
dongyuwei / init.lua
Created October 17, 2022 07:36
use LUA_INIT to preload inspect.lua, so we can use it in lua.
tail ~/.config/fish/config.fish
`set -gx LUA_INIT @/Users/yuwdong/.init.lua`
cat /Users/yuwdong/.init.lua
```lua
inspect = require('inspect')
ins = inspect
```
@dongyuwei
dongyuwei / test.lua
Last active October 17, 2022 07:08
test inspect.lua and http request with luasocket
local inspect = require('inspect')
local http = require("socket.http")
inspect(http)
r, c, h = http.request('https://www.baidu.com/')
print(r)
print(c)
inspect(h)
var voronoi = new Voronoi();
var sites = generateBeeHivePoints(view.size / 200, true);
var bbox, diagram;
var oldSize = view.size;
// var spotColor = new Color('red');
var mousePos = view.center;
var selected = false;
onResize();
ffmpeg -i GMT20211220-054810_Recording_1792x1120.mp4 -acodec copy -vcodec copy -ss 0 -t 00:56:12 onboarding.mp4
@dongyuwei
dongyuwei / test_fish_event_handler.fish
Last active December 16, 2021 06:26
test event handler of fish shell script
function custom_event_test --on-event test_event
echo 'event hook'
echo event test: $argv
end
emit test_event foo bar
function on_pwd_changed --on-variable PWD
echo 'on_pwd_changed hook'
@dongyuwei
dongyuwei / foo.test.js
Last active September 17, 2022 12:34
mock a default export function in another module
jest.mock('../utilities/prompt/prompt', () => {
const originalModule = jest.requireActual('../utilities/prompt/prompt');
return {
__esModule: true,
...originalModule,
default: jest.fn((args)=> {
if(args.onConfirm){
args.onConfirm('lost reason')
}
}),
const path = require('path');
const fs = require('fs');
const shell = require('shelljs'); // Todo: `npm install --save-dev shelljs@0.8.4` for the first time on CI
const crypto = require('crypto');
// 如果 package-lock.json 都没有变化,就 skip `npm install`,节省ci时间。
const dirPath = path.join(__dirname, '..');
shell.cd(dirPath);