Skip to content

Instantly share code, notes, and snippets.

View ambakshi's full-sized avatar

Amit Bakshi ambakshi

View GitHub Profile
@ambakshi
ambakshi / docker-direct-lvm.sh
Last active January 14, 2021 13:15
docker-direct-lvm
#!/bin/bash
set -e
## striping seems to break docker
#STRIPE="-i2 -I64"
#DEVS="/dev/xvdf /dev/xvdg"
DEVS="$1"
if [ -z "$DEVS" ]; then
echo >&2 "Specify which block devices to use"
exit 1
@ambakshi
ambakshi / parse-opts.sh
Last active January 10, 2021 10:31
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 / cloud-init.sh
Last active December 11, 2020 02:52
Amazon Linux cloud-init script
#!/bin/bash
#
# Amazon Linux cloud-init script
#
# Amit Bakshi
# 10/2014
#
if [ `id -u` -ne 0 ]; then
sudo exec /bin/bash -x "$0" "$@"
fi
@ambakshi
ambakshi / ssh-keygen.service
Last active August 6, 2020 00:52 — forked from TimJDFletcher/ssh-keygen.service
Systemd unit to generate missing ssh keys on boot
[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 / storeid_rpmdeb.go
Last active May 9, 2018 14:16
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
package main
import (
"bufio"
"fmt"
"os"
"regexp"
"strings"
)
@ambakshi
ambakshi / osx-fix-home-and-end-keys.sh
Created February 20, 2018 13:51
Fixes the osx home/end keys so they work the way they do on Linux/Windows.
#!/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 / vmrun.sh
Last active February 14, 2018 16:36
vmrun wrapper to run a command over vix and get the stdout/stderr
#!/bin/bash
#
# vmrun.sh
#
# Wrapper around vmrun to make running a shell command
# or script in the path easier. Outputs stdout/stderr
# from the command in the guest and exits with the
# same return code.
#
# Amit Bakshi
@ambakshi
ambakshi / vimrc.basic
Last active January 6, 2018 11:27
Minimal/basic vimrc
"
" Original: https://gist.github.com/ambakshi/9334557/raw/vimrc.basic
" By Amit Bakshi
"
set nocompatible
filetype plugin indent on
set modeline
set incsearch hlsearch ignorecase smartcase
set expandtab smarttab shiftwidth=4 shiftround softtabstop=4 tabstop=4
set smartindent autoindent copyindent cindent
@ambakshi
ambakshi / letsencrypt.sh
Last active May 15, 2017 21:39
Obtain LE certs for multiple SANs
#!/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 / aws-sdb-example.md
Last active April 24, 2017 14:42
Accessing sdb from the awscli
$ aws configure set preview.sdb true
$ aws sdb create-domain skv
$ aws sdb put-attributes --domain-name skv --item-name ami_idx --attributes Name=app-mwios-asg,Value=1
$ aws sdb put-attributes --domain-name skv --item-name ami_idx --attributes Name=app-ccand-asg,Value=5

$ aws sdb get-attributes --domain-name skv --item-name ami_idx --attribute-names app-mwios-asg
{
"Attributes": [

{