Skip to content

Instantly share code, notes, and snippets.

@hoangitk
hoangitk / Git_Practices.md
Last active March 11, 2022 06:18
[Git Practice] #git
@hoangitk
hoangitk / ExampleUsage.cs
Created November 27, 2021 04:24 — 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))
{
@hoangitk
hoangitk / Shrink your WSL2 Virtual Disks and Docker Images and Reclaim Disk Space.md
Created November 3, 2021 07:04
[Shrink your WSL2 Virtual Disks and Docker Images and Reclaim Disk Space] #wsl #tips

Shrink your WSL2 Virtual Disks and Docker Images and Reclaim Disk Space

Credit: https://www.hanselman.com/blog/shrink-your-wsl2-virtual-disks-and-docker-images-and-reclaim-disk-space

Docker Desktop for Windows uses WSL to manage all your images and container files and keeps them in a private virtual hard drive (VHDX) called ext4.vhdx.

It's usually in C:\Users\YOURNAME\AppData\Local\Docker\wsl\data and you can often reclaim some of the space if you've cleaned up (pruned your images, etc) with Optimize-Vhd under an administrator PowerShell shell/prompt.

You'll need to stop Docker Desktop by right clicking on its tray icon and choosing Quit Docker Desktop. Once it's stopped, you'll want to stop all running WSL2 instances with wsl --shutdown

Mine was 47gigs as I use Docker A LOT so when I optimize it from admin PowerShell from the wsl\data folder

@hoangitk
hoangitk / curl in Powershell.md
Created October 27, 2021 10:08
[curl in Powershell] #powershell
@hoangitk
hoangitk / How to download file without browser.md
Last active October 19, 2021 13:57
[How to download file without browser] #tips

How to download file without browser

bitsadmin /transfer myDownloadJob /download /priority normal https://downloadsrv/10mb.zip c:\\10mb.zip
  • Powershell
@hoangitk
hoangitk / SSH Command.md
Last active October 15, 2021 08:48
[SSH Command] #ssh

SSH Command

  • Connect to server
> ssh <user>@<server>
  • Send remote command
> ssh <user>@<server> <command>
@hoangitk
hoangitk / Favorites Folder.md
Last active July 28, 2022 02:47
[Favorites Folder] #refs #windows
@hoangitk
hoangitk / auto_backup_all_db.sql
Created August 4, 2021 09:15
[Auto backup all DB] #backup #mssql
/*
credit: https://www.mssqltips.com/sqlservertip/1070/simple-script-to-backup-all-sql-server-databases
*/
DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name
-- specify database backup directory
@hoangitk
hoangitk / Fresh Installation.md
Last active April 3, 2026 04:43
[Fresh Installation] #install #fresh #windows #cmd

Fresh Installation

Apps

# Universal Runner:
winget install Esubaalew.Run

Prompt

  • Command Line