Skip to content

Instantly share code, notes, and snippets.

View alonsosilvaallende's full-sized avatar

Alonso Silva Allende alonsosilvaallende

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Mukei
Mukei / conda_environment_rename.sh
Created November 30, 2017 07:01
How to rename a conda environment (workaround)
#One workaround is to create clone environment, and then remove original one:
#(remember about deactivating current environment with deactivate on Windows and source deactivate on macOS/Linux)
conda create --name new_name --clone old_name --offline #use --offline flag to disable the redownload of all your packages
conda remove --name old_name --all # or its alias: `conda env remove --name old_name`
#There are several drawbacks of this method:
# time consumed on copying environment's files,
# temporary double disk usage.
@treuille
treuille / render_svg.py
Last active May 20, 2024 21:42
Workaround: Displaying SVG images in Streamlit
import streamlit as st
import base64
import textwrap
def render_svg(svg):
"""Renders the given svg string."""
b64 = base64.b64encode(svg.encode('utf-8')).decode("utf-8")
html = r'<img src="data:image/svg+xml;base64,%s"/>' % b64
st.write(html, unsafe_allow_html=True)
@hichamjanati
hichamjanati / plot_optim.py
Last active November 12, 2021 18:19
Optimization visualization with pyvista
import pyvista as pv
import numpy as np
make_gif = True
# increase n_points for a higher resolution
n_points = 100
xmin, xmax = -1.2, 1.2
bounds = 1.25 * np.array([xmin, xmax, xmin, xmax, 0., 0.])
---
title: "Muertes por comuna, mes y año en Chile 2000-2020"
output: html_notebook
---
```{r}
library(tidyverse)
```
# Cargar datos
@korakot
korakot / asyncio.py
Last active January 3, 2024 02:15
Use asyncio (async) in Colab
import nest_asyncio
nest_asyncio.apply()
@AustinRochford
AustinRochford / revisit_bayes_survival.ipynb
Last active May 5, 2024 23:36
Revisiting Bayesian Survival Analysis in Python with PyMC
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
import openai
from rich.console import Console
console = Console()
openai.api_key = os.getenv("OPENAI_API_KEY")
history = [{"role": "system", "content": "You are a helpful assistant."},]
@kylemcdonald
kylemcdonald / function-calling.ipynb
Created June 14, 2023 01:10
Example of OpenAI function calling API to extract data from LAPD newsroom articles.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@RaphaelWimmer
RaphaelWimmer / chatgpt_pick_random_number.py
Last active July 16, 2023 11:01
Ask GPT to pick a random number between 1 and 10
#!/usr/bin/env python3
import openai
import time
import matplotlib.pyplot as plt
def pick_numbers(n, model, temperature, clean_session):
numbers = []
messages = []
system_msg = "Please only respond with the number, don't say anything else."
messages.append({"role": "system", "content": system_msg})