Skip to content

Instantly share code, notes, and snippets.

@hristog
hristog / remove_newline_from_filename.sh
Created June 10, 2020 10:46
Remove newline characters from filenames in bash
# From https://unix.stackexchange.com/a/397659.
# Locates all files containing line feed and replaces each occurrence with a space.
find -name $'*\n*' -exec rename $'s|\n| |g' '{}' \;
@hristog
hristog / upgrade_docker_compose.sh
Created July 17, 2019 18:45
Upgrade docker-compose to the latest version available
#!/bin/bash
# From: https://stackoverflow.com/questions/49839028/how-to-upgrade-docker-compose-to-latest-version
#
# Requires `sudo` access.
apt-get remove docker-compose
apt-get install -y jq
VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
DESTINATION=/usr/bin/docker-compose
curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o $DESTINATION
chmod 755 $DESTINATION
@hristog
hristog / pastebin.md
Last active July 17, 2019 08:44
Paste command line output to paste bin services
  1. From https://unix.stackexchange.com/a/108494 (which references http://mewbies.com/pastebinit_how_to_pastebin_commnad_line_output_from_terminal_to_pastebin.htm):

There are several services that provide this but 2 that are pretty easy to use from the command line are fpaste and pastebinit. These 2 tools link to the sites, paste.fedoraproject.org and pastebin.com.

fpaste

NOTE: This is a Fedora/CentOS/RHEL only option

If you're using any of the Red Hat based distros you can install the package fpaste which gives you a command line tool for posting content to paste.fedoraproject.org.

@hristog
hristog / kubectl_minicube.sh
Last active July 16, 2019 16:16
Install kubectl, minikube and use with the KVM2 driver (Ubuntu 16.04)
# 1. Kubectl.
sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
@hristog
hristog / lof_predict_example.py
Created October 22, 2017 12:03
Adapting a non-predicting estimator to make predictions on unseen data
"""
An example for adapting a non-predicting estimator (i.e.,
one that doesn't expose a public ``predict`` method, but
only a ``fit_predict`` one), such as ``LocalOutlierFactor``
to make predictions on "unseen" data.
One could argue whether or not this particular approach is
entirely legitimate, as not exposing a ``predict`` method,
in most sensible cases will have been due to design and
semantic constraints.