Skip to content

Instantly share code, notes, and snippets.

View alantsai's full-sized avatar

Alan Tsai alantsai

View GitHub Profile
@alantsai
alantsai / 01-readme.md
Last active June 1, 2020 09:58
[disable sql constraints (foregin key)] how to disable all sql contraints or goregin key - use for import data #sql
@alantsai
alantsai / ReadMe.md
Last active June 1, 2019 03:45
20190601-分享DevOps以及Azure DevOps的Pipeline功能做到CI以及CD
@alantsai
alantsai / remove-bin-and-obj-folder.ps1
Last active February 12, 2018 07:49
[Remove packages, bin and obj folder 刪除 packages,bin和obj資料夾] 用來快速清理solution裡面非必要檔案減少空間 #powershell
# 看看那些會刪掉
dir -Directory -Recurse -Include bin,obj | %{$_.FullName}
# 實際刪掉
dir -Directory -Recurse -Include bin,obj | Remove-Item -Force -Recurse
@alantsai
alantsai / delete-large-data-without-tracation-log-grow-without-space.md
Last active February 3, 2018 04:37
delete large data without transaction log full with no space

When delete large data showed

The transaction log for database '{db name}' is full due to 'ACTIVE_TRANSACTION'.

which means there is no more space for log

if you don't have that much space for large delete, do it in chunks

more info checkout

@alantsai
alantsai / ReadMe.md
Created February 1, 2017 16:10
use powershell to sort file by using natural number #powershell

有時候檔案名稱裡面會有數字,但是排序的時候因為是用字串排序,所以順序不如預期。 例如說有以下幾個檔案:

a1
a2
a10
a20

預期的排序應該如上,但是實際上排序出來會類似:

@alantsai
alantsai / deleteFilesFromZip.ps1
Created January 30, 2017 14:32
Delete files from zip file using powershell #powershell
# original from http://stackoverflow.com/questions/20269202/remove-files-from-zip-file-with-powershell
# 這邊是從某個zip檔案裡面的對應對應files刪掉
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression')
$zipfile = 'C:\path\to\your.zip'
$files = 'some.file', 'other.file', ...
$stream = New-Object IO.FileStream($zipfile, [IO.FileMode]::Open)
$mode = [IO.Compression.ZipArchiveMode]::Update
@alantsai
alantsai / setFileTime.ps1
Created January 28, 2017 03:32
Set Timestamp for specific file #powershell
# usage Set-FileTimeStamps -path C:Ref -date 7/1/11
# From https://blogs.technet.microsoft.com/heyscriptingguy/2012/06/01/use-powershell-to-modify-file-access-time-stamps/
Function Set-FileTimeStamps
{
Param (
[Parameter(mandatory=$true)]
@alantsai
alantsai / get-installed-sql-server-instance.md
Last active December 19, 2016 07:06
Get installed Sql Server Instance - 取得安裝在機器上面的 sql server #powershell

Location of installed sql server Instance

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL

EDIT:

If you are looking for 32 bit instances on a 64 bit OS, you will need to look here:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\Instance Names\SQL

@alantsai
alantsai / show-index-usage.sql
Last active May 29, 2016 09:01
Find Index Usage of a Database since it start the server - 取得db自啟動來的索引使用量 - #sql
DECLARE @databaseId nvarchar(128);
SET @databaseId = 'dbname'; ---改成要查看的資料庫
-- 用戶索引查找次數 -> 這個表示主動用where條件過濾的欄位
-- 用戶索引被動查找次數 -> 這個表示被動做join的次數
select db_name(database_id) as N'資料庫名稱',
@alantsai
alantsai / remove-ignore-file-from-track.md
Last active January 11, 2018 19:25
remove all track file which are ignored in the .gitignore - 把git裡面屬於.gitignore檔案被加入版控的檔案從版控刪掉 #git

Sometimes some files are accedntily added into the source control, which later relaized caused by not include a project level .gitignore

Below command provide way to remove all track files which should be ignored

  1. Produce the .gitignore file first and place in the root of git project

  2. Remove all files (-r for recurse, . mean from current directory) from git
    but leave the physical file untouch (indicate by the --cache option)