Skip to content

Instantly share code, notes, and snippets.

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

dongyuwei dongyuwei

💭
天天听儿歌
View GitHub Profile
@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);
@dongyuwei
dongyuwei / transition.css
Created June 30, 2021 01:40
transition top and bottom 上下同时展开的动画效果
.page {
position: relative;
width: 1000px;
height: 800px;
border: 1px solid red;
.foo {
background-color: red;
position: absolute;
transition: all 2s ease 0s;
@dongyuwei
dongyuwei / custom-react-render.js
Created December 1, 2020 06:58
a tiny custom react dom render reimplementtion
const Reconciler = require("react-reconciler");
function traceMethod(obj) {
return new Proxy(obj, {
get(target, propKey) {
const origMethod = target[propKey];
if (typeof origMethod === 'function') {
return function (...args) {
console.log('propKey, args:', propKey, args);
return origMethod.apply(target, args);
# bash cli
sbt "testOnly akka.stream.javadsl.FlowTest"
# in sbt interactive cli
sbt >
testOnly akka.stream.javadsl.FlowTest
import { range, merge, Subject } from 'rxjs';
import { take, takeLast, multicast } from 'rxjs/operators';
range(1, 10)
.pipe(
multicast(() => new Subject(), o => merge(
o.pipe(take(1)),
o.pipe(takeLast(1)),
)),
)
@dongyuwei
dongyuwei / config.fish
Created July 11, 2019 02:18
cat ~/.config/fish/config.fish
set HOMEBREW_NO_AUTO_UPDATE 1
alias st "git status"
alias tigf "tig --follow"
set -gx LC_ALL en_GB.UTF-8
set -gx ANDROID_HOME ~/Library/Android/sdk
set -gx ANDROID_SDK_ROOT ~/Library/Android/sdk
set -gx ANDROID_NDK ~/Library/Android/sdk/ndk-bundle
set -gx ANDROID_NDK_HOME ~/Library/Android/sdk/ndk-bundle

cat /Users/dongyuwei/.proxychains/proxychains.conf

strict_chain
proxy_dns  force
remote_dns_subnet 224
tcp_read_time_out 15000
tcp_connect_time_out 8000
localnet 127.0.0.0/255.0.0.0
quiet_mode
wget --load-cookies=cookies.txt -c https://download.developer.apple.com/Developer_Tools/Xcode_11_Beta_2/Xcode_11_Beta_2.xip