Learning Current Angular Tool Best Practices
Over the last couple of weeks I have been diving back into Angular development using Angular 6 and ngrx. One of the things that quickly became apparent is that now the best practices of installing JavaScript tools is to install them locally instead of globally to prevent version collisions.
When I first started I installed the angular cli globally and encountered this type of error when running many of the sample apps that I downloaded.
Your global Angular CLI version (6.0.8) is greater than your local version (1.7.3). The local Angular CLI version is used.
This didn’t seem to cause me an issues but still the error bugged me and when I was reading the book Angular 6 for Enterprise-Ready Web Applications by Doguhan Uluca he really drives home that you should keep the number of globally installed packages to a minimum.
I was able to find out what commands I had installed globally using this command
npm list -g --depth=0
Which showed I only had the angular cli and npm install globally.
So I was able to uninstall the global angular cli and get rid to the ugly warnings.
Doguhan also points our that you should use npm-windows-upgrade instead of using npm i -g npm to upgrade npm on Windows or you are going to run into npm corruption issues.
Random Stuff I want to remember
Windows 10 Home password expiration.
Today I had a couple of Windows 10 Home machines had their passwords expire.
To turn off the Windows 10 password expiration
net accounts /maxpwage:0
From http://www.thewindowsclub.com/customizing-the-password-policy-in-windows-7
Upgrading npm on Windows
I was installing jspm on a new machine and after I installed node 4.3.1 it was running npm I was trying to upgrade npm. I tried a bunch of different commands I found on stack overflow but this command from the npm site (I feel like Colonel Sanders looking for the Nashville Hot Chicken Recipe) did the trick on both Windows and the Mac.
npm install npm@latest –g
From*:* https://docs.npmjs.com/getting-started/installing-node
http-server
In my recent javascript library/framework exploration I found myself needing a quick way to server html without having to have gulp or more permanent web server. I found http-server fits the bill nicely.
npm install –g http-server
http-server –o –c-1
-o opens browser window after starting the server
-c-1 disables caching
VisualStudio Code fix for icons not appearing
When VisualStudio code was announced I went out and installed it right away on my Mac and Windows machines. One my home development machine I was unable to see the icons. I was thinking that it was due to my 4K display and an High DPI issue but it turns out not to be the case.
In reading the Reacting to feedback, common issues, and our first update post on the Visual Studio Code bug it was due to the svg file extension being associated to something other than image/svg+xml in my case due to Inkscape it was set to application/svg.
Changing the Content Type to image/svg+xml made the icons visible.
There is a FAQ with several fixes and workarounds for Visual Studio Code at https://code.visualstudio.com/Docs/FAQ
Chocolatey Kickstarter Funded! A list of my current packages
The third (second successful) Kickstarter campaign that I pledged to the Chocolatey Kickstarter campaign was successfully funded. I always like reading what tools other developers are using so to celebrate, I thought I would publish the packages I currently have installed.
I may have an issue with being obsessed with editors.
Editors
Atom | Cross platform editor from github. The official Windows installation is delivered via Chocolatey. |
linqpad4.install | LinqPad essential editor for working with Linq and C# snippits. It will be interesting to see if scriptcs can be integrated |
SublimeText3.app | SublimeText3 my goto text editor. This package includes Package Control |
SublimeText3.PowershellAlias | Installs a powershell subl alias for sublimtetext |
vim | Still trying to grok vim. Probably still resent it from the late 80s. |
brackets | Adobe open source editor. Designed for web design. |
notepadplusplus.install | Before I discovered SublimeText this was my text editor of choice. Now I usually only use it when I have character encoding issues with files. |
Close behind my obsession with editors is my love to learn new programming languages.
Languages
erlang | One of the three languages I am currently getting acquainted with. Used in CouchDB and RabbitMQ. |
golang | One of the three languages I am currently getting acquainted with. |
rust | One of the three languages I am currently getting acquainted with. |
ruby | installs the current version of ruby. Currently 2.1.3 mostly used for Sass |
ruby1.9 | Installs the latest 1.9 version of ruby |
pik | Helps manage multiple versions of Ruby on Windows |
python2 | Installs the latest version of python 2 |
python3 | Installs the latest version of python 3 |
scriptcs | Interesting REPL for C#. Originally started by Glenn Block |
pscx | PowerShell Community Extensions (PSCX) is aimed at providing a widely useful set of additional cmdlets, providers, aliases, filters, functions and scripts for Windows PowerShell that members of the community have expressed interest in. |
nodejs.install | latest version of node |
Databases
mysql | Latest version of mySql |
mysql.workbench | Latest version of mySql Workbench |
mongodb | Latest version of mongodb |
Programming Utilities
baretail | great tool for viewing text log files on Windows |
dependencywalker | oldie but still necessary when trying to track down missing dependencies in c++ dlls |
beyondcompare | great cross platform file comparison tool |
git.install | Latest version of git |
githubforwindows | Latest github for Windows |
smtp4dev | Utility for capturing emails sent during development |
SourceCodePro | My new font of choice for code |
fiddler4 | Essential tool for debugging and testing web services and monitoring web traffic |
InnoSetup | Free tool to create setup programs |
InstEd | MSI editor, Better than trying to find orca |
Utilities
ConEmu | Great Windows console emulator. |
EthanBrown.ConEmuConfig | Great initial settings for ConEmuConfig |
7zip.install | Free file archiver with support for unpacking most compression formats |
7zip.commandline | command line utility for 7-zip |
autohotkey.install | Free open source macro creation and automation software |
autoit.commandline | comes with github |
scite4autohotkey | AutoHotkey script editor |
cdburnerxp | Free CD/DVD burner application. Also lets you create Isos |
crystaldiskinfo | Show the health status of hard drives |
winsplit | Utility that is great for managing windows on a 4K display |
pidgin | multiple chat network client |
ditto | Advanced clipboard manager |
dropbox | I mostly use OneDrive but occasionally use dropbox |
filezilla | Simple and full featured ftp client. |
flashplayerplugin | Easy way to keep flash player updated |
virtualbox | latest VirtualBox install |
virtualbox.extensionpack | and extensions |
windirstat | a good way to find out where all your space went. |
WindowsLiveWriter | still my favorite blog editor |
PreCode.WLW | code formatting plugin for Windows Live Writer |
sumatrapdf.install | Free pdf, epub, mobi, and other ebook reader |
teamviewer | Great cross platform remote access program |
truecrypt | Free open-source disk encryption software for Windows – 7.1a |
vcredist2010 | Visual Studio runtime |
yumi | Universal multibook installer |
puretext | Paste text as pure text |
Media Utilities
Ghostscript.app | A package of apps to work with postscript files |
audacity | Free software for recording and editing sound files |
handbrake.install | A tool for converting video from nearly any format to a selection of modern, widely supported codecs. |
ffmpeg | Converts any media file to any other media type |
paint.net | Replaces most of what I use Adobe Photoshop for. |
gimp | Still trying to get used to this program after all these years but since I decided to cut my Adobe Creative Cloud Subscription it works well enough for the occasions when I need more than paint.net |
inkscape –pre | Adobe Illustrator replacement |
vlc | Plays anything thrown at it |
Display Collection+JSON in the browser
In the last year I have become enamored with Hypermedia APIs and the Collection+JSON API in particular that I first came across in Mike Amundsen’s book Building Hypermedia APIs with HTML5 and Node. It seems to be a perfect fit for many of the APIs that I have been working on. Glenn Block created the CollectionJson.Net library to make it easy to create Collection+JSON based ASP.NET Web APIs.
However when I browse to a WebAPI endpoint that returns a Collection+JSON result in Internet Explorer or Firefox I get a prompt to download the file.
Chrome displays the raw JSON result in a more friendly manner.
Although Fiddler or the browser debug tools make it fairly easy to see the results as JSON sometimes it is convenient to see the results rendered directly in the browser.
I found an old post from Rick Strahl’s blog regarding how to display application/json. He suggests using JSONView for Firefox and adding a registry entry for Internet Explorer. I was able to easily tweak the Internet Explorer registry keys to handle vnd.collection+json. Unfortunately JSONView for Firefox will not work for the application/vnd.collection+json media type. https://github.com/bhollis/jsonview/issues/7
For internet Explorer it is just a matter of changing the Content type entered in the registry from application/json to application/vnd.collection+json
Create a new application/vnd.collection+json key in:
- HKEY_CLASSES_ROOT\MIME\Database\ContentType**application/vnd.collection+json**
- Add a string value of CLSID with a value of {25336920-03F9-11cf-8FD0-00AA00686F13} (the CLSID for the “Browse in place” action)
- Add a DWORD value of Encoding with a hex value of 0x00080000
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/vnd.collection+json] “CLSID”=”{25336920-03F9-11cf-8FD0-00AA00686F13}” “Encoding”=hex:08,00,00,00
Now Collection_JSON results will display directly in Internet Explorer.
For Firefox it was just a matter of specifying the application to open the media type as Firefox.
This adds the application/vnd.collection+json media type to the Applications list in the Firefox Options dialog.
And now Collection+JSON results will display directly in the Firefox window.
This technique will work for other types of +json media types as well such as Mason (application/vnd.mason+json) and HAL (application/vnd.hal+json).
Setting an IP address using netsh instead of arp -s on Windows 8.1
I recently had to setup many Epson TM-T88V receipt printers for a POS installation and out of the box they are configured with a static address of 192.168.192.168. Pressing the reset button for 3 seconds prints out the status of the printer including the MAC address so I though I would just use arp –s to configure the printers but I received an error. So after a some googling with Bing I turned up this article that pointed me to the the fact that you need to use netsh with recent versions of Windows.
First you need to get the name of the interface that the device is connected to. Then you execute the netsh interface ipv4 add neighbors command.
netsh interface ipv4 show interfaces Idx Met MTU State Name --- ---------- ---------- ------------ --------------------------- 3 10 1500 connected Ethernet 1 50 4294967295 connected Loopback Pseudo-Interface 1 63 10 1400 connected vowire hosting 10 5 1500 connected vEthernet (Internal Ethernet Port Windows Phone Emulator Internal Switch) 29 10 1500 connected vEthernet (VirtualBox Host-Only Ethernet Adapter Virtual Switch) netsh interface ipv4 add neighbors "Ethernet" 10.1.10.45 xx-xx-xx-xx-xx-xx