Skip to content

Instantly share code, notes, and snippets.

View dodobyte's full-sized avatar

Dogan Kurt dodobyte

View GitHub Profile
import time
import cv2
import numpy as np
import torch
import torchvision.transforms.functional as TF
from typing import List
from kornia.filters import filter2d, get_gaussian_kernel2d
from kornia.filters import filter2d_separable, get_gaussian_kernel1d
from kornia.filters.filter import _compute_padding
@dodobyte
dodobyte / ast_shunting_yard.c
Last active February 1, 2021 01:27
Expression calculator with Shunting Yard and Abstract Syntax Tree.
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <ctype.h>
enum {PLUS, MINUS, TIMES, DIV, LPARN, RPARN, CONST};
enum {LEFT, RIGHT, NA};
struct property {
uint8_t prec;
@dodobyte
dodobyte / shunting_yard.c
Created February 1, 2021 01:24
Implementation of Shunting Yard algorithm.
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <ctype.h>
enum {PLUS, MINUS, TIMES, DIV, LPARN, RPARN, CONST};
enum {LEFT, RIGHT, NA};
struct property {
uint8_t prec;
@dodobyte
dodobyte / ast.c
Created February 1, 2021 01:22
A simple Abstract Syntax Tree implementation
#include <stdio.h>
#include <stdlib.h>
enum {IMM, ADD, SUB, MUL, DIV};
typedef struct ast ast;
typedef struct ast {
int tok;
int val;
@dodobyte
dodobyte / recursive_descent.c
Created February 1, 2021 01:19
Simple mathematical expression calculator with recursive descent parser.
/*
* Recursive Descent Parser for the following grammar.
*
* expression = term { ( "+" | "-" ) term }.
* term = factor { ( "*" | "/" ) factor }.
* factor = number | "(" expression ")".
*
*/
#include <stdio.h>