Skip to content

Instantly share code, notes, and snippets.

View PanagiotisPtr's full-sized avatar
:shipit:
I use vim btw

Panagiotis Petridis PanagiotisPtr

:shipit:
I use vim btw
View GitHub Profile
@PanagiotisPtr
PanagiotisPtr / exercise4b.ts
Created January 26, 2022 20:35
Solution to exercise 4.b from Chapter 5 of "Programming TypeScript"
/**
* Create a class that uses the builder pattern and only allows the 'send' method to be called only
* when both setUrl and setMethod have been called before it (in any order)
*/
interface WithUrl {
getUrl(): string;
setMethod(method: string): ReadyToSend;
}
@PanagiotisPtr
PanagiotisPtr / MCMF.h
Created April 28, 2021 23:25
Maximum Flow Minimum Cost implementation with SPFA
#include <cstdio>
#define min(a, b) a < b ? a : b
using namespace std;
template<typename lt = long, typename sz = size_t>
struct MCMF {
static constexpr lt INF = 1e9;
static constexpr lt MAX_NODES = 1e6 + 5;
@PanagiotisPtr
PanagiotisPtr / Dinic.h
Last active April 28, 2021 23:24
Simple implementation of the Dinic algorithm with Current Arc optimisation to find maximum flow
#include <limits>
#define min(a, b) a < b ? a : b
using namespace std;
// note - only works with positive flows
// for negative flows just add to make positive
template<typename lt = long, typename sz = size_t>
struct Dinic {
@PanagiotisPtr
PanagiotisPtr / stack.yml
Created April 2, 2021 14:46
basic PostgreSQL PgAdmin stack.yml
version: "3.4"
services:
pgAdmin:
restart: always
image: dpage/pgadmin4
container_name: "pgadmin"
ports:
- "8000:80"
@PanagiotisPtr
PanagiotisPtr / json_lib.cpp
Last active April 15, 2021 10:52
A very basic JSON Serialiser and Deserialiser in C++
#ifndef JSONLIB_H
#define JSONLIB_H
#include <iostream>
#include <cctype>
#include <unordered_map>
#include <sstream>
#include <memory>
#include <type_traits>
#include <iterator>
@PanagiotisPtr
PanagiotisPtr / parse_competition.py
Created July 3, 2019 20:50
codeforces parsers and C++ solution tester
import requests
from bs4 import BeautifulSoup
import sys
import os
template = """#include <bits/stdc++.h>
using namespace std;
class Solution {
@PanagiotisPtr
PanagiotisPtr / card.html
Created May 2, 2019 12:23
Simple Material Design card
<!DOCTYPE html>
<!-- Similar to: https://storage.googleapis.com/spec-host-backup/mio-design%2Fassets%2F1eZNTdj8h1J0BFkbl23LyzEwjjvMzY_uV%2Fcards-elements-2b.png -->
<html>
<style>
body {
font-family: 'Roboto', sans-serif;
}
.row-container {
display: flex;
flex-direction: row;
@PanagiotisPtr
PanagiotisPtr / encoding.cpp
Created April 19, 2019 21:27
Tic Tac Toe Board Encoding and Comparing (TTTBEC for short)
#include <iostream>
#include <vector>
#include <array>
using namespace std;
template<typename T>
using board = vector<vector<T> >;
typedef array<char, 3> encoding;
@PanagiotisPtr
PanagiotisPtr / Trie.h
Created January 10, 2019 15:27
Simple Trie implementation in C++
#ifndef TRIE_H
#define TRIE_H
#include <unordered_map>
#include <exception>
#include <memory>
#include <string>
#include <list>
#include <stack>
@PanagiotisPtr
PanagiotisPtr / ppa.h
Last active January 25, 2019 00:34
Simple examples of parallel and serialized algorithms in C++
#ifndef PPA_H
#define PPA_H
#include "ppa_impl.h"
namespace ppa {
template<
typename RandomIt,
typename value_type = typename std::iterator_traits<RandomIt>::value_type