Skip to content

Instantly share code, notes, and snippets.

View TangChr's full-sized avatar

Christian Tang TangChr

View GitHub Profile
@TangChr
TangChr / Test-IsAdmin.ps1
Last active March 15, 2022 20:52
Check if Command window is running with administrator permissions
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
TangChr / RemoveOldModules.ps1
Last active April 29, 2021 09:35
PowerShell method to remove old versions of installed modules
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
TangChr / datepicker-da.js
Last active February 27, 2021 15:29
jQuery: Danish localization of the jQuery UI Datepicker
(function($){
$.ui.datepicker.regional['da'] = {
closeText: 'Luk',
prevText: '&#x3c;Forrige',
nextText: 'N&aelig;ste&#x3e;',
currentText: 'I dag',
monthNames: ['januar','februar','marts','april','maj','juni',
'juli','august','september','oktober','november','december'],
monthNamesShort: ['jan','feb','mar','apr','maj','jun',
'Jul','Aug','sep','okt','nov','dec'],
@TangChr
TangChr / slated-corners.scss
Last active December 17, 2020 15:12
Slated corners with SASS
@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
TangChr / aliases.txt
Last active July 20, 2019 16:18
Git Aliases
[alias]
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
TangChr / cmd_here.reg
Created July 26, 2016 14:53
Registry: Add "Open in cmd" shortcut to Windows Explorer’s Context Menu
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\cmd_here]
@="Open cmd here"
"Icon"="cmd.exe"
[HKEY_CLASSES_ROOT\Directory\Background\shell\cmd_here\command]
@="cmd.exe /s /k pushd \"%V\""
[HKEY_CLASSES_ROOT\Directory\shell\cmd_here]
@TangChr
TangChr / MyActivity.java
Last active September 25, 2018 18:49
Java: Simulate Home-button in Android
package dk.tcdev.android.gist;
import android.app.Activity;
import android.content.Intent;
public class MyActivity extends Activity {
public void exitApp() {
startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME));
}
@TangChr
TangChr / .gitconfig
Last active August 6, 2018 06:18
Adding Visual Studio Code to .gitconfig
[core]
editor = "code --wait"
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = "code --wait --diff $LOCAL $REMOTE"
[merge]
@TangChr
TangChr / clean-jekyll.cmd
Created June 18, 2016 14:19
Batch: Delete all Jekyll-related files and folders created during run time
rmdir _site /s /q
rmdir .sass-cache /s /q
del Gemfile.lock
@TangChr
TangChr / .travis.yml
Last active March 2, 2017 15:57
Travis CI: Build and test Jekyll website using HTMLProofer
language: ruby
rvm: 2.3.3
branches:
only:
- master
script: bundle exec rake test