Skip to content

Instantly share code, notes, and snippets.

@gpshonik
gpshonik / 1 - BackupDatabase.ps1
Created April 7, 2024 18:13 — forked from jhelmink/1 - BackupDatabase.ps1
Creates a dacpac file from a SQL Server database, with FULL SCHEMA and TABLE DATA, but optionally EXCLUDES specific table data
# Creates a dacpac file from a SQL Server database, with FULL SCHEMA and TABLE DATA, but optionally EXCLUDES specific table data
# Designed for use in GitHub Actions
# Example Usage:
# .\BackupDatabase.ps1 -DatabaseName "rtlc-prod" -ConnectionString "data source=.\SQLEXPRESS;initial catalog=rtlc-prod;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework;TrustServerCertificate=True" -ExludeTableNames "Log4net,LogEvent,__MigrationHistory" -DacpacOutputPath "C:\Users\joshh\AppData\Local\Temp"
# Target Database & Parameters
param (
[Parameter(Mandatory = $true)]
[string]$DatabaseName,
[Parameter(Mandatory = $true)]
@gpshonik
gpshonik / install_bfg
Created March 11, 2023 16:07 — forked from kucho/install_bfg
Install bfg-repo-cleaner
#!/bin/bash
set -e
# Install Java and jq
sudo apt -y install default-jre-headless jq
# Get latest version
latestVersion=$(curl -s https://search.maven.org/solrsearch/select?q=a:bfg | jq -r '.response.docs[0].latestVersion')
# Fetch latest bfg.jar
@gpshonik
gpshonik / Clean-DotNetCore.ps1
Last active March 15, 2019 16:31
Safely remove outdated dotnet core runtimes, SDKs and hosting bundles.
function Clean-DotnetCore{
Write-Host "Collecting installed products"
$Script:counter = 1
$results = Get-ItemProperty 'HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' |
Where-Object {$_.displayname `
-match 'Windows Server Hosting' `
-or $_.displayname -like 'Microsoft .NET Core Runtime*' `
@gpshonik
gpshonik / ExampleUsage.cs
Created July 7, 2017 15:03 — forked from NickCraver/ExampleUsage.cs
Code to mark a SQL string before it's passed to Dapper.
public static List<T> Query<T>(this DataContext db, string sql, object param = null, int? commandTimeout = null, IDbTransaction transaction = null, [CallerFilePath]string fromFile = null, [CallerLineNumber]int onLine = 0, string comment = null)
{
using (db.Connection.EnsureOpen())
{
try
{
return db.Connection.Query<T>(MarkSqlString(sql, fromFile, onLine, comment), param, transaction ?? db.Transaction, true, commandTimeout).AsDapperList();
}
catch (SqlException ex) when (ex.Is(SqlErrorCode.DatabaseReadOnly_3906))
{
@gpshonik
gpshonik / The Technical Interview Cheat Sheet.md
Last active August 29, 2015 14:28 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.