Skip to content

Instantly share code, notes, and snippets.

View danielk333's full-sized avatar

Daniel Kastinen danielk333

  • Institutet för rymdfysik
  • Kiruna
View GitHub Profile
@danielk333
danielk333 / fix-hash.js
Created May 16, 2023 09:24
Allow revealjs hash with files in subfolders
const originalReplaceState = history.replaceState;
// Run below Reveal.initialize like
// enable_hash('/presentations/2023/my-presentation.html');
function enable_hash(path) {
history.replaceState = (_a, _b, url) => {
url = url.toString();
if (url[0] == '#') {
url = path + url;
}
@danielk333
danielk333 / venv_tools.sh
Last active September 9, 2022 08:59
HPC-venvs
activate () {
source ~/projects/$1/.venv/bin/activate
}
venv () {
if [ -z $1 ]
then
echo "No project name given, exiting"
return
fi
@danielk333
danielk333 / fish_venv.fish
Last active April 7, 2022 05:41
venv_tools_fish
function activate
source ~/venvs/$argv/bin/activate.fish
end
function lazyvenv
set -l name (basename (pwd))
if test -d ~/venvs/$name
activate $name
else
echo "No venv found: creating venv"
@danielk333
danielk333 / venv_tools
Created November 9, 2021 12:55
Venv tools in bash
activate () {
source ~/venvs/$1/bin/activate
}
lazyvenv () {
name=$(basename $(pwd))
if [ -d ~/venvs/$name ]
then
activate $name
@danielk333
danielk333 / gcal_events.py
Created May 3, 2021 06:02
Simple script to get google calendar events using the Google API
#!/usr/bin/env python
import datetime
import pathlib
ROOT = pathlib.Path(__file__).resolve().parent
#List of calendar names to get events from
#if empty, just take all calendars
GOOGLE_CALENDARS = [
@danielk333
danielk333 / overleaf_diff.sh
Created March 20, 2021 07:26
Performing latexdiff on an overleaf repository between two tags
#Execution: ./overleaf_diff [overleaf git hash] [main tex file name] [tag 1] [tag 2]
get_overleaf () {
if [ -d "$1" ]; then
cd "$1"
git pull
cd ..
else
git clone "https://git.overleaf.com/$1"
fi