Skip to content

Instantly share code, notes, and snippets.

View chrisgrande's full-sized avatar

Christopher Grande chrisgrande

View GitHub Profile
chrisgrande /
Created January 8, 2024 22:55
macOS Software Update DDM Extension Attribute
# Define the path to the property list file
# Check if the file exists
if [ -f "$plist_file" ]; then
# Use PlistBuddy to extract the Declarations section
declarations=$(/usr/libexec/PlistBuddy -c "Print SUCorePersistedStatePolicyFields:Declarations" "$plist_file")
chrisgrande /
Created August 31, 2023 20:26
A python version of the Ruby syntax.
#!/usr/bin/env python3
from datetime import datetime, timedelta
class TimeDeltaWrapper:
def __init__(self, delta): = delta
def ago(self):
return -
chrisgrande /
Created May 3, 2023 01:06
Exports DNS Zone information from your account for each domain
import requests
import json
# Username and password
name = 'username'
password = 'password'
# Login to Hover
s = requests.Session()
r ='',
chrisgrande /
Created March 24, 2023 17:00
Django view mixin to redirect to a named view on 404
from django.http import Http404
from django.urls import reverse
from django.shortcuts import redirect
from django.views.generic.detail import SingleObjectMixin
class RedirectOn404Mixin(SingleObjectMixin):
redirect_url_name = None
def get(self, request, *args, **kwargs):
# Get Policy Paramamter for the Installer UID.
if [ -z "$BOMGAR_CODE" ]; then
echo "You must configure the installer UID in the Jamf Policy!"
exit 1
#!/usr/bin/env python3
from AppKit import NSWorkspace
def is_alias (path):
uti, err = NSWorkspace.sharedWorkspace().typeOfFile_error_(
os.path.realpath(path), None)
if err:
raise Exception(err)
import os
from docklib import Dock
from AppKit import NSBundle, NSRunningApplication
from pathlib import Path
import sys
import time
import pwd
chrisgrande / slugify_controller.html
Last active April 17, 2021 07:45
Generic slugify Stimulus controller. Takes input text and outputs slugified version as you type to another input field.
<div data-controller="slugify">
<input data-slugify-target="input" data-action="input->slugify#inputToOutput" type="text">
<input data-slugify-target="output" type="text">
chrisgrande /
Created September 22, 2020 22:46 — forked from zulhfreelancer/
How to upgrade Heroku Postgres database plan?
  1. Assuming you have multiple Heroku apps and Git remote like so:
development (fetch)
development (push)
origin  (fetch)
origin  (push)
production (fetch)
production (push)
staging (fetch)