Skip to content

Instantly share code, notes, and snippets.

View bsnux's full-sized avatar
💭
👨‍💻

Arturo Fernandez bsnux

💭
👨‍💻
View GitHub Profile
@bsnux
bsnux / set-zsh.sh
Created October 27, 2021 17:07
How to modify shell when auth is done by LDAP
#!/bin/bash
#
# Set zsh as default shell when auth is done by LDAP
#
set -eou pipefail
getent passwd afernandez | perl -pne 's/bash/zsh/' | sudo tee -a /etc/passwd
@bsnux
bsnux / create-python-standalone.md
Created September 10, 2021 19:03
Creating Python Standalone Applications with zipapp

Creating Python Standalone Applications with zipapp

zipapp module allows us to create self-contained Python standalone programs that can be distributed to users who have Python already installed on their system.

Python packages not using C extensions can be bundled as well. shiv is recommended for those applications using those kind of extensions. In general, if your dependencies don't require a C compiler, you should be good to go using zipapp module.

Simple aplication listing current directory content

@bsnux
bsnux / run-cmd-pod.sh
Last active October 8, 2021 00:30
Runs commands in K8s pods when those are not installed there but they're in the worker node
#!/bin/bash
#------------------------------------------------------------------------
# run-cmd-pod.sh
#
# Runs commands in K8s pods when those are not installed there
# but they're in the worker node.
#
# Motivation: You want to run a command in a pod without
# installing anything in the pod. If that command exists
# in the worker node running the pod, then you can use
#!/bin/bash
# Print only lines matching expression
awk -F: '/ssh/ { print } ' /etc/group
# Print only if field 4 matchs expression
awk -F: 'match($4,/ssh/) { print } ' /etc/group
# Print field 1 only if field 4 matchs expression
awk -F: 'match($4,/ssh/) { print $1 } ' /etc/group
@bsnux
bsnux / simple-cheatsheet.sh
Created August 12, 2020 23:22
Simple and quick bash scripting reference
#!/bin/bash
#----------
# simple-cheatsheet.sh
#
# source: https://devhints.io/bash
#
#----------
# Variables
NAME="John"
@bsnux
bsnux / ansible-cookie-cutter.sh
Last active October 1, 2020 21:07
Ansible cookie cutter
@bsnux
bsnux / get-public-ip.sh
Created July 23, 2020 16:34
Getting public IP from Linux box
dig +short myip.opendns.com @resolver1.opendns.com
@bsnux
bsnux / deletePipelineOldBuilds.groovy
Created July 14, 2020 17:00
Delete old Jenkins pipeline job builds
import java.util.ArrayList
def MULTIBRANCH_JOBNAME = "project"
def BRANCH_NAME = "develop"
def MAX_TO_KEEP = 10
def hi = hudson.model.Hudson.instance
def item = hi.getItemByFullName(MULTIBRANCH_JOBNAME)
def jobs = item.getAllJobs()
@bsnux
bsnux / help-template.sh
Created July 8, 2020 21:00
Simple template for shell scripts
#!/bin/bash
# help-template.sh
#
# Simple template for shell scripts
#
Help=$(cat <<-"HELP"
my-script — does one thing well
Usage:
my-script <input> <output>