Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python3
import os
# pip3 install openpyxl pandas to be able to read Excel contents
import pandas
import sys
# Sub in your actual excel file for NAMEOFEXCELFILE.xlsx
excel_file = os.path.expanduser('~/Downloads/NAMEOFEXCELFILE.xlsx')
@aysiu
aysiu / raffle.py
Created March 18, 2021 18:48
Quick Python script to get raffle winner(s) from a list of contestants
#!/usr/local/munki/munki-python
import random
import sys
## Specify the total number of winners
total_winners = 3
## Specify the potential contestants
raffle_contestants = ['contestant 1', 'contestant 2', 'contestant 3', 'contestant 4', 'contestant 5']
<?php
/* Notes:
This is a simple page that allows users to change their own passwords in Active Directory via LDAP.
Believe it or not, this kind of password-change PHP page is not easy to find, at least as of summer 2018.
Some easy-to-find resources on this are outdated and don't work.
Many involve the need for an admin password in order to change the user's password, which is fine, but I really wanted to have something that didn't require a separate admin account. This may still require an account of some kind (not necessarily admin) that can just search for a distinguished name, since some instances of AD don't allow for anonymous LDAP binding.
Even though Active Directory uses LDAP, there are also some specific quirks to password changes on AD, as opposed to general LDAP password changes.
<?php
// A bit messy... would be easier using CFPropertyList
// Put in the relative path to your optional installs manifest, assuming you have only one, in this situation
$optionals_manifest='RELATIVE/PATH/TO/manifests/OPTIONALINSTALLSMANIFEST';
// Get the contents of the manifest
$xml=simplexml_load_file($optionals_manifest);
#!/usr/bin/python
import os
import plistlib
# Modify to be the pkgsinfo path for your Munki repo
pkgsinfo_path='/PATH/TO/YOUR/MUNKI/REPO/pkgsinfo'
# Create a list to hold all unattended installs items
unattended_installs=[]
@aysiu
aysiu / SourceDestinationMove.js
Created March 6, 2017 22:38
Moves files from one Google Drive folder to another
function SourceDestinationMove() {
// The folder IDs are the tailend of the URL for the folder in Google Drive
// The source folder where you want things moved out of.
var source_folder = DriveApp.getFolderById('INSERTSOURCEFOLDERIDHERE');
// The destination folder where you want things moved to.
var destination_folder = DriveApp.getFolderById('INSERTDESTINATIONFOLDERIDHERE');
@aysiu
aysiu / HideMSCOptionalItems.html
Last active March 3, 2017 19:19
Hides optional items in Managed Software Center
<script>
// Put this at the top of the footer_template.html
// Get the page name
var current_page=document.getElementsByClassName('title')[0].getElementsByTagName('H2')[0].innerHTML;
// If the page name is All items or Featured items
if ( current_page == "All items" || current_page == "Featured items"){
// Create an array of optional items to hide
@aysiu
aysiu / printerpkginfoswap.sh
Created December 7, 2016 18:05
Create Printer pkginfo with lpd or ipp switched
#!/bin/bash
# Loop through everything that has a Printer as the first part of the name and 1.0 as the last part
for pkginfo in /PATH/TO/pkgsinfo/Printer*1.0*; do
echo "$pkginfo"
# See if a 1.1 version already exists
newer=$(echo "$pkginfo" | sed -e "s/1\.0/1\.1/g")
if [ ! -f "$newer" ]; then
# If it doesn't exist, let's create it
cp "$pkginfo" "$newer"
@aysiu
aysiu / lowrez.py
Last active November 8, 2016 22:05 — forked from pudquick/lowrez.py
Enable the "Open in Low Resolution" setting for an arbitrary application in macOS
#!/usr/bin/python
# Some notes about using this script:
# - Configure the application path and bundle id below
# - This script needs to be run as the user you need to set the checkmark for
# - The setting will not take effect until they log out and log back in at least once
import os.path
from Foundation import NSHomeDirectory, CFPreferencesCopyMultiple, CFPreferencesSetMultiple, kCFPreferencesAnyUser, kCFPreferencesCurrentHost, NSMutableDictionary, NSURL, NSURLBookmarkCreationMinimalBookmark, NSMutableArray