Skip to content

Instantly share code, notes, and snippets.

Richard Gomes frgomes

Block or report user

Report or block frgomes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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'
}
@frgomes
frgomes / slick_schema_more_than_22_fields.scala
Last active Aug 10, 2019
Scala/Slick :: More than 22 fields using nested case classes
View slick_schema_more_than_22_fields.scala
//----------------------------------------------------------------------------------------------------------------------
// This is an example of how more than 22 fields could be mapped with Slick 3.3.1 (other versions may work as well?).
//
// The general idea is pretty simple:
// 1. define a case class made of nested case classes.
// 2. define a projection made of nested projections.
//
// In addition, you can just get rid of noisy usages of ``GetResult`` generated by the Slick Code Generator.
// Just get rid of that, since usage of ``mapTo[T]`` makes definition of projections clean and hygienic.
//----------------------------------------------------------------------------------------------------------------------
@frgomes
frgomes / openssl_pfx.sh
Last active Jul 1, 2019
openssl - Convert from .PFX to CRT, CER, root PEM and client PEM
View openssl_pfx.sh
#!/bin/bash
# This lists the contents of a PFX file
# This is the last resort in case everything else fails.
# Just see its contents as a text file, cut whatever you need from it and
# paste manually onto separate files.
openssl pkcs12 -info -in input.pfx
# Found this in the internet. Not tested at all!
openssl pkcs12 -in input.pfx -out mycerts.crt -nokeys -clcerts
@frgomes
frgomes / thunderbird_exchange_server.md
Last active May 28, 2019
Thunderbird - connect to Exchange Server
View thunderbird_exchange_server.md
@frgomes
frgomes / instanceOf.rs
Created Apr 11, 2019
Rust - instanceOf
View instanceOf.rs
enum FooBar {
Foo(u8),
Bar(u8)
}
fn test(v: bool) -> FooBar {
if v {
FooBar::Foo(5)
} else {
FooBar::Bar(10)
@frgomes
frgomes / git_rebase1.sh
Created Apr 4, 2019
git - rebase (B from A from master) onto (B from master)
View git_rebase1.sh
#!/bin/bash
git rebase --onto master A B
@frgomes
frgomes / ChainingTry.scala
Last active Mar 1, 2019
Scala - Chaining Try/Success/Failure, return first successful
View ChainingTry.scala
def a: Try[String] = Failure(new RuntimeException)
def b: Try[String] = Failure(new RuntimeException)
def c: Try[String] = Success("C")
def d: Try[String] = Failure(new RuntimeException)
def e: Try[String] = Success("E")
def f: Try[String] = Failure(new RuntimeException)
val result = a orElse b orElse c orElse d orElse e orElse f
// result is Success("C")
@frgomes
frgomes / RegexDomainName.scala
Last active Mar 1, 2019
Scala - Regex domain names, IPv4, IPv6
View RegexDomainName.scala
/** Parse any IPv4 address or IPv6 address or domain name */
def parsePeerAddress(value: String): Try[String] =
parseIPv4(value) orElse parseIPv6(value) orElse parseHostname(value)
/** Parse IPv4 address */
def parseIPv4(value: String): Try[String] = {
def checkInvalid(address: String): Try[String] =
if(address == "0.0.0.0") Failure(new java.net.UnknownHostException(address)) else Success(address)
value.trim match {
You can’t perform that action at this time.