Skip to content

Instantly share code, notes, and snippets.

View codejake's full-sized avatar
☕

Jake Shaw codejake

☕
View GitHub Profile
@codejake
codejake / basic-csv-parse.py
Last active July 9, 2021 20:10
Basic CSV parsing with Python3, for my homies.
#!/usr/bin/env python3
import csv
infile = open("input-file.csv")
inreader = csv.reader(infile)
for row in inreader:
print(f"first field: {row[0]} second field: {row[1]} third field: {row[2]}")
#!/usr/local/bin/pwsh
if ("abc def" -match "abcx*") {
Write-Host "Found a match! 1"
}
if ("abc def" -match "axc*") {
Write-Host "Found a match! 2"
}
select a.* from (
select
[id],
[User_Name],
[Client_IP_Address],
[Called_Station_Id],
[Packet_Type],
[Reason-Code],
LAG([Calling_Station_ID],1) OVER( PARTITION BY [User_Name] ORDER BY [User_Name]) client FROM [NPSODBC].[dbo].[accounting_data] WHERE [Reason-Code] != 0
) a
// This file was initially generated by Windows Terminal 1.3.2651.0
// Version: Oct 26, 2020 jake541 @ gmail.com
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
package main
import (
"log"
"os"
)
func main() {
emptyFile, err := os.Create("emptyFile.txt")
if err != nil {
@codejake
codejake / hook.ps1
Created August 10, 2020 17:26
Example: Send Slack Webhooks with PowerShell, without the need for some dumb library.
# We don't need no steenkin' PS libraries to Slack!
$results = Get-DhcpServerv4ScopeStatistics -ComputerName my_dhcp_server_fqdn | where {$_.PercentageInUse -gt 70} | select -property scopeid,percentageinuse
ForEach ($subnet in $results) {
$payload = @{
text="Warning: DHCP subnet " + $subnet.ScopeId + " is " + [math]::Round($subnet.percentageinuse) +"% full."
}
$json = $payload | ConvertTo-Json
$response = Invoke-RestMethod 'https://hooks.slack.com/services/T0AXXXXX/B01XXXXXXKF/uklXXXXXYYYYsb' -Method Post -Body $json -ContentType 'application/json'
! Create an Ether-channel
interface Port-Channel 1
switchport trunk encapsulation dot1q
switchport mode trunk
logging event bundle-status
logging event trunk-status
! Configure and add a port to the Ether-channel
int Gi0/13
#!/bin/bash
# unshare-all.sh
# Unshare all the printers on a macOS system.
# Jake Shaw
#
# version: 19.10.8.1
# One-liner version
# lpstat -p | awk '{ print $2 }' | while read printer; do lpadmin -p "$printer" -o printer-is-shared=false;done
function prompt {
$currentUser = $env:USERNAME.ToLower()
$currentDirectory = get-location
$computerName = $env:COMPUTERNAME.ToLower()
Write-Host ""
Write-Host "[" -NoNewLine
Write-Host "${currentDirectory}" -ForegroundColor Yellow -NoNewLine
Write-Host "] on " -NoNewLine
Write-Host "${computerName} " -ForegroundColor Cyan -NoNewLine
@codejake
codejake / Rudimentary-logging.bash
Last active January 31, 2019 16:37
Bash rudimentary logging example
#!/bin/bash
export BU_DEST=${HOME}/data
export BU_DEST_USER=${BU_DEST}/${USER}
export LOGFILE=BU_DEST_USER/test.log
# If desired, clear the log file with >.
echo "" > ${LOGFILE}
# Append a log entry with the date/time to our log with >>