Skip to content

Instantly share code, notes, and snippets.

Santiago Castro bryant1410

Block or report user

Report or block bryant1410

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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 = '...'
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@bryant1410
bryant1410 / mp4amp3
Created Nov 28, 2014
Convert all mp4 files to mp3 in current directory, deleting them
View mp4amp3
#!/usr/bin/env bash
# seen in http://www.unixmen.com/linux-basics-convert-mp4-mp3/
for filename in *.mp4
do
name=`echo "$filename" | sed -e "s/.mp4$//g"`
ffmpeg -i "$filename" -b:a 192K -vn "$name.mp3"
rm "$filename"
done
@bryant1410
bryant1410 / onehot_pandas_scikit.py
Last active Aug 29, 2015 — forked from kljensen/onehot_pandas_scikit.py
This function helps to do a one hot encoding of a pandas' dataframe instead of a features numpy matrix. This has some advantages, for instance the fact of knowing which new columns have been created (identifying them easily).
View onehot_pandas_scikit.py
# -*- coding: utf-8 -*-
""" Small script that shows hot to do one hot encoding
of categorical columns in a pandas DataFrame.
See:
http://scikit-learn.org/dev/modules/generated/sklearn.preprocessing.OneHotEncoder.html#sklearn.preprocessing.OneHotEncoder
http://scikit-learn.org/dev/modules/generated/sklearn.feature_extraction.DictVectorizer.html
"""
import pandas
import random
View PartToString.java
public String partToString() throws Exception {
javax.servlet.http.Part part;
try (java.util.Scanner scanner = new java.util.Scanner(part.getInputStream())) {
if (scanner.useDelimiter("\\A").hasNext()) {
return scanner.next();
} else {
return "";
}
}
}
You can’t perform that action at this time.