Skip to content

Instantly share code, notes, and snippets.

Avatar

Fábio Fortkamp fabiofortkamp

View GitHub Profile
@fabiofortkamp
fabiofortkamp / latex-problem-set.tex
Created Oct 8, 2020
LaTeX template for college problem sets
View latex-problem-set.tex
\documentclass[english,brazil,shortlabels,article]{techreport}
%% see https://github.com/fabiofortkamp/techreport
%% I honestly cannot remember where I got this from
\newenvironment{problem}[2][Problem]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\usepackage{siunitx}
\usepackage{enumitem}
\usepackage{pdfpages}
@fabiofortkamp
fabiofortkamp / ST1GEE1.bunch
Created Mar 23, 2020
Example bunch file that I use to prepare classes (file names are in Portuguese)
View ST1GEE1.bunch
# Comments start with a hash symbol, blank lines are ignored
# Use @@ to hide all visible apps. Usually used at the top of the file
# before launching the rest of the bunch
@@
# Include a line starting with a dash to open specific
# files in the app
# If the first file listed is "XX", all open windows
# for the app will be closed first
View emacs-close-buffer.sh
# function to close the buffer corresponding to a given file in emacs
# cf = close file
function cf() {
emacs -e "(if (get-buffer \"$1\") (kill-buffer \"$1\"))"
}
@fabiofortkamp
fabiofortkamp / custom_errors.py
Created Oct 23, 2019
Definiing custom exceptions in Python with a meaningful message
View custom_errors.py
class InvalidParameterError(ValueError):
pass
@fabiofortkamp
fabiofortkamp / calculate_radial_remanence.py
Created Oct 7, 2019
How to calculate radial remanence directions
View calculate_radial_remanence.py
import numpy as np
# example input parameters
phi_S_IV = 50
# how much each segment occupies of the whole magnet region
fractions_phi = np.array([20,20,20,20,20])
assert sum(fractions_phi) == 100
@fabiofortkamp
fabiofortkamp / stop.sh
Last active Sep 25, 2019
Example prm stop script for my "paper" project, on Windows
View stop.sh
# Sincroniza de volta mudanças feitas
git push origin
# ver explicações abaixo para esses comandos
cf PaperMagneticProfiles_JBSMSE.tex
closew "paper-magnetic-profiles - Visual Studio Code"
closew "Sourcetree"
closew "Outline_Paper_Profiles"
@fabiofortkamp
fabiofortkamp / start.sh
Last active Sep 25, 2019
Example prm start script to work on a paper, on Windows
View start.sh
cd $HOME/latex-writing/paper-magnetic-profiles/
# sync repo
git pull origin master
# open Visual Studio Code to edit and run scripts
code -n .
# Sourcetree is a Git client
SourceTree.exe
@fabiofortkamp
fabiofortkamp / closewindows.ahk
Created Sep 25, 2019
AutoHotKey script to close window whose name is passed on as argument
View closewindows.ahk
; This script closes the window name passed as argument, e.g.
; AutoHotkey.exe closewindow.ahk "Visual Studio Code"
; To match strings anywhere in the window title
SetTitleMatchMode 2
If (WinExist(A_Args[1]))
WinClose
View macos-closeapp.sh
function closeapp() {
osascript -e "quit app \"$1\""
}
@fabiofortkamp
fabiofortkamp / configure_matplotlib.py
Created Jul 12, 2017
Common matplotlib configuration, with LaTeX and my own packages, for easier generation of engineering plots
View configure_matplotlib.py
import matplotlib
import matplotlib.pyplot as plt
mpl_params = {'text.usetex': True,
'font.family': 'serif',
'font.serif': 'Palatino',
'text.latex.preamble': [r'\usepackage{engsymbols}',
r'\usepackage{magref}',
r'\usepackage{siunitx}']}
matplotlib.rcParams.update(mpl_params)