Skip to content

Instantly share code, notes, and snippets.

View ak9999's full-sized avatar
🎯
Focusing

Abdullah "AJ" Khan ak9999

🎯
Focusing
  • New York
View GitHub Profile
@ak9999
ak9999 / create_mojave_iso.py
Created January 20, 2019 17:57
Simple script written for fun that creates a macOS Mojave ISO.
#!/usr/bin/env python3
"""
This script creates a macOS Mojave bootable ISO.
Requires Python 3.6, macOS, and macOS Mojave app installed.
Created using info gathered from here: https://gist.github.com/agentsim/00cc38c693e7d0e1b36a2080870d955b
Purpose: I just wanted to try out the subprocess library.
"""
@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 / 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)
@ak9999
ak9999 / leetcode_problem.txt
Last active March 5, 2021 02:26
Mob programming solutions to the Ransom Note problem from Leetcode: https://leetcode.com/problems/ransom-note/
Link: https://leetcode.com/problems/ransom-note/
Given an arbitrary ransom note string and another string containing letters from all the magazines,
write a function that will return true if the ransom note can be constructed from the magazines;
otherwise, it will return false.
Each letter in the magazine string can only be used once in your ransom note.
Example 1:
Input: ransomNote = "a", magazine = "b"