Skip to content

Instantly share code, notes, and snippets.

Avatar

Amit Bakshi ambakshi

View GitHub Profile
View secure-aes-gen.sh
#!/bin/bash
#
# Create a variable `$key` for use in powershell as a AES encyrption key
# constant with (ConvertFrom-SecureString)[https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/convertfrom-securestring?view=powershell-7.2)]
#
# param: $1 secret key (optional, default: secret)
# param: $2 cipher (optional, default: aes-256-cbc)
# output: An byte array (in decimals), the size of the encryption key (AES256 = 32 bytes)
genkey() {
@ambakshi
ambakshi / parse-opts.sh
Last active Jan 10, 2021
parse-opts.sh
View parse-opts.sh
#!/usr/bin/env bash
#
# MIT Licensensed
# Amit Bakshi Jan 2021
# Generic option parser.
# Usage:
# parse_opts --valid-args 'foo bar link' -- --with-foo=yes --bar=fizz --no-link
#
# Yields:
@ambakshi
ambakshi / ssh-keygen.service
Last active Aug 6, 2020 — forked from TimJDFletcher/ssh-keygen.service
Systemd unit to generate missing ssh keys on boot
View ssh-keygen.service
[Unit]
Description=Generate sshd keys
Before=ssh.service
ConditionPathExists=!/etc/ssh/ssh_host_rsa_key
[Service]
Type=oneshot
ExecStart=/usr/bin/ssh-keygen -A
RemainAfterExit=true
StandardOutput=journal
@ambakshi
ambakshi / gcccpuopt.sh
Last active Aug 22, 2018
Determine set of best gcc optimization flags for the current host.
View gcccpuopt.sh
#!/bin/sh
# Print the gcc cpu specific options tailored for the current CPU
# Author:
# http://www.pixelbeat.org/
# Notes:
# This script currently supports Linux,FreeBSD,Cygwin
# This script is x86 (32 bit) specific
# It should work on any gcc >= 2.95 at least
@ambakshi
ambakshi / osx-fix-home-and-end-keys.sh
Created Feb 20, 2018
Fixes the osx home/end keys so they work the way they do on Linux/Windows.
View osx-fix-home-and-end-keys.sh
#!/bin/sh
mkdir -p ~/Library/KeyBindings
cd ~/Library/KeyBindings
if test -e DefaultKeyBinding.dict; then
echo >&2 "WARNING: Skipping customizing key bindings. $(pwd)/DefaultKeyBinding.dict already exists"
exit 0
fi
cat > DefaultKeyBinding.dict <<'EOF'
{
@ambakshi
ambakshi / storeid_rpmdeb.go
Last active May 9, 2018
Simple store_id_program for squid. Build it, put it into /usr/lib64/squid/, and add "store_id_program /usr/lib64/squid/storeid_rpmdeb" to your squid.conf
View storeid_rpmdeb.go
package main
import (
"bufio"
"fmt"
"os"
"regexp"
"strings"
)
@ambakshi
ambakshi / letsencrypt.sh
Last active May 15, 2017
Obtain LE certs for multiple SANs
View letsencrypt.sh
#!/bin/bash
#
# Get LetsEncrypt SSL certs
#
# Usage:
# letsencrypt.sh host1.domain.com host2.domain.com ...
#
# You must have your git config user.email set correctly
#
# The way this script works is that you register a wildcard DNS
@ambakshi
ambakshi / g++-5.sh
Created Apr 1, 2016
Install g++ 5.x on Ubuntu Trusty (14.04)
View g++-5.sh
#!/bin/bash
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common
add-apt-repository ppa:ubuntu-toolchain-r/test
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y g++-5 gcc-5
@ambakshi
ambakshi / xcabakshimbp.pub
Created Apr 1, 2016
abakshi@xcabakshimbp.local
View xcabakshimbp.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDeFQ/NE6ZgqhUaj+lyc5jbEJkkwWjDxSddXOhFDs5e4Mni06m+vrI4rNoZ4mdP3l2p2rECBgPjE59SYbswUlzJWKhdBWLK0BH+rKn5fXjH/2VbE4YrVJaHONjhsLqLNKfvD7C5CC6T7hcwafwNwDjVblmXr/VydIhETnLnwnRZTXA0fTvd/W15gwpMQ+XY/cpTLaAH00oX26nfZRJCdKcVnPIa+OwBD3t2R3tzGdsevvprVCg80Tmyy6LYqLF4dLZVYz/o8G1QNgyjmvhIxyEYFQscT9LL70qfKz/UAUQTdiYr8Z73OXAzDXqNN46PvHSm35W3kQzizsd4KQWEom8J abakshi@xcabakshimbp.local
@ambakshi
ambakshi / debian-jdk8-install.sh
Last active May 27, 2016
Install Oracle JDK 8 on a Debian based system.
View debian-jdk8-install.sh
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get install -yq software-properties-common apt-utils
add-apt-repository ppa:webupd8team/java -y && apt-get update && \
echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C2518248EEA14886 && \
apt-get install -y --no-install-recommends oracle-java8-installer