Skip to content

Instantly share code, notes, and snippets.

@ergosteur
ergosteur / Chromebook-OQRE.ps1
Last active October 11, 2016 16:13
Script to move Chromebooks according to CSV file. Depends on gam.py.
#!/usr/bin/powershell
<#
.SYNOPSIS
.
.DESCRIPTION
.
.PARAMETER FullInventoryCSV
The path to the fully inventory CSV output from GAM.py print cros allfields. CSV must be comma-separated.
.PARAMETER LocalInventoryCSV
The path to the local school inventory CSV as prepared by the tech.
@ergosteur
ergosteur / hotaddcpuram.sh
Created October 16, 2018 18:26
Script to detect hot-plugged CPU and RAM in VM. Tested on Ubuntu 16.04
#!/bin/bash
# Based on script by William Lam - http://engineering.ucsb.edu/~duonglt/vmware/
# Found at http://askubuntu.com/questions/764620/how-do-you-hotplug-enable-new-cpu-and-ram-in-a-virtual-machine
# Bring CPUs online
for CPU in $(ls /sys/devices/system/cpu/ |grep -E '(cpu[0-9])')
do
CPU_DIR="/sys/devices/system/cpu/${CPU}"
echo "Found cpu: \"${CPU_DIR}\" ..."
CPU_STATE_FILE="${CPU_DIR}/online"
@ergosteur
ergosteur / prepare_ubuntu_template.sh
Last active October 16, 2018 20:43
Prepare Ubuntu teplate for VMware
#!/bin/bash
#add VMware package keys
#wget http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-DSA-KEY.pub -O - | apt-key add -
#wget http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-RSA-KEY.pub -O - | apt-key add -
#grab Ubuntu Codename
codename="$(lsb_release -c | awk {'print $2}')"
#add VMware repository to install open-vm-tools-deploypkg
@ergosteur
ergosteur / twitch-followingsize-userstyle.css
Created September 27, 2019 19:31
shrink the Follow header on new Twitch redesign
@-moz-document url-prefix("https://www.twitch.tv/directory/following") {
h1 {
animation-name: example;
animation-delay: 3s;
animation-duration: 3s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
@keyframes example {
@ergosteur
ergosteur / btrfs-create-subvol.sh
Created December 10, 2019 17:29
script to create subvolumes for unraid shares to allow snapshotting
#!/bin/bash
# create subvolumes for shares on unraid to allow btrfs snapshots
# reference https://forums.unraid.net/topic/73439-btrfs-snapshots/
disknum="3"
sharename="atlantic"
newsubvolpath="/mnt/disk$disknum/$sharename"
# function to check if path is subvol
# ref: https://stackoverflow.com/questions/25908149/how-to-test-if-location-is-a-btrfs-subvolume
is_btrfs_subvolume() {
# Source: https://activedirectorypro.com/how-to-get-ad-users-password-expiration-date/
$cred = Get-Credential
Get-ADUser -server domaincontroller.domain -credential $cred -filter {Description -like "SRI*" -and Enabled -eq $True -and PasswordNeverExpires -eq $False} -Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed" |
Select-Object -Property "Displayname",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}
@ergosteur
ergosteur / yamaha-scr0_unlocked.js
Created January 28, 2021 17:27
replacement scr0.js to unlock web UI controls on Yamaha receivers
var g_Backup_FileName="avr2012_backup.dat";var g_RecoveryStatus=false;function onControlMain(){g_Zone=0;changeDisplay();onBtnReload();}
function onControlZone2(){g_Zone=1;changeDisplay();onBtnReload();}
function onControlZone3(){g_Zone=2;changeDisplay();onBtnReload();}
function onControlZone4(){g_Zone=3;changeDisplay();onBtnReload();}
function onBtnPartyMode(){g_Info.m_partyMode=g_Info.m_partyMode?0:1;ajxSetPartyMode(g_Info.m_partyMode);}
function onBtnVolumeMute(zone,l_OnOff){ajxSetMute(zone,l_OnOff);}
function onBtnAllOn(){allpwronoff(1);ajxSetAllPower(1);}
function onBtnAllOff(){allpwronoff(0);ajxSetAllPower(0);}
function onZonePowerOnOff(zone,l_OnOff){g_Info.m_onZonePowerOnOff(zone,l_OnOff);ajxSetZonePower(zone,l_OnOff);}
function onSleep(time,zone){ajxSetSleep(zone,time);}
# Script to parse cisco IOS running-config.txt to csv file
# Work in progress
# Depends on cisco-config-parser (https://github.com/arezazadeh/cisco_config_parser)
# install with pip install --user cisco-config-parser
# only tested on Python 3.11 on Windows 10
# issues so far:
# - does not handle "add" lines for additional allowed vlans - ie two lines of allowed vlans. I believe this is an upstream issue in the cisco_config_parser library
#
# this script adds a column header "id" at the end of the line.
# the id field can be used to map the imported data to existing interfaces (for example created by device templates)
/**
* Processes emails in a given label in Gmail.
* Can mark emails as read and/or archive them based on the specified action.
* Only processes emails older than the specified number of days.
* Can log the subject of each email it processes if verbose mode is enabled.
*
* @param {string} labelName - The name of the label to process emails in.
* @param {number} days - The number of days old an email must be to be processed.
* @param {number} action - The action to perform on each email (0 = none, 1 = mark as read, 2 = archive, 3 = mark as read and archive).
* @param {boolean} verboseMode - Whether or not to log the subject of each email processed.
@ergosteur
ergosteur / pingbeep-enhanced.ps1
Last active June 7, 2023 17:25
Scripts for Windows and Linux/macOS/*nix that continuously pings a given IP or hostname, making a beep for every ping reply and displaying a colored character for every reply or timeout.
<#
.SYNOPSIS
Continuously pings a given IP or hostname, making a beep for every ping reply and displaying a character for every reply or timeout.
.DESCRIPTION
This script continuously pings a given IP or hostname. For every ping reply, it makes a beep sound
(unless the -NoBeep switch is used) and displays a character. For every request timed out, it also
displays a character. The characters used depend on the version of PowerShell being used and whether
the -NoUnicode switch is used: if using PowerShell 6 or newer and -NoUnicode is not used, a green
circle character is displayed for ping replies and a red circle character for timeouts; otherwise,