Skip to content

Instantly share code, notes, and snippets.

@pudquick
pudquick / computer_icon.py
Created January 10, 2018 17:58
A variation on https://scriptingosx.com/2018/01/get-an-icon-for-your-mac/ that doesn't attempt to contact WindowServer / trigger errors
#!/usr/bin/python
from Foundation import NSZeroRect, NSMakeRect, NSMakeSize
from AppKit import NSPNGFileType, NSCompositeCopy, NSGraphicsContext, NSCalibratedRGBColorSpace, NSBitmapImageRep, NSImage, NSImageNameComputer
dimension = 512
size = NSMakeSize(dimension, dimension)
rect = NSMakeRect(0, 0, dimension, dimension)
image = NSImage.imageNamed_(NSImageNameComputer)
image.setSize_(size)
@keithga
keithga / Get-LatestUpdate.ps1
Last active September 26, 2024 21:54
script to get latest build.
<#
.SYNOPSIS
Get the latest Cumulative update for Windows
.DESCRIPTION
This script will return the list of Cumulative updates for Windows 10 and Windows Server 2016 from the Microsoft Update Catalog.
.NOTES
Copyright Keith Garner ([email protected]), All rights reserved.
@zakes-it
zakes-it / Terminate-ADAccount.ps1
Created August 4, 2016 23:08
Disable an Active Directory account, logging the group membership, stripping group membership and moving the account to a disabled users OU
# turn down the AD account
Function Terminate-ADAccount {
[CmdletBinding()]
Param(
[System.Object[]]$user,
[System.Management.Automation.PSCredential]$cred,
[String]$DisabledOu,
[String]$MembershipLogPath
)
# Retrieve groups that the user is a member of
@zakes-it
zakes-it / Disable-SlackAccount.ps1
Created August 4, 2016 22:52
Disable Slack account matching a username
Function Disable-SlackAccount {
[CmdletBinding()]
Param(
[String]$user,
[String]$org,
[String]$token
)
$SlackUsers = Invoke-RestMethod -Uri $( "https://" +$org + ".slack.com/api/users.list?token=" + $token )
if ( ! $SlackUsers.ok ) {
Write-Error ( "Error getting user list from Slack: " + $SlackUsers.error )
@maxvt
maxvt / infra-secret-management-overview.md
Last active February 3, 2025 06:11
Infrastructure Secret Management Software Overview

Currently, there is an explosion of tools that aim to manage secrets for automated, cloud native infrastructure management. Daniel Somerfield did some work classifying the various approaches, but (as far as I know) no one has made a recent effort to summarize the various tools.

This is an attempt to give a quick overview of what can be found out there. The list is alphabetical. There will be tools that are missing, and some of the facts might be wrong--I welcome your corrections. For the purpose, I can be reached via @maxvt on Twitter, or just leave me a comment here.

There is a companion feature matrix of various tools. Comments are welcome in the same manner.

@nmcspadden
nmcspadden / LZMADecompressor.py
Created October 15, 2015 19:06
LZMADecompressor.py
#!/usr/bin/python
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadIdentifier</key>
<string>com.apple.mdm.moostophelees.talkingmoose.net.d8300e90-1b4b-0133-b2d5-38e856168efc.alacarte</string>
<key>PayloadRemovalDisallowed</key>
<true />
<key>PayloadScope</key>
<string>User</string>
@pudquick
pudquick / mount_shares_better.py
Last active January 19, 2023 22:07
Mounting shares in OS X using python and pyobjc - works with OS X 10.8+
import objc, CoreFoundation, Foundation
class attrdict(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
NetFS = attrdict()
# Can cheat and provide 'None' for the identifier, it'll just use frameworkPath instead
# scan_classes=False means only add the contents of this Framework
NetFS_bundle = objc.initFrameworkWrapper('NetFS', frameworkIdentifier=None, frameworkPath=objc.pathForFramework('NetFS.framework'), globals=NetFS, scan_classes=False)
#!/bin/sh
# get machine serial number
MAC_SERIAL_NUMBER=`ioreg -l | grep IOPlatformSerialNumber|awk '{print $4}' | cut -d \" -f 2`
# echo the value prefixed by "RuntimeSetBindingComputerID:" to make it compatible with the directory binding tasks
echo "RuntimeSetBindingComputerID: ${MAC_SERIAL_NUMBER}"
systemsetup -setcomputername ${MAC_SERIAL_NUMBER}
/usr/sbin/scutil --set LocalHostName ${MAC_SERIAL_NUMBER}
@chemxboy
chemxboy / AskForPackage.sh
Last active January 24, 2019 19:37
This is how we use CocoaDialog (http://mstratman.github.io/cocoadialog/) in DeployStudio (http://deploystudio.com) workflows. CocoaDialog should be added to the scripts directory. This particular example will popup a choice and set the response in a variable. A later workflow item uses that variable in its logic to install the chosen package.
#!/bin/sh
#
# This script uses cocoaDialog to bring up a GUI dialog requesting which package to install. It will set a variable to be used later in the workflow.
# Set the 891 variable
P_891=""
# Path to the cocoaDialog tool
POPUP=`dirname "$0"`/cocoaDialog.app/Contents/MacOS/cocoaDialog