Skip to content

Instantly share code, notes, and snippets.

View alfredodeza's full-sized avatar
:octocat:

Alfredo Deza alfredodeza

:octocat:
View GitHub Profile
@alfredodeza
alfredodeza / iterm-to-hex.py
Created April 23, 2018 12:55
read an itermcolors export file and spit out Vim 8's ansi color var
#!/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 / prepare-commit-msg
Last active October 13, 2021 10:39
Append a "Resolves: {tracker}#{ticket-id}" to commit messages based on branch names
#!/usr/bin/python
"""
This is a prepare-commit-msg hook that fill append commit messages with::
Resolves: {TRACKER}#{TICKET-ID}
For example a RedHat BZ 0001 would look like::
Correct the syntax error
@alfredodeza
alfredodeza / generate.sh
Created July 14, 2016 18:56
Generate a self signed cert (spits out an ssl.key and ssl.cert) in one go
#!/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
@alfredodeza
alfredodeza / osx-cmake-fix.sh
Created July 12, 2021 19:26
OSX fixing missing cmake executable
# 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 February 26, 2020 16:45
Handy vagrantfile for local VMs with some custom IP/CPU/ram mappings
# -*- 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"
$ 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 / decrypt_jenkins.rst
Created November 16, 2017 15:27
decrypt jenkins secret from xml

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 / run.py
Last active September 5, 2017 22:14
Serve a WSGI application + static files with CherryPy
import os
import cherrypy
from cherrypy import wsgiserver
from my_wsgi_app import wsgi
PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), 'public'))
class Root(object):
@alfredodeza
alfredodeza / histfile
Last active March 25, 2017 15:11
How I got netatalk 3.0.1 working in SmartOS
CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib ./configure --with-bdb=/opt/local --with-init-style=solaris --without-pam --prefix=/opt/local --with-init-dir=/var/svc/manifest/network/ --with-ssl-dir=/opt/local --with-libgcrypt --prefix=/opt/local
LD_OPTIONS="-D libs,detail" CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib make clean install
LD_OPTIONS="-D libs,detail" CC=gcc CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib make clean install
ls /opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.0/
ln -s /opt/local/lib/libiconv.so /opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.0/
LD_OPTIONS="-D libs,detail" CC=gcc CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib make clean install
ln -s /opt/local/lib/libwrap.so /opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.0/
LD_OPTIONS="-D libs,detail" CC=gcc CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib make clean install
@alfredodeza
alfredodeza / prepare.sh
Created March 21, 2017 15:22
Customize a (rhel/centos) qcow2 image so that it can be used with Vagrant
#!/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