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 / sql-get-db-backups.sql
Last active Apr 12, 2018
Script to get all backup of a SQL Server database
View sql-get-db-backups.sql
declare @dbName varchar(255);
set @dbName = 'TestDB';
SELECT m.physical_device_name,
b.backup_start_date,
b.backup_finish_date,
b.type,
b.backup_size/1024/1024 AS BackupSizeMB,
b.compressed_backup_size/1024/1024 as CompressedBackupSizeMB
@juanonsoftware
juanonsoftware / sql-get-running-jobs.sql
Last active Apr 12, 2018
To get all jobs that are running on an instance
View sql-get-running-jobs.sql
SELECT
ja.job_id,
j.name AS job_name,
ja.start_execution_date,
ISNULL(last_executed_step_id,0)+1 AS current_executed_step_id,
Js.step_name
FROM msdb.dbo.sysjobactivity ja
LEFT JOIN msdb.dbo.sysjobhistory jh
ON ja.job_history_id = jh.instance_id
JOIN msdb.dbo.sysjobs j
@juanonsoftware
juanonsoftware / sql-check-index-fragmentation.sql
Last active Apr 12, 2018
Check Fragmentation of ALL Indexes in a Database
View sql-check-index-fragmentation.sql
-- https://myadventuresincoding.wordpress.com/2013/05/27/sql-server-check-index-fragmentation-on-all-indexes-in-a-database/
SELECT dbschemas.[name] as 'Schema',
dbtables.[name] as 'Table',
dbindexes.[name] as 'Index',
indexstats.alloc_unit_type_desc,
indexstats.avg_fragmentation_in_percent,
indexstats.page_count
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS indexstats
INNER JOIN sys.tables dbtables on dbtables.[object_id] = indexstats.[object_id]
INNER JOIN sys.schemas dbschemas on dbtables.[schema_id] = dbschemas.[schema_id]
@juanonsoftware
juanonsoftware / sql-backup-database-diff
Last active Apr 12, 2018
Script to backup an SQL Server database
View sql-backup-database-diff
-- NOTE
-- Must update dbName & Folder
declare @dbName nvarchar(150);
declare @folder nvarchar(100);
set @dbName = 'TestDB';
set @folder = 'D:\Mega\Wip\SQL\TestDB\Backup\';
declare @path nvarchar(255);
@juanonsoftware
juanonsoftware / Kill-sql-locks
Created Apr 12, 2018
Kill blocking processes on a database
View Kill-sql-locks
--- Kill blocked processes on a database
DECLARE @databasename nvarchar(50)
SET @databasename = N'Datbase_Name'
-- SET @databasename = DB_NAME()
DECLARE @Sql varchar(max)
SET @Sql = ''
SELECT @Sql = @Sql + 'Kill ' + Convert(varchar, SPId) + ';'
FROM master.dbo.sysprocesses
@juanonsoftware
juanonsoftware / sql-get-all-locks.sql
Last active Dec 21, 2018
A script to list all current locks in SQL server
View sql-get-all-locks.sql
-- With SQL
select handle.text as sql, * from
(
select DB_NAME(dbid) as dbname, *
from master.dbo.sysprocesses
where blocked <> 0
union
@netsi1964
netsi1964 / RawHTML.js
Created Aug 22, 2017
RawHTML: ReactJS pure component to render HTML
View RawHTML.js
const RawHTML = ({children, className = ""}) =>
<div className={className} dangerouslySetInnerHTML={{ __html: children.replace(/\n/g, '<br />')}} />
@DavidDeSloovere
DavidDeSloovere / upload.cs
Created Nov 17, 2016
SFTP upload with SSH.NET
View upload.cs
const string host = "domainna.me";
const string username = "chucknorris";
const string password = "norrischuck";
const string workingdirectory = "/highway/hell";
const string uploadfile = @"c:\yourfilegoeshere.txt";
Console.WriteLine("Creating client and connecting");
using (var client = new SftpClient(host, port, username, password))
{
client.Connect();
@magnetikonline
magnetikonline / README.md
Last active May 9, 2021
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: