Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Garman agarman

View GitHub Profile
View simple.go
package main
import (
"fmt"
)
func main() {
fmt.Printf("%#v\n", Identity('a'))
fmt.Printf("%#v\n", Identity(Box('a')))
fmt.Printf("%#v\n", Identity(Unbox(Box('a'))))
@agarman
agarman / bitbucket.ps1
Last active Sep 14, 2020
Lists all repos in project in bitbucket
View bitbucket.ps1
#!/usr/bin/env pwsh -File
param(
[switch] [Parameter(ParameterSetName = "teams")] $teams,
[switch] [Parameter(ParameterSetName = "projects")] $projects,
[switch] [Parameter(ParameterSetName = "repos")] $repos,
[switch] [Parameter(ParameterSetName = "prs")] $prs,
# Parameters specified by switch command
[Parameter(Mandatory = $true, ParameterSetName = "projects")]
[Parameter(Mandatory = $true, ParameterSetName = "repos")]
View bitbucket_repos_in_project.sh
#!/bin/bash
# Authentication variables
USER=${BITBUCKET_USER:-`cat .user`}
SECRET=${BITBUCET_SECRET:-`cat .secret`}
ORG=${BITBUCKET_ORG:-`cat .org`}
# Setup Initial URI
PAGELEN_QS="pagelen=${PAGELEN:-100}"
FIELDS_QS="fields=${FIELDS:-next,values.full_name,values.updated_on,values.language}"
@agarman
agarman / pg_stats.sql
Created Aug 16, 2019
Return useful arrangement of stats from PostgreSQL
View pg_stats.sql
SELECT
table_name,
pg_size_pretty(table_size) AS table_size,
pg_size_pretty(indexes_size) AS indexes_size,
pg_size_pretty(total_size) AS total_size,
live_tuples,
dead_tuples,
(case
when ((live_tuples + dead_tuples) > 0)
then 100.0 * ((1.0 * dead_tuples) / (live_tuples + dead_tuples))
View pg_df.sql
SELECT
table_name,
pg_size_pretty(table_size) AS table_size,
pg_size_pretty(indexes_size) AS indexes_size,
pg_size_pretty(total_size) AS total_size,
live_tuples,
dead_tuples,
(case
when ((live_tuples + dead_tuples) > 0)
then 100.0 * ((1.0 * dead_tuples) / (live_tuples + dead_tuples))
@agarman
agarman / pg.sh
Created Apr 5, 2019
PostgreSQL + Docker Windows
View pg.sh
docker volume create PostgreSQLData
docker run -p 5432:5432 --name <<cntr_name>> -e POSTGRES_PASSWORD=<<pwd>> -d -v PostgreSQLData:/var/lib/postgresql/data postgres
docker logs <<cntr_name>>
@agarman
agarman / .emacs
Last active Oct 21, 2018
Dumped spacemacs for my own .emacs
View .emacs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; https://gist.github.com/agarman/e0eed5ff2989f938ef2cf81be9b448bd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Setup packages
(package-initialize)
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
@agarman
agarman / messagehub.md
Created Jun 27, 2017
MessageHub is Kafka
View messagehub.md

MessageHub is Kafka

Kafka/MessageHub is a distributed log. It scales writes via partitioning data. You can write a custom partitioner, though the DefaultPartitioner is often sufficient for most applications.

The DefaultPartitioner uses the message key to determine which partition to write a message. This allows control of where messages are written (important for ConsumerGroups…). This also means that Kafka is susceptible to hot partitions, where more messages are being routed to a partition than can be supported by the disk IO of the Kafka nodes hosting

View Key base.md

Keybase proof

I hereby claim:

  • I am agarman on github.
  • I am andrewgarman (https://keybase.io/andrewgarman) on keybase.
  • I have a public key ASBH0sx_Ks3r31MlPdoXUmBPdU9-2GepQcxSKoAC0qJyGgo

To claim this, I am signing this object: