Swiss Army knife of this and that

Views - PHP Code for Profile Data

If you have a custom field in your user(s) profile and you're trying to pull that value into a view... here's the ticket.

If your profile field is called: "profile_custom_value"

1) For that view, add a new value under "Arguments"
2) Select "Provide default argument"
3) Under "Default argument type: ", select "PHP Code" and use this syntax.
Don't use the brackets - as noted.

global $user;
$profile =  profile_load_profile($user);
return $user->profile_custom_value;

Enabling CLR Integration

EXECUTE sp_configure 'clr enabled', 1
GO
RECONFIGURE WITH OVERRIDE
GO

Enable xmp_cmdshell on Microsoft SQL 2008 Express

EXECUTE SP_CONFIGURE 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
 
EXECUTE SP_CONFIGURE 'xp_cmdshell', '1'
RECONFIGURE WITH OVERRIDE
GO
 
EXECUTE SP_CONFIGURE 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
GO

Custom Block - Login

<?php global $user; ?>
<?php if ($user->uid) : ?>
Welcome: <?php print l($user->name,'user/'.$user->uid); ?> |<?php print l("logout","logout"); ?>
<?php else : ?>
Please Login/Register: <?php print l("Login/Register","user/login"); ?>
<?php endif; ?>

Taxonmy - SQL INSERT Example

This example will explain how to write a simple SQL statement that will add items to the term_node table. To do this example, you will need access to your database by using a 3rd party program such as phpmadmin.

Reset Identity Column Value in SQL Server

If you are using an identity column on your SQL Server tables, you can set the next insert value to whatever value you want. An example is if you wanted to start numbering your ID column at 1000 instead of 1.

It would be wise to first check what the current identify value is. We can use this command to do so:

DBCC CHECKIDENT (’tablename’, NORESEED)

For instance, if I wanted to check the next ID value of my orders table, I could use this command:

DBCC CHECKIDENT (orders, NORESEED)

To set the value of the next ID to be 1000, I can use this command:

Linux - Remove Null Values from files

#!/bin/bash
DIR=$1;
#	Created By Aaron Moline Aaron.Moline@molinesoftware.com
#	Date: 02/26/2010
#	Description: Enumerate each file $DIR and remove null values
#	Version: 1.0
#
for file in $DIR/*.*
do
        od -b < $file | grep ' 000 ' > nullchk
        CMD=$[ $(cat nullchk | grep '000' | wc -l) ]
 
        if [ $CMD -gt 0 ]; then
                tr -d '\000' < $file > tmp
                mv tmp $file
                echo "Cleaned File: " $file
        fi
    continue
done
rm nullchk

Drupal Upgrade - Command Line

This little command will update your drupal code

tar -xzvpf ./drupal-x.x.tar.gz --strip-
components 1

Get DNS Information

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")
 
Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_AType")
 
For Each objItem in colItems
    Wscript.Echo "IP Address: " & objItem.IPAddress
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Record Class: " & objItem.RecordClass

Connect to Drupal with JAVA

Installation Steps
For this to work, you'll need to download and include a few *.jar files for ApacheXmlRpc.

From http://www.apache.org/dyn/closer.cgi/ws/xmlrpc/ download the appropriate "apache-xmlrpc-current-bin.*" file.
Extract the files to a location that can be used to import them for NetBeans in you project.
Add them to your projects Libraries.
To use it, you will need to know the sites Service Key, Service Domain, and the Service URL. Below is a sample of how you use the class

        service = new DrupalXmlRpcService(
                "dev.mysite.com",