Skip to content

Instantly share code, notes, and snippets.

View pythoninthegrass's full-sized avatar

pythoninthegrass

View GitHub Profile
@pythoninthegrass
pythoninthegrass / secure_bash_passwords.sh
Created April 26, 2020 20:42
Store and use secure passwords in bash
#!/bin/bash
# Mixing in python with bash we can easily retrieve our passwords securely in our shell scripts.
# Read this first: https://live.gnome.org/GnomeKeyring/SecurityPhilosophy
# Make sure your distro has gnome-keyring-daemon installed and running at login,
# as well as python-keyring installed (sudo apt-get install python-keyring)
##
# Follow these steps to see what it does. Verify by looking in Seahorse for your password.
##
@pythoninthegrass
pythoninthegrass / jcds_upload.py
Created May 20, 2020 20:41
A quick-and-dirty script for uploading packages to a Jamf Cloud Distribution Server
#!/usr/bin/python
'''
JCDS package upload script
by G Pugh
Developed from an idea posted at
https://www.jamf.com/jamf-nation/discussions/27869#responseChild166021
Usage:
@pythoninthegrass
pythoninthegrass / Change Jamf Pro Activation Code.sh
Created December 2, 2020 22:27 — forked from talkingmoose/Change Jamf Pro Activation Code.sh
Programmatic method to change a Jamf Pro server's Activation Code via the Classic API.
#!/bin/bash
# server connection information
URL="https://jss.talkingmoose.net:8443"
userName="JSSAPI-Editor"
password="password"
# XML data to upload
THExml="<activation_code>
<organization_name>Talking Moose Industries</organization_name>
@pythoninthegrass
pythoninthegrass / lambda_vs_itemgetter.py
Created January 29, 2021 04:25 — forked from nickholt-driver/lambda_vs_itemgetter.py
Benchmark for lambdas versus itemgetter
import random
from operator import itemgetter
import timeit
def random_point():
return (random.randint(0, 100), random.randint(0, 100), random.randint(0, 100))
points = None # Global because of timeit scoping
def test_lambda():
@pythoninthegrass
pythoninthegrass / Proxmox reload services
Created February 15, 2021 21:19 — forked from kevin39/Proxmox reload services
Proxmox reload services properly (services order is important)
service pve-cluster restart && service pvedaemon restart && service pvestatd restart && service pveproxy restart
@pythoninthegrass
pythoninthegrass / ccdl.command
Last active April 10, 2021 01:27 — forked from ayyybe/ccdl.command
Adobe Offline Package Generator v0.1.2 (macOS only)
#!/bin/bash
CYAN="$(tput bold; tput setaf 6)"
RESET="$(tput sgr0)"
clear
if command -v python3 > /dev/null 2>&1; then
if [ $(python3 -c "print('ye')") = "ye" ]; then
clear
@pythoninthegrass
pythoninthegrass / MegaPKGr.zsh
Last active May 28, 2021 23:59 — forked from talkingmoose/MegaPKGr.zsh
The pkgbuild binary and Jamf Composer don't support adding single files of 8 GB or more to a package. Some apps like Install macOS Big Sur.app include files larger than 8 GB in their bundles. This script will create a deployable PKG file from apps whose bundles include those large files.
#!/bin/zsh
:<<ABOUT_THIS_SCRIPT
-------------------------------------------------------------------------------
Written by: William Smith
Professional Services Engineer
Jamf
bill@talkingmoose.net
https://gist.github.com/e9ed319226c6da30dd633725e48a97b0
@pythoninthegrass
pythoninthegrass / LICENSE
Created June 7, 2021 20:01 — forked from noelbundick/LICENSE
Exclude WSL installations from Windows Defender realtime protection
MIT License
Copyright (c) 2018 Noel Bundick
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@pythoninthegrass
pythoninthegrass / remove_completed_torrents.sh
Last active June 21, 2021 06:53 — forked from root-hal9000/removecompletedtorrents.sh
Transmission-Daemon: Remove Completed Torrents
#!/usr/bin/env bash
# SOURCE: https://gist.github.com/ffcruz85/6c9fb792fce4af0c4cb561fd653c86b6
# Script to check for complete torrents in transmission folder, then stop and move them
# either hard-code the MOVEDIR variable here…
MOVEDIR='/data/complete'
# TODO: read $env vars or file
@pythoninthegrass
pythoninthegrass / beautiful_idiomatic_python.md
Created January 28, 2022 22:03 — forked from 0x4D31/beautiful_idiomatic_python.md
[Beautiful Idiomatic Python] Transforming Code into Beautiful, Idiomatic Python #python

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]: