Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Creating a kill switch for the OSX VPN client Network
I live in China so I have to use VPN all the time if I want any kind of stable connection to sites in the west. Unfortunately the VPN will at times randomly disconnect and then all traffic will immediately start going over chinese Internet again. While this is not a big deal really, I would just prefer not to be logged in to Facebook or Gmail and have my traffic open to be sniffed by the great firewall. It also occurred to me that many people use VPNs in the states in order to safely torrent.

I know some VPN providers have 'Internet kill switches' for their VPN that will cut your Internet connection incase of a disconnect and make sure you are not leaking anything. The problem with these is that they are almost all using openVPN, while I use L2TP over IPSec for my VPN. I searched for a long time for a way to do this and could not find one so I thought of a way to do it on my own. The following is how I set my system up. Please keep in mind that I am not an experienced Terminal user or power user so if anyone knows of a better way to do this please let me know.
read more (1,035 words)   Post a comment  •  Comments (0)  
  • Currently 1.19 / 5
  You rated: 4 / 5 (54 votes cast)
[15,468 views]  View Printable Version
Automator Service to toggle the alias bit System 10.9
Aliases in OS X are identified to the system by an attribute referred to as the alias bit. This hint provides a very simple way to be able to toggle the alias bit of selected files within the Finder.

There may be some need to be able to toggle the alias bit of files from within the Finder. For example, I found that using Bittorrent Sync to keep files synchronized across multiple devices is very useful and a real time saver, but suffers from a bug in the OS X version, that causes aliases to lose their status as aliases. I traced the problem to the alias bit not syncing and though the developers continue to promise to fix it, I got tired of waiting.

So I put together an Automator action that installs as a service in OS X. It adds a Service to the contextual menu that will toggle the alias bit on any file or folder in the Finder. It works on multiple files at once. Just select what you want, right click, and choose 'Toggle Alias Bit.' I made it a toggler rather than a setter so you can undo it if you accidentally turn a regular file into an alias.

I'm hosting it via my Google Drive if you want to download it.

To install, unzip it, double click it, done (sort of). If you don't have Xcode installed, the first time you try to use it there will be a short pause, then you'll be prompted to download and install Xcode developer tools. This will happen automatically, you just need to OK it. The reason for the developer tools requirement is the use of the GetFileInfo and SetFile commands, which are part of that.

If you want to do it yourself in Automator, here are the relevant steps:
  • Open Automator and choose Service as the type of new document.
  • Drag Run Shell Script to the workflow. Make sure the Service receives selected files or folder in Finder, are checked for the options. Shell should be /bin/bash and pass input as arguments
  • Copy and paste the following into the 'Run Shell script' box:
    #This script will toggle the alias bit for a file  
    for f in "$@"  
    #GetFileInfo -aa should return 1 for alias, 0 for not alias  
        if [ `GetFileInfo -aa "$@"` == "1" ] # if it's an alias  
          SetFile -a "a" "$@" # set it to not be an alias  
          SetFile -a "A" "$@" # otherwise, it's not an alias, so make it one  
  • Save it as something useful like 'Toggle Alias bit.'
  • Use as described above.
Apologies if this is not the most simple or efficient scripting. It is the first bit of programming I have done in about twenty years. Also, this will likely work in older versions of OS X, but how far back, I do not know.

[crarko adds: I haven't fully tested this one. I had some problems working with the downloadable version, so I'd recommend creating the Service from scratch using the code above. I already have Xcode installed so I did not get the prompt to install it, as expected.]
  Post a comment  •  Comments (2)  
  • Currently 1.12 / 5
  You rated: 5 / 5 (100 votes cast)
[9,652 views]  View Printable Version
Add Multiple URLs to a Calendar Event Apps
I frequently want to add multiple URLs to Calendar events. Of course, you can put them in the Notes section, but given that there's a URL field, it seems a little kludgey. This solution is kludgey too, but perhaps a bit less so.

Drag the additional link(s) to the Finder to create a .webloc file; then drag that file to the attachment field for the event.

You can double-click the file to open the link, which is better than the link being non-clickable in the Notes field, where you would have to highlight and right-click (Control+click). The URL won't appear in the body of an email when you send an event to someone, but it will be in the attached .ics file.

[crarko adds: I haven't tested this one.]
  Post a comment  •  Comments (4)  
  • Currently 1.56 / 5
  You rated: 4 / 5 (18 votes cast)
[15,600 views]  View Printable Version
Create a Fusion Drive with a Recovery Partition Storage Devices
There are many step-by-step guides on the internet that explain how to add an SSD to an existing Mac, and create a 'Fusion Drive' that has the speed of an SSD, but also the capacity of a Hard Drive. All these guides fall short in one way that was important to me.

Creating the Fusion Drive the way these walkthroughs say (including OWC's exceptional guides), destroys the Recovery Partition that exists on the drive. Without a Recovery Partition, you cannot enable FileVault2, and will need some other external boot drive if you ever need to perform maintenance on your internal drives. For a laptop computer that might be far from home, not having a Recovery Partition was unacceptable to me. Also note that if you buy a Mac from Apple today with Fusion Drive, it DOES come with a Recovery Partition, so it is indeed possible to do.

It turns out that Apple's Core Storage technology is more flexible than these walkthroughs give on. You can enroll an individual partition of a drive in a Fusion Drive, instead of the whole drive. This means that you can join just a specific data partition of your HD with an SSD, and leave the Recovery Partition intact.
read more (536 words)   Post a comment  •  Comments (6)  
  • Currently 1.41 / 5
  You rated: 5 / 5 (32 votes cast)
[19,121 views]  View Printable Version
Using Time Machine on unsupported volumes System
I wanted to use Time Machine on my exFAT hard drive, but turns out that these volumes aren't supported from Time Machine! There is a very simple way to use Time Machines on unsupported hard drives, as long as you follow these instructions carefully you shouldn't have any issues at all.

First, connect the unsupported volume (in this case, an exFAT external hard drive.) When it mounts, open the Terminal and type these commands, substituting 'My External HDD Name' for the name of the unsupported volume.

cd /Volumes
cd 'My External HDD Name'

Next, type this code, substituting for your needs:

hdiutil create -size 320g -type SPARSEBUNDLE -fs "HFS+J" MacBook-Backup.sparsebundle
open MacBook-Backup.sparsebundle

Here, a 320GB sparse bundle named 'MacBook-Backup' is being made and mounted. You can change these values as you see fit. From herein, I'll refer to the sparse bundle name as 'MacBook-Backup'.

After you've run these commands, a new volume named untitled will appear on your Desktop. This will become your Time Machine backup volume. If you want, rename it to something else (I called mine MacBook Pro Backup) and run the command:

diskutil list

You should see a list appear of all connected volumes. Find your new volume's name and read along until you find the disk identifier. In this case, my identifier is disk2s2, but yours may be different.

Finally, enter the commands below (entering your password if prompted). Replace disk2s2 with your identifier, and 'MacBook Pro Backup' with the name of your new Time Machine volume.

sudo diskutil enableOwnership /dev/disk2s2
sudo tmutil setdestination '/Volumes/MacBook Pro Backup'

Now, open the Time Machine preference pane in System Preferences, and turn Time Machine on. That's it - you've set up Time Machine with an unsupported volume!

[crarko adds: I'd suggest having a known good backup handy before trying any procedure like this, just in case. If Time Machine recognizes the volume you should be good. The hint resembles what has been done using network volumes. If you do try this out please post your experience to the comments.]
  Post a comment  •  Comments (11)  
  • Currently 1.62 / 5
  You rated: 1 / 5 (21 votes cast)
[16,154 views]  View Printable Version
10.8: AppleScript to close iCal Alerts System 10.8
I'd just installed OS X 10.8, and booted to find the right side of my screen covered in Birthday and Calendar notifications! Since installing I've clicked 'Close' on way too many iCal notification alerts.

Here's a script to close them all for you in one fell swoop. Since I still want iCal to popup a Notification alert for event alarms I've set, I don't want to simply disable all the iCal notifications (or set them to temporary banner alerts).

However, it still occurs that sometimes a small pile of alerts have accrued while I was away from the computer, and I really hate hitting 'Close' a bunch of times.

So, followng is a script to simply close all the piled-up Notification Alerts. The script was put together using these two webpages for inspiration: (most of the nice code comes from here) and (just how to click a button with AppleScript).

on run
end run

on closeNotifications()
  -- This function closes all currently displaying notification alerts. It used to also return the titles of each notification, which I have commented out to disable.
  tell application "System Events"
   tell process "Notification Center"
    set theseWindows to every window whose subrole is "AXNotificationCenterAlert" or subrole is "AXNotificationCenterBanner"
    --set theseTitles to {}
    repeat with thisWindow in theseWindows
      -- Save the title of each alert window:
      --set thisTitle to the value of static text 1 of scroll area 1 of thisWindow
      --set the end of theseTitles to thisTitle
      -- Close each alert:
      click button "Close" of thisWindow
     end try
    end repeat --"theseWindows"
    --return theseTitles
   end tell -- "NotCenter"
  end tell -- "SysEvents"
 on error errorMessage number errorNumber
  if errorNumber is errorNumber then
   my addAppletToAccessibilityList()
   error number -128
  end if
 end try
end closeNotifications

on addAppletToAccessibilityList()
 -- This function gets the user to enable Accessibility, for scripting the UI interface (hitting buttons etc.)
 set thisAppletFile to (path to me)
 tell application "Finder" to reveal thisAppletFile
 tell application "System Preferences"
  reveal anchor "Privacy_Assistive" of pane id ""
  display alert 
   "Add Applet to Accessibility" message "In order to respond to user clicks on Notification panels and alerts, this applet must be added to the lost of apps approved to use accessibility controls of the OS." & return & return & 
   "To add this app:" & return & return & 
   "1) Click the lock icon (if it is locked) and enter your password." & return & return & 
   "2) If '' is in the list, check the box next to it's name." & return & return & 
   "Otherwise, if the applet's name is in the list, check the box next to it's name. If it's not in the list, drag the applet (currently shown in the Finder) into the list area." & return & return & 
   "3) Click the lock to re-lock the preference pane, close System Preferences."
 end tell
end addAppletToAccessibilityList

[crarko adds: I haven't tested this one, as I don't run Mountain Lion any more. I remember the problem very well, though. I did compile the script successfully.]
  Post a comment  •  Comments (2)  
  • Currently 1.09 / 5
  You rated: 4 / 5 (55 votes cast)
[13,204 views]  View Printable Version
Create very unique signatures in Preview Apps
You can make signatures in Preview that are pen and ink style drawings.

I don't know if this has been posted yet, or if it is generally known, but I stumbled upon a neat feature of signatures in When you create a signature, if you you don't hold up a piece of paper with a signature on it, and simply smile for a mug shot, Preview will create a signature that is a neat pen and ink style image of yourself, or whatever is in front of the camera. I've created several, that for the right client, can be used as a humorous alternative to an actual signature. I also used a screen capture of the signature on a document and made the image into a Facebook Profile picture.

[crarko adds: Well I didn't know about it. Most folks use Photo Booth to do things like this, I'd guess, but I always appreciate a creative use of a program.]
  Post a comment  •  Comments (8)  
  • Currently 1.08 / 5
  You rated: 5 / 5 (264 votes cast)
[9,702 views]  View Printable Version
Custom margins in TextEdit Apps
There is already an old hint about this topic, but it doesn't really explain it very clearly, only in the comments.

Here's how you can change the margins in TextEdit to your favourite size, so that you can use, for example, the whole space on a sheet of paper when printing.

First, save your document first as a Rich Text file (.rtf), if you have not already done this. To see the effect directly in your document, open it and enable under the Format menu the setting Wrap to Page for your document.

Next open up the TextEdit preferences, switch to the tab Open and Save and check on the option Display RTF files as RTF code instead of formatted text.

Open the document again and you will see the raw code that defines how the document look like. You want to look in the 4th row, where it says:


This defines the left and right margins, thats what the 'l' and 'r' behind marg stand for: left and right.

Now to define customized top and bottom margins you have to add margt and margb, and similarly to before 't'=top, and 'b'=bottom. So add these after the given ones for the side margins, like this:


Now you can set the margins how you like. You have to replace the stars with the correct number in Twips (1 Twip = 1/1440 inch). Here a few examples:
  • 360 (.25 inch)
  • 720 (.5 inch)
  • 1080 (.75 inch)
  • 1440 (1 inch)
  • 567 (1 cm)
Finally save the modified document and change the preference settings back to what they were originally. Then open the document again and you'll have your custom margins.

[crarko adds: I haven't tested this one. Please note that updating older hints and clarifying them is always a good thing, so don't be shy about submitting ideas that do just that.]
  Post a comment  •  Comments (1)  
  • Currently 2.60 / 5
  You rated: 3 / 5 (10 votes cast)
[9,097 views]  View Printable Version
Low-power mode for iOS devices
It's possible to save power when using Maps to navigate in a car. It's an obvious trick once you know about it, and easy too.

When you're navigating with the Maps app, you're probably used to it chewing through battery life. Even on a full charge my iPhone 5 doesn't last more than 2-3 hours when navigating.

To eke out extra life, just press the Sleep button (top of the phone), once you're on your way and are on a long stretch before the next turn/navigation point (i.e. on a freeway for 50 miles). The screen will blank, but the navigation will continue. The phone will briefly wake 10 miles from your next turn/navigation point, to tell you about it, and will wake 2 miles from it and stay awake until you get past it.

To switch back to non-power-saving mode, just swipe as usual to wake the phone.

To be honest this doesn't save a huge amount of battery life in my tests, but it's better than nothing. For long journeys,you really need a USB power source such as those that fit into cigarette lighter sockets.

[crarko adds: I haven't tested this one, but I will on my next long drive.]
  Post a comment  •  Comments (7)  
  • Currently 2.67 / 5
  You rated: 5 / 5 (9 votes cast)
[7,113 views]  View Printable Version
Hiding Software Updates System
Since the introduction of Lion the system's Software Opdate mechanism has been integrated into App and the Software Update Preference Pane has been removed and substituted with "App Store".

If you constantly are being reminded to install software updates you don't really want to install, you can right-click (Control+click) the name of the update and hide it, eliminating the reminder.

[crarko adds: I think this is probably known already to many of you, but if it's not it can be a handy trick. I find the whole App Store method for Software Update a lot less pleasant than the old Snow Leopard mechanism where it was separate, but maybe I'm just old fashioned.]
  Post a comment  •  Comments (11)  
  • Currently 2.50 / 5
  You rated: 2 / 5 (10 votes cast)
[10,591 views]  View Printable Version