Skip to content

Instantly share code, notes, and snippets.

@superseb
superseb / README.md
Last active August 30, 2024 18:02
Deploy kubernetes-dashboard on Rancher 2.x cluster exposed using NodePort

Deploy kubernetes-dashboard on Rancher 2.x cluster exposed using NodePort

This has been updated to install Dashboard v2.0.0, see below for pre v2.0.0 instructions

Requirements

Step 1: Generate kubeconfig from the UI

Generate the kubeconfig file for your cluster using the Kubeconfig File button in the Cluster view of your cluster.

@superseb
superseb / cleanup.sh
Last active August 13, 2024 07:31
Cleanup host added as custom to Rancher 2.0
#!/bin/sh
# OUTDATED: please refer to the link below for the latest version:
# https://github.com/rancherlabs/support-tools/blob/master/extended-rancher-2-cleanup/extended-cleanup-rancher2.sh
docker rm -f $(docker ps -qa)
docker volume rm $(docker volume ls -q)
cleanupdirs="/var/lib/etcd /etc/kubernetes /etc/cni /opt/cni /var/lib/cni /var/run/calico /opt/rke"
for dir in $cleanupdirs; do
echo "Removing $dir"
rm -rf $dir
done
@conorsch
conorsch / sops.py
Created March 5, 2018 04:56
Ansible vars_plugin for reading host/group vars encrypted with Mozilla SOPS
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = '''
vars: sops
version_added: "N/A"
short_description: In charge of loading SOPS-encrypted vars
description:
- Loads SOPS-encrytped YAML vars into corresponding groups/hosts in group_vars/ and host_vars/ directories.
- Only SOPS-encrypted vars files, with a top-level "sops" key, will be loaded.

RediSearch Aggregations

[TOC]

Aggregations are a way to process the results of a search query, group, sort and transform them - and extract analytic insights from them. Much like aggregation queries in other databases and search engines, they can be used to create analytics report, or to perform Faceted Search style queries.

For example, indexing a web-server's logs, we can create report for unique users by hour, country or any other breakdown; or create different reports for errors, warnings, etc.

@ChrisMcKee
ChrisMcKee / installpackerterraform.sh
Last active October 2, 2024 15:59
hashicorp terraform packer
#!/bin/bash
cd /tmp
sudo apt-get install --assume-yes jq > /dev/null
terraform_url="https://releases.hashicorp.com/terraform/$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version')/terraform_$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version')_linux_amd64.zip"
packer_url="https://releases.hashicorp.com/packer/$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r -M '.current_version')/packer_$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r -M '.current_version')_linux_amd64.zip"
@donzpixelz
donzpixelz / badbots.lst
Created January 13, 2018 01:38
A list of bad and "good" User-Agents (robots) that are worth blocking with haproxy. This will help stop your bandwidth being used up by these crawlers. I continually add to this list at least once a week. This is the haproxy rule I use. acl badbots hdr_reg(User-Agent) -i -f /etc/haproxy/badbots.lst block if badbots
# -----------------------------------------------------------------
# User-Agent strings that are worth blocking with the following rule
# in haproxy to prevent your content being stolen, stop spammers and
# to limit your bandwidth usage.
#
# acl badbots hdr_reg(User-Agent) -i -f /etc/haproxy/badbots.lst
# block if badbots
#
# By Danny Sheehan
# http://www.setuptips.com
@danisla
danisla / terraform-install.sh
Last active July 15, 2024 13:36
Terraform latest version install script
#!/bin/bash
function terraform-install() {
[[ -f ${HOME}/bin/terraform ]] && echo "`${HOME}/bin/terraform version` already installed at ${HOME}/bin/terraform" && return 0
LATEST_URL=$(curl -sL https://releases.hashicorp.com/terraform/index.json | jq -r '.versions[].builds[].url' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | egrep -v 'rc|beta' | egrep 'linux.*amd64' |tail -1)
curl ${LATEST_URL} > /tmp/terraform.zip
mkdir -p ${HOME}/bin
(cd ${HOME}/bin && unzip /tmp/terraform.zip)
if [[ -z $(grep 'export PATH=${HOME}/bin:${PATH}' ~/.bashrc) ]]; then
echo 'export PATH=${HOME}/bin:${PATH}' >> ~/.bashrc
@nassor
nassor / compressor.go
Last active March 16, 2021 20:15
Zlib Compress in Go -> Redis List -> Zlib Uncompress in Ruby
package main
import (
"bytes"
"compress/zlib"
"fmt"
"time"
"github.com/vmihailenco/msgpack"
redis "gopkg.in/redis.v5"
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
@VojtechVitek
VojtechVitek / slice-batch-in-parallel.go
Last active December 17, 2024 21:46
Golang - Loop over slice in batches (run something in parallel on a sub-slice)
package main
import "fmt"
func main() {
slice := make([]int, 159)
// Split the slice into batches of 20 items.
batch := 20