Skip to content

Instantly share code, notes, and snippets.

View grantcarthew's full-sized avatar
🙂
Coding

Grant Carthew grantcarthew

🙂
Coding
View GitHub Profile

CLI Improved

This document lists improvements over the default Linux command line tools.

The list was initially motivated by a blog post by Remy Sharp.

CLI Tools

@grantcarthew
grantcarthew / Connect-Telnet.ps1
Last active June 1, 2022 13:48
A full graceful telnet client using PowerShell and the .NET Framework. http://uglygizmo.blogspot.com.au/
<#
.SYNOPSIS
A full graceful telnet client using PowerShell and the .NET Framework.
.DESCRIPTION
This script was made with a view of using it to have full control over the text
stream for automating Cisco router and switch configurations.
.PARAMETER TelnetHost
The address of the server or router hosting the telnet service.
@grantcarthew
grantcarthew / Get-ActiveIP.ps1
Created October 16, 2013 00:16
Determine the active IP address on a Windows machine with PowerShell. http://uglygizmo.blogspot.com.au/
<#
.Synopsis
Returns IPv4 address details for the local machine.
Information is gathered from the active interface being used by the default route.
#>
[CmdletBinding()]
[OutputType([string])]
Param ()
Write-Verbose -Message ("Begin: " + $MyInvocation.MyCommand.Path)
@grantcarthew
grantcarthew / Markdown Test.md
Last active October 3, 2020 03:27
GitHub Markdown Test Document

I use this Gist to test GitHub markdown format.

Cheat Sheet

[Mr Blobby]

Install-Module -Name <module name> -Force
@grantcarthew
grantcarthew / Test-SSD.ps1
Last active November 5, 2019 05:13
PowerShell script to test if a hard disk is an Solid State Disk (SSD) or not.
<#
.SYNOPSIS
Detects if the passed Physical Disk Id is a Solid State Disk (SSD) or a
spindle disk. Returns true for an SSD and false for anything else.
.DESCRIPTION
Use Get-PhysicalDisk to get the Physical Disk Ids for the system you wish
to test. This script supports values being passed throught the pipeline.
The methods used for detecting are by reading the Nominal Media Rotation
@grantcarthew
grantcarthew / New-ACMEUser.csv
Last active October 22, 2019 12:19
Office 365 User Provisioning
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 15 columns, instead of 4. in line 8.
User Name,First Name,Last Name,Display Name,Job Title,Department,Office Number,Office Phone,Mobile Phone,Fax,Address,City,State or Province,ZIP or Postal Code,Country or Region
Porky,Porky,Pig,Porky Pig,Sidekick,ACME,12345,67890,1234567890,0987654321,4000 Warner Blvd,Burbank,CA,91522,USA
Daffy,Daffy,Duck,Daffy Duck,Bugs Bunny Sidekick,ACME,12345,67890,1234567890,0987654321,4000 Warner Blvd,Burbank,CA,91522,USA
Elmer,Elmer,Fudd,Elmer Fudd,Hunter,ACME,12345,67890,1234567890,0987654321,4000 Warner Blvd,Burbank,CA,91522,USA
Bugs,Bugs,Bunny,Bugs Bunny,Lead Character,ACME,12345,67890,1234567890,0987654321,4000 Warner Blvd,Burbank,CA,91522,USA
Tweety,Tweety,,Tweety,Cute Bird,ACME,12345,67890,1234567890,0987654321,4000 Warner Blvd,Burbank,CA,91522,USA
Sylvester,Sylvester,,Sylvester,Hungry Cat,ACME,12345,67890,1234567890,0987654321,4000 Warner Blvd,Burbank,CA,91522,USA
Yosemite,Yosmite,Sam,Yosmite Sam,Gun Slinger,ACME,12345,67890,1234567890,0987654321,4000 Warner Blvd,Burbank,CA,91522,USA
Foghorn,Foghorn,Leghorn,Forho
$logPath = 'D:\Temp\github-ping.log'
$title = "Script started at " + (Get-Date)
Set-Content -Value $title -Path $logPath
Write-Host -Object $title
$ip = 'Error'
$logIt = $false
$count = 0
$result = $null
$newResult = $null
$newIp = $null
@grantcarthew
grantcarthew / server.js
Last active April 11, 2019 00:57
medium-server.js
// server.js
const log = require('./logger').child(module)
const driver = require('./store/driver')
const app = require('./app')
const SERVERPORT = process.env.SERVERPORT
if (process.listeners('unhandledRejection').length < 1) {
process.on('unhandledRejection', (reason, promise) => {
console.error(reason)
process.exit(1)
@grantcarthew
grantcarthew / global-teardown.js
Created March 2, 2019 08:19
medium-global-teardown.js
// global-teardown.js
module.exports = async function () {
await global.__MONGOD__.stop()
}
@grantcarthew
grantcarthew / http-setup.js
Created March 2, 2019 07:50
medium-http-setup.js
// http-setup.js
const axios = require('axios')
const app = require('../../src/server')
const log = require('../../src/logger').child(module)
module.exports = async function httpSetup () {
log.info('HTTP test setup initiated')
const listener = app.listen()
const port = listener.address().port
const baseURL = `http://localhost:${port}/api`