Skip to content

Instantly share code, notes, and snippets.

View mttmantovani's full-sized avatar

Mattia Mantovani mttmantovani

  • TNG Technology Consulting GmbH @TNG
View GitHub Profile
@mttmantovani
mttmantovani / install_pyenv.sh
Created March 17, 2021 11:23
Install pyenv on Ubuntu 20.04
#!/bin/bash
sudo apt-get install git python3-pip python-is-python3 make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl libffi-dev
pip install virtualenvwrapper
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
git clone https://github.com/pyenv/pyenv-virtualenvwrapper.git ~/.pyenv/plugins/pyenv-virtualenvwrapper
cat << EOF >> ~/.bashrc
@mttmantovani
mttmantovani / check_jobs.py
Last active January 21, 2021 16:33
Remotely check of SGE cluster jobs through SSH using paramiko
#!/usr/bin/env python3
import paramiko
import os
import warnings
warnings.filterwarnings('ignore')
keyfile = os.path.expanduser('~')+'/.ssh/id_rsa.pub'
cred = {"username": "mattia",
"hostname": "scc.uni-konstanz.de",
@mttmantovani
mttmantovani / .bashrc
Last active January 22, 2021 17:34
BASH configuration file (fermi17)
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mttmantovani
mttmantovani / plist2html.sh
Created June 17, 2019 14:51
Convert binary .plist file of Safari bookmarks to html
#!/bin/bash
BOOKMARKS=$HOME/Library/Safari/Bookmarks.plist
plutil -convert xml1 $BOOKMARKS
sed >/tmp/plist2html.xsl <<EOF
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns='http://www.w3.org/1999/xhtml'>
@mttmantovani
mttmantovani / latexit_preamble.tex
Last active December 14, 2020 14:55
LaTeXiT preamble to produce equations in different fonts
\documentclass[10pt]{article}
\usepackage[usenames]{color} %used for font color
\usepackage{amssymb} %maths
\usepackage{amsmath} %maths
%\usepackage[utf8]{inputenc} %useful to type directly diacritic characters
\usepackage{mathspec}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\setmainfont{Arial}
@mttmantovani
mttmantovani / thermal
Last active January 21, 2021 16:23
Thermal Bose distribution
#!/usr/bin/env python
"""
Plot the Fock distribution for a thermal state at given frequency
and temperature.
Author: mattia
Last modified: Thu Jan 21, 2021 05:20PM
Version: 1.0
3 arguments from command line:
@mttmantovani
mttmantovani / 2dplot.py
Created February 10, 2019 16:45
2dplot example - Python
import numpy as np
import matplotlib.pyplot as plt
# Generate fake data
x = np.linspace(-5, 5, 151);
y = np.linspace(-3, 3, 251);
X, Y = np.meshgrid(x, y)
Z1 = np.sin(X*Y)**2 - np.cos(X*Y)**2 - X - Y
@mttmantovani
mttmantovani / 2dplot.m
Last active February 11, 2019 09:18
2dplot example - MATLAB
% 2D PLOT EXAMPLE
% Make grid and data
x = linspace(-5, 5, 151);
y = linspace(-3, 3, 251);
[X, Y] = meshgrid(x, y);
Z = sin(X.*Y).^2 - cos(X.*Y).^2 - X - Y;
% Save the data in a readable format to use later
@mttmantovani
mttmantovani / .vimrc
Last active January 21, 2021 15:32
Vim configuration file
" VIM configuration file
" author: mattia
" Last modified: Thu Jan 21, 2021 04:30PM
"{{{ Basic
syntax on
set showmatch
set number
set nocompatible
set bs=2