Skip to content

Instantly share code, notes, and snippets.

@atoa
atoa / infuse unlock
Created May 3, 2013 10:45
find unlock code Samsung Infuse (possibly other SGS variants). Execute from android shell (e.g. terminal or adb shell)
dd if=/efs/root/afs/settings/nv_data.bin skip=8 count=4 2>/dev/null | strings | \
grep -v '^0\{8\}$' | (grep '^[0-9]\{8\}' || echo 'ERROR - Unlock code not found' >&2 ) | \
sed -e 's/^\([0-9]\{8\}$\)/UNLOCK CODE: \1/'
@atoa
atoa / route2csv.sh
Created May 8, 2013 19:41
shell pipeline to convert a Linux routing table to a prefix based network address CSV. depends on having ipcalc installed.
netstat -rn | grep UG | awk '{print $1 " " $3 " " $2 " " $8}' | \
xargs -n4 sh -c 'ipcalc -p -n $0 $1 ; echo $2 $3' | xargs -n4 | \
sed -e 's/PREFIX=\([0-9]\{1,\}\) NETWORK=\([0-9\.]\{1,\}\)/\2\/\1/; s/ /, /g ' | \
sort -V
@atoa
atoa / cert_bundle_expand
Created May 16, 2015 00:27
expand cert bundle
#!/usr/bin/perl -n
$cert++ if /BEGIN/ ;
$certs{ $cert } .= "$_";
END{
foreach $key (keys %certs) {
open(OPENSSL, "|openssl x509 -text");
print OPENSSL $certs{ $key };
}
}
@atoa
atoa / docker-mount.sh
Last active September 10, 2019 13:36
#!/usr/bin/env bash
# Docker for Windows drive mount helper
# Manually mounts a Windows shared drive inside the MobyLinuxVM virtual machine
# (host running on HyperV) so that it is visible to Docker containers.
# It enters the moby VM using nsenter via the 'docker4w/nsenter-dockerd'
# container.
# Then mounts the share drive using the DockerNAT ip address
# This can be useful with unix like environments under Windows
@atoa
atoa / ssh-agent-helper.sh
Created September 25, 2016 02:43
ssh-agent helper
#!/bin/bash
# ssh-agent helper script. runs ssh-agent and adds ~/.ssh/*.pem keys
PATH="/bin:/usr/bin"
umask 077
IFS=' '
readonly AGENT_SOCKET="${HOME}/.ssh/.ssh-agent-socket"
readonly AGENT_INFO="${HOME}/.ssh/.ssh-agent-info"
#!/usr/bin/env bash
# from: http://blog.yohanliyanage.com/2015/05/docker-clean-up-after-yourself/
#https://lebkowski.name/docker-volumes/
#docker rm -v $(docker ps -a -q -f "status=exited")
#docker rmi $(docker images -f "dangling=true" -q)
docker system df
# remove unused volumes:
echo '[INFO] removing unused volumes'
@atoa
atoa / docker-mount.ps1
Created September 26, 2016 18:40
mount drive on docker for windows
$drive = $env:homedrive.Substring(0,1)
$ip = Get-NetIPConfiguration -InterfaceAlias "vEthernet (DockerNAT)" | Select IPv4Address
$unc = "//" + $ip.IPv4Address.IPAddress + "/" + $drive
[Environment]::SetEnvironmentVariable("UNC", $unc, "Process")
[Environment]::SetEnvironmentVariable("DRIVE", $drive, "Process")
docker run -ti --rm --privileged --pid=host -e USERNAME -e USERDOMAIN -e DRIVE -e UNC ubuntu nsenter --target 1 --mount --uts --ipc --net --pid sh -x -c '
[ -d "/${DRIVE}" ] || mkdir "/${DRIVE}" && \
mount.cifs "${UNC}" "/${DRIVE}" \
@atoa
atoa / delete-empty-cw-log-groups.sh
Created November 15, 2017 14:20
delete empty cloudwatch log groups
#!/usr/bin/env sh
# AWS cli delete empty cloudwatch log groups
aws logs describe-log-groups \
--query 'logGroups[?storedBytes == `0`].logGroupName' --output text | \
xargs -r -n1 aws logs delete-log-group --log-group-name
@atoa
atoa / m-git-grep.sh
Created January 5, 2024 17:50
script to recursively git grep multiple repos in subdirectories
#!/usr/bin/env sh
#
# Git grep on multiple repos in descendant directories from cwd
set -euo pipefail
IFS=$'\n\t'
# how many directories to recurse - helps with performance to keep it low
# but may miss subdirectories if too low
# it can be overriden by setting this variable in the calling shell