Skip to content

Instantly share code, notes, and snippets.

View DominicCronin's full-sized avatar
💭
Still Upskilling on Azure DevOps.

Dominic Cronin DominicCronin

💭
Still Upskilling on Azure DevOps.
View GitHub Profile
@DominicCronin
DominicCronin / ValidateXmlFile.ps1
Last active November 29, 2022 12:26
ValidateXmlFile: a powershell script for validating XML
function ValidateXmlFile {
param ([string]$xmlFile = $(read-host "Please specify the path to the Xml file"))
$xmlFile = resolve-path $xmlFile
"==============================================================="
"Validating $xmlFile using the schemas locations specified in it"
"==============================================================="
# The validating reader silently fails to catch any problems if the schema locations aren't set up properly
# So attempt to get to the right place....
pushd (Split-Path $xmlFile)
@DominicCronin
DominicCronin / gist:9089012
Last active March 24, 2020 11:09
Import Export Utilities
function DownloadPackageToFile($packageId, $filePath){
InitImportExport
$downloadService = get-ImportExportServiceClient -type Download
try {
$packageStream = $downloadService.DownloadPackage($packageId, $true)
$fileStream = [IO.File]::Create($filePath)
$packageStream.CopyTo( $fileStream)
}
$params = @{
client_id='cduser'
client_secret='CDUserP@ssw0rd'
grant_type='client_credentials'
resources='/'
}
$token = Invoke-RestMethod -Uri 'http://localhost:9082/token.svc' -Method POST -Body $params
$Authorization = $token.token_type + ' ' + $token.access_token
set
{
if (value == null)
{
this._guid = null;
return;
}
if (value.Length == 0)
{
this._guid = new Guid?(Guid.Empty);
for (int i = 0; i < 9999999; i++)
{
double number = null;
if( double.TryParse(bigArray[i], out number)
{
ProcessNumber(number);
}
else
{
DoSomethingElse();
for (int i = 0; i < 9999999; i++)
{
try
{
double number = double.Parse(bigArray[i]);
ProcessNumber(number);
}
catch (Exception)
{
DoSomethingElse();
# Setup
$publicationId = 20 # The publication where your content is published
# Broker database - substitute your own settings here.
$connStringBuilder = new-object System.Data.SqlClient.SqlConnectionStringBuilder
$connStringBuilder["Data Source"] = "WEB8,1433"
$connStringBuilder["Initial Catalog"] = "Tridion_Broker"
$connStringBuilder["User ID"] = "TridionBrokerUser"
$connStringBuilder["Password"] = "Tridion1"
[PresentationsByView(ViewPrefix ="ContentBlock")]
public List<IRenderableViewModel> ContentBlocks { get; set; }
@foreach (var cp in Model.ContentBlocks)
{
@Html.Render(cp)
}
public List<IRenderableViewModel> ContentBlocks {
get
{
return ComponentPresentations
.Where(cp => cp.RenderData.View == "ContentBlock")
.ToList<IRenderableViewModel>();
}
}