Skip to content

Instantly share code, notes, and snippets.

View ffledgling's full-sized avatar
🏠
🔢

Anhad Jai Singh ffledgling

🏠
🔢
View GitHub Profile
@ffledgling
ffledgling / k8s-create-deployment.go
Created July 12, 2017 11:37
kubernetes client-go example: Create a Deployment based on json
package main
import (
"encoding/json"
"log"
"os"
// We use pretty instead of the common go-spew or pretty-printing because,
// go-spew is vendored in client-go and causes problems
"github.com/kr/pretty"
@ffledgling
ffledgling / libvirt-install.md
Created March 4, 2018 20:52
Compile a custom libvirt+libvirt-python+virt-manager stack

Download and install a custom version of libvirt/virsh

CUSTOM_ROOT=/home/ajaisingh/n4/nested-vm/

mkdir -p $CUSTOM_ROOT/src
wget https://libvirt.org/sources/libvirt-4.0.0.tar.xz

# Compiling a new version of libvirt (v4.0.0), requires libnl-devel, libnl-route, libyajl-devel, libdevmapper-devel

sudo apt-get install libnl-route-3-dev
@ffledgling
ffledgling / debug.hpp
Created January 19, 2020 23:10
C++ DEBUG MACROS
#define PRINT_MAP(M) for(auto m: M) cout << m.first << "," << m.second << " "; cout << endl;

Keybase proof

I hereby claim:

  • I am ffledgling on github.
  • I am ffledgling (https://keybase.io/ffledgling) on keybase.
  • I have a public key ASDIDtlKG35WXAbfBJu1XkQ3jOFrflk2RkZleXRSrVMaeQo

To claim this, I am signing this object:

@ffledgling
ffledgling / Basic irssi setup walk-through
Last active April 23, 2019 12:36
Gist to help someone (Usually me) setup irssi after a fresh install. All changes mentioned here can be made directly to your .irssi/config file also.
Typically used irssi config
### Large portions shamelessly copied from https://wiki.archlinux.org/index.php/Irssi (Thank you Arch Wiki )
# Please refer to the aforementioned link for more detail and customization.
# irssi has a pretty good default config that you don't usually want to mess with much
# A couple of basic things that are needed are specified here. Type /set to see a complete list of modifiable parameters.
# BASIC SETUP:
@ffledgling
ffledgling / kube-prompt.sh
Last active February 27, 2019 11:55
Dead simple PS1 prompt add-on for bash to display the current kubernetes namespace and context
#!/bin/bash
# Simple prompt addon to display kubernetes ns and cluster context
# To use, add the following in your .bashrc:
# ```
# source $PATH_TO_FILE/kube-prompt.sh
# KUBE_PROMPT_COLORS=y
# PS1='{$(__kube_ps1)}'$PS1
# ```
@ffledgling
ffledgling / filter-job-builds-by-param-values.groovy
Created March 14, 2017 11:20
Groovy script for use with Jenkins to get builds of jobs that were run with a a certain parameter set to a certain value.
//def hi = hudson.model.Hudson.instance
// Just use Jenkins.instance, it's the same thing
def ji = Jenkins.instance
def param_name = "GERRIT_REFSPEC"
def job_pattern = /.*/ //Job Name pattern, used to select jobs we want to select
def param_value_filter = /.*/ // Pattern to select values of
def matchedJobs = ji.items.findAll { job ->
@ffledgling
ffledgling / rbd-create.go
Created July 10, 2017 14:44
ceph-go example: create rbd volume with image features
func createRBDStorage() error {
// Runs the equivalent of rbd --pool ffledgling-pool ls
// Contains basic connection logic that's reusable
log.Println("Function started...") // We have this because connection setup etc take a while.
// If like me, you tried this first and expected it to work, it doesn't:
/*
conn, _ := rados.NewConn()
args := []string{"--name", "client.ffledgling", "--conf", "/home/ffledgling/ceph.conf"}
@ffledgling
ffledgling / ubuntu-18-docker-install.sh
Created November 23, 2018 17:44
Install Docker on Ubuntu 18.04 (without having to copy paste each step from the docs)
#!/bin/bash
sudo apt update -y
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
@ffledgling
ffledgling / prompt.sh
Last active October 9, 2018 10:49
Custom AWS prompt, configurable with aws instance variables
# Custom prompt for debian/ubuntu AWS instances the default is garbage
# Works best with dark terminals, tested often with solarized dark
# Define colors
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"