Skip to content

Instantly share code, notes, and snippets.

View theinventor's full-sized avatar

Troy Anderson theinventor

View GitHub Profile
@theinventor
theinventor / async_file_download_from_urls.js
Created May 7, 2024 02:16
A simple function in a stimulus controller in rails. It will post IDs of your objects to an endpoint to fetch their public URLs, then zip up all those files from the public URLs and give them a download.zip file.
async download(event) {
event.preventDefault();
console.log("Download function initiated");
const spinner = document.querySelector('.downloadLoading'); // Show the spinner
spinner.classList.remove('hidden');
const contentIds = this.selectedIds;
const csrfToken = document.querySelector("[name='csrf-token']").content;
@theinventor
theinventor / gist:5ef2aeeb1ffb84c5aa372e696ef04583
Created May 7, 2024 02:15
async_download_remote_files.js
async download(event) {
event.preventDefault();
console.log("Download function initiated");
const spinner = document.querySelector('.downloadLoading'); // Show the spinner
spinner.classList.remove('hidden');
const contentIds = this.selectedIds;
const csrfToken = document.querySelector("[name='csrf-token']").content;
@theinventor
theinventor / bad-events.txt
Created February 22, 2018 15:27
Things you might want to watch for in windows eventlog
EventID,Source,LogName,EventType,Message,Severity
9,%,%,0,%did not respond within the timeout period%,High
11,%,%,0,%controller error%,High
1000,%Microsoft-Windows-DHCP-Server%,%,0,%The DHCP service received the unknown option%,Critical
1064,%Microsoft-Windows-DHCP-Server%,%,0,%There are no IP addresses available for BOOTP clients%,Critical
1069,%Microsoft-Windows-DHCP-Server%,%,0,%Iashlpr cannot contact the NPS service%,Critical
1070,%Microsoft-Windows-DHCP-Server%,%,0,%Iashlpr initialization failed%,Critical
1142,%Microsoft-Windows-DHCP-Server%,%,0,%The DHCP server is unable to reach the NPS server%,Critical
3,%Microsoft-Windows-DNS-Server-Service%,%,0,%The DNS server has shut down%,Critical
10,%Microsoft-Windows-DNS-Server-Service%,%,0,%The DNS server could not start because it is dependent on the NTDS service which is not started%,Critical
@theinventor
theinventor / syncro-sample-rest-api.ps1
Last active September 29, 2021 23:27
A sample powershell script with some functions to work with the SyncroMSP HTTP REST API
Import-Module $env:SyncroModule
###########################################################################################
# First, some functions, these are just declarations that get used lower down the script. #
###########################################################################################
function Query-Syncro-Tickets ($SyncroSubdomain,$SyncroAPIKey,$Query) {
$uri = "https://$SyncroSubdomain.syncromsp.com/api/v1/tickets?api_key=$SyncroAPIKey&query=$Query"
$response = Invoke-RestMethod -Uri $uri
$response
@theinventor
theinventor / install-and-run-ccleaner.ps1
Created November 28, 2017 02:24
Powershell to install and run ccleaner. In Syncro set this up to run as System, Powershell.
Import-Module $env:SyncroModule
# Silent Install CCleaner
# http://www.piriform.com/ccleaner/download
# Path for the workdir
$workdir = "c:\temp\"
$sixtyFourBit = Test-Path -Path "C:\Program Files (x86)"
Import-Module $env:SyncroModule
# this depends on bemcli being installed!
#Setting default CLI
import-module bemcli
#Getting Alerts
$Alerts = Get-BEAlert
#Looping through the alerts and setting them.
@theinventor
theinventor / veeam_backup_monitor.ps1
Created December 1, 2017 16:10
Sample powershell for Syncro to get event viewer data (for last 1 day, so make this a daily script) and create an alert in your Syncro account if it finds issues.
Import-Module $env:SyncroModule
# Create RMMAlerts when a backup fails
$event = Get-EventLog "Veeam Backup" -newest 1 -After (Get-Date).AddDays(-1)| Where-Object {$_.EventID -eq 0}
if($event.entrytype -eq "Error") {
write-host "We got an event that is an error from Veeam Backup!"
Rmm-Alert -Category "veeam_backup_failed" -Body "Veeam Backup Failed on $(%computername%) - message: $($event.message)"
} else {
@theinventor
theinventor / syncro-install.ps1
Created January 15, 2018 05:40
Download Syncro agent and install it from command line
# Download the installer
$source = "https://rmm.syncromsp.com/GetThisURLfromYourCustomerDetailPageAndPutItHere.exe"
$destination = "C:\temp\syncro-installer.exe"
# Check if Invoke-Webrequest exists otherwise execute WebClient
if (Get-Command 'Invoke-Webrequest'){
Invoke-WebRequest $source -OutFile $destination
} else {
$WebClient = New-Object System.Net.WebClient
@theinventor
theinventor / teamviewer.rb
Created April 1, 2014 17:30
A quick ruby api wrapper for the teamviewer api
module Teamviewer
class Connector
attr_reader :client
def initialize
@client = connection(credentials)
end
@theinventor
theinventor / rake_task_template.rake
Created October 1, 2012 23:03
Rake Task Template
namespace :some_thingy do
task :my_big_fixer, [:production_run] => :environment do |t, args|
production_run = args[:production_run] == "true"
ap "doing a dry run" unless production_run
my_logger = Logger.new("#{Rails.root}/log/my_thingy.log")
require 'progress_bar'
bar = ProgressBar.new(User.all.count) # pass the total for the progress bar
my_logger.info "Starting at #{Time.now}"