This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
SET var=C:\Folder1\Folder2\File.txt | |
echo before: %var% | |
call :getFolder "%var%" var | |
echo after: %var% | |
exit /b | |
:getFolder | |
set "%2=%~dp1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function heavyTask() { | |
i=0 | |
// do a heavy job | |
for (let j = 0; j < 1e8; j++) { | |
i++; | |
} | |
} | |
setTimeout(function(){console.log(1)}, 10) | |
heavyTask(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import warnings | |
warnings.warn = lambda *a, **kw: (a, kw) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-antrun-plugin</artifactId> | |
<version>1.3</version> | |
<executions> | |
<execution> | |
<id>ant-validate</id> | |
<phase>validate</phase> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bastion is the jump server | |
# target is the target server | |
# %h stands for host given to ssh, here is target | |
# %p stands for port given to ssh, here is 22(the default port) | |
ssh -go ProxyCommand='ssh user@bastion nc %h %p' user@target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 二叉树前中后序遍历统一写法: | |
// https://leetcode-cn.com/problems/binary-tree-postorder-traversal/solution/bang-ni-dui-er-cha-shu-bu-zai-mi-mang-che-di-chi-t/ | |
class Solution { | |
// 前序遍历 | |
public List<Integer> preorderTraversal(TreeNode root) { | |
if (root == null) return new LinkedList<>(); | |
List<Integer> res = new LinkedList<>(); | |
Stack<TreeNode> st = new Stack<>(); | |
st.push(root); | |
while (!st.isEmpty()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_balance_list(servers): | |
whole_weight = sum(srv[1] for srv in servers) | |
balance = [] | |
weight_so_far = 0 | |
for server in servers: | |
weight = server[1] | |
weight_so_far += weight | |
balance.append(weight_so_far / whole_weight) | |
return balance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bubble(a): | |
for i in range(len(a)): | |
for j in range(len(a) - i - 1): | |
if a[j] > a[j + 1]: | |
a[j], a[j + 1] = a[j + 1], a[j] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BigHeap { | |
// 大根堆, 大顶堆, 最大堆 | |
int capacity = 0; // 容量 | |
int size = 0; // 当前大小 | |
int[] hp; // 数组模拟堆, 本实现使用数组下标 0 位置 | |
public BigHeap(int k) { | |
capacity = k; | |
hp = new int[capacity]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void qsort(int[] a, int bl, int br) { | |
if (bl >= br) return; | |
int m = a[bl], l = bl, r = br; | |
while (l < r) { | |
while (l < r && a[r] >= m) r--; | |
if (l < r) a[l++] = a[r]; | |
while (l < r && a[l] <= m) l++; | |
if (l < r) a[r--] = a[l]; | |
} | |
a[l] = m; |
NewerOlder