Skip to content

Instantly share code, notes, and snippets.

@pgassendi
pgassendi / urlinfo.c
Last active April 19, 2023 21:16
get url info
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#define case_return(ENUM_VALUE) case ENUM_VALUE: return #ENUM_VALUE;
const char* get_family(int f) {
@pgassendi
pgassendi / toPolishNotation.py
Last active August 24, 2022 01:17
infix to prefix notation for arithmetic expressions using python
import sys
priority = { '+': 1, '-': 1, '*': 2, '/': 2, '^': 3, '(': 0 }
def read_number(s, i):
return next((k for k,e in enumerate(s[i+1:]) if e in " +-*/^()"), len(s[i:]) - 1) + i + 1
def read_string(s):
tokens = []
@pgassendi
pgassendi / calcu.py
Created August 24, 2022 00:53
Simple calculator using python
import sys
priority = {
'+': 1,
'-': 1,
'*': 2,
'/': 2,
'^': 3,
'(': 0
}