Skip to content

Instantly share code, notes, and snippets.

View natewalck's full-sized avatar

Nate Walck natewalck

View GitHub Profile
@gregneagle
gregneagle / gist:60ce73c7e267d993f1c1
Created August 13, 2014 17:23
Using the SystemConfiguration framework via PyObjC to get "ComputerName"
import SystemConfiguration
prefs = SystemConfiguration.SCPreferencesCreate(None, "SystemConfiguration", None)
print SystemConfiguration.SCPreferencesGetValue(prefs, "System")["System"]["ComputerName"]
# main config
libdir = /usr/share/mcollective/plugins
logfile = /var/log/mcollective.log
daemonize = 1
keeplogs = 1
max_log_size = 10240
loglevel = debug
identity = my_laptop
registerinterval = 300
#! /usr/bin/env ruby
require 'rubygems'
require 'sinatra/base'
require 'webrick'
#require 'webrick/https'
#require 'openssl'
require 'resolv'
require 'json'
@gregneagle
gregneagle / gurl.py
Last active December 28, 2015 22:29
# http://httpstat.us - for test error codes
# http://uri-labs.com/macosx_headers/NSURLConnection_h/Protocols/NSURLConnectionDelegate/index.html
# Notes:
# - Errors are only thrown when the connection:
# - Is interrupted before the headers can complete
# - SSL couldn't happen correctly
# - The connection never happens
# - A delegate.response always has a NSHTTPURLResponse key for HTTP/HTTPS
# For a file:// transfer, it's NSURLResponse
@grahamgilbert
grahamgilbert / com.grahamgilbert.crypt.launcher.plist
Created December 12, 2013 17:19
LaunchDaemon, LaunchAgent and script to run Crypt as root at login without using a loginhook. The user can click on the desktop and quit the app, but it does get around any networking issues that might happen when running before login is finished.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.grahamgilbert.crypt.launcher</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/crypt/Crypt.app/Contents/MacOS/Crypt</string>
</array>
@groob
groob / hi_frogor.go
Last active December 12, 2019 01:26 — forked from pudquick/hi_groob.py
Search my gists ;p
package main
import (
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
)
@pudquick
pudquick / AppleJRE.py
Created April 9, 2015 05:40
Use Apple's PrivateFramework "JavaLaunching" functions to determine if the Apple JRE is installed (without triggering the dialog)
import sys
from ctypes import CDLL
JavaLaunching = CDLL('/System/Library/PrivateFrameworks/JavaLaunching.framework/JavaLaunching')
if (JavaLaunching.JLIsRuntimeInstalled() == 0):
print "Apple JRE is not installed."
sys.exit(1)
else:
print "Apple JRE is installed."
sys.exit(0)
@gregneagle
gregneagle / gist:6957826
Last active January 4, 2021 09:39
Using PyObjC and NSWorkspace to set the desktop picture. I am such a hypocrite!
#!/usr/bin/python
'''Uses Cocoa classes via PyObjC to set a random desktop picture on all screens.
Tested on Mountain Lion and Mavericks.
See:
https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSWorkspace_Class/Reference/Reference.html
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html
@pudquick
pudquick / pids.py
Last active September 19, 2022 21:06
Get pids and path executables for processes running on OS X in python
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))()
@pudquick
pudquick / 8021x_inspect.py
Last active September 27, 2022 10:04
802.1x configuration / data collection on OS X using python and the PrivateFramework "EAP8021X.framework"
# This was all run from user space
# I haven't tested it with root
# ... but it didn't prompt for any permissions under userspace ^_^
# Tested on 10.11.5
import objc
from Foundation import NSBundle
EAP8021X_bundle = NSBundle.bundleWithPath_('/System/Library/PrivateFrameworks/EAP8021X.framework')
Security_bundle = NSBundle.bundleWithIdentifier_('com.apple.security')