Skip to content

Instantly share code, notes, and snippets.

View carmelom's full-sized avatar

Carmelo Mordini carmelom

View GitHub Profile
@carmelom
carmelom / parse_indexing.py
Last active February 12, 2022 03:20
Parse a numpy-style indexing string to a tuple of slices
import re
re_ix = r"(\[[\s\d,]+\]|[-\d:]+)"
def parse_indexing(indexing: str):
"""Parse a numpy-style indexing string to a tuple of slices
freely inspired from https://stackoverflow.com/a/43090200
Args:
indexing: str: can contain digits, commas, square brackets, colons, and whitespace
@carmelom
carmelom / spawnLabBook.gs
Last active August 26, 2019 10:28
Scheduled creation of a Google document, for the online lab book of BEC1 cold atoms lab, Trento.
/**
* A script to create a new labbook instance the first day of each month and to save to pdf the old one
* 2019-08 Carmelo Mordini <carmelo.mordini@gmail.com>
*
* Create a new document: this is pretty similar to the helloWorld described here:
* https://developers.google.com/apps-script/overview
* I'll make the suited changes to copy the template and edit the new doc, instead of making a new one
*
* Save to pdf:
* https://stackoverflow.com/a/28359290/11754331
@carmelom
carmelom / makemath.py
Last active June 7, 2019 23:02
Python script to create standalone latex formulas from the command line
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Create: 06-2019 - Carmelo Mordini <carmelo> <carmelo.mordini@unitn.it>
"""Python script to create standalone latex formulas from the command line
Examples:
- python makemath.py 'f(x) = 0'
- python makemath.py formula.tex -n euler.png
@carmelom
carmelom / bib_parsing.py
Last active December 3, 2020 10:20
A small script to parse the big Mendeley bibliography and customize it (from my PhD thesis)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Create: 05-2019 - Carmelo Mordini <carmelo> <carmelo.mordini@unitn.it>
"""
Use bibtexparser to read .bib files (e.g. from Mendeley, Jabref etc) as list of dictionaries
and conveniently edit entries at will.
For further customization options, refer to https://bibtexparser.readthedocs.io/en/master/index.html
"""
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@carmelom
carmelom / euroscipy2018-links.md
Last active March 8, 2019 20:01
A short summary of things I heard about at the EuroSciPy 2018 conf
@carmelom
carmelom / fitting-properly.ipynb
Last active August 9, 2018 10:22
fitting-properly.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@carmelom
carmelom / beam-profiler.py
Created June 21, 2018 11:34
Small python script to fit a gaussian laser beam profile from a picture
# coding: utf-8
# In[ ]:
import numpy as np
from PIL import Image
from scipy.optimize import curve_fit
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("name", type=str, help="image name")
@carmelom
carmelom / git-auto-push.sh
Last active April 25, 2022 06:36
Script to auto push a git repo and leave a logfile.
#!/bin/bash
# Script to auto push a git repo and leave a logfile.
# Crontab as (e.g.)
# 59 23 * * fri /home/stronzio/bin/bec1-data-auto-push.sh -o
LOCAL_REPO="/home/stronzio/exp-control/data"
FAIL_EMAIL="carmelo.mordini@unitn.it"
cd $LOCAL_REPO
@carmelom
carmelom / open_github_themes.py
Created August 6, 2017 14:45
Open webbrowser tabs to pewview GitHub Pages supported Ruby gem themes
import webbrowser
L = ['architect',
'cayman',
'dinky',
'hacker',
'leap-day',
'merlot',
'midnight',
'minima',
'minimal',