Archive for August, 2011

Problems accessing Samba SMB shares on Mac OS X Snow Leopard

Problem:

In OS X Snow Leopard, you may experience problems accessing a SMB network share using either of the following methods:

Go > Network;

or, using Finder’s pane, under Shared;

.. and clicking ‘Connect As’ to log in.

You get the following error message:

You entered an invalid username or password. Please try again.

Workaround:

In Safari, type the following into the address bar:

smb://servername:139

Where servername is the server name of your SMB server.

Example:

smb://diskstation:139

a dialog box will appear, prompting you to log in. This should succeed and you will be prompted with a list of your devices shares. Selecting a share will mount it and display the contents.

Enjoy.

Leave a comment

Converting a Mac DMG image to ISO in Ubuntu

Mac DMG images are practically unusable in a non-Mac system in that format. They can be converted to ISO images in Ubuntu for easy burning, mounting, or use in a virtual machine.

Once you have the DMG file you want to convert to an ISO file, you need to install dmg2img

sudo apt-get install dmg2img

Now, assuming the DMG file you want to convert is image.dmg, run the following command:

dmg2img image.dmg

After a few minutes or processing, your DMG will be converted to an IMG file in ISO format (image.img). If you need the ISO extension, simply rename the file:

mv image.img image.iso

Note: IMG files created by Nero are NOT in ISO format and cannot simply be renamed. If you want to convert a Nero IMG file to ISO, use the ubuntu utility nrg2iso, but it’s not required above.

Leave a comment

How to create an unfiltered input type in Drupal 7

The default input types in Drupal strip out unapproved HTML tags and optionally format links with tags. If you’re creating a block for some more advanced purpose, such as the insertion of JavaScript or other HTML that you don’t want stripped, you will likely want an input type with no filters.

Note that an unfiltered input type will not support PHP; you must enable the PHP module for this. Once you enable the PHP module, it will create an input type specifically for PHP. The PHP block will allow unfiltered HTML, but may present an unnecessary security risk.

To create an unfiltered input type in Drupal 7, do this:

Go to Configuration > Content Authoring > Text Formats

You should see the default text formats appear.

Click add new text format and give your new text format a name, such as “Unfiltered HTML.” Choose the roles that will be allowed access to this input type. Be aware that allowing untrusted users access to an unfiltered input type may have security implications. Don’t check anything under Enabled Filters. Click Save Configuration.

That’s it. Your input type is now ready for use.

Now, if you want to create a block with unfiltered content, such as the display of JavaScript code, simply choose “Unfiltered HTML” as the input type of the block.

,

Leave a comment

How to enable mp3 support in K3b

By default, K3b does not support MP3 file sources for audio CD burning. You can install support for MP3 by running the following command:

sudo apt-get install libk3b6-extracodecs

This is current as of Ubuntu 11.04

,

Leave a comment

How to generate a unique time-based hash in PHP

This PHP code is especially handy if you want to generate a time-based hash for some security purpose. You can adjust the code to generate hashes every month, every day, or down to every second if that’s what you want. These can be used to generate automatically-changing passwords, password salts, time-based challenges, etc.

NOTE: This is example code only and shouldn’t be copy/pasted for use in a production environment. Instead, modify the code below and change the hash function, the date string, and maybe add your own customizations. See the PHP date() and hash() manual pages for reference.

<?php
// length of hash to generate, up to the output length of the hash function used
$length = 12;
// The following should retrieve the date down to your desired resolution.
// If you want a daily code, retrieve only the date-specific parts
// For hourly resolution, retrieve the date and hour, but no minute parts
$today = date("m.d.y"); // e.g. "03.10.01"
$out = substr(hash('md5', $today), 0, $length); // Hash it
echo "$out";
?>

I’m sure there are plenty of other ways, but this is a code snippet that I used. Feel free to share your thoughts on this in the comments below, thanks!

Leave a comment

How to post an email address in Drupal’s ‘filtered HTML’ mode without creating a link

In Drupal’s ‘filtered HTML’ input mode, email addresses are automatically turned into links. However, there are times when you don’t want this behavior, such as when you’re posting a SIP address, Google calendar address, or any string that looks like an email address but isn’t.

While you can turn off this behavior globally by editing the input type, that may not be what you want if you’re only posting a few of these addresses.

Instead, take a trick from HTML and post a character code. The character code for the @ symbol is @

Drupal will format this address as a link:

example@example.com

This will display just the same as the above, but will not be formatted as a link:

example@example.com

This helped me, so I thought I’d share it. If you have any Drupal tricks, feel free to share them in the comments below! Thanks!

Leave a comment