Skip to content

Instantly share code, notes, and snippets.

View theMansib's full-sized avatar
💭
I may be slow to respond.

Mansib theMansib

💭
I may be slow to respond.
View GitHub Profile
@theMansib
theMansib / HyperV_DDA_Setup.ps1
Last active November 14, 2022 07:06
[GPU Partitioning & Driver Setup] Utility scripts for leveraging Discrete Device Assignment (DDA) and GPU Paravirtualization (GPU-PV) under Hyper-V. Tested under Win11 Enterprise 22H2.
$vm = "GPUPV DDA Environment" # Name of your VM goes here.
# Shut the VM down before enabling these.
Add-VMGpuPartitionAdapter -VMName $vm
Set-VMGpuPartitionAdapter -VMName $vm -MinPartitionVRAM 80000000 -MaxPartitionVRAM 100000000 -OptimalPartitionVRAM 100000000 -MinPartitionEncode 80000000 -MaxPartitionEncode 100000000 -OptimalPartitionEncode 100000000 -MinPartitionDecode 80000000 -MaxPartitionDecode 100000000 -OptimalPartitionDecode 100000000 -MinPartitionCompute 80000000 -MaxPartitionCompute 100000000 -OptimalPartitionCompute 100000000
Set-VM -GuestControlledCacheTypes $true -VMName $vm
Set-VM -LowMemoryMappedIoSpace 1Gb -VMName $vm
Set-VM –HighMemoryMappedIoSpace 32Gb –VMName $vm
@theMansib
theMansib / SheetSync.py
Last active July 25, 2021 10:33
SheetSync - Staging
from Schema import EstablishPymongoConnection, SetSchedulerState, Config
import gspread
import pandas as pd
from oauth2client.service_account import ServiceAccountCredentials
from gspread_formatting import *
from io import StringIO, BytesIO
import csv
import datetime
import openpyxl
import requests
@theMansib
theMansib / Legacy_Python_IDLE_on_ARM_Macs.MD
Last active June 10, 2021 06:18
Most performant solution to running versions of Python prior to 3.9.1, alongside all of its modules (IDLE, Tkinter, Spyder, etc.)

Run Legacy Python (< 3.9.1) + Tkinter on ARM-based Macs

Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.


Since the launch of ARM-based Macs, students and developers alike have been racking their heads over how they can continue using older versions of Python on their system, alongside all of their modules without the use of proprietary virtualization software.

@theMansib
theMansib / WSL2_PortForwardingFix.md
Created May 8, 2021 04:20
WSL Port Forwarding Fix

WSL2 Port Forwarding Fix

  1. Read this documentation
  2. Add a file with these contents to %USERPROFILE%\.wslconfig:
[wsl2]
localhostForwarding=true

Global Dark Mode for Creative Cloud Desktop

Add the following chunk of code to the <head> section of C:\Program Files\Adobe\Adobe Creative Cloud\ACC\resources\index.html:

<style>

        #overlay {
            backdrop-filter: invert(1) hue-rotate(180deg) saturate(300%) !important;
            position: fixed;
@theMansib
theMansib / Secure-Vagrantfile.rb
Created March 20, 2020 05:55
Encryption support for Vagrant boxes.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Adapted from https://gist.github.com/gabrielelana/9189eab5df963deba30f & zqlu's fork
# Works with Vagrant 2.2.7 (trigger)
# After the first `vagrant up` stop the VM and execute the following steps
# Take the identifier of the storage you want to encrypt
# > HDD_UUID=`VBoxManage showvminfo <VM_NAME> | grep 'SATA.*UUID' | sed 's/^.*UUID: \(.*\))/\1/'`
# Store your username (whitespaces are not allowed) in a variable
@theMansib
theMansib / LoginHandler.py
Created March 12, 2020 13:22
Generic Login Handler for Flask (SQLite3 backend, supports REST APIs, AJAX-compatible)
@app.route('/functions/login', methods=["POST"])
def login():
INTERNAL()
# print("[INFO] Received:", request.get_json(force=True))
response = request.get_json(force=True)
role = response['role']
username = response['username']
password = response['password']
if USER_ROLES.index(role) < 0:
abort(make_response(jsonify(error="Provided user role ('%s') does not exist. Accepted: %s" % (role, USER_ROLES)), 406))
@theMansib
theMansib / input.sh
Last active December 14, 2019 13:23
[Bash] QuickInput (w/ GCC support)
#!/bin/bash
GCC_ARGS="g++ -Wall -std=gnu++17"
# Terminal coloring
ALERT='\033[;5;1;4;7m'
NC='\033[0m' # No Color
SUPPORTED_FILETYPES=("cpp")
if [ -z ${QUIET_MODE+x} ]; then QUIET_MODE=2; else QUIET_MODE=1; fi
@theMansib
theMansib / Bookstore.py
Last active July 8, 2019 09:37
CLI Bookstore (NYP Programming Essentials AY2019)
# import sys
# [NOTE] Data persistence: https://stackoverflow.com/questions/4529815/saving-an-object-data-persistence
try:
import cPickle as pickle
except ModuleNotFoundError:
import pickle
# [NOTE] For date-parsing.
from dateutil.parser import parse