Skip to content

Instantly share code, notes, and snippets.

@jadametz
jadametz / git-rename-default-branch.sh
Created November 29, 2020 19:58
Git rename default branch
git branch -m master main
git push -u origin main
# https://github.com/<org>/<repo>/settings/branches
# update default branch
git branch -D master
git push origin --delete master
@jadametz
jadametz / do-update.sh
Created May 25, 2019 03:03
Updates ~/.kube/config for a Digital Ocean K8s cluster
#!/usr/bin/env bash
# export DO_TOKEN=foo
# export K8S_CLUSTER_ID=bar
if [[ -z "$DO_TOKEN" ]] || [[ -z "$K8S_CLUSTER_ID" ]]; then
echo "DO_TOKEN and K8S_CLUSTER_ID must be set" 1>&2
exit 1
fi
echo "Updating DigitalOcean K8s config file..."
@jadametz
jadametz / k8s_iterm2_user_vars.sh
Last active November 23, 2021 09:51
iTerm2 User Vars for setting Kubernetes Context and Namespace badges
############################## Installation Instructions ##############################
#
# 1. brew update && brew install jq yq
# 2. Click iTerm2 > Install Shell Integration
# 3. Put `iterm2_print_user_vars` function in .bashrc or equivalent
# 4. Edit your iTerm2 profile(s) to have something like `\(user.kctx)\n\(user.kns)\n` in the "Badge" field
#
# Note: The important part of the badge is the user variables. Outside of those you can
# customize with plaintext, line returns, etc.
#
[03:35 PM]~/Desktop ➭ docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.

Ordered List Example

  1. This is
  • an ordered
  • list
{
"editor.fontSize": 14,
"explorer.openEditors.visible": 0,
"editor.minimap.enabled": false,
"editor.rulers": [120],
"files.autoSave": "onFocusChange",
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/tmp": true,
@jadametz
jadametz / spinner.go
Created September 29, 2017 06:07
CLI spinner for Golang
func spinner(message string) {
// go func() {
for {
for _, r := range `-\|/` {
fmt.Printf("\r%s%s %c%s", message, "\x1b[92m", r, "\x1b[39m")
time.Sleep(time.Millisecond * 100)
}
}
// }()
}
# Here's that framework we talked about!
# It's perfect for ephemeral build servers.
# Why install Serverspec everywhere?
# Use a container to test your container(s)!
$ docker run --rm --name integration-test \
➭ -v /var/run/docker.sock:/var/run/docker.sock \
➭ -v $(pwd):/test \
➭ -w /test \
➭ jadametz/serverspec \
~/.../docker-serverspec ➭ git diff Dockerfile
@@ -6,3 +6,6 @@ RUN apk add --update --no-cache build-base
COPY Gemfile Gemfile.lock ./
RUN bundle install
+ENTRYPOINT ["rspec"]
+CMD ["-h"]
+
~/.../docker-serverspec ➭ bundle exec rspec
~/.../docker-serverspec ➭ git diff spec/Dockerfile_spec.rb
@@ -39,4 +39,12 @@ describe "Dockerfile" do
it { should be_installed.by('gem') }
end
end
+
+ it "should execute rspec" do
+ expect(@image.json["Config"]["Entrypoint"][0]).to eq("rspec")
+ end
+