Skip to content

Instantly share code, notes, and snippets.

View ak9999's full-sized avatar
🎯
Focusing

Abdullah "AJ" Khan ak9999

🎯
Focusing
View GitHub Profile
@ak9999
ak9999 / UninstallLabTechAgent.ps1
Created September 21, 2019 23:48
Uninstall LabTech and ScreenConnect Agents: For those who are having a hard time uninstalling the LabTech Agent from their computer, the first script will remove the LabTech Agent, and the second will remove ScreenConnect aka (ConnectWise Control).
$url = "https://s3.amazonaws.com/assets-cp/assets/Agent_Uninstaller.zip"
$output = "C:\Windows\Temp\Agent_Uninstaller.zip"
(New-Object System.Net.WebClient).DownloadFile($url, $output)
# The below usage of Expand-Archive is only possible with PowerShell 5.0+
# Expand-Archive -LiteralPath C:\Windows\Temp\Agent_Uninstaller.zip -DestinationPath C:\Windows\Temp\LTAgentUninstaller -Force
# Use .NET instead
[System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null
# Now we can expand the archive
[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Windows\Temp\Agent_Uninstaller.zip', 'C:\Windows\Temp\LTAgentUninstaller')
Start-Process -FilePath "C:\Windows\Temp\LTAgentUninstaller\Agent_Uninstall.exe"
@ak9999
ak9999 / DefineLocalAdminAccount.ps1
Created September 21, 2019 23:51
Create or update a local administrator account, optionally choosing username and password.
param([string]$username='LocalAdministrator',[string]$password='P@ssw0rd!')
$secure_password = $password | ConvertTo-SecureString -AsPlainText -Force
try {
$LocalUserObject = Get-LocalUser -Name $username -ErrorAction Stop
}
catch [Microsoft.PowerShell.Commands.UserNotFoundException] {
"User $($username) Not Found" | Write-Warning
}
@ak9999
ak9999 / download_example.go
Created December 29, 2019 23:10
Downloads a file and saves it to a given location.
package main
import (
"fmt"
"io"
"net/http"
"os"
)
// DownloadFile will download a url to a local file.
@ak9999
ak9999 / not_twosum.py
Created February 2, 2020 14:53
Return two numbers that add up to a target sum.
from typing import List
def twoSum(nums: List[int], target: int) -> List[int]:
answers = []
for n in nums:
answers.append(target - n)
ans = set(answers) & set(nums)
return ans
@ak9999
ak9999 / get_complaint_data.py
Created February 2, 2020 14:56
Just grabbing JSON data from NYPD Complaint Data Historic from NYC Open Data, and pretty print it. Link: https://data.cityofnewyork.us/Public-Safety/NYPD-Complaint-Data-Historic/qgea-i56i
import json
from datetime import *
import pprint
from dateutil.relativedelta import *
from dateutil.parser import *
import requests
import pytz
EASTERN_TZ = pytz.timezone('US/Eastern')
@ak9999
ak9999 / Dockerfile
Created February 6, 2020 01:09
Here's a dummy docker file. Assume this is in a top level folder that has some folder called `contained` with an __init__.py in there that runs the app.
FROM python:3.7-slim
COPY contained /src/app/contained
WORKDIR /src/app
RUN pip install Flask
ENV FLASK_APP contained
CMD ["flask", "run", "--host=0.0.0.0"]
# Generate Report of BitLocker Status for Computers in the BitLocker Machines OU.
param([string]$OutputDirectory="~/Desktop",[string]$OrganizationalUnit=([adsi]'').distinguishedName)
if(!([Security.Principal.WindowsPrincipal] `
[Security.Principal.WindowsIdentity]::GetCurrent() `
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host -ForegroundColor Yellow "Only Administrators can read BitLocker Recovery Keys."
exit
}
$computers = Get-ADComputer -Filter * -SearchBase $OrganizationalUnit
$results = ForEach ($computer in $computers) {
@ak9999
ak9999 / Get Recovery Keys.ps1
Created February 7, 2020 13:48
Retrieve BitLocker Recovery Keys From Active Directory
# Generate Report of BitLocker Status for Computers in the BitLocker Machines OU.
# Sources: https://4sysops.com/archives/find-bitlocker-recovery-passwords-in-active-directory-with-powershell/
param([string]$OutputDirectory="~/Desktop",[string]$OrganizationalUnit=([adsi]'').distinguishedName)
if(!([Security.Principal.WindowsPrincipal] `
[Security.Principal.WindowsIdentity]::GetCurrent() `
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host -ForegroundColor Yellow "Only Administrators can read BitLocker Recovery Keys."
exit
}
$computers = Get-ADComputer -Filter * -SearchBase $OrganizationalUnit
@ak9999
ak9999 / NYCPythonVSCodeLiveShare.Dockerfile
Created December 21, 2020 03:21
Dockerfile for pair programming at NYC Python
# Live Share image built from official Python image
FROM python:slim
# Create a new user, dev
RUN useradd --create-home --shell /bin/bash dev
# Give dev a password
RUN echo 'dev:secret' | chpasswd
# Add dev to sudo group
RUN usermod -a -G sudo dev
# Update package list and install packages
RUN apt-get update
@ak9999
ak9999 / missing_number.py
Created January 30, 2021 01:35
My answer to the missing number problem on Leetcode
# https://leetcode.com/problems/missing-number/
import random
def generate_input_array(n: int) -> list:
if not (1 <= n <= 104):
raise ValueError('Given `n` does not fulfill 1 <= n <= 104')
nums = list()
while len(nums) != n:
temp = random.randint(0, n)