Skip to content

Instantly share code, notes, and snippets.

@rmanly
rmanly / applescript_window.bash
Created October 1, 2012 21:24
AppleScript Window
#!/bin/bash
# script your commands here
touch file1
# this is the window block
/usr/bin/osascript << EOF
tell application "Finder"
activate
display dialog "Running Maintenance Tasks" buttons {"Finish IT!"} with icon caution
@rmanly
rmanly / ard_multi_login.bash
Created October 25, 2012 17:57
ARD login to lab with different accounts
#!/bin/bash
computer_name=$(scutil --get ComputerName)
login() {
/usr/bin/osascript << EOF
tell application "System Events"
keystroke "${1}"
keystroke return
delay 1
@rmanly
rmanly / recordname_for_greatest_user.bash
Created November 27, 2012 22:13
returns DOMAIN\Username for user with the most time logged on
#!/bin/bash -
#===============================================================================
#
# FILE: recordname_for_greatest_user.bash
#
# USAGE: ./recordname_for_greatest_user.bash
#
# DESCRIPTION: returns DOMAIN\user for the network user with most time on system
# * with changes to dscl this no longer works in 10.8 and maybe 10.7
#
#!/bin/bash
# sets cups to abort-job instead of default stop-job
# for all currently installed printers
shopt -s nullglob
for file in /etc/cups/ppd/* ; do
path="${file%.ppd}"
name="${path##*/}"
@rmanly
rmanly / read_example.bash
Created April 5, 2013 19:36
read example with prompt
#!/bin/bash
# our naming convention for computers includes first initial & last name of employee
# when there is a marriage or some other reason to change the name this is the script
# I created to make that easier.
main() {
read -r -p "What should I change the computer name to? " new_name
@rmanly
rmanly / gist:5322408
Created April 5, 2013 20:33
Ask for folders with Applescript dialog boxes then rsync. Mostly an exercise to pass the variables from Applescript to a cli program
set sourceFolder to quoted form of POSIX path of (choose folder)
set destFolder to quoted form of POSIX path of (choose folder)
do shell script "rsync -auv --ignore-errors --exclude '.Trash' --exclude 'MobileSync' " & sourceFolder & " " & destFolder with administrator privileges
@rmanly
rmanly / remove ' 2' from filenames
Last active December 16, 2015 03:49
Script for mac-e mailing list to remove ' 2' from end of all filenames. EDIT: to remove extra asterisk from find command
#!/bin/bash
while read -r -d $'\0' file; do
mv "${file}" "${file% *}"
done < <(find . -iname "* 2" -print0)
# here is what it looks lik on the command line
@rmanly
rmanly / gist:5541351
Last active December 17, 2015 03:09
Use Spotlight to find Skype and delete it.
while read -r -d $'\0' skype; do
rm -rf "${skype}"
done < <(mdfind kMDItemCFBundleIdentifier = "com.skype.skype" -0)
import re, urllib2, json, webbrowser, console, SimpleHTTPServer, SocketServer, sys
html_template = """
<html><head><title>Updates</title>
<meta name="viewport" id="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<style media="all">
::-webkit-scrollbar { width: 1px; }
html { width: 100%%; height: 100%%; margin: 0; padding: 0; }
body {
font: normal normal normal 13px/1.5 'Helvetica Neue',Arial,Helvetica,sans-serif;
import urllib2, urlparse, sys, webbrowser
itags = {'45': 'webm_720p',
'44': 'webm_480p',
'43': 'webm_360p',
'38': 'mp4_3072p',
'37': 'mp4_1080p',
'36': 'phone_mp4_240p',
'35': 'flv_480p',
'34': 'flv_360p',