(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
package com.company; | |
public class MergeSort { | |
public void mergeSort(int[] nums) { | |
// 在排序前,先建好一个长度等于原数组长度的临时数组,避免递归中频繁开辟空间 | |
int[] tmps = new int[nums.length]; | |
sort(nums, 0, nums.length - 1, tmps); | |
} |
package com.company; | |
public class QuickSort { | |
public void quickSort(int[] nums) { | |
sort(nums, 0, nums.length - 1); | |
} | |
public void sort(int[] nums, int left, int right) { | |
int pivotIndex; |
import numpy as np | |
def largest_indices(array: np.ndarray, n: int) -> tuple: | |
"""Returns the n largest indices from a numpy array. | |
Arguments: | |
array {np.ndarray} -- data array | |
n {int} -- number of elements to select |
#/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
nii_to_tif | |
convert all mha files in a directory to nifti | |
Author: Jacob Reinhold (jacob.reinhold@jhu.edu) | |
""" |
import shutil | |
import urllib | |
import pathlib | |
import requests | |
from PIL import Image | |
from io import BytesIO | |
def get_file_name(url: str) -> str: | |
return url.split('/')[-1].split('?')[0] |
import argparse | |
import numpy as np | |
from PIL import Image | |
def pad_image(image: Image, desired_size: tuple, pad_value: str='#fff') -> Image: | |
""" | |
pad image to make image in center. | |
Args: |
/* 快速排序 */ | |
/** 待排序原始数据 */ | |
let data = [4, 10, 14, 11, 17, 8, 13, 15, 12, 2, 6, 9]; | |
let n = data.length; | |
/** 快速排序 */ | |
function quickSort(data, low, hight) { | |
/** 枢轴 */ | |
let pivot = 0; |
// NOTE: 在线学习正则表达式:http://regexr.com/ | |
// NOTE: XMLDocument 对象可用 new XMLSerializer().serializeToString(obj); 的方式转换为 JS 中的字符串 | |
let data = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><schs><sch><dm><![CDATA[10593]]></dm><mc><![CDATA[广西大学]]></mc></sch><sch><dm><![CDATA[10608]]></dm><mc><![CDATA[广西民族大学]]></mc></sch><sch><dm><![CDATA[10603]]></dm><mc><![CDATA[广西师范学院]]></mc></sch><sch><dm><![CDATA[10596]]></dm><mc><![CDATA[桂林理工大学]]></mc></sch><sch><dm><![CDATA[10601]]></dm><mc><![CDATA[桂林医学院]]></mc></sch></schs>'; | |
// 结尾 g 代表全局匹配 | |
let reg = /(<mc><\!\[CDATA\[)(.*?)(\]\]\><\/mc>)/g; | |
let r; | |
while((r = reg.exec(data)) != null) { | |
console.log(r[2]); | |
} |