Skip to content

Instantly share code, notes, and snippets.

Avatar

Santiago Castro bryant1410

View GitHub Profile
@bryant1410
bryant1410 / change_terminal_width.py
Created Apr 13, 2020
Quick workaround to change PyCharm's remote terminal width
View change_terminal_width.py
# See https://youtrack.jetbrains.com/issue/PY-40900#focus=streamItem-27-4082296.0-0
width = 215; print("Terminal width:", width)
import fcntl, struct, sys, termios; fcntl.ioctl(sys.stdin, termios.TIOCSWINSZ, struct.pack("HHHH", 0, width, 0, 0))
@bryant1410
bryant1410 / set_terminal_width.py
Created Apr 13, 2020
Script to change the terminal width (passed by arg) from Python.
View set_terminal_width.py
#!/usr/bin/env python
"""Script to change the terminal width (passed by arg) from Python."""
import argparse
import fcntl
import struct
import sys
import termios
from array import array
from typing import IO
@bryant1410
bryant1410 / find_commits.sh
Created Feb 20, 2020
Find any commit from any repo for a given author and between given dates
View find_commits.sh
#!/usr/bin/env bash
for d in ~/repos/*; do
pushd "$d" > /dev/null
if [ -d .git ]; then
echo $d
echo "branch $(git rev-parse --abbrev-ref HEAD)"
git --no-pager log --color=always --all --oneline --graph --decorate --after 2019-04-20 --before 2019-05-15 --author='Santiago Castro'
fi
popd > /dev/null
View bashprofile.py
#!/usr/bin/env python
import argparse
import heapq
def parse_args():
parser = argparse.ArgumentParser(description="Analyze bashstart log for speed.")
parser.add_argument('filename', help="often /tmp/bashstart.<PID>.log")
parser.add_argument('-n', default=20, help="number of results to show")
return parser.parse_args()
View conda-python
#!/usr/bin/env bash
set -e
if [[ $# -eq 0 ]]; then
echo "Illegal number of arguments. Usage: ${0} env_name_or_prefix [args]..."
exit 2
fi
name=$1
View layernorm_vs_fused.py
import time
import torch
import torch.nn as nn
from apex.normalization import FusedLayerNorm
torch.backends.cudnn.benchmark = True
@bryant1410
bryant1410 / snap-refresh-home-nfs.sh
Last active Nov 20, 2018
This script is a workaround to refresh the snaps under a NFS /home directory with root_squash option (the default).
View snap-refresh-home-nfs.sh
#!/usr/bin/env bash
# This script is a workaround to refresh the snaps under a NFS /home directory with root_squash option (the default).
# Note that using no_root_squash is insecure.
# The bug was already filed: https://bugs.launchpad.net/snappy/+bug/1804281
set -ex
BACKUP_DIR=/s # CREATE AND/OR CHANGE THIS.
@bryant1410
bryant1410 / tensorboard_pb.py
Created Jun 14, 2018
Load protobuf in tensorboard
View tensorboard_pb.py
# import tensorflow as tf
# from tensorflow.python.platform import gfile
# with tf.Session() as sess:
# model_filename ='aaa.pb'
# with gfile.FastGFile(model_filename, 'rb') as f:
# graph_def = tf.GraphDef()
# graph_def.ParseFromString(f.read())
# g_in = tf.import_graph_def(graph_def)
# LOGDIR='logsst2'
# train_writer = tf.summary.FileWriter(LOGDIR)
@bryant1410
bryant1410 / make-arXiv-package.sh
Last active Jan 24, 2017 — forked from robince/make-arXiv-package.sh
Script to prepare arXiv package of a document that depends on a recent texlive version of biblatex (using pdflatex)
View make-arXiv-package.sh
#!/usr/bin/env bash
# This script is useful if:
# - you have a manuscript that you want to upload to the arXiv,
# - you are using biblatex, and
# - you are using a recent version of texlive while arXiv is still on texlive2011
#
# Put this file in a directory containing the manuscript you want to
# upload to arXiv.org, and adapt the paths below.
@bryant1410
bryant1410 / remove_channels.py
Created Jul 12, 2016
Remove channels from Twilio IP Messaging
View remove_channels.py
#!/usr/bin/env python3
import requests
# noinspection SpellCheckingInspection
SERVICE_SID = '...'
# noinspection SpellCheckingInspection
ACCOUNT_SID = '...'
# noinspection SpellCheckingInspection
AUTH_TOKEN = '...'
You can’t perform that action at this time.