Skip to content

Instantly share code, notes, and snippets.

@macieklad
macieklad / match.tsx
Created November 14, 2023 10:14
Match util
import {
Children,
FunctionComponent,
isValidElement,
PropsWithChildren,
ReactElement,
useMemo,
} from "react";
// Match util simplifies conditional code in your application
// replace all occurences of abs(content) with |content| inside a string
function changeAbs(str) {
let out = str
let size = str.length
let buf = ''
let pos = 0
let parens = 0
let marker = 0
while (pos < size) {
classdef myDataSourceCam < handle
% Klasa realizująca odczyt danych z kamery
% - SZABLON DO UZUPELNIENIA
% WERSJA: 17.09.2020, R2020a
% Przykład użycia (użyj tego kodu do testów poprawności działania klasy):
%{
parametryImportu=[];
parametryImportu.nr = 1;
vid1 = myDataSourceCam(parametryImportu);
IM = vid1.pobierzDane;
- name: assignment
- variables:
c00 >= 0
c01 >= 0
c02 >= 0
c10 >= 0
c11 >= 0
c12 >= 0
c20 >= 0
c21 >= 0
`ifndef MAPPED
`include "simple_gates.v"
`else
`include "impl1/simple_gates_impl1_mapvo.vo"
//`include "impl1/simple_gates_impl1_vo.vo"
//`define sdf_path "impl1/simple_gates_impl1_mapvo.sdf"
`endif
`timescale 1ns / 1ps
def gradient(img, kernel_size = 5):
sx = cv2.Sobel(img, cv2.CV_64F, 1, 0, ksize=kernel_size)
sy = cv2.Sobel(img, cv2.CV_64F, 0, 1, ksize=kernel_size)
# Siła i kierunek gradientu
G = np.hypot(sx, sy).astype(np.float32)
G = G / G.max() * 255
theta = np.arctan2(sy, sx)
return G, theta
// ==UserScript==
// @name Moodel
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://upel2.cel.agh.edu.pl/*
// @grant none
// ==/UserScript==
head() {
    if ((this as any).singlePost) {
      return {
        title:
          (this as any).singlePost.title ||
          (this as any).singlePost.description ||
          'MEDizzy - Free medical cases, photos, videos and more',
        meta: [
          {
            hid: 'description',
import cv2
import os
from matplotlib import pyplot as plt
import numpy as np
if not os.path.exists('ainvert.py') :
!wget https://raw.githubusercontent.com/vision-agh/poc_sw/master/05_Resolution/ainvert.py --no-check-certificate
import ainvert
coins = np.squeeze(cv2.imread("coins.png", cv2.IMREAD_GRAYSCALE))
def get_treshold_iteratively(image: np.ndarray, min_diff: float = .5) -> float:
# Load image and separate pixels of each brightness level to its bin
# bins=256 gets us buckets for values 0-1, 1-2, 2-3 ... 255-256.
hist, _ = np.histogram(image, bins=256)
# This next two lines give us vector of P(k) values
# First we count all occurences of given brigthness level, then
# we divide each by the ammount of pixels in the image.