Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
import sys, os
import urllib, urllib2
import base64
import json
import requests
import xml.etree.ElementTree as ET
def requests_xml(jss_user, jss_pass, jss_url, category):
@krispayne
krispayne / freeipa.md
Created March 27, 2018 04:34 — forked from devynspencer/freeipa.md
FreeIPA api notes
[devyn@ipa ~]$ ipa help commands
automember-add                         Add an automember rule.
automember-add-condition               Add conditions to an automember rule.
automember-default-group-remove        Remove default (fallback) group for all unmatched entries.
automember-default-group-set           Set default (fallback) group for all unmatched entries.
automember-default-group-show          Display information about the default (fallback) automember groups.
automember-del                         Delete an automember rule.
automember-find                        Search for automember rules.
automember-mod                         Modify an automember rule.
@krispayne
krispayne / freeipa.py
Created March 22, 2018 17:44 — forked from devynspencer/freeipa.py
Use FreeIPA hostgroups as a dynamic inventory source for Ansible. Badass.
#!/usr/bin/env python
import argparse
import json
from ipalib import api
def initialize():
'''
This function initializes the FreeIPA/IPA API. This function requires
#!/usr/bin/python3.4
"""
Custom inventory script for Ansible populated by the JSS
"""
from os.path import dirname, realpath, join
from urllib.parse import quote
import argparse
import json
import configparser
@krispayne
krispayne / spotify-to-itunes-playlists.rb
Last active June 7, 2017 22:29 — forked from cheshire137/spotify-to-itunes-playlists.rb
Ruby script to create iTunes playlists from your Spotify playlists. Requires a Spotify API app.
#!/usr/bin/env ruby
require 'uri'
require 'json'
require 'net/https'
require 'time'
require 'cgi'
require 'csv'
# You need a Spotify API app to have a client ID and client secret. Create
# one at https://developer.spotify.com/my-applications/#!/applications/create
@krispayne
krispayne / bring_the_payne.py
Last active May 4, 2017 21:13 — forked from sheagcraig/bring_the_payne.py
Get IP Address for all computers in the JSS
#!/usr/bin/env python
"""https://twitter.com/krispayne/status/859833552078225408:
@shea_craig is possible with python-jss to generate a list of IP addresses for
computers in the JSS?
"""
from operator import itemgetter
# This example uses python-jss 2.0.0+
@krispayne
krispayne / ToggleWiFi.md
Last active July 25, 2016 17:19 — forked from markaltmann/Toggle WiFi
Automatically disable Wifi when an Ethernet connection (cable) is plugged in on a Mac.

Overview

This is a bash script that will automatically turn your wifi off if you connect your computer to an ethernet connection and turn wifi back on when you unplug your ethernet cable/adapter. If you decide to turn wifi on for whatever reason, it will remember that choice. This was improvised from this mac hint to work with Yosemite, and without hard-coding the adapter names. It's supposed to support growl, but I didn't check that part. I did, however, add OSX notification center support. Feel free to fork and fix any issues you encounter.

Most the credit for these changes go to Dave Holland and Albert Bori

Requirements

  • Mac OSX 10+
  • Administrator privileges
@krispayne
krispayne / macs-on-active-directory.md
Created October 8, 2015 00:55 — forked from bzerangue/macs-on-active-directory.md
Binding and Unbinding to Active Directory from Mac OS via Command Line

Binding and Unbinding to Active Directory from Mac OS via Command Line

  • Open the Terminal Application
  • Type in sudo -i and type in your Mac Administrator account password. sudo gives you root level or administrator level privileges.

To View current Active Directory Settings

dsconfigad -show

To Unbind a Computer from an Active Directory Domain

#!/bin/bash
# NOTE: this is an OSX launchd wrapper shell script for Tomcat (to be placed in $CATALINA_HOME/bin)
CATALINA_HOME=/Users/username/tomcat
function shutdown() {
date
echo "Shutting down Tomcat"
$CATALINA_HOME/bin/catalina.sh stop