Skip to content

Instantly share code, notes, and snippets.

@jalex19100
jalex19100 / change_password_expect.sh
Created November 2, 2024 04:13
Bare Bones (basic) Change password on unix server via Expect
#!/usr/bin/expect -f
#
# Usage: <scriptname> <username> <existingpassword> <newpassword> <servername/host>
set timeout 10
set username [lindex $argv 0]
set password [lindex $argv 1]
set newpassword [lindex $argv 2]
set serverid [lindex $argv 3]
spawn ssh -a -oIdentitiesOnly=yes -oStrictHostKeyChecking=no $username@$serverid
@jalex19100
jalex19100 / sqldeveloper_decrypt_saved_passwords.sh
Created November 2, 2024 04:11
Locates the latest sqldeveloper settings directory and decrypts all saved passwords to stdout, in case they weren't previously recorded
#!/bin/bash
##
# Auto wrapper to decrypt "super-secure" saved passwords for Oracle SQL Developer 19.x+
#
# Author: Lazy Jason.Alexander
# Date: 20230110
#
# Requires: sqldeveloperpassworddecryptor (install via pip) or see https://github.com/maaaaz/sqldeveloperpassworddecryptor
#
@jalex19100
jalex19100 / JenkinsDeleteEcsSlaveNodes.groovy
Created November 2, 2024 04:09
Delete all ECS slave nodes. If they are inactive in ECS, the exception will be ignored. Useful in runaway slaves or node issues.
for (aSlave in hudson.model.Hudson.instance.slaves) {
println('====================');
println('Name: ' + aSlave.name);
println('getLabelString: ' + aSlave.getLabelString());
println('getNumExectutors: ' + aSlave.getNumExecutors());
println('getRemoteFS: ' + aSlave.getRemoteFS());
println('getMode: ' + aSlave.getMode());
println('getRootPath: ' + aSlave.getRootPath());
// println('getDescriptor: ' + aSlave.getDescriptor());
println('getComputer: ' + aSlave.getComputer());
@jalex19100
jalex19100 / active_connection.sh
Created February 9, 2024 22:40
List active Linux TCP connections with only grep and awk
grep -v "rem_address" /proc/net/tcp | awk 'function hextonum(str, ret, n, i, k, c) {if (str ~ /^0[xX][0-9a-fA-F]+$/) {str = substr(str, 3);n = length(str);ret = 0;for (i = 1; i <= n; i++) {c = substr(str, i, 1);c = tolower(c);k = index("123456789abcdef", c);ret = ret * 16 + k}} else ret = "NOT-A-NUMBER";return ret} {y=hextonum("0x"substr($2,index($2,":")-2,2));x=hextonum("0x"substr($3,index($3,":")-2,2));for (i=5; i>0; i-=2) {x = x"."hextonum("0x"substr($3,i,2));y = y"."hextonum("0x"substr($2,i,2));} print y":"hextonum("0x"substr($2,index($2,":")+1,4))" "x":"hextonum("0x"substr($3,index($3,":")+1,4));}'
@jalex19100
jalex19100 / .zprofile
Created December 5, 2023 00:01
dot zprofile snippets (MacOS)
alias dockandbash='docker run --rm -ti --entrypoint /bin/bash '
alias forward80='socat tcp-l:80,fork,reuseaddr tcp:127.0.0.1:8080'
alias cleardns='sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder'
alias clearaws='unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN'
alias aws_whoami='aws sts get-caller-identity'
alias aws_config_mgr_parameters="aws ssm get-parameters-by-path --path /ced/live/ --recursive | jq \'.Parameters[] | select(.Name) | {name: .Name, value: .Value}\'"
alias psa='ps auxww|grep '
alias hog='du -I".." -sk .* *|sort -n'
alias ll='ls -la'
alias tf='terraform'
#!/bin/bash
# https://raygun.com/blog/git-aliases/
# unstage files
git config --global alias.unstage 'reset HEAD --'
# stash changes including untracked files
git config --global alias.stash-unstaged 'stash -k -u'
# switch to previous branch
@jalex19100
jalex19100 / split_on_delimiter.sh
Created June 24, 2021 21:58
Split on Delimiter in bash
# https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash
#!/usr/bin/env bash
IN="example@example;struff@stuff"
# Do something with each element separated by ;
IFS=';' read -ra ADDR <<< "$IN"
for i in "${ADDR[@]}"; do
# process "$i"
done
@jalex19100
jalex19100 / rust_info.md
Last active February 19, 2020 19:10
Rust Resources
@jalex19100
jalex19100 / treat_touch_events_as_mouse_events.js
Created March 19, 2019 17:31
Treat touch events as mouse events. Useful for legacy code that you cannot change but could load a small piece to support touch events.
/* First we need to listen to touch events and call a function 'touch2Mouse' each time a touch event is fired:
*/
document.addEventListener("touchstart", touch2Mouse, true);
document.addEventListener("touchmove", touch2Mouse, true);
document.addEventListener("touchend", touch2Mouse, true);
/* The following function will initiate and fire mouse events (event.initMouseEvent), for each touch events type we'll fire the equivalent mouse event :
*/
Touchstart => Mousedown
Touchend => Mouseup
@jalex19100
jalex19100 / git_last_commit.sh
Last active October 9, 2018 16:09
Show last commit on all git projects within a dir
# usage <scriptname> <directory below to look in>
find $1 -depth 2 -type d -name .git -execdir git log -1 --format=%cd" `pwd`" \;