Skip to content

Instantly share code, notes, and snippets.

View aboucaud's full-sized avatar

Alexandre Boucaud aboucaud

View GitHub Profile
@aboucaud
aboucaud / slides2pdf.sh
Created March 18, 2021 21:37
[Convert HTML slides to PDF with decktape]
#!/usr/bin/env bash
#: Name : slides2pdf
#: Date : 2020-10-05
#: Author : Alexandre Boucaud
#: Version : 1.0.0
#: Description : Convert HTML slides to PDF with decktape
#: Options : See usage() function.
## Initialize defaults
WEBSITE="https://github.com/astefanutti/decktape"
@aboucaud
aboucaud / app.py
Created January 28, 2021 23:20
Easy Python config
from my_service import config
def create_application():
engine = Engine(url=config.get_config().DB_URL)
...
@aboucaud
aboucaud / isolate_galaxy_recipe.py
Created October 2, 2020 13:57
[Isolate a galaxy in an image] #astro #visualisation #python
import numpy as np
from scipy.ndimage import binary_dilation
def isolate_galaxy(image, seg_map, galaxy_value,
n_dilation = 5,
use_background_pixels = False,
noise_factor = 0.0):
"""
Isolate a galaxy in an image by replacing its neighbors with background noise
@aboucaud
aboucaud / gan.py
Last active September 24, 2020 12:28
[GAN model in keras]
import tensorflow as tf
class GAN(tf.keras.model):
def __init__(self, discriminator, generator, latent_dim):
super(GAN, self).__init__()
self.discriminator = discriminator
self.generator = generator
self.latent_dim = latent_dim
def compile(self, d_optimizer, g_optimizer, loss_fn):
@aboucaud
aboucaud / push.sh
Created September 21, 2020 08:00
[Skip CI on push] #vcs #git #ci
git push -o ci.skip
@aboucaud
aboucaud / fd-vs-find_bench.sh
Created June 8, 2020 13:54
[Benchmark command-line tools] #unix #performance
# https://github.com/sharkdp/hyperfine
hyperfine --warmup 3 'fd -e jpg -uu' 'find -iname "*.jpg"'
@aboucaud
aboucaud / subclip.sh
Created May 29, 2020 23:17
[Extract short clip from video] #video #media
# from https://bernd.dev/2020/04/trim-videos-instantly/
INFILE="video.mp4"
OUTFILE="shortenedclip.mp4"
START="00:00:12.35" # Start Time in hh:mm:ss.msec format
DURATION="00:01:05.4" # Duration in hh:mm:ss.msec format
################## Alternative format ##################
# START="12.35" # Start time in s.msec format #
@aboucaud
aboucaud / convert.sh
Created May 18, 2020 16:43
[HTML video embedding] Use compressed videos instead of GIF #web #videos
ffmpeg -f gif -i dancing-baby.gif dancing-baby.mp4
@aboucaud
aboucaud / pandas_table_style.py
Last active May 13, 2020 17:24
[Pandas table styling] #python #visualisation
# https://pandas.pydata.org/pandas-docs/stable/reference/style.html
# https://towardsdatascience.com/style-pandas-dataframe-like-a-master-6b02bf6468b0
import pandas as pd
# Option examples
pd.set_option('precision', 4)
pd.set_option('max_rows', 10)
pd.set_option('max_columns', 7)
pd.set_option("display.max_colwidth", -1)
@aboucaud
aboucaud / plot_colors_from_colormap.py
Last active May 4, 2020 11:20
Extract colors from matplotlib colormap #python #visualisation
import numpy as np
import matplotlib.pyplot as plt
N = 10
colors = plt.cm.viridis(np.linspace(0.25, 1.0, N))
x = np.linspace(0, 1, 30)
powers = np.arange(N) + 1
for power, color in zip(powers, colors):