Skip to content

Instantly share code, notes, and snippets.

View cchitsiang's full-sized avatar
💭
continuous coding and debugging

Chew Chit Siang cchitsiang

💭
continuous coding and debugging
  • Kuala Lumpur, Malaysia
View GitHub Profile
@cchitsiang
cchitsiang / 0_reuse_code.js
Created October 14, 2013 02:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@cchitsiang
cchitsiang / httphander.cs
Created October 14, 2013 03:55
Sampe code for HttpHandler
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "html";
context.Response.Write("Hello World");
manaeform(context);
}
public void manaeform(HttpContext context)
@cchitsiang
cchitsiang / slmgr.bat
Created October 18, 2013 00:30
Reset Windows Activation to pre-key state
Open a command prompt as an Administrator.
Enter slmgr /upk and wait for this to complete. This will uninstall the current product key from Windows and put it into an unlicensed state.
Enter slmgr /cpky and wait for this to complete. This will remove the product key from the registry if it's still there.
Enter slmgr /rearm and wait for this to complete. This is to reset the Windows activation timers so the new users will be prompted to activate Windows when they put in the key
slmgr /ipk 7BNJT-PXJR8-J9G6D-DHJVQ-DV3KQ
slmgr /ato
@cchitsiang
cchitsiang / convertEvalToFull.bat
Created October 18, 2013 01:16
Convert Windows Server Eval to Full
DISM /online /Get-TargetEditions
DISM /online /Set-Edition:ServerStandard /ProductKey:XC9B7-NBPP2-83J2H-RHMBY-92BT4 /AcceptEula
@cchitsiang
cchitsiang / getuserandgroup.ps1
Created October 18, 2013 08:03
Get User and Group
-- Username1 | Group1, Group 2, Group 3, Group 4, Group 5 etc.
$memberOf = @{n='MemberOf';e={ ($_.MemberOf -replace '^CN=([^,]+).+$','$1') -join ';' }}
Get-QADUser -SizeLimit 0 | `
Select-Object Name,DN,SamAccountName,$memberOf | `
Export-Csv report.csv
@cchitsiang
cchitsiang / getusermembership.ps1
Created October 18, 2013 08:04
Get Group Membership of Particular AD User
$ID = read-host "Enter the user's ID you wish to scan"
$FQDN = "cn=block_cloning,dc=yourdomain,dc=com" #full FQDN of the block_cloning group
Get-ADUser -Identity $ID -Properties memberOf | % {$_.memberOf} | % {Get-ADGroup $_ -Properties *} `
| select name, mail, GroupCategory, GroupScope,@{Label="Block_Cloning";Expression={
If ($_.MemberOf -contains $FQDN)
{ "Yes"
}
Else
{ "No"
}}} | Sort mail, name | Export-CSV c:\pathofexport.csv
@cchitsiang
cchitsiang / SendEmailActivity.cs
Created October 24, 2013 07:33
SendEmail Custom Activity
using System;
using System.Activities;
using System.ComponentModel;
namespace MyActivityLibrary {
public sealed class SendEmailActivity : CodeActivity {
public InArgument<string> to { get; set; }
public InArgument<string> subject { get; set; }
public InArgument<string> body { get; set; }
private string from = "*****@****.com";
@cchitsiang
cchitsiang / togetherjs-demo.htm
Created October 27, 2013 07:36
TogetherJS example
<script src="https://togetherjs.com/togetherjs-min.js"></script>
<button onclick="TogetherJS(this); return false;">Collaborate!</button>
@cchitsiang
cchitsiang / copysatelliteassemblies
Created November 1, 2013 10:28
CopySatelliteAssemblies After Finish Build
<Target Name="WSPCopySatelliteAssemblies" AfterTargets="AfterBuild">
<ItemGroup>
<ResourceFiles Include="$(MSBuildProjectDirectory)\..\Nintex.Workflow.Globalisation\$(OutDir)*\*.dll"/>
</ItemGroup>
<Message Condition="'@(IntermediateSatelliteAssembliesWithTargetPath)' != ''" Text="Server: Copying Satellite Assemblies to known location from project: Nintex.Workflow.Resources" />
<!-- Copy all satellite assemblies in each project built to a known folder for isolation -->
<RemoveDir Condition="'@(IntermediateSatelliteAssembliesWithTargetPath)' != ''" Directories="$(MSBuildProjectDirectory)\SatelliteAssemblies" />
<Copy Condition="'@(IntermediateSatelliteAssembliesWithTargetPath)' != ''" SourceFiles="@(IntermediateSatelliteAssembliesWithTargetPath)" DestinationFiles="@(IntermediateSatelliteAssembliesWithTargetPath->'$(MSBuildProjectDirectory)\SatelliteAssemblies\%(Culture)\$(TargetName).resources.dll')" SkipUnchangedFiles="false" />
<Message Condition="'@(IntermediateSatelliteAs
@cchitsiang
cchitsiang / CopyLinkedContentFiles
Created November 1, 2013 10:38
Copying linked content files at each build using MSBuild
<!--http://mattperdeck.com/post/Copying-linked-content-files-at-each-build-using-MSBuild.aspx-->
<Target Name="CopyLinkedContentFiles" BeforeTargets="Build">
<Copy SourceFiles="%(Content.Identity)"
DestinationFiles="%(Content.Link)"
SkipUnchangedFiles='true'
OverwriteReadOnlyFiles='true'
Condition="'%(Content.Link)' != ''" />
</Target>