Skip to content

Instantly share code, notes, and snippets.

View AdamGagorik's full-sized avatar

Adam Gagorik AdamGagorik

View GitHub Profile
@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 / ext
Last active September 17, 2015 16:20
Extract extension from file name in bash.
ext=${file##*.}
@AdamGagorik
AdamGagorik / stub
Last active September 17, 2015 16:19
Extract stub from file name in bash.
stub=${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 / 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}%
}%
}%
@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
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 / fopen.sh
Last active January 25, 2024 23:19
A script to find and open files from the command line
#!/usr/bin/env bash
DEFAULT_MACOS_OPEN="open"
DEFAULT_LINUX_OPEN="gvfs-open"
if ! [ -x "$(command -v ${DEFAULT_LINUX_OPEN})" ]; then
DEFAULT_LINUX_OPEN="browse"
fi
declare -A OPEN_MACOS
#!/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 $*"