Skip to content

Instantly share code, notes, and snippets.

@ayubmalik
ayubmalik / nvim-cheat-sheet.md
Last active July 11, 2023 19:53
Neovim Cheat Sheet

Neovim cheat sheet

argdo

run substitute on all args

:set hidden
:argdo %s/\a/*/ge

populate argslist with *.txt :args *.txt or command args `ag -g *.txt`

revert all unsaved :argdo edit!

@ayubmalik
ayubmalik / main.go
Last active December 4, 2023 18:47
Golang AWS SSO login from the command line. Will start a new AWS SSO session and retrieve valid access token.
package main
import (
"context"
"log"
"strings"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
@ayubmalik
ayubmalik / cipherstreams.go
Last active September 27, 2023 19:43
Go (golang) crypto sample using cipher.StreamWriter and cipher.StreamReader to wrap io.Writer and io.Reader with AES encryption.
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/md5"
"crypto/rand"
"errors"
"fmt"
"io"
@ayubmalik
ayubmalik / docker-compose.yaml
Last active March 5, 2024 17:24
Kafka REST proxy with Docker compose. Everything required to get Confluent REST proxy docker images working so you can post messages to consumers with curl etc
---
version: '3.5'
networks:
default:
name: kafka-net
services:
zookeeper:
image: confluentinc/cp-zookeeper:4.1.1
hostname: zookeeper
@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).
@ayubmalik
ayubmalik / site.yml
Created August 14, 2017 16:07
sample site.yml
---
- name: Install WordPress, MySQL, Nginx, and PHP-FPM
hosts: all
remote_user: root
# remote_user: user
# become: yes
# become_method: sudo
roles:
- common
@ayubmalik
ayubmalik / es
Last active January 27, 2024 19:30
Bash script using Google Translate API to translate English to Spanish using curl and sed only. You can change the 'sl' and 'tl' (source/target language) query parameter to whatever you want. Optionally if you create a symlink and call it 'en' it will translate back to spanish
#!/bin/bash
# uncomment and fix with appropriate values if you are behind a proxy
#export https_proxy='http://localhost:3128'
sl=en
tl=$(basename $0)
if [[ "${tl}" != "es" ]]; then
sl=es
fi
base_url="https://translate.googleapis.com/translate_a/single?client=gtx&sl=${sl}&tl=${tl}&dt=t&q="
ua='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'