Skip to content

sql reindexing…

EXECUTE sp_MSforeachtable ‘DBCC DBREINDEX  ([?])';

Google Tag Manager

Used to inject “code” into a website. Useful to put things like google analytics or double click tracking code into site, but may be used for injecting custom tracking code.

Note the Firing rules on the right hand side is set to all page. This is essential. You also need to put in the Tracking Id which can be found in Google analytics.

tagmanager1

Add a click listener. This means that you can hook into click events throughout the site:

tagmanager2

Add the actual event that you want to track:

tagmanager1tagmanager3

Tools and stuff

SQL

Red-gate sql comparison bundle.

http://www.sql-format.com/

Json

http://www.jsoneditoronline.org/

Rest

https://www.getpostman.com/

https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm

JS

JSFiddle

JSLint

Boilerplate

bootstrap

http://www.initializr.com/

Selenium

http://docs.seleniumhq.org/

http://docs.seleniumhq.org/download/

 

PM> Install-Package Selenium.WebDriver

PM> Install-Package Selenium.Support

PM> Install-Package Selenium.WebDriverBackedSelenium

PM> Install-Package Selenium.RC

 

Chrome Drivers:

https://code.google.com/p/chromedriver/downloads/list

IE Drivers:

https://code.google.com/p/selenium/wiki/InternetExplorerDriver

https://code.google.com/p/selenium/downloads/list (update path statement)

 

Others:

https://code.google.com/p/selenium/downloads/list

 

c# Documentation:

http://selenium.googlecode.com/svn/trunk/docs/api/dotnet/index.html

WebElement we = driver.findElement(By.cssSelector(“html body.uk form#Form1 div#whiteBackground div#mainContainer div#mainNavigationContainer ul.firstLevelMenu li.first a.selected”));

 System.out.println(we.getText())  ;   

Powershell stuff

Replaces the command window (to list files type dir or ls or ipconfig). Has full support for .net. These can be written in text files, and run (I think the extension is .ps1).

 

You can start a program…

start notepad

 

TeamCity

…has the option for a powershell build step (rather than msbuild or nant)

 

Access the Registry (HKCurrent user)

cd HKCU:

 

Find running services

get-service

Get-Service | Export-CSV d:\service.csv

Get-Service | Where-Object {$_.status -eq “stopped”} > d:\running-services.txt

 

Open event logs

show-eventlog

Write .net:

# create the FtpWebRequest and configure it

$ftp = [System.Net.FtpWebRequest]::Create(“ftp://ftp.guardianprofessional.co.uk”)

$ftp = [System.Net.FtpWebRequest]$ftp

$ftp.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile

$ftp.Credentials = new-object System.Net.NetworkCredential(“username”,”password”)

$ftp.UseBinary = $true

$ftp.UsePassive = $true

# read in the file to upload as a byte array

$content = [System.IO.File]::ReadAllBytes(“C:\me.png”)

$ftp.ContentLength = $content.Length

# get the request stream, and write the bytes into it

$rs = $ftp.GetRequestStream()

$rs.Write($content, 0, $content.Length)

# be sure to clean up after ourselves

$rs.Close()

$rs.Dispose()

 

It has its own IDE

Powershell ISE

Powershell to rename

To rename all files in a [tmpfiles] folder, and replace all spaces with a dash…

 

gci -Path c:\tmpfiles | rename-item -newname {$_.name -replace ” “, “-”}

 

could also be written

gci | %{rni $_ $_.name.Replace(” “, “-”)}

 

The shortcuts here are:

gci = Get-Childitem

% = ForEach-Object

rni = Rename-item

| = pipes into next section

 

To Search for text in a folder

Select-string c:\projects\*\*.aspx -pattern “div”

 

To find big files

Get-ChildItem -path c:mydata -recurse | where  { ($_.Length /1GB) -gt 2 } | foreach { ($_.length/1GB).Tostring(“0.00?) }

 

Filters:

Get-Process | Where-Object {$_.Name –eq “iexplore”}

 

Azure with powershell

http://wappowershell.codeplex.com/

 

Getting Help

help

help gci

get-command

get-command -commandType Application

get-command -commandType Function

Powershell Blogs

http://blogs.msdn.com/b/powershell/

http://technet.microsoft.com/en-us/library/ee177003.aspx

IIS administration

http://blogs.iis.net/sergeia/archive/2009/06/16/how-to-automate-windows-7-powershell-start-up-with-iis-module.aspx

run in elevated permissions:

import-module webadministration

gci iis://sites

gci -Path iis:\

gci iis:\apppools

Get-ItemProperty iis:\\sites\Umbraco49

Get-ItemProperty iis:\\sites\Umbraco49 pspath

set-location

http://technet.microsoft.com/en-us/library/ee909471(v=ws.10).aspx

 

$site = “Stage”

$iispath

Set-ItemProperty $iispath -name physicalpath -value “f:\stage\wwwroot2″

http://pscx.codeplex.com/


Void][Reflection.Assembly]::LoadWithPartialName(“Microsoft.Web.Administration”)

$siteName = “Default Web Site”
$serverName = “Server1″

$serverManager = New-Object Microsoft.Web.Administration.ServerManager
$serverManager = [Microsoft.Web.Administration.ServerManager]::OpenRemote($Server1)
$site = $serverManager.Sites | where { $_.Name -eq $siteName }

$rootApp = $site.Applications | where { $_.Path -eq “/” }
$rootVdir = $rootApp.VirtualDirectories | where { $_.Path -eq “/” }

$rootVdir

NuGet basics

NuGet is a packet manager. It is used within Visual Studio and Team City. You can use either a command line console or a GUI. It makes updating third party (and our own)  modules a doddle. There is a public website available to host packages (https://nuget.org/) or these can be hosted privately (I think team city has an option configurable for this).

 

Using within Visual Studio

ToolS -> Library Package Manager ->

View -> Other Windows -> Package Manager Console

Useful console commands:

PM> get-package -filter umbraco -listavailable

PM> install-package umbraco

 

Get-Package

Install-Package

Uninstall-Package

Update-Package

Add-BindingRedirect

Get-Project

Open-PackagePage

Register-TabExpansion

 

http://docs.nuget.org/

http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package

Writing Packages

  1. Write a class library or similar
  2. Generate a spec file:

nuget spec MyAssembly.dll

To use the gnm private repo

Tools -> Options -> Package Manager -> Package Sources

add:

TeamCity

http://gnm-build.cloudapp.net/httpAuth/app/nuget/v1/FeedService.svc

You may need to enter the TeamCity username/password to access this repository

 

Within Team City view the example at

Administration -> nuget packages Projects -> Configuration-extender-nugetpackager Configuration

http://gnm-build.cloudapp.net/admin/editBuildRunners.html?id=buildType:bt3

Note the step 2, has a build runner of type “NuGet Pack”

 

The example is hosted on github at:

https://github.com/guardian/da-libs.git

azure sql membership

aspnet_regsqlazure -s vp5mybqouf.database.windows.net -d timesheets-prod_db -u {username}@{servername} -p +{password}-a mr

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

Follow

Get every new post delivered to your Inbox.