Skip to content

Instantly share code, notes, and snippets.

View IlyaFinkelshteyn's full-sized avatar

Ilya Finkelshteyn IlyaFinkelshteyn

  • Azure App Service
  • Seattle WA
View GitHub Profile
<Query Kind="Statements">
<Namespace>System.Text.RegularExpressions</Namespace>
</Query>
Regex regex = new Regex(@"a*");
Match match = regex.Match("aaaaa");
if (match.Success)
{
Console.WriteLine(match.Value);
@IlyaFinkelshteyn
IlyaFinkelshteyn / set-maven-proxy.ps1
Last active July 25, 2016 19:39 — forked from FeodorFitsner/set-maven-proxy.ps1
Setup Maven builds to use AppVeyor HTTP proxy
if(-not $env:APPVEYOR_HTTP_PROXY_IP) { return }
$mavenConfig = '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>' + $env:APPVEYOR_HTTP_PROXY_IP + '</host>
-
version: 2.0.0.{build}-{branch}
branches:
only:
- master
- /\d\.\d\.\d{1,3}/ #regex between "/"
install:
- ps: 'Write-host "Top config. Branch: "$env:APPVEYOR_REPO_BRANCH'
param ([string] $instance, [string] $port )
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement") | Out-Null
$serverName = $env:COMPUTERNAME
$smo = 'Microsoft.SqlServer.Management.Smo.'
$wmi = new-object ($smo + 'Wmi.ManagedComputer')
$uri = "ManagedComputer[@Name='$serverName']/ServerInstance[@Name='$instance']/ServerProtocol[@Name='Tcp']"
cd..
del $env:APPVEYOR_BUILD_FOLDER
$gitbashfolder = $env:APPVEYOR_BUILD_FOLDER.Replace("\", "/");
Add-Content -Value "git clone -q --branch=develop git@git.assembla.com:projects^projectA.umbraco.git $gitbashfolder" -Path .\clone.sh
cmd /c "C:\Program Files\Git\git-bash.exe" .\clone.sh
cd $env:APPVEYOR_BUILD_FOLDER

##For private projects:

Points 1 – 3 needed to allow appveyor to push, as by default SSH key used is deployment key which has read-only permissions.

  • Add the following to appveyor.yml (you can do on_success if you need):
version: 1.0.{build}
environment:
bbpwd:
secure: <encrypted_BitBucket_Password>
clone_script:
- ps: Write-Host "Preparing repo download environment..."
- ps: $bbUserName = $env:APPVEYOR_REPO_NAME.Substring(0, $env:APPVEYOR_REPO_NAME.IndexOf("/"))
- ps: $bytes = [System.Text.Encoding]::ASCII.GetBytes("$bbUserName" + ":" + "$env:bbpwd")
$port = 15672;
[int]$attempt=0
$maxAttempts = 5
while(!$client.Connected -and $attempt -lt $maxAttempts) {
try {
$client = New-Object System.Net.Sockets.TcpClient([System.Net.Sockets.AddressFamily]::InterNetwork)
$attempt++; $client.Connect("127.0.0.1", $port); write-host "service is listening on port $port"
}
catch {
try {
Write-Host "Downloading Visual Studio Tools for Azure Functions..."
$exePath = "$($env:USERPROFILE)\WebToolsAzure2015.exe"
(New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/F/8/A/F8A2905B-25FF-4C82-95D3-14ED11CF252A/WebToolsAzure2015.exe', $exePath)
Write-Host "Installing Visual Studio Tools for Azure Functions..."
cmd /c start /wait "$exePath" /q
# Function to determine if theres a file lock on the given file
Param(
[Parameter(Mandatory = $true)]
[string]$serviceName,
[Parameter(Mandatory = $true)]
[string]$appFolder
)
function Is-Any-Locked($filePaths) {
Foreach ($filepath in $filePaths) {