Skip to content

Instantly share code, notes, and snippets.

View aladinoster's full-sized avatar
🐢
I'm here to try and learn!

Andres Ladino aladinoster

🐢
I'm here to try and learn!
View GitHub Profile
@aladinoster
aladinoster / add_to_zshrc.sh
Created August 26, 2024 00:54 — forked from karpathy/add_to_zshrc.sh
Git Commit Message AI
# -----------------------------------------------------------------------------
# AI-powered Git Commit Function
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It:
# 1) gets the current staged changed diff
# 2) sends them to an LLM to write the git commit message
# 3) allows you to easily accept, edit, regenerate, cancel
# But - just read and edit the code however you like
# the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/
gcm() {
@aladinoster
aladinoster / bag_of_little_bootstraps.py
Created October 9, 2023 11:57 — forked from cgreer/bag_of_little_bootstraps.py
Bag of Little Bootstraps (w/ example usage)
import random
from typing import (
List,
Dict,
Callable,
Union,
)
import numpy
@aladinoster
aladinoster / fonts.py
Created May 19, 2023 06:12
Python: Adding Custom Fonts to Matplotlib
from matplotlib import font_manager
font_dirs = ['path/to/font/']
font_files = font_manager.findSystemFonts(fontpaths=font_dirs)
for font_file in font_files:
font_manager.fontManager.addfont(font_file)
# set font
plt.rcParams['font.family'] = 'Comic Sans'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aladinoster
aladinoster / click-example.py
Created November 22, 2021 20:16
Python: Click application + tests
import click
@click.group()
@click.pass_context
@click.argument('CHALLENGE', type=int)
def challenge(ctx, challenge):
ctx.obj = challenge
@challenge.command()
@click.pass_obj
@aladinoster
aladinoster / pool.py
Created October 28, 2021 13:28
Python: Pool for smart instance management
""" Pool example for smart memory instantiation"""
class Reusable:
"""Reusable class"""
def test(self):
"""Test function"""
print(f"Using object: {id(self)}")
@aladinoster
aladinoster / conditionalinst.py
Created October 28, 2021 13:21
Python: Conditional instantiation
"""Conditional instantiation"""
class Demo:
"""Class with conditional instantiation"""
def __new__(cls, **kwargs):
if kwargs.get("create"):
return super(Demo, cls).__new__(cls)
return None
@aladinoster
aladinoster / paralell.py
Created October 28, 2021 13:13
Python: Launch in paralell diferent functions
from multiprocessing import Process
from tqdm import tqdm
from functools import partial
import time
def runInParallel(*fns):
"""
Handle processs in paralell
"""
@aladinoster
aladinoster / fmm.yaml
Last active October 29, 2021 04:29
Conda: Environment to compile FMM github.com/cyang-kth/fmm
name: fmm
channels:
- conda-forge
- anaconda
dependencies:
- python=3.9
- boost-cpp
- libgdal=3.2.1
- bzip2
- expat
@aladinoster
aladinoster / compile_symuflow_osx.sh
Last active October 11, 2021 13:53
CMake: Compile Symuflow
#!/bin/bash
git clone [email protected]:licit-lab/symuflow-dev.git symuflow
cd symuflow
git checkout dev
conda env create -f conda/env.yaml
conda install -c conda-forge cmake -y
conda install -c anaconda make -y
conda install -c anaconda clangxx_osx-64 -y
mkdir build
cd build