Skip to content

Instantly share code, notes, and snippets.

View upupming's full-sized avatar
🎯
Working

Yiming Li upupming

🎯
Working
View GitHub Profile
@upupming
upupming / auto-start-shadowsocks.md
Created June 18, 2018 08:10
Configure shadowsocks for automatically start on Ubuntu 17.10, 18.10, etc.

Add shadowsocks ppa

$ sudo add-apt-repository ppa:max-c-lv/shadowsocks-libev
$ sudo apt update

Install using apt

@upupming
upupming / gist:aaf78d0ed82203b253a9d08be0ce7daf
Created December 23, 2018 06:29
Windows 10 disable Cortana & enable UTC time
# Windows 10 disable Cortana & enable UTC time
1. WIN + R, REGEDIT
2. HKEY_LOCAL_MACHINE > SOFTWARE > Policies > Microsoft > Windows, New > Key, "Windows Search", New > DWORD (32-bit) Value. Type in AllowCortana, and hit enter.
3. cmd; Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_QWORD /d 1
let a = [
{
width: 0,
height: 1
},
{
width: 2,
height: 3
},
]
// 实现 Promise.allConcurrent
// Promise.allConcurrent(2)([()=>fetch('BLAH1'), ()=>fetch('BLAH2'),...()=>fetch('BLAHN')])
// 先同时执行 BLAH1、BLAH2,BLAH1 执行完毕之后立即开始执行 BLAH3,以此类推……
Promise.allConcurrent = n => list => promiseAllStepN(n, list)
/**
* 带并发数限制的 Promise.All
* @param {*} n 同时并发数
* @param {*} list 需要执行的 Promise 列表
*/
@upupming
upupming / DICOMDIR_Open.cpp
Created March 22, 2021 08:59 — forked from JulesGorny/DICOMDIR_Open.cpp
How to open a DICOMDIR file and retrieve the DICOM files.
//Open the DICOMDIR File
QString DICOMDIR_folder = "C:/Folder1/Folder2";
const char *fileName = "C:/Folder1/Folder2/DICOMDIR";
DcmDicomDir dicomdir(fileName);
//Retrieve root node
DcmDirectoryRecord *root = &dicomdir.getRootRecord();
//Prepare child elements
DcmDirectoryRecord *rootTest = new DcmDirectoryRecord(*root);
DcmDirectoryRecord *PatientRecord = NULL;
DcmDirectoryRecord *StudyRecord = NULL;

~/.zshrc:

# proxy list
# https://zhuanlan.zhihu.com/p/47849525
# https://zhuanlan.zhihu.com/p/153124468
# 注意不 export 的话,别的 bash 脚本是访问不到这个变量的,为了能在 .ssh/config 访问到,必须 export 一下
# https://unix.stackexchange.com/a/495163
export host_ip=$(cat /etc/resolv.conf |grep "nameserver" |cut -f 2 -d " ")
# wget 比较特殊,不认 all_proxy,只认 http_proxy 和 https_proxy
```bash
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
```

参考 element plus,很巧妙地使用动态类型定义,同时使用 ExtractPropTypes 得到静态类型。

packages/components/radio/src/radio.ts:

// buildProps 的实现比较复杂,可以直接拿来使用就行了,就是对类型做了优化,有了静态类型类似 `PropType<string>`
export const radioPropsBase = buildProps({
  size: useSizeProp,
  disabled: Boolean,
  label: {
const fs = require('fs')
const path = require('path')
const move = (a, b) => {
console.log(`moving from ${a} to ${b}`)
// return
fs.renameSync(a, b)
}
# Test saving speed of different data format
import numpy as np
import pickle
import nibabel as nib
import time
from os import path
import SimpleITK as sitk
a = np.empty((512, 512, 512))