Skip to content

Instantly share code, notes, and snippets.

View Kenny2github's full-sized avatar
🏫
University

AbyxDev Kenny2github

🏫
University
View GitHub Profile
@Kenny2github
Kenny2github / when2meet-copier.user.js
Last active March 5, 2024 06:46
Copy your when2meet responses from one when2meet to another.
// ==UserScript==
// @name When2meet Copy-Paste
// @match https://www.when2meet.com/?*
// @version 2024-03-06
// @description Copy your when2meet responses from one when2meet to the other.
// @author AbyxDev
// @icon https://www.google.com/s2/favicons?sz=64&domain=when2meet.com
// @grant none
// @updateURL https://gist.github.com/Kenny2github/c614b71dd67a5e80abcadfab3e54b4f0/raw/when2meet-copier.user.js
// @downloadURL https://gist.github.com/Kenny2github/c614b71dd67a5e80abcadfab3e54b4f0/raw/when2meet-copier.user.js
@Kenny2github
Kenny2github / !translations.md
Last active December 18, 2023 01:41
ECE253 Past Finals ARM to RISC-V translations

ECE253 Past Finals ARM to RISC-V translations

These are an attempt to translate ARM code appearing in ECE253 past finals and/or their solutions into RISC-V due to the use of the latter in newer iterations of the course. Each file is named as follows: YYYYM-Q##.s (or YYYYM-Q##X.s where X is a version letter) and may be updated as errors are discovered and corrected. If you discover an error or have feedback, leave a comment.

Translations

Legend: ☑️ Done 🟨 WIP 🟦 To-do

@Kenny2github
Kenny2github / git-del-branches.cmd
Created July 6, 2022 16:31
A git script to batch delete branches by glob pattern.
@echo off
if "%1"=="" (
echo usage: git del-branches ^<glob pattern^>
) else (
for /f "usebackq" %%b in (`git branch --list %1`) do (
git branch -d %%b
)
)
@Kenny2github
Kenny2github / set_like_flag.py
Last active June 30, 2022 20:53
An enum.Flag subclass that supports all frozenset operations.
from enum import Flag
class SetLikeFlag(Flag):
"""Flag that additionally supports all frozenset operations."""
def __repr__(self):
"""Only show the flag names, not values."""
return super().__repr__().split(':', 1)[0] + '>'
def __sub__(self, other):
"""Asymmetric difference of this set of flags with the other."""
if not isinstance(other, type(self)):
@Kenny2github
Kenny2github / squaredle.exs
Created June 9, 2022 07:03
Generate words for Squaredle - https://squaredle.app
defmodule Squaredle do
def find_word(row, col, word, board, past_path) do
coords = [
{row + 1, col + 1},
{row + 1, col + 0},
{row + 1, col - 1},
{row + 0, col + 1},
{row + 0, col - 1},
{row - 1, col + 1},
{row - 1, col + 0},
@Kenny2github
Kenny2github / combinatorics.ex
Last active June 9, 2022 04:19
Implementation of combinations and permutations in Elixir
defmodule Combinatorics do
def combinations(_, 0), do: [[]]
def combinations([], _), do: []
def combinations([head | rest], n) do
(for item <- combinations(rest, n - 1), do: [head | item]) ++ combinations(rest, n)
end
def permutations([]), do: [[]]
def permutations(list) do
for h <- list, t <- permutations(list -- [h]), do: [h | t]
@Kenny2github
Kenny2github / resistors.py
Last active April 17, 2022 02:05
Compute the equivalent impedance between two nodes.
from __future__ import annotations
from itertools import combinations
class Node:
components: set[Component]
num: int = 1
def __init__(self, components: set = None) -> None:
self.num = type(self).num
@Kenny2github
Kenny2github / generalized_exp.py
Created November 30, 2021 04:56
A Python implementation of the exponential function generalized to anything that supports Taylor series operations.
def exp(z, zero=None, one=None, equality=lambda a, b: a == b):
"""Raise e to the power of z.
z need only support the following:
- Addition with its own type
- Multiplication with its own type
- Multiplication with float
Provide ``zero`` if z - z != the zero of its type.
This function will probably not produce correct results
if this is the case, but it is provided for completeness.
@Kenny2github
Kenny2github / a_star.py
Last active August 20, 2019 07:23
A* algorithm implemented in Python.
import math
import random
from random import randint
from types import SimpleNamespace as Record
import pygame
from pygame.locals import *
SIZE = WIDTH, HEIGHT = 640, 360
HALFWIDTH, HALFHEIGHT = WIDTH // 2, HEIGHT // 2
BLOCS = BLOCW, BLOCH = 20, 20
@Kenny2github
Kenny2github / vigenere.py
Created July 25, 2019 16:28
Transform text with the vigenere cipher.
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def vigenere(string, key, direction=1):
"""Transform text with the vigenere cipher.
``string`` is the text to transform.
``key`` is the key to use in the process.
``direction`` is the direction of transformation:
1 for encoding, and -1 for decoding.