Adobe Dreamweaver Cleanup

I used Adobe Dreamweaver for probably close to a decade. I have since moved on to VSCode, but I still maintain several old sites built with Dreamweaver. Since no one in our organization uses Dreamweaver I finally decided it was time to remove the extra directories and files associated with Dreamweaver. This involved cleaning up both the server and my local Mac.

Following are instructions for removing Adobe Dreamweaver directories and files from a Windows server and a local Mac. I recommend logging and reviewing what’s being cleaned up before deleting, but if Danger is your middle name feel free to skip it.

Server Side (Windows)

Note: Server Side instructions assumes you are running the command(s) from the directory you want to clean up.

Directories (_baks,_notes,_mm,MMWIP)

Log all occurrences of the directories to c:\directories-log.txt

for /d /r . %d in (_baks,_notes,_mm,MMWIP) do @if exist "%d" echo "%d" > c:\directories-log.txt

Delete all occurrences of the directories

for /d /r . %d in (_baks,_notes,_mm,MMWIP) do @if exist "%d" rd /s/q "%d"

Files (*.LCK)

Log all occurrences of the files to c:\files-log.txt

dir /s/b *.LCK > c:\files-log.txt

Delete all occurrences of the files

del /f *.LCK

Local (Mac OSX)

Note: Local instructions assume you are running the command(s) on a directory you want to clean up located in /Users/developer/website

Directories (_baks,_notes,_mm,MMWIP)

Log all occurrences of the directories to ~/log.txt

find /Users/developer/website -name '_notes' -o -name '_baks' -o -name '_mm' -type d > ~/directories-log.txt

Unlock all files in the directories (to avoid “Operation not permitted” error on locked files)

find /Users/developer/website -name '_notes' -o -name '_baks' -o -name '_mm' -type d | xargs chflags -R nouchg

Delete all occurrences of the directories

find /Users/developer/website -name '_notes' -o -name '_baks' -o -name '_mm' -type d | xargs rm -rf

Files (*.LCK)

Log all occurrences of the files to ~/files.txt

find /Users/developer/website -name '*.LCK' -type f > ~/files-log.txt


Delete all occurrences of the files

find /Users/developer/website -name '*.LCK' -type f | xargs rm -rf

Atom support for Emmet in ColdFusion .cfm and .cfc files

I’m late to the party, but I’m trying out a new editor: GitHub’s Atom. My mission when I try out a new editor is to see if I can get the following 3 items set up properly (because if I can’t the editor is unfortunately not going to work for me).

  1. Language Support for ColdFusion
  2. An Emmet package
  3. Support for Emmet functionality within a .cfm, .cfc file

Setting up Language support for ColdFusion is easy. Simply install the language-cfml package. To install a package in Atom:

  • From the Atom editor menu, navigate to Atom -> Preferences
  • Click the Install button
  • Type language-cfml in the Search Packages field and click the Packages button
  • Click the Install button for the language-cfml package

Setting up Emmet is easy. Simply install the emmet package (see package install instructions above).

Setting up Emmet support for ColdFusion .cfm and .cfc files requires editing your Keymap. This step was derived from the emmet-atom Tab key documentation

  • Open the Keymap file (keymap.cson): Atom > Keymap...
  • Add the following to the keymap.cson file (proper indention counts):
'atom-text-editor[data-grammar="text html cfml"]:not([mini])':
    'tab': 'emmet:expand-abbreviation-with-tab'

Processing ColdFusion using .htm and .html files with Lucee

If you want Lucee to use the .htm and .html file extensions instead of (or in addition to) .cfm and .cfml you can set this up in 3 quick steps.

1. Stop Lucee
2. Edit the web.xml file located at

/conf/web.xml

From:


     CFMLServlet
     *.cfc
     *.cfm
     *.cfml
     /index.cfc/*
     /index.cfm/*
     /index.cfml/*

To:


     CFMLServlet
     *.cfc
     *.cfm
     *.cfml
     *.htm
     *.html
     /index.cfc/*
     /index.cfm/*
     /index.cfml/*

3. Start Lucee

Connecting ColdFusion 10 to FoxPro 9

My company has a legacy application built in FoxPro 9 which contains a table that I need to extract data from on a recurring basis. I have never worked with FoxPro. Apparently in FoxPro each table has a corresponding .dbf file. For this example we will say that the table file is persons.dbf, which resides at C:\legacyapp\data\.

The first step for connecting ColdFusion to the FoxPro database was to find an acceptable driver. I initially tried to use some ODBC drivers but abandoned this route. Not only was it just not working, but I do my development on a Mac (whereas production is Windows) and I really wanted a solution that did not involve a Windows and a Mac configuration.

So the following steps describe how I set up a jdbc connection to FoxPro 9 from ColdFusion.

  1. Download the StelsDBF JDBC Driver
  2. Place the dbfdriver.jar file in {ColdFusion-Home}/cfusion/lib aka C:\ColdFusion10\cfusion\lib\
  3. Restart the ColdFusion services
  4. Login to the CFADMIN and set up a Data Source
    • For ‘Data Source Name’ enter ‘legacyapp’
    • For ‘Driver’ select ‘Other’
    • Click ‘Add’
    • For JDBC URL enter ‘jdbc:jstels:dbf:c:/legacyapp/data’
    • For Driver Class enter ‘jstels.jdbc.dbf.DBFDriver2’
    • Click ‘Submit’
  5. When using cfquery to select data use the file name as the table name:
    SELECT 
        LASTNAME, FIRSTNAME
    FROM
        persons
    

It was actually not too bad to set up once I located the driver.

Clean Up Google Drive Icon Files

I had a Git repo that I was storing on Google Drive (Yes that probably was not a great idea, but it was a lazy way of sharing some pdfs in the repo with a non-technical coworker). The Google Drive app on the Mac uses an “Icon” file to indicate sync statuses of folders.  Unfortunately this kept screwing up the repo by also putting “Icon” files in all the folders in the .git directory.  Having the repo was more important than it being in Google Drive so I moved the folder out of Google Drive.  Once the folder was moved the “Icon” files remained and the repo was still throwing an error when I tried to code in Adobe Brackets.

Here is how I cleaned up all the Google Drive “Icon” files.

WARNING: BE SURE YOU DON’T HAVE FILES NAMED WITH “Icon” AS THE FIRST 4 LETTERS OR THIS WILL DELETE THEM.

  1. Open terminal
  2. Change directories into the folder that was once in Google Drive
  3. Issue the following terminal command:
    find . -name 'Icon*' -type f -delete

Now the repo is back to normal.

SQL Server SELECT into existing table

This morning I needed to add a single record to an existing table in database1 from an existing table in database2. Here’s how I was able to do it:

INSERT INTO database1.dbo.tablename
     SELECT *  
     FROM 
          database2.dbo.tablename
     WHERE 
          ID='4d08aeb0bedd01452dfef3eabc2816dcc75533c8'

Please note that the databases use a SHA-1 Hash for the ID field. If you use an IDENTITY field in SQL you’d have to take some extra steps to briefly allow inserting an IDENTITY field.

Using a ColdFusion Ternary Operator for an Optional Tag Attribute

Today I had to write a script to process a form and send an email as part of the processing. The form allows the user to specify an email address to bcc, but it’s not required. I’m a big fan of using the Ternary Operator for doing either/or stuff like css classes. So I decided to extend that fandom to set the bcc attribute of the <cfmail> tag if the email specified in the form was valid.

Assumptions for this example:

1. You have validated form.bccEmail as a valid email.
2. You have a default mail server specified in Application.cfc or CFADMIN.
3. You may see more utility in using the Ternary Operator for other conditional cases.

The “magic” is in the bcc attribute below:

    
	    Message Body here...
    

ColdFusion function returns space before value

I had an annoying issue this morning where a function I wrote that rounds and formats values for use in an internal financial app kept sticking a single space before the value returned. This was obviously not good for a financial app. After spending 10-15 minutes tearing the function’s innards apart it turns out what was going on in the function was not the cause. The cause was simple.

In a tag based ColdFusion function you need to be sure to include the ‘output=”no”‘ attribute.

 
     ... MAGIC STUFF HERE ...

A LESS Mixin to change font-color based on font-size

Just a little LESS fun for the day… Here is a LESS Mixin to change font-color based on font-size.

Green big.
Yellow just right.
Red little.

It can be used with or without passing units (without units will use pixels). Adds bold just for fun.


.colorBySize(@pxValue) when (@pxValue < 12px){ color:red; } .colorBySize(@pxValue) when (@pxValue =< 16px) and (@pxValue >= 12px){
color:yellow;
}

.colorBySize(@pxValue) when (@pxValue > 16px){
color:green;
}

.colorBySize(@_) when not (ispixels(@_)){
font-size: ~"@{_}px";
// font-size: @_;
font-weight: bold;
}

.colorBySize(@_) when (ispixels(@_)){
font-size: @_;
font-weight: bold;
}

p.little{
.colorBySize(9);
}

p.justright{
.colorBySize(12);
}

p.big{
.colorBySize(18);
}