Skip to content

Instantly share code, notes, and snippets.

View juanonsoftware's full-sized avatar

Juan on Software juanonsoftware

  • Rabbit Software
  • Vietnam
View GitHub Profile
@juanonsoftware
juanonsoftware / remove-all-messages-in-sql-queue.sql
Created April 26, 2018 08:45
To empty all messages from a queue
begin tran
declare @c uniqueidentifier
while(1=1)
begin
select top 1 @c = conversation_handle from dto.YourQueueName
if (@@ROWCOUNT = 0)
break
end conversation @c with cleanup
end
@juanonsoftware
juanonsoftware / Search StoredProcedures by name.sql
Created May 2, 2018 08:02
Search for stored procedures in a given database
SELECT name, create_date, modify_date
FROM sys.objects
WHERE type = 'P'
ORDER BY modify_date desc, create_date desc
@juanonsoftware
juanonsoftware / ChocoInstallCommonSoftwareForServer.ps1
Last active May 15, 2018 07:45
Common and Must have software for a Windows server installation script via Chocolatey. Just need to run this script in a Powershell console (with Administrator right)
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# 7Zip - https://chocolatey.org/packages/7zip
choco install 7zip -y
# Notepad++ - https://chocolatey.org/packages/notepadplusplus.install
choco install notepadplusplus.install -y
# TreeSize Free https://chocolatey.org/packages/treesizefree
choco install treesizefree -y
@juanonsoftware
juanonsoftware / ChocoInstallSqlServer2014WithManagementStudio.ps1
Created May 15, 2018 07:55
Powershell script to install SQL Server 2014 and SQL Server Studio Management via Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Install SQL Server 2014 Management Studio
choco install mssqlservermanagementstudio2014express -y --version 12.2.5000.20170905
# Install SQL Server 2014
choco install mssqlserver2014express -y --version 12.2.5000.20170905
@juanonsoftware
juanonsoftware / EmbededAssemblyHelper.cs
Last active June 1, 2018 07:07
A class that helps to load embeded dll files into app domain
public class EmbededAssemblyHelper
{
private static Assembly _embededResourcesAsm;
private static string _embededResourcesNamespace;
public static void Setup(Assembly embededResourcesAsm, string embededResourcesNamespace)
{
_embededResourcesAsm = embededResourcesAsm;
_embededResourcesNamespace = embededResourcesNamespace;
}
@juanonsoftware
juanonsoftware / README.md
Created September 6, 2018 09:43 — forked from magnetikonline/README.md
PowerShell execute command (.exe) with arguments safely (e.g. with spaces).

PowerShell execute command with arguments safely

In my opinion this is the best way for executing external commands from PowerShell with arguments in a safe manner - via the use of an array to hold the arguments.

Consider this one a PowerShell gem to keep in the toolbox.

Note: the example below makes use of EchoArgs.exe - a small utility that simply echoes back arguments passed to it. Utility is part of the PowerShell Community Extensions, or the exe alone can be downloaded at http://ss64.com/ps/EchoArgs.exe.

Example

Running example.ps1 yields the following output:

@juanonsoftware
juanonsoftware / Restore database.sql
Created October 22, 2018 08:30
Restore a SQL Server database from backup files
-- Get all db files from a bak
RESTORE FILELISTONLY
FROM DISK = 'Path to full backup file'
GO
-- Restore database from a bak with move logical files (note on NORECOVERY)
RESTORE DATABASE FindTheBest FROM DISK = 'Path to full backup file'
WITH MOVE 'Data file 1' TO 'Path to data file',
MOVE 'Log file 1' TO 'Path to log file',
NORECOVERY
@juanonsoftware
juanonsoftware / Config ARR as a Proxy Server.md
Created November 1, 2018 15:24
Config ARR as a Proxy Server

Steps to config ARR as a Proxy Server for AutoACME

1/ Go to ARR Cache, then Server Proxy Settings

2/ Check on Enable proxy

3/ Create a site call AutoACME and add a binding to support autoacme.com port 80

4/ Go to URL Rewrite

@juanonsoftware
juanonsoftware / Config ARR as a Proxy Server.md
Created November 1, 2018 15:25
Config ARR as a Proxy Server

Steps to config ARR as a Proxy Server for AutoACME

1/ Go to ARR Cache, then Server Proxy Settings

2/ Check on Enable proxy

3/ Create a site call AutoACME and add a binding to support autoacme.com port 80

4/ Go to URL Rewrite

@juanonsoftware
juanonsoftware / docker-ps-commands.ps1
Last active September 19, 2020 08:42
This file contains some common PowerShell commands to work with Docker
# Remove ALL containers
docker ps -a -q | % { docker rm $_ }
# Stop and then remove all RUNNING containers
docker ps -q | % { docker stop $_; docker rm $_ }
# Dockerfile command to create a L drive from C:\Logs folder
RUN Set-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices' -Name 'L:' -Value '\??\C:\Logs' -Type String;