Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python3.4
"""
Custom inventory script for Ansible populated by the JSS
"""
from functools import lru_cache
from os.path import dirname, realpath, join
from urllib.parse import quote
import argparse
import json
@krispayne
krispayne / resize.sh
Created October 23, 2022 00:27
resize every jpeg in a dir into subdirs by size
#!/bin/bash
sizes=("3000" "1500" "1000" "750")
for size in "${sizes[@]}"; do
mkdir $size
for i in *.jpg; do
magick "$i" -resize ${size}x${size} -density 300 -units PixelsPerInch "${size}/${i}_${size}_300.jpg"
done
#!/bin/bash
# wrapper for wav to mp3 using ffmpeg
#ffmpeg -i Big\ Squeeze.wav -b:a 320k Big\ Squeeze.mp3
mkdir mp3
for x in *.wav; do
ffmpeg -i "$x" -b:a 320k "mp3/$(basename "${x/.wav}").mp3"
# sleep 10
@krispayne
krispayne / 32bitcheck
Created December 12, 2019 16:26
EA for 32bit apps
#!/bin/bash
# Detect all 32-bit apps installed in /Applications, /Library
# or /usr/local and output list to logfile stored in /var/log.
runOnce="true"
if [[ "$runOnce" == "true" || "$runOnce" == "1" ]]; then
if [[ -e /usr/local/xattr/.32bitAppsInstalledCheckDone ]]; then
# Using runOnce cached value:
echo "<result>$(cat /usr/local/xattr/.32bitAppsInstalledCheckDone)</result>"

Keybase proof

I hereby claim:

  • I am krispayne on github.
  • I am krispayne (https://keybase.io/krispayne) on keybase.
  • I have a public key whose fingerprint is 38B2 E3CA 9179 B6C1 9F61 9199 5F32 6F88 63FC 6602

To claim this, I am signing this object:

@krispayne
krispayne / ldap-one-liner
Created July 16, 2019 16:54
ldapsearch oneliner to find enabled users in a certain email domain (freeipa)
ldapsearch -D "uid=kris,cn=users,cn=accounts,dc=domain,dc=net" -W -b "cn=users,cn=accounts,dc=domain,dc=net" '(&(mail=*@domain.com)(!(nsaccountlock=TRUE)))' displayname mail | grep -E "displayname|mail" | grep -v "#" | awk -F': ' '{print $2}' | sed 'N;s/\n/,/'
@krispayne
krispayne / ovirt4.py
Last active May 20, 2019 13:36
changed around line 115 to get credentials from awx custom credential. taken and modified from: https://github.com/ansible/ansible/blob/devel/contrib/inventory/ovirt4.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 Red Hat, Inc.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
#!/bin/sh
# Determines who is logged in and then kills SEP and relaunches sans reboot.
# Get logged in user from /dev/console
loggedInUser=`ls -l /dev/console | awk '{ print $3 }'`
if [ "$loggedInUser" != "admin" ]
then
launchctl unload /Library/LaunchDaemons/com.symantec.Sched501-1.plist
@krispayne
krispayne / update-patch.sh
Last active April 18, 2019 13:55
wrapper to update a patch definition with patchstarter.py from brysontyrell
#!/bin/bash
# update a patch
PATCHSTARTER="/usr/local/sbin/patchstarter"
echo -n "Enter an app name: "
read -e APP_NAME
echo -n "Enter a Publisher name (blank to match App Name): "
read -e PUBLISHER_NAME
#!/bin/bash
# preflight to check for profile installed by Jamf
profile_id="SAMPLE-SAMPLE-SAMPLE-SAMPLE"
# Get logged in user
loggedInUser=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
#loggedInUID=$(id -u "$loggedInUser")
# First, see if the profile is there