Skip to content

Instantly share code, notes, and snippets.

@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/,/'
#!/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
#!/usr/bin/env python
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This script can create an Ansible Dynamic Inventory with either:
# - the FreeIPA API over HTTPS with the `python_freeipa` module
# - using kerberos authentication with the `ipalib` and `ipaclient` module
#
# DEPENDENCIES: before this script will work the python_freeipa or ipalib module has to be installed
#
# For Ansible AWX or Tower add this to your Docker image
@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
for freeipa source credential:
input config (yaml)
fields:
- type: string
id: fipahttps
label: HTTPS
default: True
- type: string
id: fipaserver
@krispayne
krispayne / jss-inventory.py
Last active July 12, 2018 17:31
trying to make a useable jss to ansible inventory based off groups of last reported ip's from the jss api.
#!/usr/bin/python
"""
JSS + Ansible inventory
A dictionary of lists of computers by group name.
Heavily influenced by https://gist.github.com/BadStreff/0af3f881de162182eaaff406ce7a7f0d
with help from https://gist.github.com/chilcote/fb670103b8e90aaea67dee0ffc6cc983
I'd really like to avoid caching, as any sort of timeout won't be appropriate since I