Skip to content

Instantly share code, notes, and snippets.

View AndreiMoraru123's full-sized avatar

Andrei Moraru AndreiMoraru123

View GitHub Profile
@AndreiMoraru123
AndreiMoraru123 / closures.cpp
Last active October 20, 2024 11:18
Objects are a poor man's Closures - a modern C++ take
#include <print>
#include <tuple>
consteval auto Vector(int x, int y) {
auto getX = [x] consteval {return x;};
auto getY = [y] consteval {return y;};
auto add = [x, y](auto other) consteval {
const auto [otherX, otherY, _] = other;
@AndreiMoraru123
AndreiMoraru123 / dll.c
Last active March 3, 2024 18:39
Doubly Linked LIst
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node *next;
struct Node *prev;
};
void printList(struct Node *node) {
@AndreiMoraru123
AndreiMoraru123 / blur.py
Created June 6, 2023 17:14
Privacy Protection Blur using Haar Cascades in OpenCV
import cv2
import matplotlib.pyplot as plt
face_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_frontalface_default.xml')
profile_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_profileface.xml')
plate_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_russian_plate_number.xml')
def blur_regions(image, regions):
for (x, y, w, h) in regions:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AndreiMoraru123
AndreiMoraru123 / lrvalues.ipynb
Created February 15, 2023 20:20
LRvalues.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AndreiMoraru123
AndreiMoraru123 / copysemantics.ipynb
Created February 12, 2023 20:07
CopySemantics.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AndreiMoraru123
AndreiMoraru123 / MalwareTree.py
Created January 7, 2023 13:30
Simple decision tree implemented in scikit-learn, trained on dummy malware data
"""
A simple decision tree implementation in scikit-learn.
Trained on fabricated malware data.
Features: file id, name, size in MB, extension and executability.
Labels: malware or not.
Output:
Accuracy: 0.75
@AndreiMoraru123
AndreiMoraru123 / Pruning.py
Created January 7, 2023 13:11
Short MNIST model pruning using a MLPClassifier in scikit-learn
"""
A simple implementation of L1 unstructured pruning.
Uses the magnitude of the weights to determine which weights to prune.
Made for the purpose of understanding pruning.
Built on top of the scikit-learn MLPClassifier.
Trained on the MNIST (28 x 28) dataset.
Output:
Accuracy before pruning: 0.901