Skip to content

Instantly share code, notes, and snippets.

View jlucaspains's full-sized avatar

Lucas Pains jlucaspains

View GitHub Profile
# $(siteName) variable must be unique. I recommend using the PR Number in it
$parsedSite = (Get-Content "c:\sites.xml" -raw) -replace "\[SiteName\]","$(siteName)"
$parsedSite | Set-Content "c:\sites.xml"
$parsedAppPool = (Get-Content "c:\apppool.xml" -raw) -replace "\[SiteName\]","$(siteName)"
$parsedAppPool | Set-Content "c:\apppool.xml"
<?xml version="1.0" encoding="UTF-8"?>
<appcmd>
<APPPOOL APPPOOL.NAME="[SiteName]" PipelineMode="Integrated" RuntimeVersion="" state="Started">
<add name="[SiteName]" managedRuntimeVersion="">
<processModel identityType="SpecificUser" userName="user" password="password" />
</add>
</APPPOOL>
</appcmd>
appcmd list apppool TemplateAppPool /config /xml > c:\apppools.xml
appcmd list site TemplateSite /config /xml > c:\sites.xml
appcmd add apppool /name:MyAppPool
appcmd add site /name:MySite /bindings:"https/mysite.lpains.com:443:" /physicalPath:"C:\inetpub\wwwroot\MySite" /applicationPool:"MyAppPool"
Import-Module SQLServer
# This will check if the DB already exists, if it does, skip the restore
# $DbName variable will be based on your PR number
# The SourceDb is used to rename the original SQL Server files to something unique using the PR number
# This script is using a server share for .bak files. You may change this and have a backup file ready in your SQL Server instead.
Invoke-Sqlcmd -ServerInstance MySQLServer -database master -query "IF(DB_ID('$(DbName)') IS NULL) exec spRestorePRBackup @TargetName = '$(DbName)', @SourceDb = 'MyAppDB', @Path = '\\MyServerShare\dbbackup\PR.BAK'"
jobs:
- job:
displayName: 'Create Database'
pool:
name: bld-rel
variables:
DbServer: 'LPainsDB'
DbName: 'lpains$(prName)'
ConnectionString: 'server=$(DbServer);database=$(DbName);integrated security=sspi;'
steps:
jobs:
- job:
displayName: front-end
pool:
vmImage: 'windows-2019'
steps:
- task: Npm@1
displayName: 'npm install'
inputs:
trigger:
- master
pr:
- master
# You can name your build whichever way you see fit, however, below format will yield the build name as a date like 2021.09.01.1 which can also be used for version numbers.
name: $(Date:yyyy.MM.dd)$(Rev:.r)
stages:
const regex = /\b(ALTER|CREATE|DELETE [a-z0-9]+|DROP|EXEC|EXECUTE|INSERT INTO [a-z0-9]+|SELECT .+ INTO [a-z0-9]+|MERGE [a-z0-9]+|UPDATE [a-z0-9]+)\b/ig
regex.test("select id from tbl") // return false
regex.test("select id into tbl2 from tbl") // return true
regex.test("INSERT INTO tbl (id) values (1)"); // returns true
regex.test("INSERT INTO @tbl (id) values (1)"); // returns false
regex.test("update tbl set id = 2 where id = 1"); // return true
...
public ObservableCollection<CategoryModel> Categories { get; } = new ObservableCollection<CategoryModel>();
public ObservableCollection<object> SelectedCategories { get; } = new ObservableCollection<object>();
...