Skip to content

Instantly share code, notes, and snippets.

@mykappa
mykappa / backupOpenEditorFilesList.m
Created August 25, 2021 11:25
Save a list of MATLAB scripts and functions open in the editor in case MATLAB crahes (for people like me who always work with way too many tabs)
%% Save list of files opened in MATLAB editor
% Get a list of open files
x = matlab.desktop.editor.getAll;
editor_open_files_list = {};
for ii = 1:size(x,2)
editor_open_files_list=[editor_open_files_list; {x(1,ii).Filename} {x(1,ii).Text}]; %#ok<AGROW>
end
% Define backup path
@mykappa
mykappa / forceCloseWaitbars.m
Created August 26, 2021 11:23
Find and force the deletion of all open MATLAB waitbars that cannot be closed
% Find and force the deletion of all open MATLAB waitbars that cannot be closed
delete(findall(0,'type','figure','tag','TMWWaitbar'))
@mykappa
mykappa / resetMatlabSession
Created August 30, 2021 07:59
Reset open MATLAB session
!matlab &
exit
@mykappa
mykappa / inverseSearch.bat
Created October 13, 2021 13:38
SumatraPDF Inverse Search with Visual Studio Code
:: Set the following command in SumatraPDF->Settings->Options...->Set inverse search command-line
"%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\Code.exe" -g %f:%l
:: NOTE: The value of %USERPROFILE% must be explicitly written out!
@mykappa
mykappa / pdf2pngConv.sh
Created May 11, 2022 08:33
Use ImageMagick to convert PDFs in the current folder to PNG
find . -type f -name '*.pdf' -print0 |
while IFS= read -r -d '' file
do convert -verbose -density 600 -layers composite "${file}" "${file%.*}.png"
done
@mykappa
mykappa / fixed_precision_LaTeX_from_MATLAB.m
Created September 15, 2022 06:56
Minimalist example of how to get fixed precision LaTeX output from symbolic MATLAB calculations
latex(vpa(sym(randn(3)),4))
@mykappa
mykappa / getCurrentUserSID.ps1
Created February 10, 2023 13:25
Get current user Security Identifier (SID) with Windows PowerShell
$User = New-Object System.Security.Principal.NTAccount($env:UserDomain, $env:UserName)
$SID = $User.Translate([System.Security.Principal.SecurityIdentifier])
$SID.Value
@mykappa
mykappa / setup_nanorc_mac.sh
Created April 6, 2023 13:57
Syntax Highlighting in `nano` with `nanorc` on macOS
# Install newest version of nano and nanorc
brew update
brew install nano nanorc
# Create `~/.nanorc` file
echo "include /opt/homebrew/Cellar/nanorc/*/share/nanorc/*.nanorc" >> ~/.nanorc
# The error about the color `brightnormal`
# `Error in /opt/homebrew/Cellar/nanorc/*/share/nanorc/nanorc.nanorc on line 26: Color 'normal' takes no prefix`
# can be fixed by commenting out line 26 in /opt/homebrew/Cellar/nanorc/*/share/nanorc/nanorc.nanorc
@mykappa
mykappa / fixPDFtextCopyPaste.ahk
Created April 14, 2023 08:36
Use AutoHotkey to remove unwanted characters like line breaks from the clipboard when copying text from a PDF with ctrl+c (tested with Adobe Acrobat and SumatraPDF)
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive ahk_class SUMATRA_PDF_FRAME
^c::
old := ClipboardAll
clipboard := ""
send ^c
@mykappa
mykappa / vsc_ipywidg_bg_transparent.html
Created July 18, 2023 18:17
Make VS Code ipywidget background transparent
%%html
<style>
.cell-output-ipywidget-background {
background-color: transparent !important;
}
:root {
--jp-widgets-color: var(--vscode-editor-foreground);
--jp-widgets-font-size: var(--vscode-editor-font-size);
}
</style>