Skip to content

Instantly share code, notes, and snippets.

Avatar

Ricky RickyLin

View GitHub Profile
@RickyLin
RickyLin / InvokeJavaScriptFunctionAfterEachUpdatePanelRequest
Created Jun 11, 2020
invoke javascript functions after each UpdatePanel request
View InvokeJavaScriptFunctionAfterEachUpdatePanelRequest
$(function () {
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm != null) {
prm.add_endRequest(function (sender, e) {
/*
if (sender._postBackSettings.panelsToUpdate != null) {
DisplayCurrentTime();
}
*/
// invoke whatever functions
@RickyLin
RickyLin / fnGetCSharpTypeNameFromSQLTypeName.sql
Last active May 26, 2020
Convert SQL data type to C# data type
View fnGetCSharpTypeNameFromSQLTypeName.sql
CREATE FUNCTION fnGetCSharpTypeNameFromSQLTypeName
(
@SQLTypeName NVARCHAR(64)
, @IsNullable BIT
)
RETURNS NVARCHAR(64)
AS
-- TEST: SELECT dbo.fnGetCSharpTypeNameFromSQLTypeName('MONEY', 1)
BEGIN
DECLARE @Result NVARCHAR(64)
@RickyLin
RickyLin / DeleteLocalBranchesWhoseRemoteTrackingBranchesWereGone.ps1
Created Aug 15, 2019
Delete local branches whose remote tracking branches were gone.
View DeleteLocalBranchesWhoseRemoteTrackingBranchesWereGone.ps1
git fetch origin -np
$BranchesToDelete = New-Object -TypeName System.Collections.Generic.List[string]
$BranchList = (git branch -vv)
foreach ($Branch in $BranchList) {
if ($Branch.ToString().Contains(": gone]")) {
$BranchesToDelete.Add($Branch.ToString().TrimStart().Split(' ')[0])
}
}
@RickyLin
RickyLin / StopAppPool.ps1
Created Jan 28, 2018
Powershell script to stop an IIS Application Pool
View StopAppPool.ps1
# usage: StopAppPool.ps1 -AppPoolName DefaultAppPool
# set-executionpolicy remotesigned
# Document of WebAdministration:
# https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/ee790599(v%3dtechnet.10)
# multiple parameters sample: param([string]$paramA,[string]$paramB)
param([string]$AppPoolName)
if ([string]::IsNullOrEmpty($AppPoolName))
{
@RickyLin
RickyLin / StartAppPool.ps1
Last active Jan 28, 2018
Powershell script to start an IIS Application Pool
View StartAppPool.ps1
# usage: StartAppPool.ps1 -AppPoolName DefaultAppPool
# set-executionpolicy remotesigned
# Document of WebAdministration:
# https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/ee790599(v%3dtechnet.10)
# multiple parameters sample: param([string]$paramA,[string]$paramB)
param([string]$AppPoolName)
if ([string]::IsNullOrEmpty($AppPoolName))
{
View spGenerateSqlStatement
IF EXISTS ( SELECT 1 FROM sys.procedures WHERE name = 'spGenerateSqlStatement' )
DROP PROCEDURE spGenerateSqlStatement
GO
CREATE PROCEDURE spGenerateSqlStatement
@TableName VARCHAR(256)
AS
-- TEST: spGenerateSqlStatement 'Message'
DECLARE @SqlStmt VARCHAR(MAX)
DECLARE @Fields VARCHAR(MAX)
DECLARE @Params VARCHAR(MAX)
@RickyLin
RickyLin / SplitStringInSqlServer_XML_Approach
Last active Aug 29, 2015
Split string in Sql Server - XML approach
View SplitStringInSqlServer_XML_Approach
-- it comes from this great post: http://sqlperformance.com/2012/07/t-sql-queries/split-strings
-- this way turns out not to be very efficient
CREATE FUNCTION dbo.SplitStrings_XML
(
@List NVARCHAR(MAX),
@Delimiter NVARCHAR(255)
)
RETURNS TABLE
WITH SCHEMABINDING
AS
@RickyLin
RickyLin / StartAndStopIISAppPool
Created Nov 14, 2014
Start and Stop IIS App Pool by Cmd
View StartAndStopIISAppPool
REM stop the IIS App Pool
%windir%\system32\inetsrv\appcmd stop apppool /apppool.name:DefaultAppPool
REM start the IIS App Pool
%windir%\system32\inetsrv\appcmd start apppool /apppool.name:DefaultAppPool
You can’t perform that action at this time.