Skip to content

Instantly share code, notes, and snippets.

View chrisgrande's full-sized avatar

Christopher Grande chrisgrande

View GitHub Profile
@chrisgrande
chrisgrande / ea_ddm_decalaration.sh
Created January 8, 2024 22:55
macOS Software Update DDM Extension Attribute
#!/bin/bash
# Define the path to the property list file
plist_file="/var/db/softwareupdate/SoftwareUpdateDDMStatePersistence.plist"
# 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
chrisgrande / TimeInterval.py
Created August 31, 2023 20:26
A python version of the Ruby 5.day.ago syntax.
#!/usr/bin/env python3
from datetime import datetime, timedelta
class TimeDeltaWrapper:
def __init__(self, delta):
self.delta = delta
def ago(self):
return datetime.now() - self.delta
@chrisgrande
chrisgrande / hover_dns_exporter.py
Created May 3, 2023 01:06
Exports DNS Zone information from your Hover.com account for each domain
import requests
import json
# Username and password
name = 'username'
password = 'password'
# Login to Hover
s = requests.Session()
r = s.post('https://www.hover.com/api/login',
@chrisgrande
chrisgrande / mixins.py
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):
#!/bin/bash
# Get Policy Paramamter for the Installer UID.
BOMGAR_CODE=$4
if [ -z "$BOMGAR_CODE" ]; then
echo "You must configure the installer UID in the Jamf Policy!"
exit 1
fi
#!/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)
else:
#!/usr/local/mxcc/mxcc-python3
import os
from docklib import Dock
from AppKit import NSBundle, NSRunningApplication
from pathlib import Path
import sys
import time
import pwd
@chrisgrande
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">
</div>
@chrisgrande
chrisgrande / upgrade.md
Created September 22, 2020 22:46 — forked from zulhfreelancer/upgrade.md
How to upgrade Heroku Postgres database plan?
  1. Assuming you have multiple Heroku apps and Git remote like so:
development https://git.heroku.com/xxx.git (fetch)
development https://git.heroku.com/xxx.git (push)
origin      git@bitbucket.org:xxx/xxx.git  (fetch)
origin      git@bitbucket.org:xxx/xxx.git  (push)
production  https://git.heroku.com/xxx.git (fetch)
production  https://git.heroku.com/xxx.git (push)
staging https://git.heroku.com/xxx.git (fetch)