Dell B1160w on OS X

To install the Dell B1160w laser printer on OS X you need to download the Samsung ML-2525w driver.

1. Download the Samsung Driver for OS X from here.

2. Install the software (Printer Driver

3. Open system preferences > printers

4. Add a new printer, your network will pick it up through Bonjour as a Dell B1160w Mono Laser Printer

5. Under the select ‘Use’ box pick ‘Select software’

6. Search for Samsung and select ‘Samsung ML-2525w’

7. Click OK – try to print a test page.


Force www and ignore all other subdomains in .htaccess

This version does not require you to hard-code the domain name, and takes into account SSL connections.

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Geocode from Google API V3

If you want to get the latitude and longitude from an address using PHP then try the following code snippet:

$geoResult = file_get_contents('' . urlencode($addressString) . '&sensor=false&key=API');
if ($geoResult !== FALSE) {
$output= json_decode($geoResult);
@$lat = $output->results[0]->geometry->location->lat;
@$long = $output->results[0]->geometry->location->lng;
if ($output->status == 'OK') {
if ($lat > NULL) {
//do something

Fixing Drupal’s Clearfix CSS

Drupal’s default clearfix CSS leaves a gap at the bottom of the page, this removes this:

.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
font-size: 0;

.clearfix { display: inline-block; }
/* \*/
* html .clearfix { height: 1%; }
.clearfix { display: block; }
/* */

Drupal 7 – Starting point for creating a file object programatically

If you need to create a file object through the Drupal api then use the following code:

filename = basename('{CURRENT PATH}');
$file->filepath = '{CURRENT PATH}';
$file->filemime = file_get_mimetype($file->filename);
$file->filesize = filesize('{CURRENT PATH}');
$file->uid = $user->uid;
$file->status = FILE_STATUS_TEMPORARY;
$file->timestamp = time();
$file->list = 1;
$file = file_save($file);
$file = file_move($file, 'public://');
$file->status = FILE_STATUS_PERMANENT;
$file = file_save($file);

Drupal 7 – Starting point for programmatically creating a node

If you need to create a node within your module then use the following code:

title = '{NODE TITLE}';
$node->type = '{NODE TYPE}';
$node->language = LANGUAGE_NONE;
$node->uid = $user->uid;
$node->status = 1;
$node->promote = 0;
$node->comment = 0;
$node = node_submit($node);