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.

Helpful Commands for ColdFusion 10 on OSX… aka Start and Stop CF10 from the command line

This post assumes you are working with the default instance (cfsusion) and that you installed ColdFusion 10 to the default location on you Mac.

STATUS:
/Applications/ColdFusion10/cfusion/bin/coldfusion status

START:
/Applications/ColdFusion10/cfusion/bin/cf-standalone-startup
OR
/Applications/ColdFusion10/cfusion/bin/coldfusion start

STOP:
/Applications/ColdFusion10/cfusion/bin/coldfusion stop

RESTART:
/Applications/ColdFusion10/cfusion/bin/coldfusion restart

Launch GUI for configuring Web Connectors:
sudo /Applications/ColdFusion10/cfusion/runtime/bin/wsconfig

RESET CFADMIN PASSWORD:
/Applications/ColdFusion10/cfusion/bin/passwordreset.sh
(Then Enter 1 for changing Admin Password and put in your new super strong password!)

.

Using not() in jQuery to exclude a member of a class

This is just a quick tip I thought I throw out there. We have an application that applies a fade to a .alert class on all its pages. We have 2 pages that need to not fade one particular alert. Here is one way it can be handled.

  1. Add a class of .notfade to the alert that needs to stay put and not fade out:
    <div class="alert alert-info nofade"></div>
  2. Place the following in $().ready(): $(".alert").not(".notfade")fadeOut(7000);

RDS Query Viewer not working: How to fix the ColdFusion Builder error: ‘/YOURPROJECTFOLDER/.rdsTempFiles/RDS Query Viewer’ does not exist

I have had this issue for a while and it finally made me crazy enough to try to figure it out. It appears that this error occurs when the “RDS Query Viewer” file does not exist in the .rdsTempFiles folder within your project.

On Mac

  1. Open Terminal
  2. Navigate to the directory where your project is located. For example type: cd /Applications/ColdFusion9/wwwroot/YOURPROJECTFOLDER and hit <enter>
  3. If the “.rdsTempFiles” directory does not exist type: mkdir .rdsTempFiles and hit <enter>
  4. If the “RDS Query Viewer” file does not exist type: touch “.rdsTempFiles/RDS Query Viewer” and hit <enter>. BE SURE TO SURROUND THE COMMAND WITH THE DOUBLE QUOTES BECAUSE THE FILE NAME HAS SPACES.
  5. Refresh the “RDS Query Viewer” view. RDS Query View should work now.

On Windows

  1. Open DOS
  2. Navigate to the directory where your project is located. For example type: cd C:\ColdFusion9\wwwroot\YOURPROJECTFOLDER and hit <enter>
  3. If the “.rdsTempFiles” directory does not exist type: mkdir .rdsTempFiles\rdsTempFiles and hit <enter>
  4. If the “RDS Query Viewer” file does not exist type: fsutil file createnew “RDS Query Viewer” 0 and hit <enter>. BE SURE TO SURROUND THE COMMAND WITH THE DOUBLE QUOTES BECAUSE THE FILE NAME HAS SPACES.
  5. Refresh the “RDS Query Viewer” view. RDS Query View should work now.

ColdFusion 9 SELECT IN query using ormExecuteQuery()

For some reason this took me some effort to figure out. Maybe others will find it useful.


CategoryList = '1,2,3';
Categories = ormExecuteQuery("from Category where Id IN (:IdList)",{IdList=ListToArray(CategoryList)});

If you know a better way please drop me a comment. I posted this in the Adobe Coldfusion forum for a few days but didn’t get anything.

Adding more resource navigator filters to ColdFusion Builder (Eclipse) Redux

There is a post at 12robots.com for how to add resource navigator filters to CFBuilder:

http://www.12robots.com/index.cfm/2010/8/10/Adding-more-resource-navigator-filters-to-ColdFusion-Builder-Eclipse

The solution below is similar, but does not involve accessing .jar files.

Step 1: Locate your version of CFBuilder by selecting “About Adobe ColdFusion Builder 2”.  Make a note of the Version and Build numbers.  For this post I am on Version: 2.0.0 and Build: 277745
Step 2: Locate the plugin.xml file in the com.adobe.ide.coldfusion.rcp_X.X.X.XXXXXX folder (Notice how X.X.X.XXXXXX corresponds to the Version and Build from Step 1):
com.adobe.ide.coldfusion.rcp_2.0.0.277745
Step 2: Locate the following section:
<extension
point="org.eclipse.ui.ide.resourceFilters">

Step 3: Add a block like this for each new filter you want:
<filter
pattern="_notes"
selected="true"/>

Step 4: Start CFBuilder from the command line.  For me on the Mac I execute the following command in Terminal:
"/Applications/Adobe ColdFusion Builder 2/CFBuilder.app/Contents/MacOS/CFBuilder" -clean
Step 5: Enjoy your new navigator filter(s).