Skip to content

Instantly share code, notes, and snippets.

View alantsai's full-sized avatar

Alan Tsai alantsai

View GitHub Profile
@alantsai
alantsai / sql-delete-data-history.sql
Created November 29, 2015 17:42
umbraco delete data version last then certain date. 刪除某個日期之前的歷史資料. Source: https://our.umbraco.org/projects/backoffice-extensions/falm-housekeeping/bugs-reports/42409-The-wait-operation-timed-out #umbraco
DECLARE @versionDate date;
SET @versionDate = CONVERT(DATETIME, 11/26/2015, 102); -- delete data older than provide date
SELECT nodeId, published, documentUser, versionId, text, releaseDate, expireDate, updateDate, templateId, newest into #tmp
FROM cmsDocument WHERE versionID NOT IN
(SELECT D.versionId FROM cmsDocument D WHERE D.versionId IN
var find = 'abc';
var re = new RegExp(find, 'g');
str = str.replace(re, '');
SELECT
t.NAME AS TableName,
s.Name AS SchemaName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM
sys.tables t
INNER JOIN
@alantsai
alantsai / ps-displayAllFileWithLastWriteTime.ps1
Last active November 24, 2015 10:00
display all files under directory with LastWriteTime (Last Modify Time) and full file path order by LastWriteTime. 取得目前資料夾的所有檔案的最後修改時間和檔案路徑的Table,依照最後修改時間排序. #powershell
# inspire from https://rcmtech.wordpress.com/2010/08/12/powershell-find-files-modified-after-a-certain-date/
dir -File -recurse | Sort-object LastWriteTime -desc | format-table lastwritetime, fullname -autosize
# 匯出到檔案 files.txt
dir -File -recurse | Sort-object LastWriteTime -desc | format-table lastwritetime, fullname -autosize | out-dir files.txt
@alantsai
alantsai / ps-setFileLastWriteTime.ps1
Last active November 24, 2015 09:54
Set specific LastWriteTime (Modified Time) of a directory child file. 把資料夾下面檔案的最後修改時間改成特定時間. #powershell
# 日期格式是 dd/MM/yyyy HH:mm
dir -file -recurse | % { $_.LastWriteTime = '11/19/2015 14:20' }
@alantsai
alantsai / !ReadMe.md
Last active June 3, 2017 08:53
#Umbraco #sql delete user by user Id(用使用者Id刪除使用者)

把Umbraco user刪掉並且把本來屬於此user的資料(例如audit trail)指向admin(userid 0)

來源:Deleting Users

@alantsai
alantsai / !ReadMe.md
Last active September 18, 2019 13:56
Set All *.cs file to utf-8 encoded 設定所有目前資料夾的 *.cs檔案,重新寫入成為utf-8 encoding #powershell

設定所有目前資料夾的 *.cs檔案,重新寫入成為utf-8 encoding

使用情景

有些時候建立的檔案不知道為什麼不是utf-8檔案,而是建立成了ansi編碼。在中文作業系統看不出來,因為通常非unicode語系都會設定成中文。但是一放到非中文作業系統,就會變成亂碼,造成程式無法編譯。

因此這個script用來把所有*.cs檔案另存成為utf-8編碼

Powershell Script

There are two ways to approach this problem. Either use a simple array or an array of objects. Each solution has it pros and cons. Below you'll find one for each case.


With a simple array as input data

the html could look like:

<label ng-repeat="fruitName in fruits">

Example usage

Use like:

console.log(toQueryString({
    prop1: 'x',
    prop2: {
        y: 1,
 z: 2