Skip to content

Instantly share code, notes, and snippets.

View epcim's full-sized avatar

Petr Michalec epcim

View GitHub Profile
@epcim
epcim / vimrc
Created February 4, 2019 14:18 — forked from jonmorehouse/vimrc
UUID generator for vim. Inputs a uuid to copy buffer
fu! GenerateUUID()
python << EOF
import uuid
import vim
# output a uuid to the vim variable for insertion below
vim.command("let generatedUUID = \"%s\"" % str(uuid.uuid4()))
EOF
@epcim
epcim / gist:27240b7d6a36a1f595c2b09b5814aa54
Created February 4, 2019 14:14 — forked from goude/gist:b44b9d3938d3d30d8873f34fe2f92057
Generate and insert a UUID in vim
:r !uuidgen|sed 's/.*/"uid": "&",/'
@epcim
epcim / dhcpd.conf
Created January 16, 2019 22:41 — forked from robinsmidsrod/dhcpd.conf
Trying to chainload iPXE with full feature set from a lesser featured one, whilst still being able to boot non-supported cards with UNDI
ddns-update-style none;
deny bootp; #default
authoritative;
include "/etc/dhcp/ipxe-option-space.conf";
# GREEN (private network)
subnet 10.1.1.0 netmask 255.255.255.0 {
range 10.1.1.100 10.1.1.199;
option subnet-mask 255.255.255.0;
@epcim
epcim / _INSTALL.md
Created January 16, 2019 22:39 — forked from robinsmidsrod/_INSTALL.md
Bootstrapping full iPXE native menu with customizable default option with timeout (also includes working Ubuntu 12.04 preseed install)

Add the following chunk to your existing ISC dhcpd.conf file.

if exists user-class and ( option user-class = "iPXE" ) {
    filename "http://boot.smidsrod.lan/boot.ipxe";
}
else {
    filename "undionly.kpxe";
}

(or see https://gist.github.com/4008017 for a more elaborate setup

@epcim
epcim / libvirt_kvm.rst
Created January 4, 2019 18:05 — forked from fpytloun/libvirt_kvm.rst
Libvirt and KVM

Using Libvirt and KVM

Installation

Install required packages
apt-get install qemu-kvm libvirt-bin bridge-utils virtinst
@epcim
epcim / jq-cheetsheet.md
Created September 1, 2018 15:06 — forked from olih/jq-cheetsheet.md
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@epcim
epcim / Terraform_functions.md
Created September 1, 2018 14:33 — forked from davewongillies/Terraform_functions.md
Terraform Functions

Supported built-in functions

  • abs(float) - Returns the absolute value of a given float. Example: abs(1) returns 1, and abs(-1) would also return 1, whereas abs(-3.14) would return 3.14. See also the signum function.

  • basename(path) - Returns the last element of a path.

  • base64decode(string) - Given a base64-encoded string, decodes it and returns the original string.

@epcim
epcim / maas-squashfs-backdoor.sh
Created August 15, 2018 14:43 — forked from dshcherb/maas-squashfs-backdoor.sh
A procedure to add a root password to maas-deployed cloud images for last-resort debugging.
https://gnu-linux.org/building-ubuntu-rootfs-for-arm.html
"2) Extract the downloaded image with ‘sudo’ to allow ‘mknod’ commands to work"
# get a cloud image from here
# https://cloud-images.ubuntu.com/daily/server/xenial/
# https://cloud-images.ubuntu.com/daily/server/xenial/current/
# based on https://bazaar.launchpad.net/~maas-images-maintainers/maas-images/maas-ephemerals/view/head:/bin/img2squashfs#L161
# extract a cloud image rootfs to a directory, sudo is needed for `mknod`s to work
# doesn't have to be .tar.gz - could well unsquashfs an existing squashfs
@epcim
epcim / parse_yaml.sh
Created July 31, 2018 19:06 — forked from pkuczynski/LICENSE
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
cat terraform.tfstate | jq -r '.modules[0].resources | map(select(.type == "google_compute_instance")) | map([.primary.id, " ansible_ssh_host=", .primary.attributes["network_interface.0.access_config.0.nat_ip"]] | join("")) | sort | .[]'