Skip to content

Instantly share code, notes, and snippets.

@infinex
infinex / README.md
Created June 7, 2020 04:52 — forked from joyrexus/README.md
Perl one-liners

Hi:

perl -e 'print "hello world!\n"'

A simple filter:

perl -ne 'print if /REGEX/'

Filter out blank lines (in place):

@infinex
infinex / alias
Last active November 26, 2020 02:43
shell
z() {
if [[ "$#" -ne 0 ]]; then
cd $(autojump $@)
return
fi
cd "$(autojump -s | sort -k1gr | awk '$1 ~ /[0-9]:/ && $2 ~ /^\// { for (i=2; i<=NF; i++) { print $(i) } }' | fzf --height 40% --reverse --inline-info)"
}
k() {
@infinex
infinex / checkpoint.py
Last active May 26, 2020 13:43
checkpoint
from tensorflow_core.python.training.py_checkpoint_reader import NewCheckpointReader
import tensorflow as tf
bert_init_dir = ''
latest = tf.train.latest_checkpoint(bert_init_dir)
reader = NewCheckpointReader(latest)
name_shape_map = reader.get_variable_to_shape_map()
@infinex
infinex / dataloader.py
Last active April 10, 2020 15:46
torch
special_tok_ids = {}
for tok_name, tok_symbol in tokenizer.special_tokens_map.items():
idx = tokenizer.all_special_tokens.index(tok_symbol)
special_tok_ids[tok_name] = tokenizer.all_special_ids[idx]
class JigSawDataset(Dataset):
def __init__(self, data, special_tok_ids, is_training, targets=None):
self.special_tok_ids = special_tok_ids
self.is_training = is_training
if self.is_training:
@infinex
infinex / Makefile
Last active November 6, 2020 07:25
utils
DATA_DIR=./data
field_keywords=$(wildcard $(DATA_DIR)/field_keywords_*)
out_keywords=$(patsubst $(DATA_DIR)/field_keywords_%,out%.txt,$(field_keywords))
REAL_PATH=$(abspath $(DATA_DIR))
NN_FRAMEWORK_DATA=~/.nn_framework_Data
field_keyword=$(patsubst $(DATA_DIR)/field_keywords_%,$(DATA_DIR)/field_keywords_\%,$(word 1,$(field_keywords)))
## all: run command
all: $(out_keywords)
@infinex
infinex / cloudSettings
Last active December 30, 2020 06:47
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-12-30T06:47:43.145Z","extensionVersion":"v3.4.3"}
@infinex
infinex / surfingKeys.js
Last active November 24, 2018 13:27
surfingKeys config
mapkey('\\F', "Toggle fullscreen (YouTube)", ytFullscreen, {
repeatIgnore: true,
domain: /(youtube\.com)/i
});
function ytFullscreen() {
$('.ytp-fullscreen-button.ytp-button').click();
}
// 优酷搜索
addSearchAliasX('yk', 'youku', 'http://www.soku.com/search_video/q_', 's', 'http://tip.soku.com/search_tip_1?query=', function(response) {
@infinex
infinex / config save
Created November 21, 2018 14:05
temp
clear mod1
clear mod4
keycode 64 =Super_L
keycode 133 = Alt_L
add mod1 = Alt_L
add mod4 = Super_L
! Unmap capslock
clear Lock
keycode 66 = Hyper_L
! Set mod3 to capslock
@infinex
infinex / xtensorflow18macos.patch
Last active October 23, 2018 12:41
xtensorflow18macos.patch
diff --git a/tensorflow/core/kernels/concat_lib_gpu_impl.cu.cc b/tensorflow/core/kernels/concat_lib_gpu_impl.cu.cc
index 0f7adaf24a..934ccbada6 100644
--- a/tensorflow/core/kernels/concat_lib_gpu_impl.cu.cc
+++ b/tensorflow/core/kernels/concat_lib_gpu_impl.cu.cc
@@ -69,7 +69,7 @@ __global__ void concat_variable_kernel(
IntType num_inputs = input_ptr_data.size;
// verbose declaration needed due to template
- extern __shared__ __align__(sizeof(T)) unsigned char smem[];
+ extern __shared__ __align__(sizeof(T) > 16 ? sizeof(T) : 16) unsigned char smem[];
@infinex
infinex / gist:1e0fda899d3192ac0c2dede34a9bf9ca
Last active November 24, 2020 16:01
manjaro deep learning installation
sudo mhwd -a pci nonfree 0300
pacman -S cuda cudnn
yaourt Ananconda
git clone https://github.com/fastai/fastai
cd fastai
conda-env create -f environment.yaml
build gcc 6
yay -S gcc6