Skip to content

Instantly share code, notes, and snippets.

View frgomes's full-sized avatar

Richard Gomes frgomes

View GitHub Profile
@frgomes
frgomes / yaml_solve_references.rs
Created January 29, 2022 18:35
Rust - Render YAML resolving environment variables and YAML references.
#![allow(unused_parens)]
use anyhow::{Context,Result, anyhow};
use clap::{arg, App, AppSettings};
use std::ffi::OsStr;
fn main() -> Result<()> {
let matches = App::new("mkvm")
.about("Make virtual machines easily!")
.setting(AppSettings::SubcommandRequiredElseHelp)
@frgomes
frgomes / kvm_host_network_interfaces
Created January 10, 2022 01:42
Linux - Turn off AAAA queries in Debian
## /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
System Information
-------------------
Manufacturer: HP
Product Name: HP ENVY x360 Convertible 15-ee0xxx
@frgomes
frgomes / linalg.sh
Last active May 3, 2021 01:04
Bash - Matrix multiplication, passing associative arrays to functions, returning associative arrays from functions
#!/bin/bash -eu
function linalg_matrix_dump {
local -n M=${1}
local -a data=(${M[data]})
typeset -i rows=${M[rows]}
typeset -i cols=${M[cols]}
typeset -i i j
printf "%s:\n" ${1}
for ((i=0;i<rows;i++)) ; do
@frgomes
frgomes / github_clone_user.py
Last active April 17, 2021 05:12
Python - github_clone_user - clones all repositories of type=sources
#!/usr/bin/env python3
import json
import requests
import argparse
import os
import sys
from git import Repo
##
@frgomes
frgomes / gist:46d60e1da1d76df878323467a9930a8e
Created April 7, 2021 10:31
Rust - LinkedList and DoubleLinkedList
mod LinkedList {
type Link<T> = Option<Box<Node<T>>>;
struct Node<T> {
value: T,
next: Link<T>,
}
}
mod DoubleLinkedList {
use core::cell::RefCell;
@frgomes
frgomes / cmake-out_of_tree.md
Last active March 25, 2021 04:28
bash - run cmake out of tree / run cmake out of project

Instead of running cmake in tree such as:

cd ${WORKSPACE}
git clone http://github.com/WebAssembly/wabt

cd wabt
mkdir build
cd build
cmake ..

cmake --build .

@frgomes
frgomes / gist:4cb640a4507976f50a3b5847f8fd77d1
Last active March 3, 2021 20:46
salt: Create Salt installation in a virtual environment
#!/bin/bash -ex
# This script creates a Salt installation inside a virtual environment so that
# a steteful infrastructure aiming customer A is absolutely oblivious of customer B.
#
# No changes are required on configuration files, so that you can be sure that
# whatever you keep in the source control is valid in production. All you have to do
# in production is copying the trees /etc/salt and /srv/salt from the source control
# to their glorified places /etc/salt and /srv/salt in production.
#
@frgomes
frgomes / find_public_keys.py
Created February 9, 2021 23:53
Python - Find public keys matching a given list of patterns
def contents(ssh, files):
for file in files:
path = '{}/{}'.format(ssh, file)
yield open(path).read().replace("\n", "")
def keysFor(args):
ssh = '{}/.ssh'.format(os.environ['HOME'])
extensions = [ '.pub' ]
files = [f for f in os.listdir(ssh) if os.path.splitext(f)[1] in extensions]
keys = [k for k in contents(ssh, files) if k.split(' ')[2] in args]
@frgomes
frgomes / keybase.md
Last active February 20, 2020 12:04
keybase proof

Keybase proof

I hereby claim:

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

To claim this, I am signing this object: