Skip to content

Instantly share code, notes, and snippets.

View thomasswilliams's full-sized avatar

Thomas Williams thomasswilliams

View GitHub Profile
@thomasswilliams
thomasswilliams / .bashrc
Created November 20, 2025 10:45
Some quality-of-life additions to your .bashrc file on server or workstation
# rest of existing .bashrc goes here
# set prompt, green username followed by blue current path
PS1='\n[\[\033[01;32m\]\u@\h \[\033[01;34m\]\w\[\033[00m\]]\$ '
 
# ignore pwd, exit, quit, q etc. commands in bash history
HISTIGNORE="pwd":"exit":"quit":"q":"history"
# add timestamps to history
HISTTIMEFORMAT="%F %T "
# don't put duplicate lines or lines starting with space in the history.
@thomasswilliams
thomasswilliams / .vimrc
Created November 20, 2025 10:42
Basic .vimrc for server or workstation Linux
syntax on
@thomasswilliams
thomasswilliams / .inputrc
Created November 20, 2025 10:40
Basic .inputrc for Bash shell on server
# Respect default shortcuts.
$include /etc/inputrc
 
## arrow up
"\e[A":history-search-backward
## arrow down
"\e[B":history-search-forward
## esc = clear whole line
"\e": kill-whole-line
@thomasswilliams
thomasswilliams / remote-desktop-history.ps1
Last active June 18, 2024 16:20
PowerShell script to list remote desktop logon, logoff, disconnect events from the Terminal Services event log for a passed computer, collection of computers, or computer name(s) from prompt
<#
.SYNOPSIS
Get remote desktop sessions for a specified computer or computers, from the Terminal
Services event log. Adapted from https://serverfault.com/a/687079/78216, https://ss64.com/ps/get-winevent.html
Requires appropriate permission on computers to call Get-WinEvent remotely, PowerShell Active Directory module.
If using Windows Firewall, may require enabling "Remote Event Log Management" rule (from
https://social.technet.microsoft.com/Forums/en-US/69fba4e0-a248-4d1c-9e0d-80071a2a446d/getwinevent-the-rpc-server-is-unavailable)
By Thomas Williams <https://github.com/thomasswilliams>
.DESCRIPTION
@thomasswilliams
thomasswilliams / startup-shutdown-history.ps1
Created July 17, 2020 03:30
PowerShell script to get history from Windows event log for events relating to startup & shutdown for a specified computer or computers
<#
.SYNOPSIS
Get history from Windows event log for events relating to startup & shutdown for a specified computer or computers.
Adapted from https://social.technet.microsoft.com/wiki/contents/articles/17889.powershell-script-for-shutdownreboot-events-tracker.aspx
By Thomas Williams <https://github.com/thomasswilliams>
.DESCRIPTION
Pass one or more computer names, or run without parameters to be prompted for computer name(s).
.PARAMETER computers
@thomasswilliams
thomasswilliams / server-uptime.ps1
Created July 17, 2020 03:29
PowerShell script to return the boot time and calculated uptime in days, hours and minutes for a passed computer, collection of computers, or computer name(s) from prompt
<#
.SYNOPSIS
For a passed computer, collection of computers, or computer name(s) from prompt, return the boot time
and calculated uptime in days, hours and minutes.
By Thomas Williams <https://github.com/thomasswilliams>
.DESCRIPTION
Pass one or more computer names, or run without parameters to be prompted for computer name(s). Queries
WMI/CIM Win32_OperatingSystem class "LastBootUpTime", so need appropriate permissions, and WS-Management
service needs to be running.
@thomasswilliams
thomasswilliams / .eslintignore
Created November 19, 2019 10:38
Express & TypeScript Pedals API level 2, Nov 2019 - .eslintignore
node_modules
dist
@thomasswilliams
thomasswilliams / package.json
Last active November 20, 2019 05:58
Express & TypeScript Pedals API level 2, Nov 2019 - package.json
{
"name": "pedals-api-nov-2019",
"version": "0.0.2",
"scripts": {
"serve": "npm run tsc && node ./dist/server.js",
"tsc": "tsc",
"lint": "eslint \"src/**/*.ts\""
},
"eslintConfig": {
"root": true,
@thomasswilliams
thomasswilliams / tsconfig.json
Created November 18, 2019 10:44
Express & TypeScript Pedals API base, Nov 2019 - tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
@thomasswilliams
thomasswilliams / server.ts
Last active November 18, 2019 10:58
Express & TypeScript Pedals API base, Nov 2019 - server.ts
// in src directory
import express from "express";
const app = express();
// route: get pedals collection
app.get("/pedals", (req, res) => {
console.log("Got pedals collection");
// hard-code JSON response
res.send({ pedals: [{ name: "Boss SY-1", id: 1 }] });