Skip to content

Instantly share code, notes, and snippets.

View shaneholloman's full-sized avatar

Shane Holloman shaneholloman

  • Cello Ltd
  • Wellington, NZ
  • 03:01 (UTC +12:00)
View GitHub Profile
@shaneholloman
shaneholloman / Setting up OpenDevin Environment with Python, Docker, and Rust.md
Last active October 1, 2024 04:10
This code snippet creates and installs OpenDevin, sets up a Docker container with the specified key. It then configures SSH to install Rusts from TLSv1.2 using pip's orjson issue (MacOS), downloads requirements

Setting up OpenDevin Environment with Python, Docker, and Rust

Preview

git clone https://github.com/OpenDevin/OpenDevin.git
cd OpenDevin
conda create -n od python=3.10
conda activate od
docker ps
@shaneholloman
shaneholloman / bookmarks-to-notion.js
Created March 9, 2024 12:50 — forked from unrevised6419/bookmarks-to-notion.js
Export bookmarks to Notion as a Database
(function bookmarksExportToCsv() {
/**
* 1. Export bookmarks from browser (supported any Chromium based browsers and Safari) (chrome://bookmarks)
* 2. Open exported html file again in the browser
* 3. Copy paste this entire file in console, and execute it (hit enter)
* 4. You will be prompted to save a CSV file. Save it.
* 5. Open Notion. Click Import -> CSV
* 6. Select saved CSV file. Wait for import
* 7. You have a new database with all your bookmarks
*/
@shaneholloman
shaneholloman / mtr.sh
Last active February 24, 2024 01:11 — forked from ThinGuy/mtr.sh
Test all nics using mtr (my traceroute)
#!/bin/bash
mtrv4() {
[[ -z ${1} || ${1} =~ -h ]] && {
printf "Usage: %s <hostname|IP>\n" "${FUNCNAME[0]}" 1>&2
return 2
}
for i in $(ip -o -4 a | awk '{if ($2 != "lo") print $2}' | paste -sd' '); do mtr -4 -rw -c 5 -I "${i}" "${1}"; done
}
export -f mtrv4
@shaneholloman
shaneholloman / demo-msad.yaml
Last active October 1, 2024 04:22 — forked from ThinGuy/demo-msad.yaml
Create a MSAD Controller using SAMBA in an unprivileged LXD container in about 100 seconds, Includes creating 70+ MSAD accounts.
---
config:
boot.autostart: 'true'
security.nesting: 'true'
security.privileged: 'false'
user.network-config: |
version: 2
ethernets:
eth0:
dhcp4: false
@shaneholloman
shaneholloman / msad-lxd.sh
Last active October 1, 2024 04:49 — forked from ThinGuy/msad-lxd.sh
Script to create a SAMBA based Active Directory Controller in a LXD unprivileged container
#!/bin/bash
export UBUNTU_PRO_TOKEN="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
export DNS_DOMAIN="atx.orangebox.me"
export MSAD_DOMAIN="ORANGEBOX"
export DC_HOSTNAME="msadc"
export SSH_IMPORT_ID="lp:craig-bender, gh:thinguy"
export UBUNTU_REPO="us.archive.ubuntu.com"
export UBUNTU_RELEASE="lunar"
export MSADMIN_PW="Ubuntu1+"
@shaneholloman
shaneholloman / xrdp-install.sh
Last active October 1, 2024 04:48 — forked from ThinGuy/xrdp-install.sh
Scripted XRDP Install with various fixes
#!/bin/bash
##############################
# Scripted XRDP Installation #
##############################
### Note: You can only be logged in via console or RDP, not both.
### If you get blackscreen via RDP or if console keeps going
### back to login screen, run `gnome-session-quit --force --logout`
### via ssh as the same user you are trying to login
@shaneholloman
shaneholloman / ubuntu-repo-size.bash
Last active October 1, 2024 04:45 — forked from ThinGuy/ubuntu-repo-size.bash
Get Ubuntu Repo Size - Non standard repos are a WIP
#!/bin/bash
ubuntu-repo-size() {
ubuntu-repo-size_usage() {
printf "\n\e[1m\e[2G%s\e[0m\n\n" "${FUNCNAME[0]%%_*}"
printf "\e[1m\e[2GUsage\e[0m: %s [options]\n\n" "${FUNCNAME[0]%%_*}"
printf "\e[1m\e[2GOptions\e[0m:\n\n"
printf "\e[3G -a, --arch \e[28GArchitecture to display, i.e. amd64,arm64,armhf,i386,ppc64el,s390x (Default: amd64)\n"
printf "\e[3G -s, --series \e[28GRelease nicknames to get information for, (Default: current LTS)\n"
printf "\e[3G -c, --components \e[28GList of repo components to query (Default: main,universe,multiverse,restricted)\n"
@shaneholloman
shaneholloman / fix-usb2serial.sh
Created February 11, 2024 02:18 — forked from ThinGuy/fix-usb2serial.sh
Function create UDEV rules for all USB to Serial Devices so that apps such as minicom, screen, gtkterm can access device as normal user
fix-usb2serial() {
printf "\n\e[1mFix USB to Serial device permissions\e[0m\n"
local DEVREGX='.*tty[UA].*' W='s'
declare -ag TTYUSB_DEVS=($(find /sys/class/tty -type l -iregex "${DEVREGX}" -printf "%P\n" 2>&1))
[[ ${#TTYUSB_DEVS[@]} -ge 1 ]] && { local W=""; } || { printf "\nNo USB to Serial devices found using regex \x22${DEVREGX}\x22.\nQuitting\n\n";return 3; }
[[ -n $(id -Gn|grep 2>/dev/null -oE dialout) ]] && { printf "\e[2G - User $USER already a member of \x22dialout\x22 group \e[3m(Good\x21)\e[0m\n"; } || { printf "\e[2G -- Adding User $USER to the \x22dialout\x22 group\n"; sudo usermode -aG dialout $USER; }
printf "\e[2G - Creaing udev rules file: /etc/udev/rules.d/50-ttyUSB.rules\n"
sudo install -o0 -g0 -m0644 /dev/null /etc/udev/rules.d/50-ttyUSB.rules
printf "\e[2G - Adding ${#TTYUSB_DEVS[@]} udev rule${W}:\n"
(printf "%s\n" ${TTYUSB_DEVS[@]}|xargs -I{} printf "KERNEL==\x22{}\x22,\x20MODE=\x270666\x22\n")|sudo tee -a /etc/udev/rules.d/50-ttyUSB.rules|sed -r 's/^/ /g'
@shaneholloman
shaneholloman / maas-sunbeam-ci.yaml
Last active October 1, 2024 04:13 — forked from ThinGuy/maas-sunbeam-ci.yaml
Automated Install of Project Sunbeam - Tested under MAAS 3.3.4 and 3.4.
# This is a cloud-init script to deploy Sunbeam (aka Microstack) on multiple
# nodes using MAAS.
#
# THIS IS FOR ALL NODES IN CLUSTER
# Be sure to change the following elements to match you environment:
# resolv_conf: -> nameservers:
# resolv_conf: -> searchdomains:
# resolv_conf: -> domain:
# ubuntu_advantage: -> token:
# ubuntu_advantage: -> config: -> http_proxy:
@shaneholloman
shaneholloman / maas-nvidia-gpu-tags.sh
Last active November 28, 2023 20:44 — forked from ThinGuy/maas-nvidia-gpu-tags.sh
MAAS xpath auto tags for popular Nvidia GPUs (Tesla V/P/M and Quadro M/P/K series. Assists with GPGPU passthrough
#!/bin/bash
# Note - if you have a single cpu machine, change cpu:0 to just cpu at the start of the definition
maas "${MAAS_PROFILE}" tags create \
comment="Enable passthrough for Nvidia Tesla V series GPUs on Intel" \
name=gpgpu-tesla-v-i \
definition='//node[@id="cpu:0"]/capabilities/capability/@id = "vmx" and //node[@id="display"]/vendor[contains(.,"NVIDIA")] and //node[@id="display"]/description[contains(.,"3D")] and //node[@id="display"]/product[contains(.,"Tesla V")]' \
kernel_opts="console=tty0 console=ttyS0,115200n8r nomodeset modprobe.blacklist=nouveau,nvidiafb,snd_hda_codec_hdmi,snd_hda_intel video=vesafb:off,efifb:off intel_iommu=on rd.driver.pre=pci-stub pci-stub.ids=$(awk '/Tesla V/{if (/10de/) print $1":"$2;print "10de:"$1}' /usr/share/misc/pci.ids|paste -sd,) rd.driver.pre=vfio-pci vfio-pci.ids=$(awk '/Tesla V/{if (/10de/) print $1":"$2;print "10de:"$1}' /usr/share/misc/pci.ids|paste -sd,) vfio_iommu_type1.allow_unsafe_interrupts=1 vfio-pci.disable_vga=1"