Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View luiscape's full-sized avatar
🤿

Luis Capelo luiscape

🤿
View GitHub Profile
### Keybase proof
I hereby claim:
* I am luiscape on github.
* I am luiscape (https://keybase.io/luiscape) on keybase.
* I have a public key whose fingerprint is 9EA2 6BE7 45D5 E250 E1B7 F274 CAC3 B9C0 7E2B 4271
To claim this, I am signing this object:
#!/bin/bash
#
# The following script finds the
# latest (edited or created) 10 files
# on a Linux system. It runs quite
# quickly.
#
find . -type f -printf "%C@ %p\n" | sort -rn | head -n 10
#
@luiscape
luiscape / merge_csv_files.sh
Created June 27, 2016 15:37
Merges all CSV files into a single one.
#!/bin/bash
#
# Assuming files contain the same headers
# and that they are organized in the same
# way, this script merges all files from
# a given directory into a single file.
#
cat *.csv | grep -v ^Pool > merged.csv
@luiscape
luiscape / config
Created June 28, 2016 12:43
Example SSH config file.
Host intermediary
User foobar
Hostname 100.100.121.33
Port 14500
ServerAliveInterval 60
ServerAliveCountMax 30
Host target
User foobar
Hostname 100.100.232.44
#
# This file contains a shell script
# that will add a header to a TXT file
# without a header. Headers make it easier
# to navigate files. We like them.
#
# Original solution by: http://stackoverflow.com/questions/13402809/insert-a-line-in-csv-file
#
FILE=file_without_header.txt
sed -i.bak 1i"HEADER1,HEADER2,HEADER3" \
@luiscape
luiscape / close_all_postgres_connections.sql
Created July 26, 2016 19:38
Closes all PostgreSQL connections except for the one sending this query.
#
# The following statement closes
# all PostgreSQL connections except
# for the one currently open (i.e.
# the one sending the query).
#
# Original solution by: http://goo.gl/znBpH
#
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
@luiscape
luiscape / plot_facets.py
Created December 11, 2017 17:20
Plots facets using Seaborn
#
# From Seaborn's official documentation:
#
# https://seaborn.pydata.org/generated/seaborn.FacetGrid.html
#
>>> import pandas as pd
>>> df = pd.DataFrame(
... data=np.random.randn(90, 4),
... columns=pd.Series(list("ABCD"), name="walk"),
... index=pd.date_range("2015-01-01", "2015-03-31",
@luiscape
luiscape / jupyter_notebook_theme.sh
Created December 19, 2017 16:14
Install and configure Jupyter Themes.
#!/bin/bash
#
# Instally the theme library.
#
pip install jupyterthemes
#
# Configure to use preferred theme.
#
@luiscape
luiscape / download_stable_diffusion_models.py
Last active November 29, 2022 00:05
Download Stable Diffusion + `EulerAncestralDiscreteScheduler` and store pipeline
"""This script downloads all neural networks used in the HuggingFace `diffuser`'s
`StableDiffusionPipeline` pipeline. This also downloads the parameters from the scheduler
`EulerAncestralDiscreteScheduler` because that is a fast and effective scheduler.
This requires the env var `HUGGINGFACE_TOKEN` to be populated with a HuggingFace
access token.
The default cache location is: /vol/cache. This can be changed by populating
the environment variable `CACHE_PATH`.
@luiscape
luiscape / diffusers-rs-on-modal.py
Last active January 4, 2023 03:33
Runs `diffusers-rs` on Modal.
# Runs diffusers-rs on Modal.
import os
import time
import modal
import subprocess
CARGO_PATH:str = "/root/.cargo/bin/cargo"
def _convert_clip():