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
#!/bin/bash | |
TIMEOUT=60 # in seconds | |
TIMESTEP=3 # in seconds | |
JOB_NAME="tunnel" # any unique name | |
SCRIPT="/path/to/interactive.sbatch" # modify accordingly | |
# It starts an OpenSSH server to enable interactive sessions, allowing IDEs like VSCode to connect remotely. | |
# Here is an example script: https://crc-pages.pitt.edu/user-manual/slurm/vscode/#steps-performed-only-once | |
main () { |
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
env_prompt: '($(basename {default_env})) ' | |
channels: | |
- defaults | |
- conda-forge | |
pkgs_dirs: | |
- /optional/directory/in/case/your/home/directory/is/small/.conda/pkgs |
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
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages -dCompressFonts=true -dDownsampleColorImages=true -dColorImageResolution=200 -dDownsampleGrayImages=true -dGrayImageResolution=250 -sOutputFile=compressed_main.pdf |
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
# SSH after version 7.5 provides ProxyJump (-J flag) | |
# name: your username in the remote server | |
# when using Windows PowerShell, you may need to replace "ssh" by "ssh.exe" | |
ssh -J name@intermediateserver name@remoteserver | |
# In the case of multiple intermediate hosts, simple join all of them with comma | |
ssh -J name@intermediate1,name@intermediate2,name@intermediate3 name@remoteserver | |
# SSH before version 7.5 would need to use ProxyCommand | |
ssh -o ProxyCommand="ssh -W %h:%p name@intermediateserver" name@remoteserver |
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
#!/bin/bash | |
############################# | |
# from "here" to "there" | |
############################# | |
scp source_files user@destination:/path/at/the/destination | |
# with jumphost | |
scp -o 'ProxyCommand ssh user@jumphost -W %h:%p' source_files user@destination:/path/at/the/destination |
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 argparse | |
import functools | |
import http.server | |
import threading | |
class ArgumentParser: | |
def __init__(self): | |
self.parser = argparse.ArgumentParser() | |
self.parser.add_argument("port", type=int, default=9090, help="port to listen on") |
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 matplotlib as mpl | |
import matplotlib.pyplot as plt | |
# some pseudo-data (incomplete) | |
df1 = ... | |
df2 = ... | |
fig, ax = plt.subplots() | |
ax.errorbar(df1.x, df1.y, yerr=df1.yerr, label='df1') | |
ax.errorbar(df2.x, df2.y, yerr=df2.yerr, label='df2') |
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 concurrent.futures | |
import urllib | |
import numpy as np | |
links = { | |
'IU': 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/IU_at_%22Midnight_Runners%22_VIP_premiere%2C_7_August_2017_03.jpg/800px-IU_at_%22Midnight_Runners%22_VIP_premiere%2C_7_August_2017_03.jpg', | |
'Stephen Curry': 'https://www.si.com/.image/ar_233:100%2Cc_fill%2Ccs_srgb%2Cg_faces:center%2Cq_auto:good%2Cw_1920/MTg4MDIzNjkxMDA5ODYxNDE4/stephen-curry-smiles-iso.webp', | |
'Syed Saddiq': 'https://media2.malaymail.com/uploads/articles/2018/2018-08/20180802YM21.jpg', | |
'Terence Tao': 'https://s3.amazonaws.com/cms.ipressroom.com/173/files/20147/53e288debd26f511d800600e_Terence_Tao/Terence_Tao_c4560e18-0bf8-4bab-8daa-7e74d3acf907-prv.jpg', | |
} |
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 cProfile | |
import pstats | |
with cProfile.Profile() as pr: | |
routine_to_measure() | |
stats = pstats.Stats(pr) | |
stats.sort_stats(pstats.SortKey.TIME) | |
# print profiling result | |
# Method 1 |
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
Please note that the n.e. in the syntax column means "not existing". | |
There is a way, but it's too complicated to fit into the column. You can find a helpful link in the List section about it. | |
|| visible in terminal || visible in file || existing | |
Syntax || StdOut | StdErr || StdOut | StdErr || file | |
==========++==========+==========++==========+==========++=========== | |
> || no | yes || yes | no || overwrite | |
>> || no | yes || yes | no || append | |
|| | || | || | |
2> || yes | no || no | yes || overwrite |
NewerOlder