Skip to content

Instantly share code, notes, and snippets.

@niphlod
niphlod / Invoke-SqlAsync.ps1
Last active March 30, 2018 09:24
Dba Query Wrapper
function Invoke-SqlAsync {
param (
[Alias('Connection', 'Conn')]
[ValidateNotNullOrEmpty()]
[System.Data.SqlClient.SQLConnection]$SQLConnection,
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = "Query")]
[string]
$Query,
@niphlod
niphlod / Restore-DbaDatabase.md
Created November 28, 2017 17:16
function help

Restore-DbaDatabase

SYNOPSIS

Restores a SQL Server Database from a set of backupfiles

SYNTAX

Restore-DbaDatabase -Path <Object[]> -SqlInstance <DbaInstanceParameter> [-SqlCredential <PSCredential>] [-DatabaseName <Object[]>] [-DestinationDataDirectory <String>] [-DestinationLogDirectory <String>] [-RestoreTime <DateTime>] [-NoRecovery] [-WithReplace] [-XpDirTree] [-OutputScriptOnly] [-VerifyOnly] [-MaintenanceSolutionBackup] [-FileMapping <Hashtable>] [-IgnoreLogBackup] [-useDestinationDefaultDirectories] [-ReuseSourceFolderStructure] [-DestinationFilePrefix <String>] 

[-RestoredDatababaseNamePrefix <String>] [-TrustDbBackupHistory] [-MaxTransferSize <Int32>] [-BlockSize <Int32>] [-BufferCount <Int32>] [-DirectoryRecurse] [-EnableException] [-StandbyDirectory <String>] [-Continue] [-AzureCredential <String>] [-ReplaceDbNameInFile] [-DestinationFileSuffix <String>] [-KeepCDC] [-AllowContinue] [-GetBackupInformation <String>] [-StopAfterGetBackupInformation] [-SelectBackupInformation <St
@niphlod
niphlod / dbatools_tests.md
Last active December 6, 2016 21:50
draft on how to approach testing

Writing tests that matter

Given the enormous expansion dbatools is seeing, adopting ANY automated test facility adds value. Tons of pages have been written about how to correctly test code, from pieces to full apps. Take a quick google search on "unittests", "integration tests", "regression tests", "behavioural tests", "pragmatic testing" to be overwhelmed with options and opinions. This is by no means a complete guide, but just a reminder for newcomers wanting to contribute to dbatools testing, now that "appveyor via pester" recently came into play.

In a large module like dbatools, offering all kinds of features in a wide range of environments (a quick

#!/bin/bash
echo 'Requires Ubuntu = 16.04 and installs Nginx + uWSGI + Web2py'
# Check if user has root privileges
if [[ $EUID -ne 0 ]]; then
echo "You must run the script as root or using sudo"
exit 1
fi
# parse env vars
WEB2PY_PASS="${WEB2PY_PASS:-0}"
NOPASSWORD="${NOPASSWORD:-0}"
@niphlod
niphlod / gist:6260866
Last active December 21, 2015 05:59
new web2py folder structure
applications/
gluon/ > the core libraries
contrib/ > third party libraries
tests/ > unittests
extras/
? handlers/ > fix docs and scripts
anyserver.py > to run with third party servers
wsgihandler.py > handler to connect to WSGI
... > other handlers