Skip to content

Instantly share code, notes, and snippets.

View AdamGagorik's full-sized avatar

Adam Gagorik AdamGagorik

View GitHub Profile
@AdamGagorik
AdamGagorik / stub
Last active September 17, 2015 16:19
Extract stub from file name in bash.
stub=${file%.*}
@AdamGagorik
AdamGagorik / ext
Last active September 17, 2015 16:20
Extract extension from file name in bash.
ext=${file##*.}
@AdamGagorik
AdamGagorik / tar
Last active September 17, 2015 16:20
Create and extract tar archives
# create
tar -cvf output.tar input/*
gzip output.tar
# The name of the tar, "output.tar", does not matter.
# When extracted, the files will expand into a directory named "input".
# extract
tar -xvf output.tar
@AdamGagorik
AdamGagorik / gs-reprint
Last active September 17, 2015 16:20
Make PDF smaller
gs -sDEVICE=pdfwrite -sPAPERSIZE=letter -dFIXEDMEDIA -dPDFFitPage -dCompatibilityLevel=1.4 -o out.pdf in.pdf
@AdamGagorik
AdamGagorik / CreateDocumentParameter.tex
Created October 13, 2015 20:46
CreateDocumentParameter
\makeatletter
\DeclareDocumentCommand{\setvalue}{m o m}{%
\IfNoValueTF{#2}{%
% NO INDEX
\expandafter\DeclareDocumentCommand\csname @#1\endcsname{}{#3}%
}{%
% INDEX
\expandafter\DeclareDocumentCommand\csname @#1@#2\endcsname{}{#3}%
}%
}%
def create_subplots(n_row, n_col, cell_w=5.0, cell_h=5.0, sep_w=1.0, sep_v=1.0,
ls=1.0, rs=1.0, ts=1.0, bs=1.0):
"""
Create subplot grid using absolute widths.
Parameters:
n_row (int): rows in subplot grid
n_col (int): columns in subplot grid
cell_w (float): width of each cell
cell_h (float): height of each cell
@AdamGagorik
AdamGagorik / remote-jupyter-notebook.md
Last active June 5, 2023 06:48
Remote Jupyter Notebook

Description

Use these commands to run a jupyter server on a remote server and access it locally in a browser. You must have SSH access to the browser. Use any port you want.

Do not forget to change username@server to the correct value!

TLDR

where using command
#!/bin/bash
CAT=mdcat
function head() {
echo "---" | $CAT
echo "# $1"
echo ""
}
#!/bin/bash
echo ""
echo -e "running : screen -ls "
echo -e "start : screen -d -m -S NAME command"
echo -e "stop : screen -X -S NAME quit "
echo -e "attach : screen -r NAME "
if [[ $# -gt 0 ]]; then
echo ""
echo -e "screen $*"
if [[ ! -d ./.venv ]]; then
echo "no virtual environment in current directory"
exit 1
fi
. .venv/bin/activate
PYVER=`python --version | cut -d " " -f2`
DNAME="[${PYVER}]: ${PWD}"
KNAME=${PWD##*/}