Using Notepad++ to Easily Compile LESS CSS Files

Recently, I decided that I wanted to use LESS to easily generate CSS files, but I also wanted to compile these files before deploying on the web.  To accomplish this, I used Node.JS (with the LESS module) and Notepad++.  Currently, this Node.JS solution is preferred to the old Ruby compiler.  To use this setup, follow the steps below.

Installing Node.JS

To being the process, you will first need to install Node.JS.  This program basically allows you to easily use JavaScript as server-side code.  (This works with LESS because LESS is a JavaScript application.)  To begin the installation, follow these steps:

  1. Download the Node.JS installer.
  2. Run the installer with the default options.
  3. Verify that the node and npm binaries are included in the PATH by opening a command prompt and typing node. You will be given an error message if this is not available. Reboot if you see this error message.
  4. Create a directory for Node.JS modules. (I used C:\Node.JS)  This will be needed to setup your LESS module, and other modules if you choose to examine Node.JS further.

Installing the Node.JS LESS Module

Next, LESS will need to be installed.  If you are not familiar with LESS, please review their site to see the benefits of using this system instead of hard-coding your CSS files.  To install the LESS module, follow these steps:

  1. Open the command prompt.
  2. CD to your Node.JS module directory (created on step 3 above, C:\Node.JS in my case).
  3. Run this command: npm install less
  4. Take note of the lessc cmd file and its location. In my case, it is stored here: C:\Node.JS\node_modules\.bin\lessc.cmd

Create the Run Command Shortcut in Notepad++

Once the lessc.cmd file is installed, we can configure Notepad++ to compile our LESS files into CSS. Follow these steps to map Alt+F5 as a compile shortcut:

  1. Open Notepad++ and create a simple .less file. Make sure to set the encoding type to ANSI to avoid syntax error messages.
  2. Access the Run dialog box in Notepad++ by clicking Run->Run.
  3. Entering the following text into the Run dialog box (including the quotes):
    • "C:\Node.JS\node_modules\.bin\lessc.cmd" -x "$(FULL_CURRENT_PATH)" > "$(CURRENT_DIRECTORY)\$(NAME_PART).css"
    • Be sure to replace C:\Node.JS\node_modules\.bin\lessc.cmd with the location of your lessc.cmd.
    • The -x option tells lessc to output minified CSS.
  4. Click the save button.
  5. Enter a descriptive name, such as LESS Compile.
  6. Select the key combination of your choice. I used ALT+F5.
  7. Test the command on your less file.  If the command worked, you will see a new CSS file in the same directory as your less file.

Other Tweaks

It is possible to tweak this process in other ways if you do not wish to always save the CSS file in the same directory as the LESS file.  For example, you could create your own CMD, BAT, or .NET app to run the less compiler with your own options.  As always, feel free to comment with questions or additions to these steps.

Securing your Home Wi-Fi Network

Why do you need to secure your network?

With the recent release of Firesheep, it’s more important than ever to make sure that you are running a secure wireless network.  Firesheep is a recently-released Firefox extension that makes it really easy for just about anyone to take over your sessions at a few popular websites (Facebook for one) that don’t use SSL.  Even though these attacks are mostly targeted at open Wi-Fi hotspots at locations like coffee shops, airports, and hotels, they can really be used on any network that doesn’t have adequate protection.  This post will focus on the most important tips to secure your wireless network at home against these, and other, network attacks.

Tip 1: Use WPA2 Personal Encryption with AES

Today’s routers give you many encryption options, but WPA2 with AES is your best bet for preventing unauthorized users from gaining access to your network. Older technologies like WEP and WPA with TKIP have known vulnerabilities that make them less useful for encrypting your network.  If your equipment doesn’t support WPA2, then at least use WPA if it is available. WEP does little to protect your networks, as successful entry can be gained in minutes with many of the widely-available tools out there.

If you are not sure how to connect to your router to setup encryption or any other options in this article, check the manual provided by the manufacturer or this About.com article for some tips.

Tip 2: Use a Long, Randomized Encryption Key

Now that you are using WPA2 (you are using it right??), be sure to create an encryption key that cannot be cracked easily by a brute force or dictionary attack.  This is best accomplished by picking a key that is at least 20 characters long, and contains a mix of capital letters, lowercase letters, numbers, and symbols.  Since this key is normally entered once per device when connecting for the first time, I’d recommended a key as close to the 63 character limit as possible.  If you don’t want to make up your own key, use an online key generator to do it for you.

Tip 3: Change your Encryption Key Periodically

Once you have a good encryption key in place, it is a good idea to change it periodically.  Changing the key once a year is probably sufficient for WPA2 networks, but WEP network keys should be updated at least once a week. (Another reason not use WEP!) Also, changing your router password and computer user passwords periodically can be a good idea as well.

Tip 4: Reduce your Transmitter Power

Reducing the power of the router’s wireless transmissions will make it more difficult for the wireless signal to be intercepted outside the home.  It will also give you the side benefit of a cleaner signal for your network devices to use.

Bonus Performance Tip: Be sure to change the default channel on your router from 6, to either 1 or 11.  This won’t do anything for the security of your network, but it may provide you more reliability if you live in an area with many wireless networks.

Tip 5: Use Antivirus Software

This isn’t really a network configuration item, but using antivirus software can provide protection against Trojan Horse attacks that allow external attackers access to your network.  If you don’t have antivirus software and are running Windows, Microsoft has released a good free program called Security Essentials.  Just remember, no antivirus software provides 100% protection.  It is important to practice to safe browsing on the web by not downloading and installing random applications.

Tip 6: Keep your Software Up to Date

Again, not really a network configuration item, but keeping your software updated can help prevent attacks that can gain access to your network.  Using services like Windows Update are important for keeping your computer and network secure.  Do not ignore software update notifications, since attackers are always coming up with new methods to exploit vulnerable software.

As a side note, if you are using Adobe products, make sure that you are updating those applications as soon as updates are available.  Acrobat Reader and Flash are really popular targets, and attackers are always looking for new vulnerabilities in those applications.

Additional Resources

The tips in this article are not exhaustive, but are meant to give you a head start in keeping your home network secure.  If you are interested in further reading, you can check out these sites:

Sponsored Links

 

Tech Tip: Use NiMH Batteries for Remotes

LaCrosse BC-700 Charger and Rayovac NiMH Batteries

Recently, I started to replace our AA alkaline batteries with NiMH (Nickel-Metal Hydride) rechargeable batteries.  My main reasoning for the switch was the many remotes that use AA or AAA batteries (2 XBox Controllers, TV Remote, 2 DVD Remotes, and Stereo Remote) in the house.

After investigating NiMH technology, I found the following advantages:

  • Rechargeable – Less batteries to buy, means less waste for those green folks out there.
  • Low/No Memory Effect – This was more of a problem with certain NiCd (Nickel Cadmium) batteries, but it basically means that you don’t need to worrying about charging the battery when it’s only partially discharged.
  • Low Self-Discharge on Certain Batteries – These have better shelf life than standard NiMH batteries.  Manufacturers claim that these batteries will keep 70-85% of their charge after one year. Look for batteries that are labeled as pre-charged or hybrid.

If you are looking to move to NiMH batteries, keep these points in mind:

  • If you want to keep spares available for a long period of time, look for low self-discharge NiMH batteries.  Again, these will be labeled as pre-charged or hybrid.
  • NiMH batteries come with different capacities, measured in mAh (milliampere-hour). Shy away from batteries that claim a very high capacity (over 2100 mAh), as it appears that they have a higher self-discharge rate than lower capacity batteries.
  • Smart chargers are better than dumb chargers.  This mainly due to the fact that dumb chargers will not give you any indication on when a battery is charged.  There are varying degrees of smart chargers, but the main point that I’d look for is an indication that a battery is charged.
  • Avoid quick chargers, especially chargers that claim a 15 minute charge time.  Charging batteries at a higher mA (milliampere) level can degrade the battery cell.  The charger I use has charge levels of 200 mA, 500 mA, and 700 mA.  I use the 200 mA level unless I need a faster charge.

With these points in mind, I recommend the following batteries and chargers:

If you do not wish to buy from these Amazon links (I do participate in their affiliate program), most of these components can be found at Best Buy, Wal-Mart, or other online stores.

Restoring Broken Pictures with Word-Generated HTML

When pasting a Word document with graphics to Sharepoint Designer/Expressions Web, it is advisable to test the document in IE 7 to make sure that graphics are appearing. For some reason, the markup that Sharepoint/Word creates causes issues when using documents with photos. If these are not appearing, the Word vml tags must be removed. For the record, I really don’t like designing web pages with Sharepoint, but it is great for quickly posting Word documents to the net in HTML.

If you copy Word documents to Sharepoint Designer or Expressions Web, follow these steps to remove the VML markup causing graphics to fail:

  1. First, paste your Word document into Sharepoint as normal.
  2. Select the Split or Code view to enable the source code replacement feature.
  3. Open the Replace dialog box.
  4. In the Find box, paste the following text: [<]!–[if gte vml 1(.*n)#.#vml][>]
  5. Make sure that Regular Expressions and source code are checked, and that the Replace box is blank (we will be erasing the vector graphics).
  6. Click Replace All to replace the text.
  7. Next, uncheck the Regular Expressions box, erase the text in the Find field, and paste the following: <![endif]>
  8. Click Replace All to erase the text.

One note with this method: if you use conditions elsewhere in your document, make sure that you replace each item individually instead of Replace All. This should not be needed in most cases. For more information about regular expressions, check out these sites: