Skip to content

Instantly share code, notes, and snippets.

@ridingintraffic
ridingintraffic / 01 - hidden.ovpn
Last active January 13, 2019 02:55
openvpn as a systemd service with PS1 alerting
.....
.....
auth-user-pass /home/linuxuser/pass.txt
<begin python script>
# test.py
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
yield l[i:i + n]
all_ids = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
chunked_list_ids=chunks(all_ids,5)
@ridingintraffic
ridingintraffic / python set
Created January 8, 2019 02:51
quick and dirty one line to dedup a list
>>> all_ids = [1,2,3,4,5,1,2,7,8,3,4,5]
>>> print all_ids
[1, 2, 3, 4, 5, 1, 2, 7, 8, 3, 4, 5]
## create a set passing in the list and then returning a list
>>> deduped_ids = list(set(all_ids))
>>> print deduped_ids
[1, 2, 3, 4, 5, 7, 8]
`:mic_drop:`
@ridingintraffic
ridingintraffic / FIRE
Created December 23, 2018 03:50
in case of fire
function FIRE()
{
find ~/git/github/$(whoami) -maxdepth 1 -mindepth 1 -type d -exec cd {} \; -exec git pull {} \; -exec git add --all {} \; -exec git commit -a -m "firesale" {} \; -exec git push origin `git rev-parse --abbrev-ref HEAD` {} \;
}
@ridingintraffic
ridingintraffic / setMeUp.sh
Created December 23, 2018 03:33
symlink creation
#!/bin/bash
function linkwork()
{
linkTocheck="$1"
sourceLink="$2"
if [ -f "$linkTocheck" ]; then
echo "$linkTocheck is a file - backing it up"
mv "$linkTocheck" "$sourceLink.bak"
fi
if [ ! -h "$linkTocheck" ]; then
@ridingintraffic
ridingintraffic / food?
Created December 23, 2018 03:30
lunch picker
function food()
{
arr[0]="Jimmy Johns"
arr[1]="Pita Inn"
arr[2]="Noodle and company"
arr[3]="Potbelly"
arr[4]="Chipotle"
arr[5]="portillos"
arr[6]="Wendy's"
arr[7]="Josh's"
@ridingintraffic
ridingintraffic / lazy_function
Created December 23, 2018 03:18
git updater
function traffic-update()
{
currentDir=$(pwd)
cd ~/git/github/<someuser>/traffic/
git pull
git add --all
git co -a -m "autoupdate script"
git push origin `git rev-parse --abbrev-ref HEAD` # push to origin/master
cd $currentDir
}
@ridingintraffic
ridingintraffic / .common_profile_snippet
Last active December 23, 2018 03:15
system detection
# loading the system speicfic profiles
if [ "Linux" = "$(uname -a | awk '{printf $1}')" ]; then
if [ "raspbian" = "$(cat /etc/os-release | grep ^ID= |sed 's/ID=//')" ]; then
echo "raspbian"
source "$HOME/.rpi_profile"
elif [ "ubuntu" = "$(cat /etc/os-release | grep ^ID= |sed 's/ID=//')" ]; then
echo "ubuntu"
source "$HOME/.ubu_profile"
elif [ "centos" = "$(cat /etc/os-release | grep ^ID= |sed 's/ID=//')" ]; then
echo "centos"
@ridingintraffic
ridingintraffic / hashcat
Last active December 10, 2018 08:56
luks and hashcat
$ dd if=/dev/urandom of=test bs=1M count=100
$ cryptsetup luksFormat test #use password password
$ cryptsetup luksOpen test tmp
$ xxd -l 512 /dev/mapper/tmp # is random data at this point
$ mkfs.ext4 /dev/mapper/tmp # use the same file system that is used by your system/device
$ xxd -l 512 /dev/mapper/tmp # should no longer be random data
$ cryptsetup luksClose tmp
$ cryptsetup luksDump test | grep "Payload offset" # add 1 to the offset value that comes back
$ dd if=test of=luks-header bs=512 count=4097 # grabs header
$ echo "password" >>list
@ridingintraffic
ridingintraffic / _sudoers.d
Created December 6, 2018 02:45
sudo sandwich part 3
root@discworld:~# cat /etc/sudoers.d/012_twoflower-nopasswd
twoflower discworld=(rincewind) /usr/bin/less /luggage/camera/picture