Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Gomes frgomes

View GitHub Profile
View ElanTabletWACOM.txt
Section "InputClass"
Identifier "Wacom driver override"
MatchProduct "ELAN2514:00 04F3:2B05"
MatchDevicePath "/dev/input/event*"
Driver "wacom"
EndSection
@frgomes
frgomes / linalg.sh
Last active May 3, 2021
Bash - Matrix multiplication, passing associative arrays to functions, returning associative arrays from functions
View linalg.sh
#!/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 Apr 17, 2021
Python - github_clone_user - clones all repositories of type=sources
View github_clone_user.py
#!/usr/bin/env python3
import json
import requests
import argparse
import os
import sys
from git import Repo
##
@frgomes
frgomes / gist:46d60e1da1d76df878323467a9930a8e
Created Apr 7, 2021
Rust - LinkedList and DoubleLinkedList
View gist:46d60e1da1d76df878323467a9930a8e
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 Mar 25, 2021
bash - run cmake out of tree / run cmake out of project
View cmake-out_of_tree.md

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 Mar 3, 2021
salt: Create Salt installation in a virtual environment
View gist:4cb640a4507976f50a3b5847f8fd77d1
#!/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 Feb 9, 2021
Python - Find public keys matching a given list of patterns
View find_public_keys.py
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 Feb 20, 2020
keybase proof
View keybase.md

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:

@frgomes
frgomes / install_retropie.sh
Last active Dec 12, 2019
bash - install RetroPie on UDOO Bold V8
View install_retropie.sh
#!/bin/bash
##
## This script is instended to install RetroPie on a newly installed Debian Buster box.
##
## Hardware requirements:
## This script is known to work well with UDOO Bolt V8, which has an AMD Ryzen 1000 SoC.
##
## Software Requirements:
##
@frgomes
frgomes / kubectl_helpers.sh
Last active Aug 18, 2019
k8s: find cluster names in kubectl configuration
View kubectl_helpers.sh
#!/bin/bash
// one-liner which converts YAML to JSON
function yaml2json {
python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print(json.dumps(y))'
}
function kubectl_clusters {
cat ~/.kube/config | yaml2json | jq '.clusters[].name' | sed 's/"//g'
}