Skip to content

Instantly share code, notes, and snippets.

View Liwink's full-sized avatar
🎯
Focusing

Yihe Liu Liwink

🎯
Focusing
View GitHub Profile
gawk -i inplace '/T3522293/{getline} 1' *
@Liwink
Liwink / codesign_gdb.md
Created May 10, 2019 21:06 — forked from hlissner/codesign_gdb.md
Codesign gdb on OSX

Note: these instructions are for pre-Sierra MacOS. Sierra and newer users see https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d by @gravitylow.

If you are getting this in gdb on OSX while trying to run a program:

Unable to find Mach task port for process-id 57573: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))

SSD performance 2015

  • Samsung XP941 SSD (£300 0.5TB) – A fast PCIe mounted SSD drive
  • Seagate Archive 8TB HDD (£242) – A high storage mechanical drive
  • Western Digital Raptor 1TB HDD (£178) – a low storage, fast mechanical drive

Sequential Read

  • Sam HDD ~ 190MB/s
  • Rap HDD ~ 203MB/s
MAC下,系统偏好设置->网络->(你连接的网络)->高级->代理->
自动发现代理配置前打钩 ->
右方URL输入 http://pac.unlockmusic.us 或者 http://pac.onenorthtech.com
重新打开网易云,OK
brew tap caskroom/fonts
brew cask install font-hack-nerd-font
set number
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set smarttab
set softtabstop=4
set expandtab
$ export https_proxy="socks5://127.0.0.1:8899"
$ export http_proxy="socks5://127.0.0.1:8899"
@Liwink
Liwink / drawtree.py
Created May 8, 2018 12:35
Draw the binary tree in Python using `turtle`
# https://leetcode.com/problems/recover-binary-search-tree/discuss/32539/Tree-Deserializer-and-Visualizer-for-Python
class TreeNode:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
def __repr__(self):
return 'TreeNode({})'.format(self.val)
@Liwink
Liwink / pytorch_tensor_operation.md
Last active November 10, 2017 13:21
pytorch tensor operation

unsqueeze, view, expand

unsqueeze:

Returns a new tensor with a dimension of size one inserted at the specified position.

The returned tensor shares the same underlying data with this tensor.

A negative dim value can be used and will correspond to dim+input.dim()+1

def generator(features, labels, batch_size):
while True:
index_list = np.arange(len(labels))
np.random.shuffle(index_list)
for i in range(int(len(features) / batch_size)):
index = index_list[i * batch_size: (i + 1) * batch_size]
f = pad_sequences(features[index],
maxlen=data.maxSentenceLen)
l = np.expand_dims(pad_sequences(labels[index],