Skip to content

Instantly share code, notes, and snippets.

View arpat's full-sized avatar

Arun Patel arpat

View GitHub Profile
@arpat
arpat / chrome-blaster.sh
Created October 25, 2018 10:26
Finds chrome renderer processes and ups their OOM kill score on Linux
#!/usr/bin/env bash
#
# finds chrome renderer processes and ups their OOM kill score on Linux
#
while read Line
do
while read -r MemUsed Pid
do
CmdLine=$(cat /proc/${Pid}/cmdline)
@arpat
arpat / kibana-curl.sh
Created October 11, 2017 11:46
CURL the kibana endpoint to query Elasticsearch
#!/bin/bash
#
## CURL the kibana endpoint
## Use the kibana dev console to validate query json
curl -i --insecure --user User:Password -XPOST \
--header "kbn-version: 5.6.0" \
'https://kibana.yourdomain/api/console/proxy?path=_search&method=POST' \
--data '{"query":{"match_all":{}}}'
@arpat
arpat / ls-aws-ami.sh
Last active April 28, 2020 19:11
List the ten latest ubuntu public images (AMI's) on AWS
# List the ten latest ubuntu public images on AWS
# Output similar to:
# 2017-09-26T16:18:51.000Z ubuntu/images/hvm-ssd/ubuntu-zesty-17.04-amd64-server-20170922 hvm True ami-5cc00825
# 2017-09-21T21:20:20.000Z ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20170919 hvm True ami-17d11e6e
# 2017-09-19T10:54:43.000Z ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-20170918 hvm True ami-e872bf91
# 2017-09-05T13:12:32.000Z ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-20170831 hvm True ami-01589c78
# ...etc
aws ec2 describe-images \
--filters Name=name,Values=ubuntu/images/hvm-ssd/ubuntu* \
@arpat
arpat / Dockerfile.snippet
Created May 11, 2017 13:22
Embed multi-line text inside Dockerfile
# Dockerfile snippet
RUN ( echo \
"This is a multiline\n\
file to be placed\n\
somewhere but needs\n\
to be visible inside\n\
the Dockerfile" \
> /tmp/this )

Keybase proof

I hereby claim:

  • I am arpat on github.
  • I am arpat (https://keybase.io/arpat) on keybase.
  • I have a public key whose fingerprint is B9E2 1740 9133 7F51 E018 92AF AB6A AA11 2F5B B3C2

To claim this, I am signing this object:

@arpat
arpat / mk1Gswapfile.sh
Created November 17, 2016 14:32
Make a swapfile on Linux of 1GB
#!/bin/bash
## blame: arunsmtp@gmail.com
## Make a 1G swapfile in CWD
SwapFile="~~SWAPFILE.$(date +%H%m%s%N | sha1sum | cut -c1-12)"
# fallocate -l 1G $SwapFile \ ## caused issue for f2fs
dd if=/dev/zero of="$SwapFile" bs=1024 count=1048576 \
&& chmod 600 $SwapFile \
&& mkswap $SwapFile \
@arpat
arpat / git.tnt
Created October 13, 2016 15:33
git command line tips and tricks
#!/bin/sh
# Blame: arunsmtp@gmail.com
# My version of github change git author script
# https://help.github.com/articles/changing-author-info/
if [ $# -eq 0 ]; then
echo "Usage: OLD_EMAIL CORRECT_NAME CORRECT_EMAIL"
echo "...and run from the toplevel."
exit 1
fi
Backup and restore omnibus-gitlab configuration
It is recommended to keep a copy of /etc/gitlab, or at least of /etc/gitlab/gitlab-secrets.json, in a safe place.
All configuration for omnibus-gitlab is stored in /etc/gitlab.
# Example backup command for /etc/gitlab:
# Create a time-stamped .tar file in the current directory.
# The .tar file will be readable only to root.
##sudo sh -c 'umask 0077; tar -cf $(date "+etc-gitlab-%s.tar") -C / etc/gitlab'
Creating an application backup
To create a backup of your repositories and GitLab metadata, follow the backup create documentation:
@arpat
arpat / k8s.tnt
Created June 23, 2016 09:25
Tips and tricks on the command line for kubernetes
#https://storage.googleapis.com/kubernetes-release/release/v1.2.4/bin/linux/amd64/kubectl ## Get official kubernetes binary
#https://storage.googleapis.com/kubernetes-release/release/v1.2.4/bin/darwin/amd64/kubectl ## Get official kubernetes binary
@arpat
arpat / comp-ssl-certs.sh
Last active May 16, 2016 10:03
Quick way to find matching ssl pub/priv key pairs.
#!/bin/bash
# Quick way to find matching ssl pub/priv key pairs.
# usage: ./comp-ssl-certs.sh mycertfiles*
CertFiles="$1"
for Files in $(ls $CertFiles)
do
#echo "ALL FILES "$Files
for Type in x509 rsa
do
Mod=$(openssl $Type -noout -modulus -in $Files 2>/dev/null) \