Skip to content

Instantly share code, notes, and snippets.

Avatar

Troy Anderson theinventor

View GitHub Profile
@theinventor
theinventor / install-and-run-ccleaner.ps1
Created Nov 28, 2017
Powershell to install and run ccleaner. In Syncro set this up to run as System, Powershell.
View install-and-run-ccleaner.ps1
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)"
@theinventor
theinventor / syncro-sample-rest-api.ps1
Last active Aug 30, 2020
A sample powershell script with some functions to work with the SyncroMSP HTTP REST API
View syncro-sample-rest-api.ps1
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 / syncro-install.ps1
Created Jan 15, 2018
Download Syncro agent and install it from command line
View syncro-install.ps1
# 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 Apr 1, 2014
A quick ruby api wrapper for the teamviewer api
View teamviewer.rb
module Teamviewer
class Connector
attr_reader :client
def initialize
@client = connection(credentials)
end
View rake_task_template.rake
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}"
@theinventor
theinventor / bad-events.txt
Created Feb 22, 2018
Things you might want to watch for in windows eventlog
View bad-events.txt
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
View simple_form_stuff.rb
####TO CREATE A BOOLEAN VIRTUAL ATTRIBUTE WITH VALIDATION:
##In the model:
class Person < ActiveRecord::Base
validates_acceptance_of :terms_of_service
#if using attr_accessible
attr_accessible :name, :etc, :terms_of_service
end
View rs_post.php
<?php
if( $_POST["name"] )
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://YOUR_SUBDOMAIN.host.com/api/v1/leads?api_key=YOUR_API_KEY");
curl_setopt($ch, CURLOPT_POST, 1);
// example splitting a name field into first and last name bits
$pieces = explode(" ", $_POST['name']);
$last_name_parts = array_slice($pieces, 1); //each word
View en-GB.yaml
en-GB:
date:
abbr_day_names:
- Sun
- Mon
- Tue
- Wed
- Thu
- Fri
- Sat
View memory-usage.py
#!/usr/bin/python
import subprocess
import re
# Get process info
ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'], stdout=subprocess.PIPE).communicate()[0].decode()
vm = subprocess.Popen(['vm_stat'], stdout=subprocess.PIPE).communicate()[0].decode()
# Iterate processes
You can’t perform that action at this time.