Skip to content

Instantly share code, notes, and snippets.

View rsperl's full-sized avatar

Richard rsperl

  • North Carolina, United States
View GitHub Profile
@rsperl
rsperl / tsplay.sh
Last active July 25, 2022 12:26
create typescript playground in nx workspace
tsplay () {
local app="$1"
local workspace="${2:-default}"
local default_root="$HOME/tsplay"
local work_root="${TSPLAY_ROOT:-$default_root}"
local workspace_dir="$work_root/$workspace"
local lsws="$(ls -1 "$work_root"|sort|sed 's/^/ /')"
local usage="Usage: tsplay -a <app> [-w <workspace>]\n"
usage+="Existing workspaces:\n"
usage+="$lsws"
@rsperl
rsperl / filetime2timeTime.go
Last active July 25, 2022 12:36
convert filetime to time.Time in #go #snippet
package main
import (
"fmt"
"math"
"os"
"strconv"
"time"
)
@rsperl
rsperl / goplay.sh
Last active July 11, 2022 17:41
create a local go playground
#!/usr/bin/env bash
# default root directory for goplay
GOPLAY_ROOT=""$HOME/goplay""
# fn:goplay:create a go playground
function goplay() {
local module_name="${1:-anon}"
local ts="$(date +%Y-%m-%d_%H%M%S)"
local dirname="$GOPLAY_ROOT/$module_name-$ts"
local go_version=$(go version | awk '{print $3}' | sed -e 's/go//' | awk -F. '{print $1"."$2}')
@rsperl
rsperl / check_port.go
Last active July 25, 2022 12:42
check for open port in #go #snippet
package main
import (
"fmt"
"log"
"net"
"os"
"regexp"
"strconv"
"time"
@rsperl
rsperl / build.sh #snippet
Last active July 25, 2022 12:43
set variables at build time #go
#!/usr/bin/env bash
BUILD_TIME="$(date --iso-8601=seconds)"
COMMIT_SHA="$(git rev-parse HEAD 2>/dev/null && true)"
# or
# git rev-parse --short=8 HEAD 2>/dev/null && true
COMMIT_SHORT_SHA="${COMMIT_SHA:0:8}"
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD && true)
@rsperl
rsperl / byte_order_operations.go #snippet
Last active July 25, 2022 12:44
byteorder operations #go
var nativeEndian binary.ByteOrder
func setByteOrder() {
buf := [2]byte{}
*(*uint16)(unsafe.Pointer(&buf[0])) = uint16(0xABCD)
switch buf {
case [2]byte{0xCD, 0xAB}:
nativeEndian = binary.LittleEndian
@rsperl
rsperl / multiple_ssh_keys_git.md
Last active July 25, 2022 12:44
using multiple ssh keys with a single github instance #snippet

Create the ssh keys

ssh-keygen -t ed25519 -C my.email@example.com

# save to ~/.ssh/id_new_ssh_keys

Clone the repo

@rsperl
rsperl / angular_styling.md
Last active July 25, 2022 13:12
angular styling priorities #angular #snippet
  1. [ngStyle]={fontSize: '1em'}
  2. [style.fontSize.em]=2
  3. [style]={fontSize: '3em'}
  4. style="font-size: 4em"

  1. @Directive({host: {'[style.fontSize.em]': 5}})
  2. @Directive({host: {'style': 'fontSize: 6em;'}})
@rsperl
rsperl / things.md
Last active July 25, 2022 12:45
Things I might need later #snippet

keploy

Keploy is a no-code API testing platform that generates tests-cases and data-mocks from API calls. Dependency-mocks are automatically generated with the recorded request/responses.

@rsperl
rsperl / backup_mysql.sh
Last active July 25, 2022 13:12
backup mysql #snippet
#!/usr/bin/env bash
login_path="$1"
database_name="$2"
dir="$HOME/.mysql_backups"
/usr/local/bin/mysqldump --login-path="$login_path" "$database_name" | gzip > "$dir/$database_name-$(/bin/date +%Y-%m-%d_%H%M%S).sql.gz"