Skip to content

Instantly share code, notes, and snippets.

View ShailMurtaza's full-sized avatar
🏠
Working from home

Shail Murtaza ShailMurtaza

🏠
Working from home
  • /dev/random
  • Pakistan
  • 06:30 (UTC +05:00)
View GitHub Profile
@ShailMurtaza
ShailMurtaza / 3d rendering.py
Last active September 9, 2024 07:54
Render 3D cube using PYGAME
import pygame
import numpy as np
from clip import cohen_sutherland_clip
from colors import COLORS
WIDTH, HEIGHT = 600, 600
run = True
clock = pygame.time.Clock()
pygame.init()
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
@ShailMurtaza
ShailMurtaza / clip.py
Last active September 9, 2024 09:49
Cohen-Sutherland 3D clipping algorithm
# Constants for outcodes
LEFT = 0b000001 # x < -w
RIGHT = 0b000010 # x > w
BOTTOM = 0b000100 # y < -w
TOP = 0b001000 # y > w
NEAR = 0b010000 # z < -w
FAR = 0b100000 # z > w
# Function to compute the outcode for a point
def compute_outcode(x, y, z, w):
@ShailMurtaza
ShailMurtaza / grub_re_install
Created October 3, 2021 07:31
How to reinstall GRUB bootloader
Those that have Legacy instead of EFI can go to step 4)
For EFI there is one extra step: Mount your EFI partition
mount /dev/sda1 /mnt/boot/efi
Sometimes errors like this can result: mount: /mnt/boot/efi: mount point does not exist.
To solve it create the efi directory in /mnt/boot/ using this command:
mkdir /mnt/boot/efi