Skip to content

Instantly share code, notes, and snippets.

View cchitsiang's full-sized avatar
💭
🤖 AI & the Future of Work | 🏗️ Software Architecture & Design

Chew Chit Siang cchitsiang

💭
🤖 AI & the Future of Work | 🏗️ Software Architecture & Design
  • Kuala Lumpur, Malaysia
  • 19:41 (UTC +08:00)
View GitHub Profile
function hostReachable() {
// Handle IE and more capable browsers
var xhr = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" );
var status;
// Open new request as a HEAD to the root hostname with a random param to bust the cache
xhr.open( "HEAD", "//" + window.location.hostname + "/?rand=" + Math.floor((1 + Math.random()) * 0x10000), false );
// Issue request and handle response
@cchitsiang
cchitsiang / checkwebapppool.ps1
Created November 29, 2013 08:34
Check SharePoint Central Administration Web Application Pool Status
$apppool = [Microsoft.SharePoint.Administration.SPWebService]::AdministrationService.ApplicationPools
$appPoolStatus = Get-WebAppPoolState $apppool.name
$appPoolStatus.Value
powershell -ExecutionPolicy unrestricted -command blue_green_deploy.ps1
-buildZipFile package.zip -server WEBSERVER -siteName WebSite
-blueIISPath D:\Web_Blue\ -blueNetworkPath \\WEBSERVER\Web_Blue\
-greenIISPath D:\Web_Green\ -greenNetworkPath \\WEBSERVER\Web_Green\;
@cchitsiang
cchitsiang / vsshortcut
Created November 17, 2013 17:09
Visual Studio Shortcut
F5 / Ctrl+F5 - Debugging
Ctrl-M + Ctrl-O - collapse all code to definitions.
Ctrl-M + Ctrl-P - used to expand all code.
Ctrl-K + Ctrl-S is used to surrounded a block of code to an specific block or control.
Ctrl-(+) + Ctrl-. - Resolve namespace
Script Usage:
1. Copy paste the below script in a text file and save the file as say “CleanupFarmSolutionStore.ps1″.
2. Run SharePoint 2010 Management Shell and change directory to where you saved above file.
3. Run command as > .\CleanupFarmSolutionStore.ps1 -Confirm $false
Note: Setting parameter -Confirm to false will not ask for confirmation before uninstalling and removing the solution from farm solution store. Set it to true for asking the confirmation.
Usage
If you’re saving the script to a file, say “Remove-AllSPSolutions.ps1” then remember to load the script before invoking it with:
. .Remove-AllSPSolutions.ps1
You can uninstall all deployed solutions with the following command:
Uninstall-AllSPSolutions -Confirm
And then remove them with:
Add-PsSnapin Microsoft.SharePoint.PowerShell
#Do not modify anything in the script from here onwards
function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
function Deploy-Solution{
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.DirectoryServices;
using System.Collections.Generic;
[WebService(Namespace = "http://tempuri.org")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class AppServerService : System.Web.Services.WebService
@cchitsiang
cchitsiang / print.js
Created November 7, 2013 05:01
JavaScript Print: Bypass Printer Dialog in IE and Firefox
var OLECMDID = 6;
/* OLECMDID values: * 6 - print * 7 - print preview * 1 - open window * 4 - Save As */
if (navigator.appName == "Microsoft Internet Explorer")
{
var PrintCommand = '<object ID="PrintCommandObject" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
document.body.insertAdjacentHTML('beforeEnd', PrintCommand);
if(PrintCommandObject)
{
try
{
@cchitsiang
cchitsiang / closeConnection.aspx
Created November 6, 2013 03:00
Login as another user
http://siteurl/_layouts/closeConnection.aspx?loginasanotheruser=true