Skip to content

Instantly share code, notes, and snippets.

@opragel
opragel / uninstall_adobe_flash_player_osx.sh
Last active October 12, 2017 22:24
uninstall_adobe_flash_player_osx.sh
#!/bin/bash
# your funeral
LOCAL_INSTALL_MANAGER="/Applications/Utilities/Adobe Flash Player Install Manager.app/Contents/MacOS/Adobe Flash Player Install Manager"
DOWNLOAD_URL="https://fpdownload.macromedia.com/get/flashplayer/current/support/uninstall_flash_player_osx.dmg"
DMG_NAME=$(printf "%s" "$DOWNLOAD_URL" | sed 's@.*/@@')
LOCAL_DMG_PATH="/tmp/$DMG_NAME"
LOCAL_VOLUME_NAME="Flash Player"
localFlashVersion=$(/usr/bin/defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" CFBundleShortVersionString)
@joshuaclayton
joshuaclayton / gist:721214
Created November 30, 2010 05:36
Homebrew-installed Python with pyobjc-core and pyobjc
I use Homebrew and wanted to install pip for mercurial. Pip requires a homebrew-installed version of Python, which is fine and dandy; however, I noticed that webkit2png was broken after I installed Python with Homebrew (it was missing pyobjc libs, which comes with the OS X Python install by default).
This assumes that the current homebrewed version of Python is 2.7.1 and that homebrew is set up for /usr/local. If that's not the case, you may have to change the minor version of setuptools (e.g. from 2.7 to 2.8) and change the PATH accordingly.
$ brew install python
Modify your PATH to include the path to Python's bin directory:
export PATH="/usr/local/Cellar/python/2.7.1/bin:/usr/local/bin:$PATH"
FROM debian:jessie
ARG VERSION=0.12.1
ARG SHA256HASH=34de171ac1b48b0780d68f3844c9fd2e8bfe6a7780b55e1f012067c2440ebd8a
RUN apt-get update && \
apt-get install -y wget ca-certificates && \
apt-get clean && \
wget https://www.bitcoinunlimited.info/downloads/bitcoinUnlimited-${VERSION}-linux64.tar.gz && \
@rduplain
rduplain / responsive_d3_example.html
Created April 18, 2012 14:55 — forked from mattalcock/responsive_d3_example.html
Responsive d3.js D3 Javascript Histogram Example
<!DOCTYPE html>
<script src="http://mbostock.github.com/d3/d3.v2.js?2.8.1"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<style>
body {
font: 10px sans-serif;
}
rect {
@pudquick
pudquick / fastuser_logincheck.py
Created April 26, 2016 05:39
Using CGSSessionCopyAllSessionProperties to detect logged-in users the way the Fast User switching menu extra does on OS X with python and pyobjc
import objc
from Foundation import NSBundle
CG_bundle = NSBundle.bundleWithIdentifier_('com.apple.CoreGraphics')
functions = [("CGSSessionCopyAllSessionProperties", b"@"),]
objc.loadBundleFunctions(CG_bundle, globals(), functions)
# example usage: graphical_security_sessions = CGSSessionCopyAllSessionProperties()
#!/bin/bash
echo 'Requires Ubuntu = 16.04 and installs Nginx + uWSGI + Web2py'
# Check if user has root privileges
if [[ $EUID -ne 0 ]]; then
echo "You must run the script as root or using sudo"
exit 1
fi
# parse env vars
WEB2PY_PASS="${WEB2PY_PASS:-0}"
NOPASSWORD="${NOPASSWORD:-0}"
@soundsnw
soundsnw / standard-user-access.sh
Created June 11, 2019 12:33
Give macOS standard users access to networking, printing and more
#!/bin/sh
#
# Provides standard user access to preference panels they would expect to be able to access, and might need access to.
#
# Provides standard users access to system preferences
/usr/bin/security authorizationdb write system.preferences allow
@bruienne
bruienne / create_osx_pbkdf2_plist.py
Created April 24, 2016 15:52
Create an MDM-compatible PBKDF2 hash and plist for use with AccountConfiguration
#!/usr/bin/python
# Requires passlib: pip install passlib
from passlib.hash import pbkdf2_sha512
from passlib.util import ab64_decode
from biplist import *
# Checksum size must be 128 bytes for use as OS X password hash!
pbkdf2_sha512.checksum_size = 128
hash = pbkdf2_sha512.encrypt("password", rounds=38000, salt_size=32)
@gregneagle
gregneagle / gist:01c99322cf985e771827
Created January 20, 2015 18:16
Using CFPreferences in Python to set a complex preference
import plistlib
import CoreFoundation
from Foundation import NSDate, NSMutableArray, NSMutableDictionary
# read the current ManagedPlugInPolicies
policy = CoreFoundation.CFPreferencesCopyAppValue("ManagedPlugInPolicies", "com.apple.Safari")
if policy:
# policy is an immutable dict, so we have to make a mutable copy
my_policy = NSMutableDictionary.alloc().initWithDictionary_copyItems_(policy, True)
@bruienne
bruienne / pfstart.sh
Created April 4, 2016 18:40
Sample script to chainload a custom ruleset into PF, avoids editing Apple's standard config
#!/bin/bash -x
# Wait for networking to be up, just in case
/usr/sbin/ipconfig waitall
# Loop on the presence of the standard Apple ruleset before proceeding
# This way we don't accidentally get overruled (SWIDT) if com.apple.pfctl
# happens to be loaded after myorg.pf.
count=0
while [[ $(pfctl -sr 2>&1 | egrep "apple" | wc -l) -eq 0 && $count -lt 12 ]]; do