Skip to content

Instantly share code, notes, and snippets.

View fabiofortkamp's full-sized avatar

Fábio Fortkamp fabiofortkamp

View GitHub Profile
@fabiofortkamp
fabiofortkamp / gist:d6b937bdcac186a216e4
Created July 16, 2014 23:43
AppleScript to show a list of Safari tab URLS, to be used with TextExpander, but it crashes
tell application "System Events"
set numSafari to count (every process whose name is "Safari")
end tell
if numSafari > 0 then
tell application "Safari"
set URLList to {}
@fabiofortkamp
fabiofortkamp / gist:f2738a083ff235c3a57e
Created July 23, 2014 21:36
TextWrangler Script to create a Markdown link from Safari tabs
tell application "System Events"
set numSafari to count (every process whose name is "Safari")
end tell
if numSafari > 0 then
tell application "Safari"
set URLList to {}
@fabiofortkamp
fabiofortkamp / 0_reuse_code.js
Created July 11, 2017 10:38
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@fabiofortkamp
fabiofortkamp / disable_jupyter_scrolling.js
Created July 12, 2017 07:46
How to disable scrolling in Jupyter notebooks
// don't forget to put the following cell magic,
// if used inside a Jupyter notebook
// %%javascript
IPython.OutputArea.auto_scroll_threshold = 9999;
@fabiofortkamp
fabiofortkamp / configure_matplotlib.py
Created July 12, 2017 07:42
Common matplotlib configuration, with LaTeX and my own packages, for easier generation of engineering plots
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)
function closeapp() {
osascript -e "quit app \"$1\""
}
@fabiofortkamp
fabiofortkamp / closewindows.ahk
Created September 25, 2019 17:13
AutoHotKey script to close window whose name is passed on as argument
; 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
@fabiofortkamp
fabiofortkamp / start.sh
Last active September 25, 2019 17:23
Example prm start script to work on a paper, on Windows
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 / stop.sh
Last active September 25, 2019 17:23
Example prm stop script for my "paper" project, on Windows
# 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 / calculate_radial_remanence.py
Created October 7, 2019 19:58
How to calculate radial remanence directions
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