This file contains hidden or 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 sys | |
| import re | |
| import mailbox | |
| emails = set() | |
| for message in mailbox.mbox(sys.argv[1]).itervalues(): | |
| for k, v in message.items(): | |
| if k.lower() in ['from', 'to', 'cc']: | |
| emails |= set(re.split(r''' |<|>|"|,|\t''', v)) |
This file contains hidden or 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
| # Use Chrome Session Buddy plugins to export and import tab URL lists | |
| # alias splittabs='python3 <(curl -s https://gist.githubusercontent.com/vadimkantorov/ab9acf28bdb0b5f3423973106a4d13a5/raw)' | |
| # splittabs session_buddy.txt --noperc | |
| import sys | |
| input_file_path, noperc = sys.argv[1], (sys.argv + [None])[2] == '--noperc' | |
| lines = set(filter(bool, open(input_file_path))) | |
| def flt(name, lines, contains = []): |
This file contains hidden or 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
| in:inbox is:unread category:primary |
This file contains hidden or 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
| # Does not work because of https://github.com/twintproject/twint/issues/1011 | |
| # # Prerequisite: https://github.com/twintproject/twint | |
| # # Usage: dump_twitter_followed_bio vadimkantorov > followed.txt | |
| # # Takes 1h for 2500 followed accouns | |
| # # alias dump_twitter_followed_bio='twint --following --user-full -u' | |
| # Works: | |
| # Save in Chrome HAR session of scrolling the Followers / Following timeline | |
| import argparse |
This file contains hidden or 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
| set -e | |
| # for f in *.m4a; do ffmpeg -i "$f" -af "silenceremove=stop_periods=-1:stop_duration=0.2:stop_threshold=-40dB:window=1" -y "nosilence/$f"; done | |
| for f in $1/*.wav; do | |
| fname=$(basename $f) | |
| segdir=segments.$fname | |
| rm -rf $segdir | |
| mkdir $segdir | |
| for channel in 0 1; do |
This file contains hidden or 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://superuser.com/questions/650291/how-to-get-video-duration-in-seconds | |
| # Usage: duration myfile.wav | |
| alias duration="ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1" | |
| # mkdir -p sample; find segments.* -name '*.wav' -type f | while read filename; do echo "$(duration $filename) $filename"; done | grep "^5\." | while read duration_ filename_; do cp $filename_ sample; done |
This file contains hidden or 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 torch | |
| class ReLUDropout(torch.nn.Dropout): | |
| def forward(self, input): | |
| return relu_dropout(input, p = self.p, training = self.training, inplace = self.inplace) | |
| def relu_dropout(x, p = 0, inplace = False, training = False): | |
| if not training or p == 0: | |
| return x.clamp_(min = 0) if inplace else x.clamp(min = 0) |
This file contains hidden or 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
| # Usage: python3 split_audio_by_silence.py -i input_audio.m4a -o segments | |
| # will save segments in mp3 format into the segments directory | |
| # based on https://github.com/mozilla/DeepSpeech/tree/master/examples/vad_transcriber | |
| # Dependencies: webrtcvad | |
| import os | |
| import argparse | |
| import collections | |
| import subprocess | |
| import webrtcvad |
This file contains hidden or 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 torch | |
| # ported from https://github.com/NVIDIA/OpenSeq2Seq/blob/master/open_seq2seq/optimizers/lr_policies.py and https://www.tensorflow.org/api_docs/python/tf/train/polynomial_decay | |
| class PolynomialDecayLR(torch.optim.lr_scheduler._LRScheduler): | |
| def __init__(self, optimizer, decay_steps, power = 1.0, begin_decay_at = 0, end_lr = 0.0, warmup_steps = 0, last_epoch = -1): | |
| self.decay_steps = decay_steps | |
| self.power = power | |
| self.begin_decay_at = begin_decay_at | |
| self.end_lr = end_lr | |
| self.warmup_steps = warmup_steps |
This file contains hidden or 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
| # ported from https://github.com/NVIDIA/OpenSeq2Seq/blob/master/open_seq2seq/optimizers/novograd.py | |
| # paper: https://arxiv.org/abs/1905.11286 | |
| # a recent NVidia's implementation in PyTorch: https://github.com/NVIDIA/DeepLearningExamples/blob/master/PyTorch/SpeechRecognition/Jasper/optimizers.py | |
| import torch | |
| class NovoGrad(torch.optim.Optimizer): | |
| def __init__(self, params, lr=1.0, betas = (0.95, 0.98), eps=1e-8, weight_decay=0.0, dampening=False): | |
| defaults = dict(lr=lr, betas=betas, eps=eps, weight_decay=weight_decay, dampening=dampening) | |
| super(NovoGrad, self).__init__(params, defaults) |