Trace, the Ultimate Slow Down

Trace in .Net is supposedly efficient. Well, it’s not.

It’s easy to just add a Seq Trace Sync for example and not think too much about it… Well, do so at your own peril.

Adding the Trace Sync to Serilog and the fact that the Owin Test Server adds a new Trace Listener every time it’s spun up = a SLOW death and hard to track down.

So remember, TRACE MAKES SHIT SLOW.

Configure DD-WRT Printer

I’ve got a Netgear Nighthawk R7000 router which I have flashed with DD-WRT v3.0-r29316 std. It’s amazing, yada yada.

I wanted to get my printer which is currently shared off my media centre PC onto the router so that it’s more available to everyone on the network. Following are the steps I needed to follow:

  1. Turn the USB printing feature of the DD-WRT on:
    ddwrt-enable-usb 
  2. Connect the powered on printer to a USB port on the router
  3. SSH into the router (root and your router admin password), and check to see there is an lpt port available with ls -la /dev/l*
    ddwrt-check-lpt-port1 
  4. Then check to see that there is something listening on port 9100 with netstat -an
    ddwrt-check-lpt-port2
  5. Go to the Windows Devices and Printers screen, and add a new NETWORK printer
  6. Select The printer that I want isn't listed
  7. Select Add a printer using a TCP/IP port or hostname
  8. Select Autodetect for the Device Type field
  9. Use the IP address of the router for the Hostname or IP field
  10. DESELECT Query the printer and automatically select the driver to use
  11. It will fail to detect the port (9100)… that’s ok
  12. Select Custom on the Additional port information required screen
  13. Give the port a name and make sure the port number field has the value9100
  14. Go through the fdriv

Aurelia CLI and template requires

So you’ve used the Aurelia CLI to bootstrap your awesome Aurelia app and you npm install some dependencies, let’s say bootstrap and jquery:

npm i bootstrap 
npm i jqeury

Ok, ready to rock. Next, you update your aurelia.json file with the new dependencies:

"jquery",
{
  "name": "bootstrap",
  "path": "../node_modules/bootstrap/dist",
  "main": "js/bootstrap.min",
  "deps": ["jquery"],
  "exports": "$"
}

Sweet.

Next up is to import bootstrap into your main module, so that you can require it in your templates:

import 'bootstrap';

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .feature('resources');

  aurelia.start().then(() => aurelia.setRoot());
}

Amazeballs.

So, you require your bootstrap css in your app template:

<template>
  <require from="bootstrap/css/bootstrap.css"></require>
  <require from="./styles.css"></require>

  <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">
        <i class="fa fa-user"></i>
        <span>Contacts</span>
      </a>
    </div>
  </nav>

  <div class="container">
    <div class="row">
      <div class="col-md-4">Contact List Placeholder</div>
      <router-view class="col-md-8"></router-view>
    </div>
  </div>
</template>

But, what’s this??? You get this error in the console:

vendor-bundle

WTF is going on there? Hmmm… Let’s review that dependency configuration we added to aurelia.json…

Oooh, we left out the css resources:

{
  "name": "bootstrap",
  "path": "../node_modules/bootstrap/dist",
  "main": "js/bootstrap.min",
  "deps": ["jquery"],
  "exports": "$",
  "resources": [
    "css/bootstrap.css"
  ]
}

And now it works.

Visual Studio – Open Sublime

A little while ago I tweeted this:

It appears this is entirely kinda possible by wiring up Sublime as an External Tool in Visual Studio:

To open the current Visual Studio file in Sublime Text, do the following:

  1. Add Sublime as an External Tool with
    Arguments: “`$(ItemPath):$(CurLine)“`
    Initial Directory: “`$(ItemDir)“`

pasted_image_at_2015_08_06_01_04_pm

2. Create a shortcut key combo to open the current file on the current line:

Tools –> Options –> Keyboard
ExternalCommands[X] where X is the number corresponding to where in the list of external tools Sublime was added.

I use “`[Ctrl]+o+[Ctrl]+s“` for Open Sublime.

 

And that’s it. Thanks Homey Aryan for the tip!

 

 

 

Right click “Open with Sublime” in Windows

@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe

rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /t REG_SZ /v "" /d "Open with Sublime Text 3"   /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f

rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3"         /t REG_SZ /v "" /d "Open with Sublime Text 3"   /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3"         /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
pause