This file contains 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
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 ""; | |
} | |
} | |
} |
This file contains 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
# -*- 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 |
This file contains 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
#!/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 |
This file contains 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
# 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 -> |
This file contains 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
#!/usr/bin/env python3 | |
import requests | |
# noinspection SpellCheckingInspection | |
SERVICE_SID = '...' | |
# noinspection SpellCheckingInspection | |
ACCOUNT_SID = '...' | |
# noinspection SpellCheckingInspection | |
AUTH_TOKEN = '...' |
This file contains 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
#!/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. |
This file contains 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 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) |
This file contains 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
#!/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. |
This file contains 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 time | |
import torch | |
import torch.nn as nn | |
from apex.normalization import FusedLayerNorm | |
torch.backends.cudnn.benchmark = True |
This file contains 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
#!/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 |
OlderNewer