Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
ifconfig lo0 alias $1
@sofakartoffel
sofakartoffel / gist:5175899
Last active December 15, 2015 00:49
OSX seems to set 802.11d country code upon the first found network's country code. This might not be the correct one, depending on your or your neighbors' settings. This script restarts your Wi-Fi until (or 10 times) the correct country code is set.
-- This does not work if you need administrator privilieges for setting Wi-Fi power
set correctcountrycode to "DE"
repeat 10 times
set countrycode to do shell script "system_profiler SPAirPortDataType -xml | xmllint --dropdtd - | xpath '//key[text()=\"spairport_wireless_country_code\"]/following-sibling::string[1]/text()'"
if countrycode = correctcountrycode then exit repeat
do shell script "networksetup -setairportpower en1 off"
delay 6
do shell script "networksetup -setairportpower en1 on"
delay 2
end repeat
@sofakartoffel
sofakartoffel / gist:5173767
Created March 15, 2013 22:51
change the behavior of function keys (F1, F2, ...)
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
-- If we don't have UI Elements enabled, then nothing is really going to work.
if UI elements enabled then
tell application process "System Preferences"
get properties
@sofakartoffel
sofakartoffel / gist:5173724
Created March 15, 2013 22:47
Restarts coreaudio. Can help fixing problems with airplay
tell current application
activate
do shell script "killall coreaudiod" with administrator privileges
end tell