Skip to content

Instantly share code, notes, and snippets.

View davewongillies's full-sized avatar

Dave Wongillies davewongillies

View GitHub Profile
@davewongillies
davewongillies / wakelock.service
Last active February 2, 2019 17:53
Lock screen after suspend with i3lock and systemd
# /etc/systemd/system/wakelock.service
[Unit]
Description=Lock the screen on resume from suspend
Before=sleep.target suspend.target
[Service]
User=daveg
Type=forking
Environment=DISPLAY=:0
@davewongillies
davewongillies / aws_config.fish
Last active July 22, 2021 11:30 — forked from mbainter/aws_config.fish
Fish shell function to set your AWS credentials with MFA
function aws_config
if not fgrep -q "[$argv]" ~/.aws/credentials
echo "Please specify a valid profile."
else
set token_expired false
if test $AWS_SESSION_EXPIRY
set now (date +%s)
# WARNING: this date command only works with GNU date
@davewongillies
davewongillies / aws_config.fish
Created August 30, 2017 20:59 — forked from mbainter/aws_config.fish
Fish shell function to set your AWS credentials with MFA for use with Terraform
function aws_config
if not fgrep -q "[$argv]" ~/.aws/credentials
echo "Please specify a valid profile."
else
set -e AWS_ACCESS_KEY
set -e AWS_SECRET_KEY
set -g -x ATLAS_TOKEN (awk "/\[$argv\]/,/^\$/ { if (\$1 == \"atlas_token\") { print \$3 }}" ~/.aws/credentials)
set account (awk "/\[$argv\]/,/^\$/ { if (\$1 == \"account_id\") { print \$3 }}" ~/.aws/credentials)
set username (awk "/\[$argv\]/,/^\$/ { if (\$1 == \"username\") { print \$3 }}" ~/.aws/credentials)
set mfarn "arn:aws:iam::$account:mfa/$username"
@davewongillies
davewongillies / .ctags
Last active May 18, 2017 04:22 — forked from trlinkin/ctags
Ctags and vim-tagbar matching for Puppet Manifests - Based on http://comments.gmane.org/gmane.comp.sysutils.puppet.user/6152
# In your ~/.ctags
-h pp
--langdef=puppet
--langmap=puppet:.pp
--regex-puppet=/^[[:space:]]*class[[:space:]]*([a-z][a-zA-Z0-9_:\-]+)/\1/c,class/
--regex-puppet=/^[[:space:]]*stage[[:space:]]*([a-zA-Z0-9_:\-]+)/\1/t,stage/
--regex-puppet=/^[[:space:]]*site[[:space:]]*([a-zA-Z0-9_\-]+)/\1/s,site/
--regex-puppet=/^[[:space:]]*node[[:space:]]*[\'|\"]*([a-zA-Z0-9_\.\-]+)[\'|\"]*/\1/n,node/
--regex-puppet=/^[[:space:]]*define[[:space]]*([a-z][a-zA-Z0-9_:\-]+)/\1/d,definition/
@davewongillies
davewongillies / recipe.rb
Created April 22, 2016 11:13 — forked from mlafeldt/recipe.rb
Package Go tools with fpm-cookery (automatically uses godep dependencies if present)
class ChefRunner < FPM::Cookery::Recipe
GOPACKAGE = "github.com/mlafeldt/chef-runner"
name "chef-runner"
version "0.8.0"
revision 1
source "https://#{GOPACKAGE}/archive/v#{version}.tar.gz"
sha256 "a7de23f989f8353ecf838b551a8ceff09b83c8aeff2553b2c31d57615f8fcc53"
description "The fastest way to run Chef cookbooks"
@davewongillies
davewongillies / tmux.md
Created April 22, 2016 11:09 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

<!-- note that this requires the rabbitmq management plugin -->
<!-- also requires collectd 5.1 with curl_json plugin support -->
<Plugin curl_json>
<URL "http://localhost:55672/api/overview">
Instance "rabbitmq_overview"
User "guest"
Password "guest"
<Key "message_stats/publish">
Type "counter"
</Key>
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
user haproxy
group haproxy
daemon
listen rabbitmq 0.0.0.0:5672
mode tcp

What do Etcd, Consul, and Zookeeper do?

  • Service Registration:
    • Host, port number, and sometimes authentication credentials, protocols, versions numbers, and/or environment details.
  • Service Discovery:
    • Ability for client application to query the central registry to learn of service location.
  • Consistent and durable general-purpose K/V store across distributed system.
    • Some solutions support this better than others.
    • Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
  • Centralized locking can be based on this K/V store.
@davewongillies
davewongillies / gist:8697163
Last active July 14, 2019 04:54 — forked from pfreixes/gist:3187511
/etc/bash_completion.d/supervisorctl
# pfreixes, 2012-07-27
# Add to /etc/bash_completion.d/supervisorctl
_supervisor()
{
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"