REFERENCES FOR LEARNING & USING APPLESCRIPT Modified: 2018/06/19 18:47
AppleScript is a rather peculiar scripting language to learn.
| tell application "Finder" | |
| set sel to the selection as text | |
| set fPath to quoted form of POSIX path of sel | |
| do shell script ("cat " & fPath & " | pbcopy && pbpaste") | |
| end tell |
| -- allSettings is a list of records containing {width:? height:? apps:{{name:? pos:? size:?},...} | |
| -- for each display setup store the apps and their associated position and size | |
| property allSettings : {} | |
| -- create a variable for the current settings | |
| set currentSettings to {} | |
| display dialog "Restore or save window settings?" buttons {"Restore", "Save"} default button "Restore" | |
| set dialogResult to result |
| #change some specific application's interface language | |
| defaults write com.google.Chrome AppleLanguages "(zh_CN,en_US)" | |
| defaults write com.apple.iWork.Pages AppleLanguages "(zh_CN,en_US)" | |
| defaults write com.apple.Aperture AppleLanguages "(zh_CN,en_US)" | |
| #change all applications' interface language, don't recommend. | |
| defaults write NSGlobalDomain AppleLanguages "(en_US,zh_CN)" | |
| defaults write NSGlobalDomain AppleLanguages "(zh_CN,en_US)" |
If you're doing stuff with Ruby on a Mac, e.g. installling Jekyll or something, by default you'll end up having to use the sudo command to do stuff, since the permission to modify the default config is not available to your user account.
This sucks and should be avoided. Here's how to fix that.
To make this better, we are going install a new, custom Ruby. This used to be a big, scary thing, but thanks to the awesome tools Homebrew and rbenv, it's a snap.*
A word of warning: you will have to use Terminal to install this stuff. If you are uncomfortable with text, words, and doing stuff with your computer beyond pointing and hoping, this may not work well for you. But if that's the case, I'm not sure why you were trying to use Ruby in the first place.
pyenv global
| ################################################################################ | |
| # PRIVACY RULES # | |
| # * OSX EL CAPITAN - NO CONNECTIONS TO CUPPERTINO * # | |
| # MIX OF DIFFERENT /etc/hosts FILES I'VE FOUND. 80% OF THE ENTRIES CAME FROM # | |
| # MY OWN. OSX SENDS HUGE AMMOUNT OF REQUESTS TO CUPPERTINO EVENT WHEN # | |
| # SPOTLIGHT SUGGESTIONS, ICLOUD, AND OTHER SERVICES ARE DISABLED # | |
| # USE IT IF YOU DON'T LIKE OSX CALLING HOME WHEN YOU DON'T WANT IT TO HAPPEN # | |
| # NO CONNECTIONS TO APPLE SERVERS REPORTED BY MY FIREWALL FOR 2 MONTHS # | |
| ################################################################################ | |
| # SAVED FROM: http://pastebin.com/GfaXGL4r |
| # In the example below, the command we want to run is `php -f "$DIR/../run.php"` - change this on lines 30 and 46 | |
| # $DIR is just the directory containing this script file (computed automatically, but you can hardcode it if you want). | |
| # Use $DIR to specify paths relative to the script's path. | |
| # The PROCESS_NAME variable is the name of the process to kill and restart | |
| # You must ensure your process has the same name each time it runs (we use a file at $DIR/../servername to store the name) | |
| # Alternatively, you can hard code the PROCESS_NAME on line 15 if you like | |
| #!/bin/bash |
| #! /bin/bash | |
| # | |
| # TITLE: killuser | |
| # AUTHOR: Josef Gosch <[email protected]> | |
| # DESCRIPTION: Kills all processes belonging to a specific user. | |
| # Iterates signals while doing so, with a 3 second break. | |
| # Signal order: SIGHUP, SIGTERM, SIGINT, SIGKILL | |
| # VERSION: 1.0 | |
| function die { |