Skip to content

Instantly share code, notes, and snippets.

@rmanly
rmanly / gist:5576787
Last active December 17, 2015 07:59
Passing variables from Applescript to bash again...just embedded in a bash script this time.
#!/bin/bash
/usr/bin/osascript << EOF
property compName : ""
repeat while compName is ""
tell application "Finder"
activate
display dialog "What should this computer be named:" default answer compName
@rmanly
rmanly / ppd_single-sided.bash
Created July 3, 2013 19:15
edit the PPDs for the new printers for single-sided default printing
for ppd in ./*; do
{ rm "${ppd}" && awk '/^\*DefaultDuplex/{ sub(/DuplexNoTumble/,"None") }; { print }' > "${ppd}"; } < "${ppd}"
done
@rmanly
rmanly / disable_gatekeeper
Created July 25, 2013 17:21
Demonstrates extended globbing +() and a character class [:alpha:] by testing to see if the first bit of a computer name (in our naming convention) is all letters except in the case of "NIMC-ML-CKOUT"
#!/bin/bash
shopt -s extglob
compname=$(scutil --get ComputerName)
if [[ "${compname}" = "NIMC-ML-CKOUT" ]]; then
exit 0
elif [[ "${compname%%-*}" = +([[:alpha:]]) ]]; then
/usr/sbin/spctl --master-disable
@rmanly
rmanly / YoutubeDL.py
Created November 22, 2013 20:54 — forked from pudquick/YoutubeDL.py
changed iDownloads:// to ghttp:// for downloading via Goodreader
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',
@rmanly
rmanly / SoundcloudDL.py
Created November 22, 2013 20:55 — forked from pudquick/SoundcloudDL.py
changed iDownloads:// to ghttp:// for downloading via Goodreader
import requests, random, datetime, sys, webbrowser, console
def main():
song_page = None
if (len(sys.argv) > 0):
try:
song_page = sys.argv[1]
except Exception:
song_page = None
if not song_page:
@rmanly
rmanly / play_soup-1.py
Created November 25, 2013 21:01
Playing with my food
import requests
import webbrowser
from bs4 import BeautifulSoup
page = requests.get('http://xkcd.com')
soup = BeautifulSoup(page.text)
comic = soup.find(id='comic').img['src']
webbrowser.open(comic)
@rmanly
rmanly / mv_txt_md.bash
Created December 12, 2013 15:45
mv txt files to md for replacing notesy with Editorial and getting pretty text
while read -r -d $'\0'; do
mv "$REPLY" "${REPLY%.*}.md"
done < <(find $HOME/Dropbox/notes -type f -iname "*.txt" -print0)
# Banner-style (default)
from Foundation import NSUserNotification, NSUserNotificationCenter
def notify(title, subtitle, text):
notification = NSUserNotification.alloc().init()
notification.setTitle_(str(title))
notification.setSubtitle_(str(subtitle))
notification.setInformativeText_(str(text))
notification.setSoundName_("NSUserNotificationDefaultSoundName")
NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)
@rmanly
rmanly / pkgbuild_mas_apps.bash
Last active August 29, 2015 14:00
build array with brace expansion per Allister's recomendation
#!/bin/bash
# build array with brace expansion per Allister's recomendation
array=(/Applications/{GarageBand,Pages,iMovie,iPhoto,Keynote,Numbers}.app)
for path in "${array[@]}"; do
app_name="${path##*/}"
name="${app_name%.*}"
version=$(defaults read "${path}"/Contents/Info CFBundleShortVersionString)
pkgbuild --component "${path}" $HOME/Desktop/"${name}-${version}".pkg
@rmanly
rmanly / change_hostname_popup.bash
Created May 8, 2014 14:34
Change Hostname Applescript pop-up
#!/bin/bash
/usr/bin/osascript << EOF
property compName : ""
repeat while compName is ""
tell application "Finder"
activate
display dialog "What should this computer be named:" default answer compName
set compName to text returned of result