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
@IlyaFinkelshteyn
IlyaFinkelshteyn / InstallVs2010_Shell.ps1
Last active March 2, 2021 10:31
Install Microsoft Visual Studio 2010 Shell (Isolated) Redistributable Package
if ((Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -eq "Microsoft Visual Studio 2010 Shell (Isolated) - ENU"}) -ne $null)
{
Write-Host "Microsoft Visual Studio 2010 Shell (Isolated) Redistributable Package already installed."
}
else
{
Measure-command {
Write-Host "Downloading Microsoft Visual Studio 2010 Shell (Isolated) Redistributable Package..."
$exePath = "$($env:USERPROFILE)\VSIsoShell.exe"
(New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/1/9/3/1939AD78-F8E8-4336-83F3-E2470F422C62/VSIsoShell.exe', $exePath)
<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>
@IlyaFinkelshteyn
IlyaFinkelshteyn / StartBuildPassEnvVar.ps1
Created October 4, 2016 17:34
Start appveyor build with API and pass value for Environment Variable
Param([string]$myVar )
$token = '<API_Token>'
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
$body = @{
# Create Base64 string cert like this (note that X509KeyStorageFlags.Exportable required to export pfx with pritave key)
# X509Certificate2 cert = new X509Certificate2(<path_to_pfx>, <password>, X509KeyStorageFlags.Exportable);
# string base64Str = Convert.ToBase64String(cert.Export(X509ContentType.Pfx));
# Next store it as a secire variable named certStr in Appveyor project config
# Then use it during a build.
environment:
certStr:
secure: BWrNTKG4xirH2oPN32DOiRmnitc4S9VFYvV3wAqmA1Qsb7h92ke2YzUox8qmLWd7WJ1vu4qDjCvUweSzhGVdupg+FU8dCUMxXLN86ytGVRxCAojuXR/IyvG3J0ibxTt4ZRZc3pPinHbaz8xqe7l3uGJQDJIKlbUjglvYaptjupkEzvH8im0QOa44yFXCpZVsn/kXCCYPgA6nF7TP0YszLx0EtdNB63nWG3eOaf6CXwabOmwMzXxOZa38+vGdrC2RrRM9xnJeheTuY+FKZZ3Xxk0r4rEKQJUYj55e5mt+czaJ0YJynUMxljWgTVs/nvIMkcKirkIOFs9RxtHM+/3tEDGKDSzxG0td7hLks2tLscLxhYZBri851U3O2vRGBu6wmhYQanfB5w7eaVnV4sIJrneLnV++3EpplguiRKA1LEmQ+fpj6Gdt4Y8aGGTGm0vDflcmKdIdNAIQY0hLs4qop7VrAmlvo+RmQq3il10uhk4pOmIwXSBIuZxKRzxjgsFRJwQOHUNV/I6LM3LLPUKP7bsWSaGPloy+RUmUSU7s9oB4cFAP21XyDzusHoFu
-
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'
# 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) {
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']"
$token = '<API_Token>'
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
$body = @{
accountName="<Your_account>"
projectSlug="<Your_project_slug>"
$token = '<API_Token>'
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
#if you do not know build version and want to use latest:
#$buildVersion = (Invoke-RestMethod -Uri "https://ci.appveyor.com/api/projects/<Your_account>/<Your_project_slug>" -Headers $headers -Method GET).build.version