Skip to content

Instantly share code, notes, and snippets.

View gburd's full-sized avatar

Greg Burd gburd

View GitHub Profile
@gburd
gburd / cat-chrome.sh
Created October 18, 2016 14:29
Ubuntu 16.06 - rc.local tricks/tips
# Ensure that Google Chrome's script terminates subprocesses (like 'cat') properly
( if ! grep -q 'trap \"trap - SIGTERM && kill -- -$$\" SIGINT SIGTERM EXIT' /opt/google/chrome/google-chrome
then
LINE=$(( $(awk '$0 ~ "exec 2" {print NR}' /opt/google/chrome/google-chrome) + 1))
/bin/ed /opt/google/chrome/google-chrome <<EOF
${LINE}i
trap "trap - SIGTERM && kill -- -\$\$" SIGINT SIGTERM EXIT
.
w
q
@gburd
gburd / sysctl.conf
Created April 29, 2016 14:44
sysctl
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#
#kernel.domainname = example.com
# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3
@gburd
gburd / configure-iptables.sh
Created April 29, 2016 14:32
iptables config
# Iptables Firewall configuration script
# Allows HTTP, HTTPS, SSH, SMTP
# SSH Port easy customization
# Allows Local Loopback
# Allows specific ICMP
# Allows DNS Query and Response
# Blocks bad source
# Blocks non local Loopback
# DOS Protection and reporting
# DOS SYN Flood
@gburd
gburd / llvm-update-alternatives
Last active August 8, 2019 02:08 — forked from RaymondKroon/llvm-update-alternatives
LLVM & clang alternatives
#!/usr/bin/env sh
sudo update-alternatives --install \
/usr/bin/llvm-config llvm-config /usr/bin/llvm-config-3.6 200 \
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-3.6 \
--slave /usr/bin/llvm-as llvm-as /usr/bin/llvm-as-3.6 \
--slave /usr/bin/llvm-bcanalyzer llvm-bcanalyzer /usr/bin/llvm-bcanalyzer-3.6 \
--slave /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-3.6 \
--slave /usr/bin/llvm-diff llvm-diff /usr/bin/llvm-diff-3.6 \
--slave /usr/bin/llvm-dis llvm-dis /usr/bin/llvm-dis-3.6 \
@gburd
gburd / update.sh
Created March 16, 2016 13:37
Joyent SDC update script
#!/bin/bash
confirm () {
# call with a prompt string or use a default
read -r -p "${1:-Would you like to continue? [y/N]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
crypto:start().
<<Mac:160/integer>> = crypto:hmac(sha, <<"hello">>, <<"world">>).
%% <<138,58,132,188,208,208,6,94,151,241,117,211,112,68,124,125,2,224,9,115>>
lists:flatten(io_lib:format("~40.16.0b", [Mac])).
%% "8a3a84bcd0d0065e97f175d370447c7d02e00973"
@gburd
gburd / lines.sh
Created February 25, 2016 20:25
One Liners:
# Set the local clock.
date -r$((16#`printf "\xb%-47.s"|nc -uw1 time.nist.gov 123|xxd -s40 -l4 -p`-2208988800))
@gburd
gburd / notes.txt
Created February 25, 2016 20:21
ulimit file descriptors
su USER --shell /bin/bash --command "ulimit -n"
You need to edit /etc/pam.d/common-session* and add the following line to the end:
session required pam_limits.so
# cat /etc/security/limits.d/90-nproc.conf
* soft nproc 8192
root soft nproc unlimited
* soft nofile 102400
@gburd
gburd / confirm.sh
Created January 15, 2016 14:27
"Would you like to continue?" sh function
confirm () {
# call with a prompt string or use a default
read -r -p "${1:-Would you like to continue? [y/N]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
@gburd
gburd / Makefile
Created January 12, 2016 20:47 — forked from postmodern/Makefile
A generic Makefile for building/signing/install bash scripts
NAME=project
VERSION=0.0.1
DIRS=etc lib bin sbin share
INSTALL_DIRS=`find $(DIRS) -type d 2>/dev/null`
INSTALL_FILES=`find $(DIRS) -type f 2>/dev/null`
DOC_FILES=*.md *.txt
PKG_DIR=pkg
PKG_NAME=$(NAME)-$(VERSION)