Saturday, May 28, 2022

gRPC Stuff

https://grpc.io/docs/protoc-installation/
brew install protobuf

https://grpc.io/docs/languages/go/quickstart/
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2

example code:
git clone -b v1.46.0 --depth 1 https://github.com/grpc/grpc-go

https://github.com/fullstorydev/grpcurl
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest

Monday, May 23, 2022

Notes from gittower "Undoing Git Mistakes" presentation

Uncommited Local Changes

1. revert local changes
git restore fname

2. accidentally deleted a file
git restore fname

3. discarding chunks/lines (-p = patch)
# interactive, y/n for discard
git restore -p fname

4. discard all local changes
git restore .

(git stash)

Looking at committed history !! never change history that has been pushed

feature branch before adding to a team branch

5. fixing last commit message
git commit --amend -m "better commit message"

6. adding file to commit
git commit --amend (used tower to add file)

7. reverting a commit in the middle (c1, c2, c3; c2 is bad)
git revert bad-commit-hash

8. resetting to an old revision (everything after c2 is bad)
git reset --hard good-commit-hash
(--hard and --mixed are all you need; --mixed keeps changes as local changes)

9. resetting a file to an old revision
## returns to prior state for a specific file
git restore --source good-hash fname

## reflog -- journal of head pointer changes

10. recover a deleted revision
git reflog
-- sorted chronologically
-- get accidentally deleted
git branch happy-ending previous-state

11. recovering a deleted branch
git reflog (note we had to switch away from branch)
git branch feature/login earlier-hash

12. moving a commit to a new branch
-- supposed committed to master instead of feature branch
-- we see most recent commit on master
(drag commit from master to feature branch; delete commit on master)
git branch feature/login
git reset HEAD~1 --hard

13. moving a commit to a different branch (which exists)
-- use cherry pick to move commit to correct branch
-- clean up master
git checkout feature/newsletter
git cherry-pick sha
git checkout master
git reset --hard HEAD~1

interactive rebase (use for only local history!!!)

14. edit old commit
git rebase -i HEAD~3
-- commits in reverse order
-- go to parent commit of commit you want to change
action keyword: reword
-- git opens editor for commit message

15. delete old commits
git rebase -i HEAD~2 (or copy commit hash)
action keyword: drop

16. squashing multiple commits into one
git rebase -i HEAD~3
action keyword: squash
-- line marked squash is combined with line above
-- get edit for this squashing commit

17. adding a change (file) to an old commit
-- c4 has fix for c2
-- c4 is good
-- two steps: use fixup to commit, rebase autosquash
git add missing-file
git commit --fixup broken-hash
git rebase -i HEAD~4 --autosquash
-- changes order of bandaid commit

18. splitting/editing old commit
(in gui)

git-tower.com/learn
git-tower.com/help

Go Vim notes

# install ycm

linux:
$ sudo apt install vim-youcompleteme
$ vim-addon-manager install youcompleteme

mac:
% brew install youcompleteme
maybe:
% cd .vim/bundle/youcompleteme
% python3 ~/.vim/bundle/youcompleteme/third_party/ycmd/build.py --all --verbose
     (or just --go-completer)

# install vundle
% git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

% cat .vimrc
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'valloric/youcompleteme'
Plugin 'fatih/vim-go'
call vundle#end() " required
filetype plugin indent on " required

% vim
:PluginInstall
:GoInstallBinaries

Saturday, May 21, 2022

Bud - RoR for Go?

https://github.com/livebud/bud

https://denim-cub-301.notion.site/Hey-Bud-4d81622cc49942f9917c5033e5205c69

Bud is a full-stack framework that helps you build web applications faster. You can think of Bud as the Ruby on Rails for the Go ecosystem.

I'm All-In on Server-Side SQLite

https://fly.io/blog/all-in-on-sqlite-litestream/

How Litestream works is that it takes control of SQLite's WAL-mode journaling. In WAL mode, write operations append to a log file stored alongside SQLite's main database file. Readers check both the WAL file and the main database to satisfy queries. Normally, SQLite automatically checkpoints pages from the WAL back to the main database. Litestream steps in the middle of this: we open an indefinite read transaction that prevents automatic checkpoints. We then capture WAL updates ourselves, replicate them, and trigger the checkpointing ourselves.

JSON and virtual columns in SQLite

https://antonz.org/json-virtual-columns/

Generated columns have another great use case.

tldr: index your generated columns, just as good as a nosql db!

alter table events
add column object_id integer
as (json_extract(value, '$.object_id'));

create index events_object_id on events(object_id)

TimescaleDB

https://docs.timescale.com/timescaledb/latest/#welcome-to-the-timescaledb-documentation

TimescaleDB is a time-series database, built on top of PostgreSQL. More than that, however, it's a relational database for time-series. Developers who use TimescaleDB get the benefit of a purpose-built time-series database, plus a classic relational database (PostgreSQL), all in one, with full SQL support.

https://docs.timescale.com/timescaledb/latest/overview/how-does-it-compare/timescaledb-vs-postgres/#why-use-timescaledb-over-relational-databases

TimescaleDB also includes a number of time-oriented features that aren't found in traditional relational databases. These include special query optimizations (like the merge append above) that provide some of the huge performance improvements for time-oriented queries, as well as other time-oriented functions (some of which are listed below).

https://www.timescale.com/blog/observability-powered-by-sql-understand-your-systems-like-never-before-with-opentelemetry-traces-and-postgresql/

Today, we are announcing the general availability of OpenTelemetry tracing support in Promscale, the observability backend for metrics and traces built on the rock-solid foundations of PostgreSQL and TimescaleDB. We’re now closer to becoming the unified data store for observability powered by SQL, bringing the PostgreSQL and observability worlds together.