Skip to content

Instantly share code, notes, and snippets.

View JPRuskin's full-sized avatar

James Ruskin JPRuskin

View GitHub Profile
function Get-Deck {
param([int]$decks=1)
$return = Invoke-WebRequest -Uri "http://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=$decks"
if ($return.StatusCode -eq 200) {return $return.Content | ConvertFrom-Json}
else {break $return.StatusCode}
}
function Get-Cards {
param(
[Parameter(ValueFromPipelineByPropertyName,Mandatory)]
@JPRuskin
JPRuskin / Get-StarCitizen.ps1
Last active December 4, 2015 01:26
Gets all of the files from the public or test StarCitizen manifests and downloads them to $directory (prompts if not imported).
function Get-StarCitizenManifest {
[CmdletBinding(SupportsShouldProcess)]
param()
$return = Invoke-WebRequest -Uri 'http://manifest.robertsspaceindustries.com/Launcher/_LauncherInfo' -OutFile $env:temp/launcherInfo
Get-Content -Path $env:temp/launcherInfo | ConvertFrom-StringData
}
function Get-StarCitizenFiles {
[CmdletBinding(SupportsShouldProcess)]
param(
@JPRuskin
JPRuskin / qif_datefix.py
Created June 20, 2016 14:06
Converts dates in a QIF formatted file from %b to %m.
import sys, re
from datetime import datetime
if sys.argv[1].lower().endswith(".qif"):
redate = re.compile("D\d{2}\/\D{3}\/\d{4}")
with open(sys.argv[1], "r") as infile:
print("Now reading "+infile.name+"...")
with open(sys.argv[1][:-4]+"_converted.qif", 'w') as outfile:
<#
.Synopsis
Begins an Azure DirSync.
.Description
Contains a function that will connect to a server (defaulting to ADFS01), load the Azure DirSync profile, and kick off a sync.
Prompts for creds regardless of account, but can be given credentials to use.
.Parameter server
The server to connect to. Defaults to ADFS01.
.Parameter Credential
Credentials to try connecting to the server with.
@JPRuskin
JPRuskin / DiskReport.sh
Last active September 2, 2016 14:28
E-mails a warning to the e-mail address when disk-usage on the main partition is over 90% ($threshold). Overwrites a log with the last runtime and usage stat. Requires SSMTP
#! /bin/bash
CURRENT=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g')
THRESHOLD=90
LOGFILE=~/Scripts/DiskReport.log
echo "Last Run: $(date "+%d%m%Y %T") : $CURRENT% Used." > $LOGFILE
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
ssmtp -s 'Disk Space Alert' helpdesk@domain.tld << EOF
Root partition remaining free space is critically low. Used: $CURRENT%
@JPRuskin
JPRuskin / export-hashtable.ps1
Last active September 28, 2016 13:49
Converts [PSObjects] into a format suitable for storing in a file, so you can dot-source hashtables.
function Export-HashTable {
param(
[Parameter(Mandatory, ValueFromPipeline)]
[Alias('InputObject')]
[PSObject]$HashTable,
[String]$Path,
[String]$Name
)
process {
$divWidth = ($HashTable.Keys.Length | Measure-Object -Maximum).Maximum + 8
@JPRuskin
JPRuskin / Update-SysInternals.ps1
Last active April 16, 2017 00:59
Updates all SysInternals tools contained within $localDirectory from live.sysinternals.com.
function Get-SysInternalsTools {
[CmdletBinding(DefaultParameterSetName='Update')]
param(
[Parameter(Mandatory)]
$localDirectory,
[Parameter(ParameterSetName='Download')]
[Switch]$DownloadAll
)
begin {
$localTools = Get-ChildItem $localDirectory -Filter *.exe
@JPRuskin
JPRuskin / ConvertTo-OTBStyle.ps1
Last active June 29, 2017 11:43
Converts a given script or directory of PS1 files to One True Brace Style formatting.
function ConvertTo-OTBStyle {
#Requires -Modules @{ModuleName='PSScriptAnalyzer';ModuleVersion='1.15.0'}
[CmdletBinding()]
param(
[Parameter(Mandatory, ParameterSetName = 'Directory')]
[ValidateScript( {Test-Path -Path $_ -PathType Container})]
[IO.DirectoryInfo]$Directory,
[Parameter(ParameterSetName = 'Directory')]
[Switch]$Recurse,
@JPRuskin
JPRuskin / Remove-LocalTFSFolders.ps1
Last active July 19, 2017 16:29
Quick method for removing all Release folders from a given local workspace
function Update-LocalTFSFolder {
[CmdletBinding()]
param(
[ValidateScript({Test-Path $_ -Include "tf.exe" -Type Leaf})]
$TF = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\TF.exe",
[Parameter(ValueFromPipeline,Mandatory,ParameterSetName='Path')]
[String]$Path,
[Parameter(ValueFromPipelineByPropertyName,Mandatory,ParameterSetName='FullName')]
@JPRuskin
JPRuskin / Pok3r.ahk
Created August 30, 2017 14:46 — forked from JarvisPrestidge/Pok3r.ahk
Personal AutoHotKey script that turns any keyboard into a Pok3r.
#CommentFlag //
#InstallKeybdHook
// Author: Jarvis Prestidge
// Description: Simulates my preferred keyboard layout, similiar to that of the Pok3r 60% keyboard
// on any keyboard without programmable keys. i.e. my laptop ^^
// <COMPILER: v1.1.22.00>