Skip to content

Instantly share code, notes, and snippets.

View andreimerlescu's full-sized avatar
:shipit:
Building Something Incredible…

Andrei Merlescu andreimerlescu

:shipit:
Building Something Incredible…
  • United States
  • 06:41 (UTC -04:00)
View GitHub Profile

The basics

#[arg()] decorates a field in a #[derive(Parser)] struct and tells clap how to parse that field from the command line. Every option inside #[arg()] is a key-value pair.


Naming

long — creates a --flag style argument. If you write #[arg(long)] with no value, it uses the field name. If you write #[arg(long = "1p")] it uses that string instead. That's why we have:

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Amazon.Runtime;
using Amazon.Runtime.CredentialManagement;
using Amazon.IdentityManagement; // For generating the signature.
using Amazon.IdentityManagement.Model;
This NFT represents $APARIO DAO NFT Owner ##/47 of Project Apario LLC. Congratulations!
Owning this NFT grants you a position on the Project Apario Decentralized Autonomous Organization.
Project Apario LLC will be lead by this Decentralized Autonomous Organization by means of voting rights on the project's tokenomics and direction. It additionally will provide you exclusive access to the dedicated web application dao.apario.app where you'll be able to manage your ownership rights over Project Apario LLC.
Purchasing this NFT directly funds Project Apario but does not contribute anything to the APARIO/XRP AMM liquidity pool. The proceeds from this NFT will be used for compensating the development team for their labor.
Royalties on this NFT are 50% and whenever a deposit of XRP reaches Project Apario due to a resell of ownership of the token, 75% of those proceeds will be air dropped equally to all $APARIO DAO NFT owners. This is performed manually by the team members at Project Apario who manage the softwar
@andreimerlescu
andreimerlescu / go_gin_tls_tutorial.md
Last active June 10, 2023 19:38
Go + Gin + A Better Way To Do TLS/SSL

Golang w/ Gin and TLS/SSL Auto-Configuration

Sometimes you need SSL, and sometimes you want to use a self signed certificate, and sometimes you want to handle certificate rotations behind the scenes without restarting the application. This tutorial will introduce an alternative way to serve TLS/SSL with Go and Gin by leveraging a few packages that I've created to provide a seemless experience to the engineer setting up TLS for their Go Gin application.

main()

package main

import (
@andreimerlescu
andreimerlescu / go_flag_usage.go
Created June 10, 2023 14:10
Format Go Flag Into Human Readable Output
flag.Usage = func() {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "%v [FLAGS]\n", os.Args[0])
fmt.Fprintln(w, "Flag\tDefault\tDescription")
nl, dl, ul := 4, 7, 11
out := ""
flag.VisitAll(func(f *flag.Flag) {
out += fmt.Sprintf("-%s\t%s\t%s\n", f.Name, f.DefValue, f.Usage)
if len(f.Name)+1 > nl {
nl = len(f.Name) + 1
REGEX_1 = /(\d{1,2})[st|nd|rd|th]?{2}\s{1}(January|Jan|February|Feb|March|Mar|April|Apr|May|June|Jun|July|Jul|August|Aug|September|Sep|October|Oct|November|Nov|December|Dec),?\s(\d{2,4})/
REGEX_2 = /(January|Jan|February|Feb|March|Mar|April|Apr|May|June|Jun|July|Jul|August|Aug|September|Sep|October|Oct|November|Nov|December|Dec)\s{1}(0\d{1}|\d{1,2})[st|nd|rd|th]{2}?(,?)\s(\d{2,4})/
REGEX_3 = /(0\d{1}|\d{1}|1\d{1})\/(0\d{1}|\d{1}|1\d{1})\/(\d{2,4})/
MONTH_STR_TO_NUM={
"JANUARY": 1,
"January": 1,
"Jan": 1,
"FEBRUARY": 2,
"February": 2,
"Feb": 2,
m,
`$b
.ss, $$: .,d$
`$$P,d$P' .,md$P"'
,$$$$$b/md$$$P^'
.d$$$$$$/$$$P'
$$^' `"/$$$' ____ _ _ _ _
$: ,$$: / ___|(_) __| | ___| | _(_) __ _
`b :$$ \___ \| |/ _` |/ _ \ |/ / |/ _` |
m,
`$b
.ss, $$: .,d$
`$$P,d$P' .,md$P"'
,$$$$$b/md$$$P^'
.d$$$$$$/$$$P'
$$^' `"/$$$' ____ _ _ _ _
$: ,$$: / ___|(_) __| | ___| | _(_) __ _
`b :$$ \___ \| |/ _` |/ _ \ |/ / |/ _` |
m,
`$b
.ss, $$: .,d$
`$$P,d$P' .,md$P"'
,$$$$$b/md$$$P^'
.d$$$$$$/$$$P'
$$^' `"/$$$' ____ _ _ _ _
$: ,$$: / ___|(_) __| | ___| | _(_) __ _
`b :$$ \___ \| |/ _` |/ _ \ |/ / |/ _` |
# ⇒ ruby string_find_test.rb
# Started 2020-01-02 15:20:04 -0500
# Ended 2020-01-02 15:20:05 -0500
# Speed 1.7854981422424316s
#
#
#
# Started 2020-01-02 15:20:05 -0500
# Ended 2020-01-02 15:20:09 -0500
# Speed 3.125840902328491s