Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Farrell farrellit

View GitHub Profile
@ayubmalik
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
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
bcatubig / ssh.sh
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!
View ssh.sh
# Works with Bash and ZSH
# Copy this into your ~/.bashrc or ~/.zshrc
# Install Lastpass cli -- https://github.com/lastpass/lastpass-cli
# Install sshpass
# OSX: $ brew install http://git.io/sshpass.rb
# 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
sivel / go-build.sh
Last active Nov 18, 2021
Ansible Binary Golang Module
View go-build.sh
go build helloworld.go
GOOS=windows GOARCH=amd64 go build helloworld.go
@stephen-mw
stephen-mw / list_ec2_instances.md
Last active Jun 15, 2020
List running EC2 instances with golang and aws-sdk-go
View list_ec2_instances.md

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 (
	"fmt"
	"github.com/awslabs/aws-sdk-go/aws"
@stuart-warren
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 (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"encoding/base64"
"io/ioutil"
"log"
"os"
)
@michaljemala
michaljemala / tls-client.go
Last active Oct 24, 2021
SSL Client Authentication Golang sample
View tls-client.go
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io/ioutil"
"log"
"net/http"
)
@kgrz
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
end
@angstwad
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
vars:
- facter_blockdevices: "sda,sdb,sdc,sdd,sde,sdf"
tasks:
- name: Let's split
debug: var=item
with_items: "facter_blockdevices.split(',')"
@XVilka
XVilka / TrueColour.md
Last active Nov 30, 2021
True Colour (16 million colours) support in various terminal applications and terminals
View TrueColour.md

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)