Skip to content

Instantly share code, notes, and snippets.

View mvalipour's full-sized avatar
🚴‍♂️
Cycling...

| Mo Valipour mvalipour

🚴‍♂️
Cycling...
View GitHub Profile
@mvalipour
mvalipour / setup.md
Created August 2, 2016 12:48
TeamCity Setup with Reverse Proxy
  • Install Teamcity
  • Go to /conf/server.xml and find <connector> node
  • set the following attributes on it
  <Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
    connectionTimeout="60000"
    redirectPort="8543"
    useBodyEncodingForURI="true"
 socket.txBufSize="64000"
@mvalipour
mvalipour / RequireDatabaseToBeUpToDate.cs
Created July 30, 2016 08:58
EF Database-First but make sure code-first migrations are not ahead
public class RequireDatabaseToBeUpToDate<TContext, TMigrationsConfiguration> : IDatabaseInitializer<TContext>
where TContext : DbContext
where TMigrationsConfiguration : DbMigrationsConfiguration, new()
{
public void InitializeDatabase(TContext context)
{
var migrator = new DbMigrator(new TMigrationsConfiguration());
var migrations = migrator.GetPendingMigrations().ToList();
if (migrations.Any())
{
@mvalipour
mvalipour / readme.md
Last active July 27, 2016 21:57
Azure Cloud Service Octopus Continuous Delivery Setup

Step 1. Deploy to Azure

  • Pre-Deploy
    • Log octopus parameters -- A
    • Transform package: Run service definition, service configuration, web/app config and file transformations/replacement bundled into the package. -- B
  • Post-Deploy
    • Log deployment -- C
    • Ensure/Add diagnostics extensions -- D
    • Wait loop for /healthcheck endpoint -- E
    • Notify Slack/Skype -- F
  • Deploy-failed
@mvalipour
mvalipour / NDP461-KB3102438-Web.exe
Created July 25, 2016 19:24
Azure Cloud Service .NET 4.6.1 Installation
download this file... see: https://azure.microsoft.com/en-gb/documentation/articles/cloud-services-dotnet-install-dotnet/
@mvalipour
mvalipour / ServiceDefinition.csdef
Created July 25, 2016 19:17
Enable Custom Load-Balancer Probing on Azure Cloud Service
<?xml version="1.0"?>
<ServiceDefinition name="Cloud" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<LoadBalancerProbes>
<LoadBalancerProbe name="healthcheck" path="/healthcheck" protocol="http" port="80" intervalInSeconds="30" timeoutInSeconds="61" />
</LoadBalancerProbes>
<WebRole name="Web" vmsize="Large">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="httpIn" />
git log --merges --pretty=oneline --abbrev-commit --grep="Merge pull request #" origin/master..origin/develop
@mvalipour
mvalipour / sql-set-max-dop.sql
Created April 2, 2016 16:23
Set Maximum Degree of Parallelizm (number of CPUs) on an Azure Premium SQL Database
ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP =2
@mvalipour
mvalipour / sql-update-statistics-fullscan.sql
Created April 2, 2016 16:21
Update SQL Statistics with Full Scan
DECLARE @sql nvarchar(MAX);
SELECT @sql = (SELECT 'UPDATE STATISTICS [' + DB_NAME() + '].[' + rtrim(sc.name) + '].[' + rtrim(so.name) + '] WITH FULLSCAN, ALL;' + CHAR(13) + CHAR(10)
from sys.sysobjects so
join sys.schemas sc
on so.uid = sc.schema_id
where so.xtype = 'U'
FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)');
PRINT @sql
EXEC (@sql)
@mvalipour
mvalipour / azure-bulk-set-db-quota.ps1
Created March 22, 2016 15:05
Powershell script to set correct size quota to all SQL databases on an azure subscription
param([Parameter(Mandatory=$true)] $subscriptionId)
Import-Module Azure
Set-AzureSubscription -SubscriptionId $subscriptionId
Select-AzureSubscription -SubscriptionId $subscriptionId
function Do-Server($serverName) {
Get-AzureSqlDatabase -ServerName $serverName | ForEach-Object { Do-DB $_ }
}
@mvalipour
mvalipour / readme.md
Last active March 16, 2016 09:11
Pre-Authenticated URLs with IIS URL Rewriting

This configuration allows having pre-authenticated URLs.

-- i.e. mapping /auth/xyz/some/resource to /some/resource?token=xyz

NOTE: This DOES preserve other querystrings on the URL.

pre-authenticated urls were useful for our elasticsearch reverse proxy to allow us use authentication with sense.