Skip to content

Instantly share code, notes, and snippets.


Christian Tang TangChr

View GitHub Profile
TangChr / RemoveOldModules.ps1
Last active Apr 29, 2021
PowerShell method to remove old versions of installed modules
View RemoveOldModules.ps1
function Remove-OldModules
Write-Prompt "------------------------------------------" -ForegroundColor Cyan
Write-Prompt "Removing old versions of installed modules" -ForegroundColor Cyan
Write-Prompt "------------------------------------------" -ForegroundColor Cyan
$modules = Get-InstalledModule
Write-Prompt "$($modules.count) module(s) found." -ForegroundColor Yellow
Write-Prompt ""
foreach ($module in $modules)
TangChr / .gitconfig
Last active Aug 6, 2018
Adding Visual Studio Code to .gitconfig
View .gitconfig
editor = "code --wait"
tool = default-difftool
[difftool "default-difftool"]
cmd = "code --wait --diff $LOCAL $REMOTE"
TangChr / Test-IsAdmin.ps1
Last active Mar 15, 2022
Check if Command window is running with administrator permissions
View Test-IsAdmin.ps1
function Test-IsAdmin {
try {
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal -ArgumentList $identity
return $principal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator )
} catch {
throw "Failed to determine if the current user has elevated privileges. The error was: '{0}'." -f $_
TangChr / cmd_here.reg
Created Jul 26, 2016
Registry: Add "Open in cmd" shortcut to Windows Explorer’s Context Menu
View cmd_here.reg
Windows Registry Editor Version 5.00
@="Open cmd here"
@="cmd.exe /s /k pushd \"%V\""
TangChr / aliases.txt
Last active Jul 20, 2019
Git Aliases
View aliases.txt
ec = config --global -e
br = branch
sa = !git add --all
ca = !git add --all && git commit -m
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
lrb = !git remote -v
co = checkout
cob = checkout -b
crb = !git cob $1 && git push origin -u
TangChr / .travis.yml
Last active Mar 2, 2017
Travis CI: Build and test Jekyll website using HTMLProofer
View .travis.yml
language: ruby
rvm: 2.3.3
- master
script: bundle exec rake test
TangChr / clean-jekyll.cmd
Created Jun 18, 2016
Batch: Delete all Jekyll-related files and folders created during run time
View clean-jekyll.cmd
rmdir _site /s /q
rmdir .sass-cache /s /q
del Gemfile.lock
TangChr / slated-corners.scss
Last active Dec 17, 2020
Slated corners with SASS
View slated-corners.scss
@mixin slated-top-left($size, $foreground, $background) {
content: '';
position: absolute;
width: 0;
top: 0;
left: 0;
border-top: $size solid $background;
border-right: $size solid $foreground;
TangChr / archive.html
Last active Jun 6, 2016
Liquid/Jekyll: Monthly Archive
View archive.html
<ul class="post-archive">
{% for p in site.posts %}
{% assign fdate = | date: '%b %Y' %}
{% if cur_date != fdate %}
{% assign cur_date = fdate %}
<h3>{{ | date: '%B, %Y' }}</h3>
{% endif %}
<a href="{{ p.url }}">{{ p.title }}</a>
TangChr / session-activator.php
Last active Dec 11, 2015
PHP: Enable sessions ($_SESSION) in WordPress plugins and themes
View session-activator.php
Plugin Name: Session Activator
Description: Enable the use of sessions ($_SESSION) in plugins and themes.
Version: 1.0.0
Author: Christian Tang
Author URI:
add_action('init', 'session_activator_start', 1);
add_action('wp_logout', 'session_activator_end');