Skip to content

Instantly share code, notes, and snippets.

View nicerobot's full-sized avatar
๐Ÿค–
โ˜ฏ๏ธ โ˜ฎ๏ธ ๐Ÿถ ๐Ÿพ ๐Ÿ‘พ ๐ŸŽฎ ๐ŸŽผ ๐ŸŽถ ๐Ÿ•บ ๐ŸŽง ๐ŸŒป ๐ŸŒฑ ๐Ÿž ๐ŸŒŠ ๐ŸŒ” ๐ŸŒŽ

nicerobot

๐Ÿค–
โ˜ฏ๏ธ โ˜ฎ๏ธ ๐Ÿถ ๐Ÿพ ๐Ÿ‘พ ๐ŸŽฎ ๐ŸŽผ ๐ŸŽถ ๐Ÿ•บ ๐ŸŽง ๐ŸŒป ๐ŸŒฑ ๐Ÿž ๐ŸŒŠ ๐ŸŒ” ๐ŸŒŽ
View GitHub Profile
@matryer
matryer / term_context.go
Last active March 10, 2022 05:23
Making Ctrl+C termination cancel the context.Context
func main() {
ctx := context.Background()
// trap Ctrl+C and call cancel on the context
ctx, cancel := context.WithCancel(ctx)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
defer func() {
signal.Stop(c)
@plinyar
plinyar / FirehoseTransformer.kt
Last active September 5, 2018 16:56
Sample AWS Kinesis Firehose lambda transformation in Java (Kotlin indeed)
import com.amazonaws.services.lambda.runtime.Context
import com.amazonaws.services.lambda.runtime.LambdaLogger
class FirehoseTransformer {
private lateinit var logger: LambdaLogger
fun handler(event: KinesisFirehoseEvent, context: Context): KinesisFirehoseResponse {
logger = context.getLogger()
logger.log("Lambda started. Got messages ${event.records.size}.")
@posener
posener / go-shebang-story.md
Last active April 23, 2026 00:03
Story: Writing Scripts with Go

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, Iโ€™ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion Iโ€™ll deep dive to scripts, shells, and shebangs. Finally, weโ€™ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.

@nicerobot
nicerobot / keybase.md
Created September 13, 2017 16:41
keybase.md

Keybase proof

I hereby claim:

  • I am nicerobot on github.
  • I am nicerobot (https://keybase.io/nicerobot) on keybase.
  • I have a public key whose fingerprint is 0C6F 8A92 78AA 679B C74F BD66 2C7A 5B8A 0CF4 9016

To claim this, I am signing this object:

@koop
koop / ensure-cert-macos.sh
Created November 28, 2017 20:27
Ensures a certificate is in the macOS system keychain.
#!/bin/bash
# Usage
# $ ./install-cert-macos.sh "/path/to/cert"
CERT_PATH="$1"
# First, grab the SHA-1 from the provided SSL cert.
CERT_SHA1=$(openssl x509 -in "$CERT_PATH" -sha1 -noout -fingerprint | cut -d "=" -f2 | sed "s/://g")
# Next, grab the SHA-1s of any standard.dev certs in the keychain.
# Don't return an error code if nothing is found.
@nicerobot
nicerobot / Dockerfile
Last active January 17, 2021 06:03
A Docker Multi-Stage Scratch Build for Go with binary compression using UPX and including SSL certificates.
FROM golang:1.9.2-alpine3.7 as build-env
RUN apk add --no-cache git build-base && \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apk add --no-cache upx=3.94-r0
ADD . /go/src/github.com/gomatic/app/
WORKDIR /go/src/github.com/gomatic/app
RUN go get -d ./ && \
CGO_ENABLED=0 GOOS=linux go build -o app -a -ldflags="-s -w" -installsuffix cgo && \
@m4t7e0
m4t7e0 / hosts
Last active June 30, 2019 18:12 — forked from consti/hosts
/etc/hosts to block shock sites etc.
# 20180201 Adobe Activation Added
# This hosts was an improved version of the file brought from Dan Pollock and can be found at
# http://someonewhocares.org/hosts/
# You are free to copy and distribute this file for non-commercial uses,
# as long the original URL and attribution is included.
#
# See below for acknowledgements.
# Please forward any additions, corrections by git comment
@cjus
cjus / .docker_aliases
Last active July 13, 2023 23:50
Docker aliases
#!/bin/sh
alias dm='docker-machine'
alias dmx='docker-machine ssh'
alias dk='docker'
alias dki='docker images'
alias dks='docker service'
alias dkrm='docker rm'
alias dkl='docker logs'
alias dklf='docker logs -f'
@nicerobot
nicerobot / tgzx
Last active August 9, 2019 04:13
Self-extracting, encrypted tarballs. Much simpler than https://www.linuxjournal.com/node/1005818
#!/usr/bin/env bash
tgzx() {
(( ${#} >= 2 )) || { echo 'usage: tgzx archive-file [files | directories]'; return 1; }
printf '#!/usr/bin/env bash\ntail -n+3 ${0} | openssl enc -aes-256-cbc -d -a | tar ${1:-xv}z; exit\n' >${1}
tar zc "${@:2}" | openssl enc -aes-256-cbc -a -salt >>${1} && chmod +x ${1}
}
@nicerobot
nicerobot / preamble.sh
Created October 24, 2018 02:27
Common Bash variables
#!/usr/bin/env bash
STARTD=${PWD}
SELFD=$(cd $(dirname ${0}) >/dev/null 2>&1; pwd)
SELF=$(basename ${0})
SELFN=$(basename ${SELFD})
SELFU=${SELF%.*}
SELFZ=${SELFD}/${SELF}
NOW=$(date +%Y%m%dt%H%M%S)
UNQ=${NOW}.${RANDOM}
LOGD=${SELFD}/${SELFU}.${UNQ}