Code


PHP LDAP Bind Authentication With Active Directory



<?php
$ldapserver 
'ldap://dc.name.domain/';
$ds=ldap_connect($ldapserver);

taxonomy_node_get_terms_by_vocabulary replacement for drupal 7



taxonomy_node_get_terms_by_vocabulary() is not available in Drupal 7. I discovered this when I tried to install the Tweet Module whose D7 branch still relies on it. I re-wrote the D6 version of the function for D7 which returns the same array of term objects. This should help module maintainers port their D6 modules to D7. If there is a better D7 way to do this please let me know in the comments.



<?php
      $image_uri 
$node->field_image['und'][0]['file']['uri'];
      
$image_url_with_style image_style_url('square_thumbnail',$image_uri);
      echo 
'<img src="'.$image_url_with_style.'">';
?>

Send Email Example for Cocoa



This example Xcode project shows how to send an email from within a Cocoa application. It does not require that the user have any mail client configured. It requires you to specify a mail server and account to use in the code.

Base64 encode and decode an NSString in Cocoa



Matt Gallagher has a NSData+Base64 catagory for extending an NSData object. I wanted to be able to encode and decode an NSString both ways.

 

QuotaMonitorMenu 2.0



The Situation: You have a Mac OS X Server with network home directories and disk quotas enabled. 

The Problem: The Mac OS Finder on client machines does not have very good support for warning users they are approaching their file quota limit. They end up all of sudden unable to save files with little or no explanation as to why.

The Solution: QuotaMonitorMenu places the user’s home folder quota status right in the menu bar. It will also pop up warnings at regular intervals.

All warnings and text are customizable.

Core Data Drag and Drop With Groups



In this example you are able to use drag and drop to change the order of items in a single tableview, and to change group membership of nested items in objects with relationships, all with Core Data. The behavior is like iTunes style Playlist / Song relationships.

A few other bonuses:

Example: Some common uses of the keychain



Subscribe to RSS - Code
© 2011 Adam Gerson.