grunt-codekit now supports js concatenation

9. juni 2014

A final missing piece was added to the plugin for Grunt I made a few months ago: javascript concatenation using CodeKit’s prepend and append directives. Now you might think that this is a useless feature, as we have had the grunt-contrib-concat plugin for ages, but to use that you would have to change your existing project for it to work. Adding support for handling inline build comments like these

// @codekit-prepend "some-file.js"
// @codekit-append "some-other-file.js"

makes it possible to keep using CodeKit&tm; and Grunt at the same time. That means non-Mac developers can still contribute to you project, you don’t have to change any code, and you can keep the nitty-gritty of various builds in Grunt, and just use CodeKit like you normally do. Which was kinda the point for me, since CodeKit < 2 sucked at sharing config between team members (build file changed all the time). Les resten av dette innlegget »

When OS X refuses to remember your (Enterprise) WPA passwords

26. september 2012

Due to a password policy at work, we need to change the password for our Enterprise WPA network quite often. Unfortunately this has surfaced some weird bug in OS X, where it will prompt me for my password each time I log on the network, even though I can see it has been stored correctly in the Keychain. Got some tips from this post on the Apple Discussion forums, but it was not sufficient for me to get it working. I therefore present you the full five steps needed to fix this (at least in my case):

  1. Turn off Airport while doing this
  2. Open your Keychain (just search for «Keychain» in Spotlight) and remove the password associated with the WIFI you are having problems with
  3. Open Networks, press «Advanced» and remove your network from Airport
  4. Without closing the Advanced windows, open the tab marked «802.1X». This was the missing (crucial) step for me to get it working.
  5. Turn on Airport again, choose your network, and type in your username and password.

Hopefully you will no longer be prompted for your network password again!

Absolute file path function for Bash shell scripts

19. juni 2012

An often wanted function when writing shell scripts is one that when given a file or directory, returns the absolute file path of the file. Googling for this will return many results, but few that are cross platform compatible. For instance will a search often bring up use of readlink, but this is not useful on BSD systems (such as Mac) and will thus only (?) work on Linux.

One solution that was both elegant, uncomplicated and works on all bash systems, was found on LinuxQuestions. This will probably only work in Bourne style shells, but is easy to read and reuse:

function abspath {
	if [[ -d "$1" ]]
		pushd "$1" >/dev/null
		popd >/dev/null
	elif [[ -e $1 ]]
		pushd $(dirname $1) >/dev/null
		echo $(pwd)/$(basename $1)
		popd >/dev/null
		echo $1 does not exist! >&2
		return 127

I have included it in my shell function library on GitHub.

[OS X] Better battery life while on the road.

10. februar 2012

After being annoyed for the last year that my MacBook Pro was eating up my battery life while in hibernation, I finally chose to investigate the matter further. Several articles describe the pmset command (here is one), but to make a long story short I wrote a script that will let my Mac enter hibernation mode (suspend to disk) immediately, without altering the settings (permanently at least).

I uploaded it to pastebin to increase the chances of it being spread. Link.

It should be pretty self explanatory, but to sum it up it does the following:

  1. Back up your existing hibernation settings
  2. Sets new ones that will suspend to disk and then cut power (not keeping any power to RAM)
  3. Hibernates (and shuts off)
  4. On power on, it restores the previous settings

If you find it useful, drop me a comment. Maybe I could make this into a small systray utility some day if someone finds it useful.

How to sync Things without wlan

15. mars 2011

A problem for some is that you supposedly need wifi to sync the GTD app Things on your iPhone with your computer. To make matters worse, some work environments (such as my own), split devices unto different subnets on their LAN, making it impossible to sync Things. There are (at least) two solutions to this problem:

  1. You set up a peer-to-peer network between your Mac and iPhone. This is a bit cumbersome and you lose your WLAN connection to boot.
  2. The other solution, which I found by chance, is setting up your iPhone to share the internet connection and connect your Mac to it using either USB or Bluetooth. This creates a network connection between the two and you can now sync the two without messing with your other internet settings.

Getting rid of Outlook reminders in Mac OS X

10. mars 2011

I just installed Office 2011 on my mac and tried using Outlook for a little while. Unsure of why, it seems to have somehow put all the elements from my iCal configured Google Calendar into my work calendar running on Exchange. Not sure how this happened though, but I nevertheless decided to continue using iCal to avoid any more troubles (and deleting hundreds of private calendar entries is a big pain!).

Anyway, Outlook still continued to throw reminders at me, something which was duplicating what iCal was already doing. So I searched for a possible solution, but the search turned out less than fruitful. I still found out how to do it though:

* Open the reminder app: /Applications/Microsoft Office 2011/Office/Microsoft Office
Use finder or just use Spotlight to find it.
* Press «Office-reminders» in the menu and press «Deactivate reminders». Voila!

If you ever want to turn them back on, repeat the above process, just swapping deactive for activate 🙂