Skip to content

Instantly share code, notes, and snippets.

# References: https://simpleitk.readthedocs.io/en/master/link_AdvancedImageReading_docs.html
import SimpleITK as sitk
import time
img_path = 'D:/DATA/CLD0318/patient_67.nii'
a = time.time()
X = sitk.ReadImage(img_path)
b = time.time()
const date = new Date()
const YYYY = date.getFullYear()
const MM = String(date.getMonth() + 1).padStart(2, '0')
const dd = String(date.getDate() + 1).padStart(2, '0')
const hh = String(date.getHours() + 1).padStart(2, '0')
const mm = String(date.getMinutes() + 1).padStart(2, '0')
const ss = String(date.getSeconds() + 1).padStart(2, '0')
const timestamp = [YYYY, MM, dd, hh, mm, ss].join('-')
from pathlib import Path
Path("/my/directory").mkdir(parents=True, exist_ok=True)
# 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))
const fs = require('fs')
const path = require('path')
const move = (a, b) => {
console.log(`moving from ${a} to ${b}`)
// return
fs.renameSync(a, b)
}

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

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

// buildProps 的实现比较复杂,可以直接拿来使用就行了,就是对类型做了优化,有了静态类型类似 `PropType<string>`
export const radioPropsBase = buildProps({
  size: useSizeProp,
  disabled: Boolean,
  label: {
```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
```

~/.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
@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;
// 实现 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 列表
*/