Skip to content

Instantly share code, notes, and snippets.

View natewalck's full-sized avatar

Nate Walck natewalck

View GitHub Profile
@natewalck
natewalck / quarantine_demo.py
Created February 24, 2023 00:02 — forked from gregneagle/quarantine_demo.py
Using Apple's quarantine API from PyObjC
#!/usr/local/munki/munki-python
'''Demo only. Needs more robust error checking and handling'''
import os
from Foundation import NSURL, NSURLQuarantinePropertiesKey
def getQuarantineAttribute(pathname):
'''Returns a dict contaning quarantine info for pathname or None'''
@natewalck
natewalck / boot.sh
Created June 10, 2021 17:44 — forked from Jip-Hop/boot.sh
Using Docker on TrueNAS SCALE (no Kubernetes)
#!/usr/bin/env bash
# Using Docker on TrueNAS SCALE (no Kubernetes)
#
# Don't setup Apps via the TrueNAS Web GUI (don't choose a pool for Apps when asked)
# Make a dedicated docker dataset on one of your data pools
# Store this script somewhere else on your pool (not in the Docker dataset)
# Make a daeomon.json file in the same directory with the following contents:
# {"data-root": "/mnt/path/to/desired/docker/dataset/", "exec-opts": ["native.cgroupdriver=cgroupfs"]}
# Then schedule this script to start via System Settings -> Advanced -> Init/Shutdown Scripts -> Add:
@natewalck
natewalck / ducky.md
Created June 24, 2020 12:20 — forked from schmich/ducky.md
Programming media keys on the Ducky One 2 Skyline

Programming Media Keys on the Ducky One 2 Skyline

To use media keys on the Ducky One 2 Skyline, you must record a macro to bind the media function to a hotkey combination, i.e. Fn plus some key.

Example

Important: In the instructions below, "Press X+Y+Z" means press and hold key X, press and hold key Y, press and hold key Z in that order, and then release all three.

As an example, to bind Fn+PgUp to the play/pause media function:

H
/^def macosx_sdk_root(/a
.
/cflags =/i
sdkroot = os.environ.get('SDKROOT')
if sdkroot is not None:
return sdkroot
.
/# Check the additional directories$/a
.
H
/^#include/a
#include <stdlib.h>
.
/^get_history_item(/a
.
/^#ifdef *__APPLE__/c
/*
* Recent versions of libedit have corrected the off-by-one history indexes
* (though the Apple version emulates a true offset rather than using the
H
g/-Wl,-search_paths_first/d
g/ -lSystemStubs -arch_only [^"]*/s///
g/-current_version $(VERSION)/s//-current_version $(PYTHON_CURRENT_VERSION)/
g/-O3/s//-Os/g
/^OTHER_LIBTOOL_OPT$/i
EXTRA_CFLAGS
LIBTOOL
.
/# Calculate the right deployment target for this build\./i
@natewalck
natewalck / cocoa_keypress_monitor.py
Last active August 29, 2015 14:27 — forked from ljos/cocoa_keypress_monitor.py
Showing how to listen to all keypresses in OS X through the Cocoa API using Python and PyObjC
# cocoa_keypress_monitor.py by Bjarte Johansen is licensed under a
# License: http://ljos.mit-license.org/
from AppKit import NSApplication, NSApp
from Foundation import NSObject, NSLog
from Cocoa import NSEvent, NSKeyDownMask
from PyObjCTools import AppHelper
class AppDelegate(NSObject):
def applicationDidFinishLaunching_(self, notification):
host = Host.new(:name => "whatever", :environment => Environment.first)
host.save
osfamily_fact = FactValue.new(:value => "windows", :fact_name => FactName.find_by_name('osfamily'), :host => host)
osfamily_fact.save
#!/bin/bash
# Dashing service
# Add this file to /etc/init.d/
# $ sudo cp dashboard /etc/init.d/
# Update variables DASHING_DIR, GEM_HOME, & PATH to suit your installation
# $ sudo nano /etc/init.d/dashboard
# Make executable
# $ sudo chmod 755 /etc/init.d/dashboard
# Update rc.d
# $ sudo update-rc.d dashboard defaults
@natewalck
natewalck / pids.py
Created February 18, 2014 19:37 — forked from pudquick/pids.py
from ctypes import CDLL, sizeof, memset, c_uint32, create_string_buffer
MAXPATHLEN = 1024
PROC_PIDPATHINFO_MAXSIZE = MAXPATHLEN*4
PROC_ALL_PIDS = 1
libc = CDLL('libc.dylib')
def get_pids():
number_of_pids = libc.proc_listpids(PROC_ALL_PIDS, 0, None, 0)
pid_list = (c_uint32 * (number_of_pids * 2))()