Skip to content

Instantly share code, notes, and snippets.

@tonylea
tonylea / GetLockoutLocation.ps1
Created March 10, 2016 14:32
Get Locked Out Location
#requries -Version 2.0
<#
.SYNOPSIS
This script is PowerShell script which can be used to get location of locked out user account.
.DESCRIPTION
This script is PowerShell script which can be used to get location of locked out user account.
.PARAMETER SamAccountName
Specifies the SamAccountName of user that you want search.
.EXAMPLE
@tonylea
tonylea / SortArrayNum.js
Created April 10, 2016 17:21
Sort array of numbers correctly
function sortNumber(a,b) {
return a - b;
}
var numArray = [140000, 104, 99];
numArray.sort(sortNumber);
@tonylea
tonylea / rangedArray.js
Created April 10, 2016 18:29
Create a array filled with range of numbers
function rangedArray(start, end){
if (arguments.length === 1) {
end = start;
start = 0;
}
end = end || 0;
var step = 1;
for (var result = []; ((end - start) * step) > 0; start += step) {
result.push(start);
@tonylea
tonylea / gui-boilerplate.ps1
Created April 16, 2016 00:44
PowerShell GUI Boilerplate
Function Get-FormVariables {
if ($global:ReadmeDisplay -ne $true) { Write-host "If you need to reference this display again, run Get-FormVariables" -ForegroundColor Yellow; $global:ReadmeDisplay = $true }
write-host "Found the following interactable elements from our form" -ForegroundColor Cyan
get-variable WPF*
}
# Create WPF C# Form is Visual Studio and copy the XAML data
@tonylea
tonylea / Boxstarter.txt
Created July 28, 2016 13:43
Boxstarter config
Set-ExplorerOptions -showHiddenFilesFoldersDrives -showFileExtensions
Enable-RemoteDesktop
Disable-BingSearch
cinst 7zip
cinst adobereader
cinst autohotkey
cinst cyberduck
cinst git
cinst googlechrome
@tonylea
tonylea / Get-FrameworkVersions.ps1
Created August 8, 2016 09:33 — forked from drmohundro/Get-FrameworkVersions.ps1
PowerShell script to return all installed .NET Framework versions.
<#
.Synopsis
Returns the install .NET Framework versions.
.Description
The script looks through the registry using the notes from the below
MSDN links to determine which versions of .NET are installed.
@tonylea
tonylea / self-elevate-script.ps1
Created August 22, 2016 10:52
Script block to self-elevate a script
# Script found at https://www.autoitscript.com/forum/topic/174609-powershell-script-to-self-elevate/
# Test if admin
function Test-IsAdmin()
{
# Get the current ID and its security principal
$windowsID = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$windowsPrincipal = new-object System.Security.Principal.WindowsPrincipal($windowsID)
# Get the Admin role security principal
Set-ExplorerOptions -showHiddenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
cinst Chocolatey
cinst angryip
cinst autohotkey
cinst autohotkey
cinst checksum
cinst ChocolateyGUI
cinst cutepdf
@tonylea
tonylea / nginxproxy.md
Created January 29, 2017 00:34 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@tonylea
tonylea / clean-up-boot-partition-ubuntu.md
Created September 26, 2017 07:51 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r