Skip to content

Instantly share code, notes, and snippets.


Dan Farrell farrellit

View GitHub Profile
ayubmalik / gpg-encrypt.go
Last active Sep 22, 2021
Golang encrypt file using GPG openpgp. Use standard go libs.
View gpg-encrypt.go
package main
Example hack to encrypt a file using a GPG encryption key. Works with GPG v2.x.
The encrypted file e.g. /tmp/data.txt.gpg can then be decrypted using the standard command
gpg /tmp/data.txt.gpg
Assumes you have **created** an encryption key and exported armored version.
You have to read the armored key directly as Go cannot read pubring.kbx (yet).
felixgr / hidnative.c
Created May 27, 2017
Remove Caps Delay MBP15 Touchbar Late 2016
View hidnative.c
// Build:
// clang hidnative.c -o hidnative -framework IOKit -framework CoreFoundation
// Run:
// sudo ./hidnative
#include <IOKit/hid/IOHIDManager.h>
#include <IOKit/hid/IOHIDKeys.h>
#include <IOKit/IOKitLib.h>
#include <CoreFoundation/CoreFoundation.h>
bcatubig /
Last active Jun 12, 2020
Passwordless SSH Function - inject your ssh key into a server without actually typing your password in; lastpass does that for you!
# Works with Bash and ZSH
# Copy this into your ~/.bashrc or ~/.zshrc
# Install Lastpass cli --
# Install sshpass
# OSX: $ brew install
# Be sure to change <MYLASTPASS-PASSWORD-ID> in the install_keys() function
function install_keys (){
echo "INFO: No SSH Key on server. Grabbing password from lastpass"
export SSHPASS=$(lpass show <MYLASTPASS-PASSWORD-ID> --password)
/usr/local/bin/sshpass -e ssh-copy-id $1 || return 255
sivel /
Last active Nov 18, 2021
Ansible Binary Golang Module
go build helloworld.go
GOOS=windows GOARCH=amd64 go build helloworld.go
stephen-mw /
Last active Jun 15, 2020
List running EC2 instances with golang and aws-sdk-go

This is the beginning of hopefully many new posts with golang snippets from my blog. List all of your running (or pending) EC2 instances with Amazon's golang sdk.

For a list of filters or instance attributes consult the official documentation.

package main

import (
stuart-warren / simple-gpg-enc.go
Last active Sep 12, 2021
golang gpg/openpgp encryption/decryption example
View simple-gpg-enc.go
package main
import (
michaljemala / tls-client.go
Last active Oct 24, 2021
SSL Client Authentication Golang sample
View tls-client.go
package main
import (
kgrz / sinatra_regex_routing_one.rb
Last active Jul 3, 2017
Sinatra's regex routing and captures block example
View sinatra_regex_routing_one.rb
require "sinatra"
get %r{/([\w]+)/foo} do |bar|
puts bar
angstwad / test_split_jinja_ansible.yml
Created Mar 31, 2014
Splitting in Jinja2/Ansible
View test_split_jinja_ansible.yml
- name: Test split
hosts: localhost
gather_facts: false
- facter_blockdevices: "sda,sdb,sdc,sdd,sde,sdf"
- name: Let's split
debug: var=item
with_items: "facter_blockdevices.split(',')"
XVilka /
Last active Nov 30, 2021
True Colour (16 million colours) support in various terminal applications and terminals

Most updated version is always available at termstandard/colors repository.

Terminal Colors

There exists common confusion about terminal colors. This is what we have right now:

  • Plain ASCII
  • ANSI escape codes: 16 color codes with bold/italic and background
  • 256 color palette: 216 colors + 16 ANSI + 24 gray (colors are 24-bit)
  • 24-bit truecolor: "888" colors (aka 16 million)