Skip to content

Instantly share code, notes, and snippets.

@dpkirchner
dpkirchner / .bashrc
Last active December 14, 2016 18:01 — forked from henrik/.bashrc
Got tired of leaving stashes lying around.
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
# username@Machine ~/dev/dir[master*] (stashes 2)$ # dirty working dir plus there are some stashes
function parse_git_dirty {
[ ! -z "$(git status --porcelain 2> /dev/null)" ] && echo "*"
}
# http://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch
@dpkirchner
dpkirchner / playbook.yaml
Created October 2, 2014 13:27
Playbook that demonstrates ssh pipelining not working as expected
- name: Make a host list
hosts: localhost
gather_facts: no
connection: local
tasks:
- name: add host
add_host: hostname=1.2.3.4 groupname=foo
- name: Do the do
@dpkirchner
dpkirchner / verbose_output.txt
Created October 2, 2014 13:31
Verbose output of the Ansible-not-pipelining-ssh work
# output from playbook: https://gist.github.com/dpkirchner/c5092daa208df081fc25
creating host via 'add_host': hostname=1.2.3.4
added host to group via add_host module: foo
ok: [localhost] => {"new_groups": ["foo"], "new_host": "1.2.3.4"}
PLAY [Do the do] **************************************************************
TASK: [thing one] *************************************************************
<1.2.3.4> ESTABLISH CONNECTION FOR USER: dpk
@dpkirchner
dpkirchner / gist:8682a21130d8a5de313793b8bdb8d16a
Created October 23, 2017 16:19
how to vertically center a TextInputLayout's TextInputEditText without disabling hints
TextInputLayout adds a top margin to the TextInputEditText to reserve space for the collapsing hint.
That effectively breaks vertical centering. This code simply copies the newly set top margin to the
bottom.
(Note that this isn't fully tested with all languages. The hint height is set based on font
characteristics. If you have a font with really large descenders and small ascenders you may
need to make changes to this code.
For reference, see TextInputLayout's updateInputLayoutMargins)
2019/08/05 12:23:27 [INFO] Terraform version: 0.12.6
2019/08/05 12:23:27 [INFO] Go runtime version: go1.12.4
2019/08/05 12:23:27 [INFO] CLI args: []string{"/Users/dpk/bin/terraform", "import", "google_compute_router_nat.nat-1", "nat-1"}
2019/08/05 12:23:27 [DEBUG] Attempting to open CLI config file: /Users/dpk/.terraformrc
2019/08/05 12:23:27 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2019/08/05 12:23:27 [INFO] CLI command args: []string{"import", "google_compute_router_nat.nat-1", "nat-1"}
2019/08/05 12:23:27 [DEBUG] New state was assigned lineage "7cc156fb-a7dd-448a-5742-6fe585fa0f16"
2019/08/05 12:23:27 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)
2019/08/05 12:23:27 [TRACE] Meta.Backend: instantiated backend of type <nil>
2019/08/05 12:23:27 [DEBUG] checking for provider in "."
node_modules
build
@dpkirchner
dpkirchner / misc.sh
Created June 3, 2020 22:00
dgraph, using groupby to report votes
node recreate.js
node vote.js -p 'What do?' -c 'Candidate A' -v 'Voter B'
node vote.js -p 'What do?' -c 'Candidate A' -v 'Voter D'
node vote.js -p 'What do?' -c 'Candidate C' -v 'Voter D'
node vote.js -p 'What do?' -c 'Candidate C' -v 'Voter E'
node vote.js -p 'What do?' -c 'Candidate C' -v 'Voter A'
node votes.js -p 'What do?'
# output:
# Candidate A: 1
@dpkirchner
dpkirchner / .dockerignore
Last active July 17, 2020 21:58
Relay Github webhook to a Google IAP-protected service
Dockerfile
node_modules
npm-debug.log
```
$ TF_LOG=trace terraform apply
2020/12/18 10:46:15 [INFO] Terraform version: 0.13.5
2020/12/18 10:46:15 [INFO] Go runtime version: go1.14.10
2020/12/18 10:46:15 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply"}
2020/12/18 10:46:15 [DEBUG] Attempting to open CLI config file: /Users/dpk/.terraformrc
2020/12/18 10:46:15 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/12/18 10:46:15 [DEBUG] checking for credentials in "/Users/dpk/.terraform.d/plugins"
2020/12/18 10:46:15 [DEBUG] checking for credentials in "/Users/dpk/.terraform.d/plugins/darwin_amd64"
2020/12/18 10:46:15 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
go: downloading github.com/grafana/loki v1.6.1
go: downloading github.com/prometheus/common v0.10.0
go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: downloading github.com/gorilla/websocket v1.4.0
go: downloading github.com/json-iterator/go v1.1.10
go: downloading github.com/cortexproject/cortex v1.2.1-0.20200803161316-7014ff11ed70
go: downloading github.com/fatih/color v1.9.0
go: downloading github.com/prometheus/client_golang v1.7.1
go: downloading github.com/prometheus/prometheus v1.8.2-0.20200727090838-6f296594a852
go: downloading github.com/weaveworks/common v0.0.0-20200625145055-4b1847531bc9