Skip to content

Instantly share code, notes, and snippets.

@rothgar
rothgar / talos-root.sh
Created April 10, 2024 23:57
Get a "host" shell on Talos Linux
#!/usr/bin/env bash
if ! command -v kubectl &>/dev/null; then
echo "kubectl not be found"
exit 1
fi
if ! command -v fzf &>/dev/null; then
echo "fzf not be found"
exit 1
fi
@rothgar
rothgar / tiktok-download
Created April 7, 2024 06:08
Download your tiktok videos with nushell
#!/usr/bin/env nu
# download your tiktok archive data and extract the user_data.json file
let data = (open user_data.json)
mkdir archive
# loop through videos
$data.Video.Videos.VideoList | each { |video|
# create a file name tt_$video.Date (remove spaces)
@rothgar
rothgar / main.yml
Last active March 8, 2024 07:16
Generate /etc/hosts with Ansible
# Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source.
# Will include all hosts the playbook is run on.
# Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html
- name: "Build hosts file"
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['all']
@rothgar
rothgar / tmux_local_install.sh
Last active March 3, 2024 04:24 — forked from ryin/tmux_local_install.sh
bash script for installing tmux without root access
#!/bin/bash
TMUX_VERSION="2.1"
LIBEVENT_VERSION="2.0.20"
NCURSES_VERSION="6.0"
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
@rothgar
rothgar / GNOMEShell.textile
Last active February 29, 2024 03:15
GNOME 3 keyboard shortcuts

Keyboard Shortcuts – GNOME Shell 3.8+

General Navigation

Super or Alt + F1 or Super + S Activities Overview
Alt + F2 Command window
Super + A Application View
Super + M Toggle Message Tray
Super + N Focus Notification
Ctrl + Alt + Tab Toggle System Focus (Windows, Top Bar, Messages)
@rothgar
rothgar / get-ogimage
Created July 10, 2023 21:30
Download the og:image from a URL
#!/bin/bash
set -eo pipefail
if [ $# -eq 0 ]; then
echo "Please provide a URL"
echo "$(basename $0) URL"
exit 1
fi
@rothgar
rothgar / incognito.sh
Created June 28, 2016 14:55
incognito shell function
#!/bin/bash
incognito() {
if [[ -z ${SHELL} ]]; then
echo "Could not determin shell.\nUsing /bin/bash"
SHELL=bash
fi
case "${SHELL}" in
*bash)
set -o history
;;
@rothgar
rothgar / install-tmux
Last active April 5, 2023 06:53 — forked from ekiara/how_to_install_tmux_on_centos
Install tmux 1.9 on rhel/centos 6
# Install tmux on Centos release 6.5
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -OL https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar -xvzf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local
@rothgar
rothgar / apt.ish
Created March 18, 2023 06:53
Download and convert an ubuntu deb package to rpm
#!/bin/bash
set -eo pipefail
CONTAINER=$(docker ps -a | grep ubuntu | awk '{print $1}')
if [ "${CONTAINER}" != "" ]; then
docker start $CONTAINER
else
CONTAINER=$(docker run -d --name ubuntu -e DEBIAN_FRONTEND=noninteractive public.ecr.aws/ubuntu/ubuntu:20.04 sleep 60m)
@rothgar
rothgar / git-ops
Created January 11, 2023 16:43
Local development git ops
#!/bin/bash
set -oe pipefail
if [ -d .git ]
then
while true
do
inotifywait -r -e close_write ${PWD}