Skip to content

Instantly share code, notes, and snippets.


Richard Gomes frgomes

View GitHub Profile
frgomes / SparkExampleTests.scala
Created Apr 10, 2022
Spark - template for integration tests
View SparkExampleTests.scala
package com.example
import utest._
object SparkExampleTests extends TestSuite {
import scala.util.{Try,Success,Failure}
import org.apache.spark.sql.SparkSession
val _spark: Try[SparkSession] =
Try {
frgomes / Configs.scala
Last active Apr 10, 2022
SBT - multiproject build with projectmatrix and additional configurations
View Configs.scala
//file: project/Configs.scala
import sbt._
object Configs {
val FunctionalTest = config("ft") extend (Test)
val AcceptanceTest = config("at") extend (Test)
val PerformanceTest = config("pt") extend (Test)
val Tools = config("tools") extend (Test)
frgomes / sbt_disable_publishing.sbt
Last active Mar 28, 2022
SBT - disable publishing
View sbt_disable_publishing.sbt
def disablePublishing: Seq[Setting[_]] =
publish/skip := true,
publishLocal/skip := true
frgomes / SlickConfig.scala
Created Mar 9, 2022
Scala - Read database credentials from file
View SlickConfig.scala
trait SlickConfig {
import scala.util.{Try, Success, Failure}
private val RegexDB2 = "^jdbc:(db2):.*//(.*):(.*)/([^;]*)[?:;](.*)".r
private val RegexDerby = "^jdbc:(derby):.*//(.*):(.*)/([^;]*)[?:;](.*)".r
private val RegexH2 = "^jdbc:(h2):(?:mem):()()([^;]*)[?:;](.*)".r
private val RegexHsqlDB = "^jdbc:(hsqldb):.*//(.*):(.*)/([^;]*)[?:;](.*)".r
private val RegexSqlServer = "^jdbc:(sqlserver)://(.*):(.*);DatabaseName=([^;]*)[?:;](.*)".r
private val RegexjTDS = "^jdbc:(jtds):sqlserver://(.*):(.*)/([^;]*)[?:;](.*)".r
private val RegexMySQL = "^jdbc:(mysql):.*//(.*):(.*)/([^;]*)[?:;](.*)".r
frgomes / sequence.scala
Created Mar 7, 2022
FP - sequence :: Seq[Try[T]] to Try[Seq[T]]
View sequence.scala
import scala.util.{Try,Success,Failure}
def sequence[T](seq: Seq[Try[T]]): Try[Seq[T]] =
.foldRight(Try(List.empty[T])) {
case (item, acc) => for { a <- acc; i<- item } yield i :: a
frgomes /
Created Jan 29, 2022
Rust - Render YAML resolving environment variables and YAML references.
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!")
frgomes / kvm_host_network_interfaces
Created Jan 10, 2022
Linux - Turn off AAAA queries in Debian
View kvm_host_network_interfaces
## /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
View ElanTabletWACOM.txt
Section "InputClass"
Identifier "Wacom driver override"
MatchProduct "ELAN2514:00 04F3:2B05"
MatchDevicePath "/dev/input/event*"
Driver "wacom"
frgomes /
Last active May 3, 2021
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 /
Last active Apr 17, 2021
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