Skip to content

Instantly share code, notes, and snippets.

View alantsai's full-sized avatar

Alan Tsai alantsai

View GitHub Profile
@alantsai
alantsai / jsbin.OfaVEkIG.html
Last active February 12, 2019 05:45
選取所有checkbox和判斷是否全部checkbox已經被勾選
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="選取所有checkbox和判斷是否全部checkbox已經被勾選" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<form>
@alantsai
alantsai / !use_instruction.md
Last active July 11, 2019 05:50
Chocolatey Install Scripts use by BoxStarter

set powershell executing policy

Set-ExecutionPolicy Remotesign -Force

Original link http://boxstarter.org/Learn/WebLauncher

Step 3

Install the Boxstarter Modules

You can download the Boxstarter module installer from this web site or you can use Chocolatey to install the Boxstarter. Alternatively, you may invoke the module installer over the web using powershell.

@alantsai
alantsai / ps_renameFile_containParentDirectoryFirst2char.ps1
Last active November 19, 2015 08:58
Windows Phone無法用資料夾來區分影片,因此只能夠用檔名。而檔名通常沒有到資料夾層級。因此,這個Powershell script用資料夾前2個字元(通常表示那個章節)加上本身檔名讓整個做grouping。 #powershell
# 範例資料結構
# 原本是:
# 01 Chapter1/01.xxx.mp4
# 01 Chapter1/02.xxx.mp4
# 02 Chapter2/01.xxx.mp4
# 02 Chapter2/02.xxx.mp4
#
# 執行完:
# 01 Chapter1/01_01.xxx.mp4
# 01 Chapter1/01_02.xxx.mp4
@alantsai
alantsai / ps_get_iis_wbsite_log_location.ps1
Last active November 19, 2015 08:58
Get iis website log location using powershell 快速取得某一個iis 站台的log位置 From http://stackoverflow.com/questions/6426375/where-can-i-find-the-iis-logs #powershell
# 把{yoursite}換成iis站台名稱
# 把log位置顯示在 powershell
Get-Website {yoursite} | % { Join-Path ($_.logFile.Directory -replace '%SystemDrive%', $env:SystemDrive) "W3SVC$($_.id)" }
# 用explorer開啟log資料夾
Get-Website {yoursite} | % { Join-Path ($_.logFile.Directory -replace '%SystemDrive%', $env:SystemDrive) "W3SVC$($_.id)" } | ii
@alantsai
alantsai / git_clone_error_early_EOF
Created September 11, 2015 02:08
git clone error: fatal: The remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed From http://stackoverflow.com/questions/6842687/the-remote-end-hung-up-unexpectedly-while-git-cloning
git config --global http.postBuffer 524288000
# some comments below report having to double the value:
git config --global http.postBuffer 1048576000

Example usage

Use like:

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

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">
@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

@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