Skip to content

Instantly share code, notes, and snippets.

View nicerobot's full-sized avatar
🤖
☯️ ☮️ 🐶 🐾 👾 🎮 🎼 🎶 🕺 🎧 🌻 🌱 🏞 🌊 🌔 🌎

nicerobot nicerobot

🤖
☯️ ☮️ 🐶 🐾 👾 🎮 🎼 🎶 🕺 🎧 🌻 🌱 🏞 🌊 🌔 🌎
View GitHub Profile
  • SC1000 $ is not used specially and should therefore be escaped.
  • SC1001 This \o will be a regular 'o' in this context.
  • SC1003 Want to escape a single quote? echo 'This is how it'\''s done'.
  • SC1004 This backslash+linefeed is literal. Break outside single quotes if you just want to break the line.
  • SC1007 Remove space after = if trying to assign a value (or for empty string, use var='' ... ).
  • SC1008 This shebang was unrecognized. ShellCheck only supports sh/bash/dash/ksh. Add a 'shell' directive to specify.
  • SC1009 The mentioned parser error was in ...
  • SC1010 Use semicolo
@phuctm97
phuctm97 / Dockerfile
Created September 8, 2019 14:21
Go RESTful series
FROM golang:1
# Configure to reduce warnings and limitations as instruction from official VSCode Remote-Containers.
# See https://code.visualstudio.com/docs/remote/containers-advanced#_reducing-dockerfile-build-warnings.
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils 2>&1
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed.
RUN apt-get -y install git iproute2 procps lsb-release
@nicerobot
nicerobot / ssh-tgzx
Last active February 25, 2024 02:48
Self-extracting, encrypted tarballs using SSH public keys from GitHub. Because https://ssh-vault.com is awesome but it requires an installation.
#!/bin/bash
(( ${#} >= 3 )) || { echo "usage: $(basename ${0}) github-username archive-file [files | directories]"; exit 1; }
exec >${2}
zero='${0}'
cat <<SCRIPT
#!/usr/bin/env bash
usage() {
echo "usage: bash ${zero} identity-file"
@varunchitale
varunchitale / locks.sql
Created March 25, 2019 07:10
Get a list of queries and their details that hold locks over relations in a dB.
SELECT
blocked_locks.pid AS blocked_pid,
blocked_activity.usename AS blocked_user,
blocking_locks.pid AS blocking_pid,
blocking_activity.usename AS blocking_user,
blocked_activity.query AS blocked_statement,
blocking_activity.query AS current_statement_in_blocking_process,
blocked_activity.application_name AS blocked_application,
blocking_activity.application_name AS blocking_application
FROM pg_catalog.pg_locks blocked_locks
@varunchitale
varunchitale / delete_duplicates.sql
Created March 25, 2019 06:56
Efficiently delete duplicates rows from a table with a set of specific constraints.
DELETE FROM <table> a USING (
SELECT MIN(ctid) as ctid, var1, var2
FROM <same_table> b
GROUP BY 2,3 HAVING COUNT(*) > 1
) b
WHERE a.var1 = b.var1
and a.var2 = b.var2
AND a.ctid <> b.ctid
@pepasflo
pepasflo / .gitignore
Last active October 22, 2023 12:06
Scripts for encrypting / decrypting secrets (to prevent them from being accidentally checked into git)
secrets/
@nicerobot
nicerobot / preamble.sh
Created October 24, 2018 02:27
Common Bash variables
#!/usr/bin/env bash
STARTD=${PWD}
SELFD=$(cd $(dirname ${0}) >/dev/null 2>&1; pwd)
SELF=$(basename ${0})
SELFN=$(basename ${SELFD})
SELFU=${SELF%.*}
SELFZ=${SELFD}/${SELF}
NOW=$(date +%Y%m%dt%H%M%S)
UNQ=${NOW}.${RANDOM}
LOGD=${SELFD}/${SELFU}.${UNQ}
@nicerobot
nicerobot / tgzx
Last active August 9, 2019 04:13
Self-extracting, encrypted tarballs. Much simpler than https://www.linuxjournal.com/node/1005818
#!/usr/bin/env bash
tgzx() {
(( ${#} >= 2 )) || { echo 'usage: tgzx archive-file [files | directories]'; return 1; }
printf '#!/usr/bin/env bash\ntail -n+3 ${0} | openssl enc -aes-256-cbc -d -a | tar ${1:-xv}z; exit\n' >${1}
tar zc "${@:2}" | openssl enc -aes-256-cbc -a -salt >>${1} && chmod +x ${1}
}
@cjus
cjus / .docker_aliases
Last active July 13, 2023 23:50
Docker aliases
#!/bin/sh
alias dm='docker-machine'
alias dmx='docker-machine ssh'
alias dk='docker'
alias dki='docker images'
alias dks='docker service'
alias dkrm='docker rm'
alias dkl='docker logs'
alias dklf='docker logs -f'
@m4t7e0
m4t7e0 / hosts
Last active June 30, 2019 18:12 — forked from consti/hosts
/etc/hosts to block shock sites etc.
# 20180201 Adobe Activation Added
# This hosts was an improved version of the file brought from Dan Pollock and can be found at
# http://someonewhocares.org/hosts/
# You are free to copy and distribute this file for non-commercial uses,
# as long the original URL and attribution is included.
#
# See below for acknowledgements.
# Please forward any additions, corrections by git comment