Define a Drupal 7 Block in a module

The following code is used if you want to define a new block within a Drupal module. Replace hook_ with your modules name.


t('Block Description'),
);
return $blocks;
}

function hook_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'block-name':
$block['content'] = hook_custom_function();
break;
}
return $block;
}

function hook_custom_function(){
$content = "Block Content";
return $content;
}

Useful OS X Keyboard Shortcuts

Here are a selection of great OS X shortcuts:

cmd + shift + 3 – screenshot
cmd + shift + 3 – cropped screenshot
cmd + shift + 3 then press spacebar will crop the screenshot around the current window

ctrl + cmd + space – full emoji keyboard

cmd + ~ – switches between windows in same application

shift + option when changing volume uses quarter increments

cmd + option + shift + V – paste & match text formatting

cmd + space – shows spotlight

cmd + H – hides active application

cmd + opt + H – hides all windows not in focus

alt + backspace – delete a whole word instead of a letter at a time

control + command + power (eject) – system restart

cmd + shift + i (from a Safari or Chrome) – creates a new email with the URL of the page you were visiting in the body

control + d – replicates the ‘Delete’ key from non-mac keyboards

option + right click on a dock app to show force quit

option + click on wifi icon in menu bar to show wireless speed, strength and other useful details

Thanks to reddit.com/r/apple for some of these.

YouTube to MP3 from the OS X Terminal

1. Install HomeBrew

2. Run the following from the terminal:

$ brew install youtube-dl
$ brew install ffmpeg
$ brew install lame

3. Get the URL of the YouTube video

4. At the terminal:
$ youtube-dl http://YouTubeURL

5. The downloaded file will be a .mp4 file, convert it to wav —
$ ffmpeg -i DownloadedFileName.mp4 TargetFileName.wav

6. Finally convert to MP3
$ lame FileName.wav FileName.mp3

Migrating from Parallels Desktop to VirtualBox

If you’re upgrading to Mavericks and don’t want to have to pay for a new Parallels version then you can use the free VirtualBox.

In this scenario I’m going from Parallels 4.0 to Virtual Box 4.3.10. If you are migrating from a later version of Parallels you might be able to skip the first 7 steps.

  1. In the Parallels folder open Parallels Transporter
  2. Click Continue
  3. Select Express
  4. Select Virtual Machine
  5. Select Virtual Disk
  6. Choose your Parallels virtual machine
  7. Click Migrate
  8. Wait about an hour
  9. Find the .pvm file for your converted virtual machine.
  10. Right click and select ‘Show package contents’
  11. Right click on the .hdd file and select ‘Show package contents’
  12. Copy the .hds file to somewhere else
  13. Rename the .hds file to .hdd
  14. Open VirtualBox
  15. Create a new Virtual Machine with the .hdd file from above as the virtual disk.
  16. Run your virtual machine!

Change the Power Button Behaviour in OS X Mavericks

By default in OS X Mavericks the power button sends the computer to sleep, to change this:

1.Copy the following file on your desktop
/System/Library/CoreServices/powerd.bundle/com.apple.SystemPowerProfileDefaults.plist

2. Open it with a text editor

3. Search for the following keys (there are several):
<key>Sleep On Power Button</key> <integer>1</integer>

4. Turn them all to 0

5. Save the file

6.Put the com.apple.SystemPowerProfileDefaults.plist file on your desktop back in:
/System/Library/CoreServices/powerd.bundle/

7. Enter your username and password when asked

8. Restart the computer

thanks to reddit.com/r/apple: