Skip to content

Instantly share code, notes, and snippets.

View rsha256's full-sized avatar
🧸
Loading...

rsha256

🧸
Loading...
View GitHub Profile
@rsha256
rsha256 / print_spiral_matrix.py
Created March 10, 2021 18:56
Prints a spiral ordering of a 2d matrix in O(N) time and O(1) space.
def spiralOrder(matrix):
"""
>>> spiralOrder([[1,2,3],[4,5,6],[7,8,9]])
1
2
3
6
9
8
7
@rsha256
rsha256 / stable_matching.py
Last active March 10, 2021 18:56
Job-optimal stable matching pairing solver template
class StableMatching():
def solve(self, job_prefs: dict, candidates_prefs: dict) -> list(tuple(str, int)):
"""
Returns a job-optimal stable matching pairing that gives equilibria (¬∃ x=(C*, J*) s.t. x ∉ solution set).
---------------------
| Jobs | Candidates |
---------------------
| 1 | A > B > C |
---------------------
| 2 | B > A > C |
@rsha256
rsha256 / coin_tosses.py
Created November 3, 2020 01:31
simple coin toss visualizer for a fair coin's sample space
def product(*iters):
def loop(prod, first=[], *rest):
if not rest:
for x in first:
yield prod + (x, )
else:
for x in first:
yield from loop(prod + (x, ), *rest)
yield from loop((), *iters)
@rsha256
rsha256 / reed_solomon.py
Last active March 10, 2021 18:59
Tool for finding modular inverses for me to make CS70 questions 😄
class rs():
def __init__(self, p):
self.p = p # set the Galois Field
def divide(self, a, b):
a %= self.p
b %= self.p
b_mod_inv = 0 if b % self.p == 0 else self.find_mod_inv(b)
return (a*b_mod_inv) % self.p
@rsha256
rsha256 / show-wifi.ps1
Last active August 15, 2022 10:30
A powershell script I made to make showing WiFi passwords easier
$location = Read-Host "Do you want detailed info? (you really don't) [Y/n] "
If (($location -eq "yes") -or ($location -eq "Yes") -or ($location -eq "Y") -or ($location -eq "y"))
{
netsh wlan show profiles
$networkName = Read-Host 'Which of the above is the wifi network that you want to know the password of?'
netsh wlan show profile name=`"$networkName`" key=clear
@rsha256
rsha256 / index.html
Last active March 10, 2021 19:00
Barebones Example Template for Web Design Seminar
<!DOCTYPE html>
<html>
<head>
<!-- character encoding (allows special characters) -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>tab name</title>
<meta name="description" content="An interactive getting started guide for HTML.">
<!-- link to css sheet (colors) -->