Skip to content

Instantly share code, notes, and snippets.

View bgarcial's full-sized avatar

Bernardo García bgarcial

  • Amsterdam, Nederland
  • 08:20 (UTC +02:00)
  • LinkedIn in/bgarcial
View GitHub Profile
@ianmiell
ianmiell / git-remote-url
Created April 1, 2021 08:05
Script to get git repo link
#!/bin/bash
# based on: https://stackoverflow.com/questions/47524709/how-to-get-the-full-path-of-a-file-in-a-git-remote-repo
#set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
function usage {
echo "$0 [ -h/--help ] [ FILENAME ]"
@robinmanuelthiel
robinmanuelthiel / azuredevops-editorconfig.yaml
Last active April 3, 2020 20:40
EditorConfig Check with Azure DevOps
pool:
vmImage: 'Ubuntu 16.04'
steps:
- bash: |
npm install -g eclint
eclint check eclint check $(git ls-files)
failOnStderr: true
displayName: 'Check EditorConfig violations'
@psxvoid
psxvoid / delete-evicted-pods-all-namespaces.sh
Created August 6, 2018 14:41
Delete evicted pods from all namespaces (also ImagePullBackOff and ErrImagePull)
#!/bin/sh
# based on https://gist.github.com/ipedrazas/9c622404fb41f2343a0db85b3821275d
# delete all evicted pods from all namespaces
kubectl get pods --all-namespaces | grep Evicted | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
# delete all containers in ImagePullBackOff state from all namespaces
kubectl get pods --all-namespaces | grep 'ImagePullBackOff' | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
# delete all containers in ImagePullBackOff or ErrImagePull or Evicted state from all namespaces
@mcmaur
mcmaur / docker_mint18.sh
Created February 25, 2018 10:03
Install Docker on Linux Mint 18 Sylvia
#remove old
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
@mikeckennedy
mikeckennedy / switch_in_python_example.py
Last active August 21, 2019 04:55
Could we easily add switch to the Python language? I think the answer is maybe yes!
# Here is an example of some syntax I'm proposing:
# See the github repo at https://github.com/mikeckennedy/python-switch
def test_switch():
num = 7
val = input("Enter a key. a, b, c or any other: ")
with Switch(val) as s:
s.case('a', process_a)
s.case('b', process_b)
@edsiper
edsiper / kubernetes_commands.md
Last active July 11, 2024 07:42
Kubernetes Useful Commands
@MiltonLn
MiltonLn / hangman.py
Last active July 2, 2024 08:37
A simple hangman game for Python Cali August Meetup about Testing in Python
import random
HANGMAN = [
'________',
'| |',
'| O',
'| |',
'| /|\ ',
'| |',
@alkrauss48
alkrauss48 / Dockerfile
Last active November 10, 2022 16:24
Running a docker container as a non-root user
# By default, Docker containers run as the root user. This is bad because:
# 1) You're more likely to modify up settings that you shouldn't be
# 2) If an attacker gets access to your container - well, that's bad if they're root.
# Here's how you can run change a Docker container to run as a non-root user
## CREATE APP USER ##
# Create the home directory for the new app user.
RUN mkdir -p /home/app
@caraboides
caraboides / backup-mongodb-to-s3.sh
Last active August 2, 2023 06:11
Simple script to backup MongoDB to S3, without waste diskspace for temp files. And a way to restore from the latest snapshot.
#!/bin/sh
set -e
HOST=localhost
DB=test-entd-products
COL=asimproducts
S3PATH="s3://mongodb-backups-test1-entd/$DB/$COL/"
S3BACKUP=$S3PATH`date +"%Y%m%d_%H%M%S"`.dump.gz
S3LATEST=$S3PATH"latest".dump.gz
/usr/bin/aws s3 mb $S3PATH
@so0k
so0k / kubectl.md
Last active April 25, 2024 12:40
Playing with kubectl output

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no