Skip to content

Instantly share code, notes, and snippets.

View labay11's full-sized avatar

Adrià Labay labay11

View GitHub Profile
@labay11
labay11 / steadystate_comparison.ipynb
Created July 27, 2022 10:04
Comparison of QuantumOptics.jl methods to calculate the steady-state of a Pumped cavity
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@labay11
labay11 / jksave.py
Last active January 1, 2022 17:15
Download animes from jkanime.net
"""Download animes from jkanime.net.
It is necessary to install the following python libraries:
- beautifulsoup4
- selenium
The last one requires an extra step to work:
1. Download the latest Firefox driver from: https://github.com/mozilla/geckodriver/releases
2. Put it in a folder that can be found by the system's PATH,
i.e. in LINUX it can be: '/usr/bin', '/usr/local/bin' or '/home/your-username/bin'.
@labay11
labay11 / spa.py
Created July 11, 2021 10:06
Spotify Playlist Analyser
import sys
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
@labay11
labay11 / printing_decor.py
Last active October 23, 2020 07:52
Python decorator for printing the inputs and output of any function or class.
import inspect
def build_extensive_kwargs(fn, *args, **kwargs):
function_signature = inspect.signature(fn)
extensive_kwargs = function_signature.bind_partial(*args, **kwargs)
self = extensive_kwargs.arguments.get('self', None)
return ['{}={}'.format(key, val) for key, val in extensive_kwargs.arguments.items() if key != 'self'], self
def printing(prefix=None, suffix=None):
@labay11
labay11 / file_comparison.py
Created October 16, 2020 14:53
Compares the output of the same program in the search for different behaviour.
"""
Simple script designed to compare the output of the same program in two given sitations.
Specially useful in the case that you have a working version of the program and it suddently
stops working. If you can revert the state back to the working version, save the output to a file then
you can use the `compare_files` which look for lines that are found in one of the files but not in the other.
This can help to identify functions that are not executed in one of the cases when they should be.
Usage
-----
For a given `cmd` command run
@labay11
labay11 / latexify.py
Last active March 15, 2021 09:58
Adds latex style to your matplotlib plots.
from math import sqrt
from cycler import cycler
def latexify(plt, fract=1., margin_x=0., margin_y=0.):
"""Latexify the passed matplotlib instance.
Sets the default figure size to follow the golden ratio, the default width in points is the `columnwidth`
in LaTeX. Also reduces the line widths, sets other default line colors and most importantly,
uses latex font styles.