Skip to content

Instantly share code, notes, and snippets.

Avatar

Amit Bakshi ambakshi

View GitHub Profile
@ambakshi
ambakshi / gitconfig
Last active January 23, 2023 18:10
my gitconfig
View gitconfig
; vim:set filetype=dosini:
[alias]
fap = fetch --all --prune
sb = status -sb
st = status -s
co = checkout
br = branch
bv = branch -avv
rv = remote -v
@ambakshi
ambakshi / bash_aliases
Last active January 5, 2023 20:59
Bootstrap vim and tmux
View bash_aliases
#!/bin/bash
# shellcheck disable=SC1073,SC1007,SC1072,SC1090,SC1091,SC2015
if [[ $UID -ne 0 ]]; then
if ! type -t __git_ps1 >/dev/null 2>&1 && test -e /usr/share/git-core/contrib/completion/git-prompt.sh; then
. /usr/share/git-core/contrib/completion/git-prompt.sh
fi
if type -t __git_ps1 >/dev/null 2>&1; then
PS1='[\[\033[32m\]\u@\h\[\033[00m\] \[\033[36m\]\W\[\033[31m\]$(__git_ps1)\[\033[00m\]] \$ '
@ambakshi
ambakshi / Autounattend.xml
Last active December 21, 2022 23:54
Diskpart script to create uefi partitions. Via https://technet.microsoft.com/en-us/library/Hh825686.aspx.
View Autounattend.xml
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SetupUILanguage>
<UILanguage>en-US</UILanguage>
</SetupUILanguage>
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
@ambakshi
ambakshi / fork.cpp
Last active October 30, 2022 06:21
View fork.cpp
//This is all pretty much from the ReactOS project...
#pragma once
#define _WIN32_WINNT 0x0502 // Change this to the appropriate value to target other versions of Windows.
#define DPRINT(...)
#define DPRINT1(...)
#include <stdlib.h>
#include <tchar.h>
@ambakshi
ambakshi / make-gcc
Created January 20, 2011 06:52
Build gcc from source
View make-gcc
#!/bin/sh
GCC_VER=4.5.2
wget -O /tmp/gcc-$GCC_VER.tar.bz2 ftp://ftp.gnu.org/gnu/gcc/gcc-$GCC_VER/gcc-$GCC_VER.tar.bz2
tar jxvf /tmp/gcc-$GCC_VER.tar.bz2
cd gcc-$GCC_VER
mkdir -p $HOME/opt/gcc/gcc-$GCC_VER
./configure --prefix=$HOME/opt/gcc/gcc-$GCC_VER --with-mpc
CPUCOUNT=`grep processor /proc/cpuinfo | wc -l`
make -j$CPUCOUNT
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 / g++-5.sh
Created April 1, 2016 11:57
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 / iam-assume-role.sh
Last active October 25, 2021 15:50
Assume an IAM role. An interesting way of doing IAM roles is to give the instance permissions to assume another role, but no actual permissions by default. I got this idea while setting up security monkey: http://securitymonkey.readthedocs.org/en/latest/quickstart1.html#setup-iam-roles.
View iam-assume-role.sh
#!/bin/bash
#
# Assume the given role, and print out a set of environment variables
# for use with aws cli.
#
# To use:
#
# $ eval $(./iam-assume-role.sh)
#
@ambakshi
ambakshi / route53-asg-rrdns.sh
Last active July 25, 2021 05:39
Add all instances in an autoscaling group to an equivalently named dns entry.
View route53-asg-rrdns.sh
#!/bin/bash
#
# Get all IPs from an autoscale group and update set the local ip as
# equal weight A entries (round robin dns). Takes autoscale group as
# parameter.
#
# Amit Bakshi
# 10/21/2014
#
@ambakshi
ambakshi / docker-direct-lvm.sh
Last active January 14, 2021 13:15
docker-direct-lvm
View docker-direct-lvm.sh
#!/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