Skip to content

Instantly share code, notes, and snippets.

Luis Capelo luiscape

Block or report user

Report or block luiscape

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@luiscape
luiscape / jupyter_notebook_theme.sh
Created Dec 19, 2017
Install and configure Jupyter Themes.
View jupyter_notebook_theme.sh
#!/bin/bash
#
# Instally the theme library.
#
pip install jupyterthemes
#
# Configure to use preferred theme.
#
@luiscape
luiscape / plot_facets.py
Created Dec 11, 2017
Plots facets using Seaborn
View plot_facets.py
#
# 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 / install_packages.sh
Created Jan 16, 2017
Install Python dependency packages from requirements.txt using conda.
View install_packages.sh
#
# Original solution via StackOverflow:
# http://stackoverflow.com/questions/35802939/install-only-available-packages-using-conda-install-yes-file-requirements-t
#
#
# Install via `conda` directly.
# This will fail to install all
# dependencies. If one fails,
# all dependencies will fail to install.
@luiscape
luiscape / close_all_postgres_connections.sql
Created Jul 26, 2016
Closes all PostgreSQL connections except for the one sending this query.
View close_all_postgres_connections.sql
#
# 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
View add_header_to_file.sh
#
# 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 / config
Created Jun 28, 2016
Example SSH config file.
View config
Host intermediary
User foobar
Hostname 100.100.121.33
Port 14500
ServerAliveInterval 60
ServerAliveCountMax 30
Host target
User foobar
Hostname 100.100.232.44
@luiscape
luiscape / merge_csv_files.sh
Created Jun 27, 2016
Merges all CSV files into a single one.
View merge_csv_files.sh
#!/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
View find_latest_files.sh
#!/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
#
View gist:b95953de6863cef2e94c
### 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:
You can’t perform that action at this time.