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);
}

Copy files from one Windows server to another and retain permissions

Just want the script?

If you don’t want to read the blah blah blah you can access robocopy-script on Github

I want to know the details…

At my day job I was tasked with migrating several websites and folders from one Windows server to another. The sites have a ton of quirky permissions settings because they are mostly intranet sites. Several have anonymous browsing turned off. As you may or may not know if you just copy them via drag and drop in File Explorer you will lose all of those permissions that took years to refine. Additionally you will lose creation dates, etc.

After some research I determined that Robocopy was what I needed to retain all that valuable cruft information. Unfortunately (or fortunately if you dig command line stuff) Robocopy is a command line tool with quite a few flags. A little more digging revealed there is a GUI for Robocopy which allows you to save scripts, but I decided to roll my own script.

Features:

  • A simple “config” section in the script where you define the to/from locations
  • A config option to run attended or unattended (set this in the script)
  • Logging
  • Utilization of the following flags (descriptions are verbatim from the Robocopy documentation):
    • /E – Copies all subdirectories (including empty ones).
    • /SEC – Copies NTFS security information. (Source and destination volumes must both be NTFS). Equivalent to /COPY:DATS.
    • /COPY:DATSO – Copies the file information specified by copyflags, which can be any combination of the following : D – file Data. | A – file Attributes | T – file Timestamps. | S – file Security (NTFS ACLs). | O – file Ownership information.
    • /V – Produces verbose output (including skipped files).
    • /TEE – Displays output in the console window, in addition to directing it to the log file specified by /LOG or /LOG+.
    • /NP – Turns off copy progress indicator (% copied). **
    • /LOG – Redirects output to the specified file, overwriting the file if it already exists.
    • /B – Copies files in Backup mode (Backup copies are not restartable, but can copy some files that restartable mode cannot). ***
    • /R:10 – Specifies the number of retries on failed copies. (The default is 1 million.)
    • /W:30 – Specifies the wait time between retries. (The default is 30 seconds.)

** I liked seeing the progress as it copied, but all those percentages get written to the log file same as the screen.
*** Consider /Z to use restartable mode.

Obviously you could tweak the flags in the script to get a combination more suitable for you.

If this sounds like something you might find useful you can access robocopy-script on Github. I should note that this is my first public repo on Github. Yay.

Helpful links and definitions of Raspberry Pi related hardware / software for the absolute beginner

Raspberry Pi First Boot
Here is the first boot up of my Raspberry Pi

The Raspberry Pi is basically a $25 computer (Model A) or a $35 computer (Model B) meant to encourage children to learn programming by providing an affordable computing platform that can drive all kinds of projects from controlling robots to running a media center on a tv. I am not a hardcore programmer so I bought one to tinker and encourage my inner programming child.

I bought the Model B because it has 512MB Ram, 2 USB ports, and an ethernet port. The model A has 256MB Ram, 1 USB port, and no ethernet port.

So far I have managed three tasks.

  1. I have booted up with a copy of Raspbian “Wheezy”, surfed the internet and installed a mail client.
  2. I have booted up with a copy of Raspbmc, added some music, and took XBMC for a test drive.
  3. I have installed XBMC Commander to my iPhone and controlled my Raspbmc installation by playing music, videos, etc. I had varying degrees of success with this task.

Rather than copy other people’s fine tutorials I am going to provide definitions of the different technologies, as defined at their site(s). Below the definitions are link(s) to the site(s).

Raspberry Pi

What is (a) Raspberry Pi

“The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard.”

Raspberry Pi Site

Task 1: Raspbian

What is Raspbian

“Raspbian is a free operating system based on Debian optimized for the Raspberry Pi hardware.”

Wheezy is the recommended starting distro. There is also a link below to a distro that uses the MATE desktop environement instead of the LXDE desktop environment that “Wheezy” uses.

Raspbian “wheezy”

Bootable Raspbian “Pisces+MATE” Image by Mike Thompson

Task 2: Raspbmc

What is Raspbmc?

“Raspbmc is a minimal Linux distribution based on Debian that brings XBMC to your Raspberry Pi.”

Raspbmc Site

Task 3: XBMC / XBMC Commander

What is XBMC?

“A Complete media center solution for Windows, OSX, Linux, and more!”

XBMC Site

What is XBMC Commander?

“XBMC Commander is a remote control for the iPad especially designed to interact with XBMC, one of the most advanced open source media centers out there.” (There are iPhone and Adroid versions as well)

XBMC Commander Site

App Store Software – What the Description Really Means

I buy a lot of software.  A LOT OF SOFTWARE.  The following is my tongue-in-cheek assessment of App Store software descriptions.

Gorgeous / Stunning Graphics

We have a graphic artist.  We think her work is awesome.  Lots of companies have awesome graphic artists.  Many times they are pretty much as awesome.

Feature Rich

Our app is really complex.  We put a whole bunch of stuff into it.  Unfortunately the Pareto principle (80/20 Rule) likely applies.

Minimalist

Our app is really sparse.  We <3 Getting Real.  This may or may not be good for you depending on what we consider essential.

Our most awesome version to date

Our last version had bugs / was less than awesome.

Frequent Updates

See “Our most awesome version to date”.

Winner of the Blah Blah Blah Award

If it’s not an Oscar or a Grammy… well ok, if it’s not an Oscar be suspicious.