Skip to content

Instantly share code, notes, and snippets.

@vancluever
vancluever / verify-sums.txt
Last active November 8, 2015 17:30
Verify files (sums, GPG, etc)
# Verify GPG signature - see https://www.gnupg.org/gph/en/manual/x135.html
gpg --verify doc.sig doc
# Verify SHA1 sum (if you have file)
shasum -c SIGFILE
# Verify SHA1 sum (you don't have file)
echo "SUM FILE" | shasum -c
# possible bash function for the above
shaverify() {
echo "$1 $2" | shasum -c
}
@vancluever
vancluever / gpg-import-keys.txt
Last active November 8, 2015 17:31
GPG key stuff and trust
# GPG requires signature verification for a number of reasons.
# These all require you to have the public key of the signatory,
# which are generally distributed a couple of ways:
# * Via the web (ie: public key block directly on a web page)
# * Thru GPG's public keyserver
#
# The following page has some info on public keyservers:
# https://en.wikipedia.org/wiki/Key_server_(cryptographic)
#
# So this basically leaves you with two ways to import a GPG
@vancluever
vancluever / arrayindex_rubocop_gotcha.rb
Last active November 8, 2015 17:31
Array#index - better (and rubocop detectable) single-line conditional block structuring
# Rubocop (https://github.com/bbatsov/rubocop) is pretty awesome, and
# should be a part of every rubyist's toolkit. Not only do you get basic
# syntax checking so that you know that your code actually runs, you get a
# ton of linting and style rules that will make your code more readable and
# help you avoid ambigutity issues that may lead you to do things that you
# didn't intend to do.
#
# One such useful lint rule is Lint::AssignmentInCondition, which allows one
# to avoid the classical "=" in a conditional when you meant "==", as this is
# valid ruby and will result in an assignment, which is probably not what you
@vancluever
vancluever / aws-instance-region-az.sh
Last active May 15, 2018 15:35
AWS region/availability zone one-liners (from running instance)
# One can get the availability zone easily from within an AWS EC2 instance:
AVAILABILITY_ZONE=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone`
echo $AVAILABILITY_ZONE
# Take that a step further, and you can get the region easily by just chopping
# the last character off.
REGION=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed -e 's/.$//g'`
echo $REGION
@vancluever
vancluever / multiarraysort.go
Created December 10, 2015 21:48
Go: Sort an array of interfaces so that strings are on top
// This is a very basic demonstration of how to implement sort.Interface
// to do some custom sorting. Here, a slice of interfaces
// (ints and strings) are sorted so that the strings are on top.
// There is no other sorting of the elements, but the example
// provides a layout that can be used to implement more complex sorting.
package main
import "fmt"
import "sort"
@vancluever
vancluever / gnome-tweaks.txt
Last active December 28, 2015 06:36
GNOME 3 post-install tweaks
I'm using the following tweaks on GNOME 3 to try and get things a bit sane.
I've always hated the bloat, but it can be a good DE with a bit of elbow
grease. Honestly, Ubuntu looks better, and I might go back to it.
Anyway:
* Font improvments: https://ask.fedoraproject.org/en/question/64130/how-to-improve-font-rendering-in-gnome-shell/
* Ensure you tweak your mouse (see http://www.x.org/wiki/Development/Documentation/PointerAcceleration/ and https://wiki.archlinux.org/index.php/Mouse_acceleration)
* Turn on the dark theme (should be pre-installed)
* Disable workspaces (use tweak tool to select manual workspaces and set count to 1)
@vancluever
vancluever / gnome-tracker-disable.md
Last active May 2, 2024 16:26
GNOME Tracker Disable

Disabling GNOME Tracker and Other Info

GNOME's tracker is a CPU and privacy hog. There's a pretty good case as to why it's neither useful nor necessary here: http://lduros.net/posts/tracker-sucks-thanks-tracker/

After discovering it chowing 2 cores, I decided to go about disabling it.

Directories

@vancluever
vancluever / amifind.sh
Created January 26, 2016 08:05
Find the most recent Ubuntu AMI using aws-cli (or any other AMI for that matter)
#!/bin/sh
# Use AWS CLI to get the most recent version of an AMI that
# matches certain criteria. Has obvious uses. Made possible via
# --query, --output text, and the fact that RFC3339 datetime
# fields are easily sortable.
export AWS_DEFAULT_REGION=us-east-1
aws ec2 describe-images \
2016/05/16 13:52:05 [INFO] Terraform version: 0.7.0 dev 6bcd95547632044042761123dbfa2d88b85591c9
2016/05/16 13:52:05 [DEBUG] Detected home directory from env var: **REDACTED**
2016/05/16 13:52:05 [DEBUG] Detected home directory from env var: **REDACTED**
2016/05/16 13:52:05 [DEBUG] Attempting to open CLI config file: **REDACTED**/.terraformrc
2016/05/16 13:52:05 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2016/05/16 13:52:05 [DEBUG] Detected home directory from env var: **REDACTED**
2016/05/16 13:52:05 [WARN] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2016/05/16 13:52:05 [DEBUG] plugin: waiting for all plugin processes to complete...
Failed to read state: Unknown refresh result: Local and remote state conflict, manual resolution required
2016/05/16 19:25:58 [ERROR] root.example_asg_module: eval: *terraform.EvalInterpolate, err: 1:3: unknown variable accessed: var.public_network_addresses in:
${var.public_network_addresses}
--
2016/05/16 19:25:58 [ERROR] root.example_asg_module: eval: *terraform.EvalSequence, err: 1:3: unknown variable accessed: var.public_network_addresses in:
${var.public_network_addresses}
--
2016/05/16 19:25:58 [ERROR] root.example_asg_module: eval: *terraform.EvalInterpolate, err: 1:3: unknown variable accessed: var.listener_port in: