Skip to content

Instantly share code, notes, and snippets.

View farrellit's full-sized avatar

Dan Farrell farrellit

View GitHub Profile
@kgrz
kgrz / sinatra_regex_routing_one.rb
Last active July 3, 2017 18:37
Sinatra's regex routing and captures block example
require "sinatra"
get %r{/([\w]+)/foo} do |bar|
puts bar
end
@angstwad
angstwad / test_split_jinja_ansible.yml
Created March 31, 2014 14:24
Splitting in Jinja2/Ansible
---
- 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(',')"
@arturovm
arturovm / GAEGoMap.go
Created December 8, 2012 21:31
This is a re-implementation of the GAE Go runtime Map type.
package main
import (
"reflect"
"appengine"
"appengine/datastore"
)
// define Map
@felixgr
felixgr / hidnative.c
Created May 27, 2017 07:37
Remove Caps Delay MBP15 Touchbar Late 2016
// 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 June 12, 2020 03:25
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 -- 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
@stephen-mw
stephen-mw / list_ec2_instances.md
Last active April 18, 2022 16:07
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 (
	"fmt"
	"github.com/awslabs/aws-sdk-go/aws"
@yoggy
yoggy / uuid_test.c
Created January 8, 2013 11:19
libuuid sample program
//
// libuuid sample program
//
// library install for debian
// $ sudo apt-get install uuid-dev
//
// compile
// $ gcc uuid_test.c -luuid -o uuid_test
//
#include <stdio.h>
@ayubmalik
ayubmalik / gpg-encrypt.go
Last active March 3, 2023 08:49
Golang encrypt file using GPG openpgp. Use standard go libs.
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).
@sivel
sivel / go-build.sh
Last active September 28, 2023 18:40
Ansible Binary Golang Module
go build helloworld.go
GOOS=windows GOARCH=amd64 go build helloworld.go
@stuart-warren
stuart-warren / simple-gpg-enc.go
Last active October 11, 2023 01:21
golang gpg/openpgp encryption/decryption example
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"encoding/base64"
"io/ioutil"
"log"
"os"
)