Skip to content

Instantly share code, notes, and snippets.

@ukn
ukn / position-active-window-on-a-third-part-of-display.sh
Last active October 15, 2021 20:30
Resize active window to 1/3 of the screen and position it in the middle, right or left part of the display
#!/usr/bin/env bash
#
# Resize active window to 1/3 of the screen and position it in the middle, right or left part of the display
# Tested with XFCE (xserver) and ultra wide monitor (3440x1440)
#
# based on: https://askubuntu.com/questions/104155/center-a-window-via-command-line#answer-571711
# Can this be calculated automagically?
taskBarHeight=63
@ukn
ukn / scale_toggle.sh
Created January 28, 2021 15:55
Xfce window scaling toggler
#!/usr/bin/env bash
currect_factor=`xfconf-query -c xsettings -p /Gdk/WindowScalingFactor`
echo Factor: $currect_factor
if [ "${currect_factor}" -eq "1" ]; then
echo "Change it to 2"
new_factor=2
else
echo "Change it to 1"
fi
@ukn
ukn / 99-install-facetime-camera.sh
Last active March 26, 2024 20:35 — forked from Stono/99-install-facetime-camera.sh
Install the kernal module required for the facetimehd camera to work on Linux
#!/bin/bash
set -e
export CONFIG_MODULE_SIG=n
export CONFIG_MODULE_SIG_ALL=n
# For current kernel
export KERNELRELEASE=$(cat /proc/version | awk '{print $3}')
temp_dir=$(mktemp -d)
echo "Installing FacetimeHD camera for $KERNELRELEASE"
@ukn
ukn / dynhost-cf.sh
Created January 27, 2020 20:56
Update Cloudflare A record when your IP changes
#!/bin/bash
# Updates Cloudflare dns record
# when your home IP changes
# Put in in cron with desired frequency
# but don't abuse WTF service (they throttle anyway)
set -e
API_TOKEN=YOUR_API_TOKEN_HERE
@ukn
ukn / elasticseach_index_dump.sh
Created February 28, 2019 15:04
Dirty way of getting elasticsearch index data for debugging
#!/bin/bash
set -e
# Don't use in PROD!
# Script params:
# ES_URL - https://your-elasticseach-url.local
# INDEX - your-index-name
ES_URL=$1
INDEX=$2
SUFFIX=0
@ukn
ukn / remove_servers_from_newrelic.js
Last active October 26, 2017 14:03
Remove old servers from NewRelic Server app
#!/usr/bin/env node
/*
Deletes servers from New Relic Server app that were last seen before cutoff date
*/
const https = require("https")
const cutoff = new Date("2017-10-15T00:00:00.001")
const filter = 'filter[reported]=false&sort[health_status]=false'
var promises = []
@ukn
ukn / ss.sh
Last active October 27, 2016 16:00
bash function that gives nicely formated services status from consul
ss() {
if [[ -z ${2+x} ]]; then
ssh ${1} "curl -s localhost:8500/v1/catalog/services | \
jq -rc 'keys | .[]' | while read i; do curl -s localhost:8500/v1/health/service/\${i} | jq -r '.[] | .Checks[] | select(.CheckID != \"serfHealth\") | .ServiceName + \" \" + .CheckID + \" \" + .Status'; done | column -t -x"
else
ssh ${1} "curl -s localhost:8500/v1/health/service/${2} | jq -r '.[] | .Checks[] | select(.CheckID != \"serfHealth\") | .CheckID + \"\t\" + .Status + \"\t\t\" + .Output'"
fi
}
@ukn
ukn / awsls.sh
Last active October 27, 2016 16:00
bash function that formats `aws ec2 describe-instances` into something readable
awsls(){
if [ -z ${1+x} ]; then
temp=`aws ec2 describe-instances`
else
temp=`aws ec2 describe-instances --profile ${1}`
fi
# All tags version
# aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | | select (.State.Name != "terminated") | .InstanceId + "\t" + .PrivateIpAddress + "\t" + .PublicIpAddress + "\t" + .InstanceType + "\t" + (reduce.Tags[] as $tag (""; . + $tag.Key + "=" + $tag.Value + " "))'

Keybase proof

I hereby claim:

  • I am ukn on github.
  • I am ukn (https://keybase.io/ukn) on keybase.
  • I have a public key whose fingerprint is 53CB D2D1 9D82 BA8C 8D24 E51E 9B58 DE68 310F F0FE

To claim this, I am signing this object: