Skip to content

Instantly share code, notes, and snippets.

Avatar

Juan on Software juanonsoftware

  • Rabbit Software
  • Vietnam
View GitHub Profile
@juanonsoftware
juanonsoftware / RavenDB - Start with RavenDB 4.2.txt
Last active May 20, 2021
Steps to start working with RavenDB version 4.2
View RavenDB - Start with RavenDB 4.2.txt
This contains some steps to start working with RVDB 4.2
1. Download the zip at https://ravendb.net/download
2. Unzip to a folder eg D:\Tools\RavenDB\RavenDB-4.2.113-windows-x64
3. Start a PowerShell in Admin mode and change to RVDB folder, execute run.ps1 script
4. Go through some simple steps, ignore configuring any server certificate, we can start using RVDB at this address: http://127.0.0.1:8080/studio/index.html
@juanonsoftware
juanonsoftware / remove-useless-characters.cs
Created Oct 1, 2020
Remove useless characters from a text stream (read from a text file / html file....)
View remove-useless-characters.cs
// Remove multi spaces
const string reduceSpaces = @"[ ]{2,}";
var finalText = Regex.Replace(allText.Replace('\t', ' '), reduceSpaces, " ");
// Remove empty lines
const string emptyLine = @"^\s+$[\r\n]*";
var finalText = Regex.Replace(finalText, emptyLine, string.Empty, RegexOptions.Multiline);
@juanonsoftware
juanonsoftware / pdf-text-extraction.cs
Last active Oct 1, 2020
C# How to get text from PDF file with iTextSharp
View pdf-text-extraction.cs
// source is a byte array
using (var reader = new PdfReader(source))
{
using (var output = new StringWriter())
{
for (int i = 1; i <= reader.NumberOfPages; i++)
{
output.WriteLine(PdfTextExtractor.GetTextFromPage(reader, i));
}
@juanonsoftware
juanonsoftware / docker-ps-commands.ps1
Last active Sep 19, 2020
This file contains some common PowerShell commands to work with Docker
View docker-ps-commands.ps1
# 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;
View Config ARR as a Proxy Server.md

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

View Config ARR as a Proxy Server.md

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 / Restore database.sql
Created Oct 22, 2018
Restore a SQL Server database from backup files
View Restore database.sql
-- 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 / README.md
Created Sep 6, 2018 — forked from magnetikonline/README.md
PowerShell execute command (.exe) with arguments safely (e.g. with spaces).
View README.md

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 / EmbededAssemblyHelper.cs
Last active Jun 1, 2018
A class that helps to load embeded dll files into app domain
View EmbededAssemblyHelper.cs
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 / ChocoInstallSqlServer2014WithManagementStudio.ps1
Created May 15, 2018
Powershell script to install SQL Server 2014 and SQL Server Studio Management via Chocolatey
View ChocoInstallSqlServer2014WithManagementStudio.ps1
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