Skip to content

Instantly share code, notes, and snippets.

@matejskubic
matejskubic / drop-all-constraints.sql
Created August 2, 2016 08:58
Drop all CONSTRAINTs
select
'ALTER TABLE [' + TABLE_NAME + '] DROP CONSTRAINT [' + CONSTRAINT_NAME + ']'
from INFORMATION_SCHEMA.TABLE_CONSTRAINTS
@matejskubic
matejskubic / MEcount.sql
Last active August 24, 2016 12:20 — forked from anzekrpic/MEcount.sql
AX modelElements in models between build versions
SELECT mf.name,
mf.VersionMajor,
mf.VersionMinor,
mf.VersionBuildNo,
mf.VersionRevision,
COUNT(*) AS 'Element count'
FROM modelelementdata med
JOIN modelmanifest mf ON mf.modelid = med.modelid
WHERE mf.VersionBuildNo BETWEEN 1000 AND 3999
GROUP BY mf.name,
@matejskubic
matejskubic / form_init.xpo
Created September 5, 2016 13:52
AX 2012 Form init args diag
anytype a10 = element.args().dataset();
anytype a10str = tableId2name(element.args().dataset());
anytype a11 = element.args().record();
anytype a12 = element.args().refField();
anytype a12str = fieldId2name(element.args().dataset(), element.args().refField());
anytype a13 = element.args().selectField();
anytype a13str = fieldId2name(element.args().dataset(), element.args().selectField());
anytype a20 = element.args().lookupTable();
anytype a20str = tableId2name(element.args().lookupTable());
@matejskubic
matejskubic / 0_reuse_code.js
Created September 13, 2016 15:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@matejskubic
matejskubic / wifipass.bat
Created February 6, 2017 08:40
Windows 10 WiFi password
netsh wlan show profiles
netsh wlan show profiles name="%1" key=clear
### Reference: http://deploymentresearch.com/Research/Post/578/Building-the-perfect-Windows-Server-2016-reference-image
$ISO = "C:\Setup\ISO\Windows Server 2016.iso"
$CU = "C:\Setup\Cumulative Update for Windows Server 2016 for x64-based Systems (KB3201845)\AMD64-all-windows10.0-kb3201845-x64_95e1e765344e1388fee3f7c0c143499e0b617d9f.msu"
$MountFolder = "C:\Mount"
$RefImage = "C:\Setup\REFWS2016-001.wim"
# Verify that the ISO and CU files existnote
if (!(Test-Path -path $ISO)) {Write-Warning "Could not find Windows Server 2016 ISO file. Aborting...";Break}
if (!(Test-Path -path $CU)) {Write-Warning "Cumulative Update for Windows Server 2016. Aborting...";Break}
@matejskubic
matejskubic / backupToAzure.sql
Created August 17, 2017 07:55
Backup SQL DB to azure
DECLARE @dbToBackup as sysname = 'AxDB'
DECLARE @container as nvarchar(50) = lower(HOST_NAME())
DECLARE @file as nvarchar(100) = @dbToBackup + N'_' + FORMAT(GETDATE(), N'yyyy-MM-dd_hhmmss') + N'.bak'
DECLARE @destUrl as nvarchar(500) = N'https://storageaccount.blob.core.windows.net/' + @container + N'/' + @file
PRINT @destUrl
BACKUP DATABASE @dbToBackup TO
URL = @destUrl
WITH NOFORMAT, NOINIT, NAME = N'Ax-Full Database Backup', NOSKIP, NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10
GO
@matejskubic
matejskubic / createSqlSharedAccessSignature.ps1
Last active November 3, 2022 18:08
Generate SQL shared access signature for azure storage account
[CmdletBinding()]
Param(
# subscription name
[parameter()]
[string]$subscriptionName = 'EA - MSDN - AX - ProdDev - 01'
,
# resource group name
[parameter()]
[string]$resourceGroupName='adaxbackup'
@matejskubic
matejskubic / EsbFixer.tt
Created August 31, 2017 14:26
Implement Interface by T4 Text Template Transformation
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="EnvDTE" #>
<#@ assembly name="EnvDTE80" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="EnvDTE" #>
<#@ import namespace="EnvDTE80" #>
<#@ output extension=".cs" #>
@matejskubic
matejskubic / VisualStudioReleaseEnvironmentCleanup.ps1
Created September 21, 2017 14:25
VisualStudio Release Environment Cleanup
<#
.SYNOPSIS
.DESCRIPTION
#>
[CmdletBinding()]
Param(
#