Monday, January 19, 2015

Git


Move to new folder

I had a VS solution that was in c:\TestGit\TestBootstrap\TestBootstrap
This folder had the root of the solution (however the .sln file was in c:\TestGit\TestBootstrap
I wanted to have the new folder structure be c:\TestGit\TestBootstrap\trunk\src
So I added to my local the trunk and src folders with a temp file in there so it would actually get into git.

do a 'git add *' (puts the folders into git staging)

do a 'git mv -n' first for a preview

git mv  -n TestBootstrap/TestBootstrap TestBootstrap/trunk/src
The above command worked from repo root of c:\TestGit.

Don't forget to delete the temp file.

Push to master
git push origin master

Log
Summary only: 
git log --pretty=format:"%h - %an (%ae): %s" --shortstat


Configuring git for KDiff3
Add to .gitconfig:

[diff]
    tool = kdiff3
[difftool]
    prompt = false
[difftool "kdiff3"]
    path = C:/Program Files/KDiff3/kdiff3.exe
    trustexitcode = true
[merge]
    tool = kdiff3
[mergetool "kdiff3"]
    path = C:/Program Files/KDiff3/kdiff3.exe
    keepbackup = false
    trustexitcode = true

then run it using >git difftool .\folder\Web.config
yes, using quotes to deal with the spaces in program files in .gitconfig file screws it up. Don't use quotes.

Links
Simple guide
Git in 600 words
Git docs

Thursday, January 8, 2015

Best Practices for Using Strings in the .NET Framework

http://msdn.microsoft.com/en-us/library/dd465121.aspx

Use string.Equals()
-----------------------------------
string s1 = "test";
string s2 = "test";
string s3 = "test1".Substring(0, 4);
object s4 = s3;
Debug.WriteLine("{0} {1} {2}", object.ReferenceEquals(s1, s2), s1 == s2, s1.Equals(s2));
Debug.WriteLine("{0} {1} {2}", object.ReferenceEquals(s1, s3), s1 == s3, s1.Equals(s3));
Debug.WriteLine("{0} {1} {2}", object.ReferenceEquals(s1, s4), s1 == s4, s1.Equals(s4));

output:
True True True
False True True
False False True

-----------------------------------








Tuesday, December 2, 2014

localdb tips


SQL CLR is disabled by default, to enable:

using master

select * from sys.configurations where name = 'show advanced options'

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO

select * from sys.configurations where name = 'show advanced options'

Create new localdb instance

sqllocaldb.exe create "Dev" 11.0  -s
This creates a localdb instance named Dev using the VStudio 2013 binaries and starts it.



Create  new database when getting "file already exists" errlr
-- open new query window against master db:

CREATE DATABASE CLFM ON (NAME = 'CLFM', FILENAME = 'C:\Users\vafsctonnet\UTest\CLFM.mdf')
LOG ON (NAME = 'CLFM_log', FILENAME = 'C:\Users\vafsctonnet\UTest\CLFM.ldf')

Efficient way to programmatically create localdb

http://www.jefclaes.be/2014/10/programmatically-force-create-new.html

Command line commands

from VStudio CMD:

get info on all db's on machine
SqlLocalDB.exe info
info on one db
SqlLocalDB.exe info UTest

SqlLocalDB.exe stop UTest
SqlLocalDB.exe start UTest

Make a copy of an existing database 

Make copies of the .ldf and .mdf files.
Then in server, right click Databases folder and select Attach. Select .mdf file. Done.

Monday, December 1, 2014

OO vs FP

The bottom, bottom line here is simply this. OO programming is good, when you know what it is. Functional programming is good when you know what it is. And functional OO programming is also good once you know what it is.

http://blog.cleancoder.com/uncle-bob/2014/11/24/FPvsOO.html

The Hacker Way - Facebook

Article

“Done is better than perfect”.

“Code wins arguments.”

“The riskiest thing is to take no risks.”

“Move fast and break things.” The idea is that if you never break anything, you’re probably not moving fast enough.