Tuesday, November 25, 2014

Using Perforce P4V with Windows "High Contrast Black" Theme

I use the Windows "High Contrast Black" theme to make all the backgrounds black with white text - it's much easier on my eyes. With the "High Contrast Black" theme Perforce's P4V GUI interface, like many Windows programs, shows white text on a white background, which is not all that helpful.



I contacted Perforce about the issue and got a very fast response with a work around. If you add a blank file named "p4vstyle.qss" to the directory "c:\program files\perforce\P4VResources", P4V will use the local Windows theme on next startup.



Now my retinas are happy with the cool soothing black background. Thanks Perforce.

Thursday, November 13, 2014

Photos from Austin .Net Meeting Nov 10, 2014 - Redis for .Net Developers

Shawn Weisfeld spoke to 40 developers last Monday about Redis, a caching mechanism for .Net developers. Although originally written for Linux, it has been ported to Windows. Redis allows you to store key-value pairs, and save that to a disk, but it's not guaranteed to capture all values, so don't use it for financial applications, but it is great for other applications like leader boards in games.
My Notes:
Shawn works with UserGroup.tv to record technical demonstrations
Redis now has Lua scripting
You can get Redis from Nuget, Install-Package Redis-64
Redis is the preferred key-value storage for Azure
StackExhange uses Redis
Redis is good for auto-incrementing values, it can do it in one step
redis.io is the main website and has interactive tutorials.
Shawn actually used the unit tests in Redis to learn how to use the API.
Humanizer is a library for .Net that formats data for humans, e.g., "two" instead of "2".
A rep from Iron Yard was there to tell about their 3 month boot camp for would be developers
Redis has a Desktop manager to view its contents

Emacs: Lisp error: (error "Invalid face" modeline)

After upgrading to the latest version of emacs, I got this error:  'Lisp error: (error "Invalid face" modeline)'.
After a little research it came down to the modeline color command:
 (set-face-background 'modeline "plum")
(set-face-foreground 'modeline "black")
The problem was "modeline" has been replaced with "mode-line".
(set-face-background 'mode-line "plum")
(set-face-foreground 'mode-line "black")

Now emacs is happy, and I'm happy too.

Emacs Error: maximum buffer size exceeded

When trying to load a one gigabyte file into Emacs, I got this error:"maximum buffer size exceeded", and I'm thinking to myself, "Hey, I've got a 64-bit machine with 8Gig of ram and using the awesome Emacs, it should handle one Gig".
After a little research I found a version of Emacs compiled for 64bit windows machines here.
Now I can view 1 Gig files to my hearts content.


Friday, November 07, 2014

Synergy is still Awesome

I use two machines at my desk. Synergy is an incredible program that let's you control multiple machines with a single keyboard and mouse. The latest version costs $5 and it's worth every penny. Setup which used to be awkward at best is now a breeze. Nick Bolton and his team have done a great job with this release.

Setting up a new Windows 7 machine

When setting up a new Windows 7 box, I do the following:
Set Preferences
-----------
Right-click RecycleBin, select "Properties" and uncheck "Display delete confirmation dialog" box
Right-click on background, select "Personalize" and select "High Contrast Black"
Right-click on bottom toolbar and set to small icons
In the task bar, right-click select properties and set "Taskbar buttons:" to be "Combine when taskbar is full"
Add environmental variable "HOME" and set to C:\home\mfincher so emacs can find me
Add C:\home\mfincher\bin to environmental variable "Path"
Create C:\tmp so ange-ftp can work.
Turn off error reporting, "My Computer"/Properties/Advanced system settings/Advanced/Startup and Recovery/Settings/System failure, set "Write debugging information" to "(none)"

Copy Files From Old Computer
----------------------------
Copy My Documents, My Pictures, c:\home, c:\opt
copy over all the old databases
Copy over inetpub directories
Copy over old Microsoft Mail archives, *.pst files
Copy root directory of Perforce files, C:\workfiles
Copy the old %AppData%\Launchy\Luanchy.ini config file over to new machine 
Copy Themes from %userprofile%\AppData\Local\Microsoft\Windows\Themes C:\Users\fincherm\AppData\Local\Microsoft\Windows\Themes

Install Utility Programs
------------------------
Install Chrome, Opera, and Firefox, set up sync in Firefox to get old bookmarks and addins
Install Launchy 
Install AutoHotKey
Install ConEmu http://code.google.com/p/conemu-maximus5/
Install Notepad++
Install an alternate file manager XYplorerFree, select "Favorites/Set Box Color..." and set it to black
Install Emacs
Install Mouse drivers
Install visual studio 2013, and p4vs plugin
Install pdf reader sumatra - http://blog.kowalczyk.info/software/sumatrapdf/download.html
Install Paint.Net http://www.getpaint.net/download.html
Install Mezer Tools https://www.bayden.com/mezer/ Windows-s for capture Windows-c for calipers 
Install 7-zip for zip/tar files from http://www.7-zip.org/
Install Process Explorer  http://technet.microsoft.com/en-us/sysinternals
Install cygwin, add c:\cygwin64\bin to "Path" environmental variable so emacs can see "gzip"
Install Nant http://sourceforge.net/projects/nant

Install Microsoft Programs
------------------------
Install latest version of powershell (inside Windows Management Framework 4/5) http://www.microsoft.com/en-us/download/details.aspx?id=40855   Windows6.1-KB2819745-x64-MultiPkg.msu
set powershell to use unsigned scripts: add  "set-executionpolicy remotesigned" 
Install sql server 2008R2
Install IIS  http://technet.microsoft.com/en-us/library/cc725762.aspx?ppud=4
Download SQL Server® 2008 R2 Feature Pack to get Invoke-SqlCmd working SqlServerCmdletSnapin100 sqlps
Add-PSSnapin SqlServerCmdletSnapin100
http://go.microsoft.com/fwlink/?LinkID=188436&clcid=0x409
What other programs and settings would you recommend?

Thursday, November 06, 2014

The term 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet

On my new Windows 7 machine while inside Powershell I tried "Invoke-Sqlcmd", but kept getting the error message "The term 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet".
Here was my solution:

Download the SQL Server® 2008 R2 Feature Pack from here.

Then click on the "Instructions" plus symbol.


Then search for "Microsoft® Windows PowerShell Extensions for SQL Server® 2008 R2" and select the appropriate download.

Now after installing, go inside Powershell and execute "Add-PSSnapin SqlServerCmdletSnapin100", then Invoke-SqlCmd worked for me.
To add it permanently, edit your profile and add "Add-PSSnapin SqlServerCmdletSnapin100". (You can find your profile location by executing "$profile").

ConEmu - a Console Emulator for Windows That You Need Now

You owe it to yourself to download ConEmu. It removes all the awfulness of the standard Windows cmd terminal. Things like selecting text are much easier and more natural.
By default to copy text from the console you execute hold down the left-shift key (it's different than the right-shift key), then left-mouse button to highlight and it selects over the carriage returns. If you like block copies select alt-left-click.
I recommend a few changes: Open the Settings Window by selecting the right-most icon with three bars:


Select "Keys & Macro"/Paste/ and set "Confirm pasting more than" to 20000 chars and uncheck "Confirm <Enter> keypress" so it does not nanny you to death by asking if you know you have an <enter> in your selection.
Select "Main/Confirm" and uncheck the top 5 boxes so you won't be nannied to death.
Optional: To prevent a hotkey collision with Mezer tools, remove the hotkey for Win-S by going to "Keys & Macro", select Win-S and reassign the hotkey.

How to delete the log file from sql server databases

Disclaimer: This process should not be done with databases that you really care about. This procedure is only for dev/testing environments, not for production databases. I'm using Sql Server 2008R2.

Often the log file, ".ldf", can be quite large. If it's a production database you need it, but for databases you are using for dev and testing, you can remove it carefully to save space.
Here's the steps:
  1. In Sql Enterprise Manager "detach" the database - this won't hurt it, don't worry.
    This will bring up another window and just select "OK".
  2. Then in File Explorer append ".bak" the ldf filename - just in case we need it. Location may vary, on my box it's in "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA"
  3. Attach the database
    This will bring up a window. In the upper panel select "Add" and give the location of your .mdf file.
    Now comes the tricky part, in the lower panel select the log file and then select "Remove". Then select "attach", and voila, your old boat-anchor of a log file is now gone from your database!
  4. If all goes well, delete the renamed ".ldf" file.
Did I mention that you should not do this with databases you care about?