Skip to content

Instantly share code, notes, and snippets.

View rajiteh's full-sized avatar
🅱️
'sup

Raj Perera rajiteh

🅱️
'sup
  • @ubisoftinc
  • Toronto, ON
View GitHub Profile
@rajiteh
rajiteh / hlds_launcher.sh
Last active February 4, 2023 01:18
wine hlds launcher
#!/bin/bash
set -euo pipefail
download_location="/home/wineuser/.wine/drive_c"
hlds_bin="${download_location}/Counter-Strike/hlds.exe"
function log() {
printf >&2 "%s:\t%s\n" "$(date)" "${@}"
}
@rajiteh
rajiteh / Dockerfile
Last active January 9, 2022 08:05
scan the running images in your local docker socket for vulnerabilities using trivy (log4j / log4shell)
FROM aquasec/trivy
RUN apk add --no-cache docker-cli
ADD scan.sh /scan.sh
ENTRYPOINT ["sh"]
@rajiteh
rajiteh / tall-merge-psd.js
Created July 2, 2021 07:13
Tall Merge PSDs
const ZERO = new UnitValue(0, 'px')
function appendToDoc(dstDoc, fileRef, isFirstDoc) {
const srcDoc = app.open(fileRef, undefined, true);
superSelect()
superCopy()
const dstDocWidth = new UnitValue(dstDoc.width.as('px') < srcDoc.width.as('px') ? srcDoc.width.as('px') : dstDoc.width.as('px'), 'px')
const dstDocHeight = new UnitValue(isFirstDoc ? srcDoc.height.as('px') : dstDoc.height.as('px') + srcDoc.height.as('px'), 'px')
const pasteTopLeftRightBottom = isFirstDoc ? [ZERO, ZERO, dstDocWidth, dstDocHeight] : [new UnitValue(dstDoc.height.as('px'), 'px'), ZERO, dstDocWidth, dstDocHeight]
@rajiteh
rajiteh / settings.json
Created August 7, 2020 18:49
Windows terminal
// This file was initially generated by Windows Terminal 1.1.2021.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@rajiteh
rajiteh / prometheus-repl.sh
Created February 14, 2018 23:32
because prometheus ui is terrible
#!/bin/bash
export PROMETHEUS_SERVER="http://prometheus-server.example.com"
# install prometheus-query from https://github.com/ryotarai/prometheus-query
# $ go get -u github.com/ryotarai/prometheus-query
while IFS="" read -r -e -d $'\n' -p 'query> ' query; do
history -s "$query"
prometheus-query -start "1 minute ago" -query "$query" --format tsv | column -t
echo "---"
#!/bin/bash
## ./script path1 path2
src=$1
dst=$2
function percentage {
jq -n "$(du -s $1 | cut -f1)/$(du -s $2 | cut -f1)*100"
}
cat last_check || :
@rajiteh
rajiteh / logger.sh
Last active July 30, 2022 21:46
Colourful Bash
#!/bin/bash
[ -z "${LOGGING_NO_COLORS}" ] && [ -t 1 ] && [ -n "$(tput colors)" ] || LOGGING_NO_COLORS="TRUE"
log() {
local color=$1;shift
local msg="$(date +%T.%3N) ${BASH_SOURCE[2]##*/}[${BASH_LINENO[1]}]: ${@}"
local reset="\e[0m"
if [ -n "${LOGGING_NO_COLORS}" ]; then
color="";reset=""
fi
@rajiteh
rajiteh / update-check.sh
Created July 26, 2017 04:14
Ghetto Docker Update
#!/bin/sh
RUNNING="$(docker ps --format "{{ .ID }}" | xargs docker inspect --format "{{ .Image }}" | xargs docker inspect --format "{{ .Id }} {{ .RepoTags }}")"
AVAILABLE="$(docker images --format "{{ .ID }} [{{ .Repository }}:{{ .Tag }}]" --no-trunc)"
NEEDS_UPDATE=0
echo "${RUNNING}" | while read line; do
current_id=$(echo "${line}" | awk '{print $1}')
current_tag=$(echo "${line}" | awk '{print $2}')
updated_id=$(echo "${AVAILABLE}" | grep -F "${current_tag}" | awk '{print $1}')
if [ "$current_id" != "$updated_id" ]; then
echo "Update required for ${current_tag}"
@rajiteh
rajiteh / mitmproxy_transparent_reverse_proxy.py
Created May 3, 2017 15:22
Sets up mitmproxy as a transparent reverse proxy to any upstream (as defined by the host header of the http packets)
#
# ./mitmproxy -U http://doesnt.matter -p 8001 -s mitmproxy_transparent_reverse_proxy.py
#
# HTTP_PROXY=http://localhost:8001 ./program_to_run
#
def request(flow):
if flow.request.method == "CONNECT":
return
if flow.live:
@rajiteh
rajiteh / 0_pr_status.1d.sh
Created January 30, 2017 14:39
bitbar citizenship canada timers and status
#!/bin/bash
PATH=$PATH:/usr/local/bin/
WORK_DIR=~/.bitbar/pr_status
CHANGE_FILE="${WORK_DIR}/changed"
LOGGING=0
mkdir -p ${WORK_DIR}
function errcho {
if [ "${LOGGING}" != "0" ]; then