Skip to content

Instantly share code, notes, and snippets.

View elehcim's full-sized avatar
🔭

Michele Mastropietro elehcim

🔭
View GitHub Profile
@elehcim
elehcim / build.sh
Last active November 11, 2024 12:35
termux conda installation trial
apt update && apt upgrade
apt install python python-dev pip clang
pip install --upgrade pip
pip install conda
## All the following packages are needed by conda
pip install auxlib ruamel.yaml requests
## Install pycosat (this can be ignored if https://github.com/ContinuumIO/pycosat/pull/29 is fixed)
wget https://pypi.python.org/packages/76/0f/16edae7bc75b79376f2c260b7a459829785f08e463ecf74a8ccdef62dd4a/pycosat-0.6.1.tar.gz#md5=c1fc35b17865f5f992595ae0362f9f9f
tar -xf pycosat-0.6.1.tar.gz
@elehcim
elehcim / activate.csh
Created April 21, 2017 14:38 — forked from mikecharles/activate.csh
Activate and deactivate a conda environment in C Shell
#!/bin/csh
# Get the name of this script
set script_name = `basename $0`
# Get arguments
if ( $#argv < 1 ) then
echo ""
echo "Usage: source $script_name <CONDAENV>"
exit 2
#!/bin/bash
sudo -v
wget http://www.fftw.org/fftw-2.1.5.tar.gz
tar -xzf fftw-2.1.5.tar.gz
cd fftw-2.1.5
# single precision
./configure --enable-mpi --enable-type-prefix --enable-float && make -j4
sudo make install
@elehcim
elehcim / backup_conda_envs.sh
Last active December 13, 2017 11:11
Script to backup all the conda environments and save them in .yml files ordered by day and time of the day
#!/bin/bash
# Parse conda env list
CONDA_ENVS=`conda env list --json | python -c 'import json,sys,os;obj=json.load(sys.stdin);print(" ".join(os.path.basename(p) for p in obj["envs"]))'`
# Add the root env because "conda env list --json" doesn't show the root env
CONDA_ENVS+=" root"
TODAY=`date +%F`
HOUR=`date +%Hh%Mm`
#!/bin/bash
pushd ~
mkdir -p bin
cd bin
git clone https://github.com/madler/pigz.git pigz.src
cd pigz.src
make
cd ..
ln -s pigz.src/pigz pigz.src/unpigz .
popd
@elehcim
elehcim / bleumidi_bionic.sh
Created May 20, 2019 08:41
Enable midi on bluethooth on Ubuntu 18.04 Bionic
sudo service bluetooth stop
sudo apt install build-essential debhelper fakeroot wget dh-autoreconf flex bison libdbus-glib-1-dev libglib2.0-dev libcap-ng-dev udev libudev-dev libreadline-dev libical-dev check dh-systemd libebook1.2-dev libasound2-dev
cd /tmp/
mkdir blumidi
cd blumidi/
wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/bluez/5.48-0ubuntu3.1/bluez_5.48.orig.tar.xz
wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/bluez/5.48-0ubuntu3.1/bluez_5.48-0ubuntu3.1.debian.tar.xz
tar xJf bluez_5.48.orig.tar.xz
cd bluez-5.48/
tar xJf ../bluez_5.48-0ubuntu3.1.debian.tar.xz
@elehcim
elehcim / colormap_mappable_example.py
Created October 17, 2019 09:12
How to color different plots using a colormap
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
n_plots = 10
how_many_colors = 12
cmap_name = 'jet'
norm = matplotlib.colors.Normalize(vmin=0, vmax=n_plots)
cmap = matplotlib.cm.get_cmap(cmap_name, how_many_colors)
@elehcim
elehcim / abbrv
Created March 3, 2021 14:30
Abbreviate Astronomical journals in a bib file
#!/bin/bash
# Usage:
# abbrv "input_file.bib" > output_file.bib
file=$1
awk '{sub(/{Annual Review of Astronomy and Astrophysics}/, "{ARA\{\\\\\\&\}A}"); print}' $file |
awk '{sub(/{Monthly Notices of the Royal Astronomical Society}/,"{MNRAS}"); print}' |
awk '{sub(/{Mon. Not. R. Astron. Soc}/,"{MNRAS}"); print}' |
awk '{sub(/{Publications of the Astronomical Society of the Pacific}/,"{PASP}"); print}' |