Skip to content

Instantly share code, notes, and snippets.

Avatar

Alfredo Deza alfredodeza

View GitHub Profile
@alfredodeza
alfredodeza / remote-desktop.md
Last active Jan 16, 2022
Remote k8s with docker-desktop using an SSH tunnel
View remote-desktop.md

Remote Kubernetes using SSH

My setup is using a Macmini with Docker for Desktop installed and with the Kubernetes option enabled. The main objective of the setup: use kubectl directly without any additional flags from my local computer, accessing/interacting the remote k8s instance

Ensure SSH is setup with key-based authentication

Copy public key to the remote authorized_keys file

cat ~/.ssh/id_rsa.pub | ssh admin@macmini-server 'umask 0077; mkdir -p .ssh; cat >> .ssh/authorized_keys'
@alfredodeza
alfredodeza / osx-cmake-fix.sh
Created Jul 12, 2021
OSX fixing missing cmake executable
View osx-cmake-fix.sh
# Install cmake with homebrew, which prevents:
# AssertionError: Could not find "cmake" executable!
brew install cmake
# and then install protobuf which fixes:
# CMake Error at CMakeLists.txt:292 (message):
# Protobuf compiler not found
# Call Stack (most recent call first):
# CMakeLists.txt:323 (relative_protobuf_generate_cpp)
brew install protobuf
@alfredodeza
alfredodeza / Vagrantfile
Created Feb 26, 2020
Handy vagrantfile for local VMs with some custom IP/CPU/ram mappings
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.ssh.insert_key = false
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.define 'node1' do |node1|
node1.vm.box = "ceph/ubuntu-bionic"
node1.vm.network :private_network, :ip => "192.168.111.100"
View gist:f1ead105ba06e6c7ae24ddf2312849d3
$ minishift start --show-libmachine-logs -v5
-- minishift version: v1.30.0+186b034
-- Starting profile 'minishift'
Found binary path at /usr/local/bin/docker-machine-driver-xhyve
Launching plugin server for driver xhyve
Plugin server listening at address 127.0.0.1:55267
() DBG | operation not supported by device
() Calling .GetVersion
Using API Version 1
() Calling .SetConfigRaw
@alfredodeza
alfredodeza / iterm-to-hex.py
Created Apr 23, 2018
read an itermcolors export file and spit out Vim 8's ansi color var
View iterm-to-hex.py
#!/usr/bin/env python
#
# Convert .itermcolors files to hex colors
import sys
import xml.etree.ElementTree as ET
def rgb_to_hex(rgb):
return '#%02x%02x%02x' % rgb
@alfredodeza
alfredodeza / decrypt_jenkins.rst
Created Nov 16, 2017
decrypt jenkins secret from xml
View decrypt_jenkins.rst

Open your Jenkins' installation's script console by visiting http(s)://${JENKINS_ADDRESS}/script.

There, execute the following Groovy script:

println( hudson.util.Secret.decrypt("${ENCRYPTED_PASSPHRASE_OR_PASSWORD}") )

where ${ENCRYPTED_PASSPHRASE_OR_PASSWORD} is the encrypted content of the <password> or <passphrase> XML element that you are looking for.

@alfredodeza
alfredodeza / prepare.sh
Created Mar 21, 2017
Customize a (rhel/centos) qcow2 image so that it can be used with Vagrant
View prepare.sh
#!/bin/bash -x
# Setup hostname vagrant-something.
FQDN="vagrant-rhel7"
if grep '^HOSTNAME=' /etc/sysconfig/network > /dev/null; then
sed -i 's/HOSTNAME=\(.*\)/HOSTNAME='${FQDN}'/' /etc/sysconfig/network
else
echo "HOSTNAME=${FQDN}" >> /etc/sysconfig/network
fi
@alfredodeza
alfredodeza / process.sh
Created Mar 21, 2017
Process a qcow2 image so that it can be customized as a vagrant box (meant for rhel images mostly)
View process.sh
#!/bin/bash
# The input is a qcow2 image, that gets copied via virt-customize so that it
# can be modified to work as a vagrant box. It requires the `create_box.sh` script
# from the vagrant-libvirt project::
#
# https://github.com/vagrant-libvirt/vagrant-libvirt/blob/master/tools/create_box.sh
#
# Usage:
#
# bash process.sh rhel-guest-image-7.4-10.x86_64.qcow2 rhel7.qcow2
@alfredodeza
alfredodeza / dosini.vim
Created Jan 12, 2017
Syntax file for tox.ini
View dosini.vim
" Vim syntax file
" Language: Configuration File (ini file) for Python's tox
" Version: 0.1
" Original Author: Alfredo Deza
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
@alfredodeza
alfredodeza / generate.sh
Created Jul 14, 2016
Generate a self signed cert (spits out an ssl.key and ssl.cert) in one go
View generate.sh
#!/bin/bash
# Easily generate a 10 year SSL certificate and key for development. It
# creates a configuration file for wild card domains, if no argument is passed
# in will fallback to "node.a" as the domain to use.
#
# Upon completion, these files should now exist::
#
# * openssl.cnf
# * ssl.key
# * ssl.crt