Skip to content

Instantly share code, notes, and snippets.

View quonic's full-sized avatar

Spyingwind quonic

  • Dallas
View GitHub Profile
Add-Type @'
using System;
using System.Runtime.InteropServices;
public static class Keyboard{
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
public static extern short GetKeyState(int keyCode);
public static bool Numlock{
get{
return (((ushort)GetKeyState(0x90)) & 0xffff) != 0;
}
# Converted from bash to Powershell reference: https://github.com/alexanderepstein/Bash-Snippets/blob/master/stocks/stocks
function Get-Ticker([string]$CompanyName, [string]$Ticker) {
$Query = ""
if ($CompanyName) {
$Query = $CompanyName.Replace(' ', '+')
}
elseif ($Ticker) {
$Query = $Ticker.Replace(' ', '+')
}
# Example of how to check for latest version
[xml]$rssData = Invoke-WebRequest "http://pub.kb.fortinet.com/rss/firmware.xml"
$MyDevice = "FortiOS"
[Version]$MyDeviceVersion = "1.0.0"
$rssData.rss.channel.item | ForEach-Object {
[string]$TitleData = $_.title
$a = $TitleData.Split(' ')
##
$workdir = "c:\installer\"
$LicenseFile = "$workdir\Veeamlicense.lic"
$ConfigFile = "$workdir\config.xml"
[Object[]]$List = @(
New-Object -TypeName PSObject -Property @{"File" = "$workdir\Veeam2.exe"; "URL" = "https://www.dropbox.com/s/8wawkngd9t3628x/Veeamexedl=1"}
New-Object -TypeName PSObject -Property @{"File" = $LicenseFile; "URL" = "https://www.dropbox.com/s/6ru5d4y2z5zmsqj/licensefile?dl=1"}
New-Object -TypeName PSObject -Property @{"File" = $ConfigFile; "URL" = "https://www.dropbox.com/s/Configfiledl=1"}
@quonic
quonic / _references.js
Created August 5, 2017 15:14
ScreepsAutocomplete
/// <reference path="ConstructionSite.js" />
/// <reference path="Creep.js" />
/// <reference path="Flag.js" />
/// <reference path="Game.js" />
/// <reference path="Memory.js" />
/// <reference path="Mineral.js" />
/// <reference path="Nuke.js" />
/// <reference path="Order.js" />
/// <reference path="OwnedStructure.js" />
/// <reference path="PathFinder.js" />
# This is how I would approch FizzBuzz
Function FizzBuzz {
Param(
[Parameter(ValueFromPipeline = $true)]
[int]$Number
)
Begin {
$Fizz = "Fizz"
$Buzz = "Buzz"
$pshost = get-host
$pswindow = $pshost.ui.rawui
if($pshost.ui.rawui.BufferSize.Width -lt 125){
$newsize = $pswindow.buffersize
$newsize.height = $pshost.ui.rawui.BufferSize.Height
$newsize.width = 125
$pswindow.buffersize = $newsize
}
@quonic
quonic / Mornon Contract.md
Created August 25, 2017 06:12
"I know I'm a moron" contract

Credit: https://www.reddit.com/r/sysadmin/comments/6vqpnx/manager_at_a_client_has_been_purchasing/dm28u96/

I, (moron's name), in my authority as (position) of (company), am hereby directing (your name) to do (dumb thing).

I have been advised that (dumb thing) is a Bad Idea, is against industry best practices, and is likely to cause problems including but not limited to (list of problems). If these problems occur, they are likely to harm the business by (list of consequences here). Additionally, doing this could open the business to liability from (customers/vendors/employees/government/other) because (explain).

Understanding the consequences of doing (dumb thing), and knowing that better options are available, I still choose to order (your name) to proceed with (dumb thing) against (his/her) advice. I accept any and all liability that may come from (dumb thing)'s likely consequences, and I agree that (your name) will be held harmless and blameless if/when any negative consequences occur.

Signed, (moron)

@quonic
quonic / DesktopService.ps1
Last active September 20, 2017 10:31
Send message via creating a file on remote computer
# Default config if IT's config isn't available
$Config = @{
Messenger = @{
Path = "C:\IT\"
File = "IT.Message"
}
ITConfigFile = "\\FileServer01\IT\.config.json" # This is a json file and read-only for normal users.
}
if(Test-Path -Path $Config.ITConfigFile){
@quonic
quonic / BuildXML.ps1
Last active November 22, 2017 20:09
"This:"
"<queryxml version='1.0'><entity>Ticket</entity><query><field>TicketNumber<expression op='Equals'>135481</expression></field></query></queryxml>"
"should equal this:"
$doc = new-object System.Xml.XmlDocument
$root = $doc.CreateElement("queryxml")
$root.SetAttribute("version","1.0")
$entity = $doc.CreateElement("entity")
$entity.InnerText = "Ticket"
$query = $doc.CreateElement("query")