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 / Audio.cpp
Last active March 5, 2024 09:05
WAV File Reader / Writer C++
#pragma once
#include "Audio.h"
Audio::Audio(std::string str) {
if (str.substr(str.size() - 4) != ".wav")
throw std::invalid_argument("Can only read WAV files!");
load_wav(str);
}
@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 / Sieve.cpp
Created April 21, 2017 16:25
Sieve of Eratosthenes implementation with Bitset in C++
#include <iostream>
#include <bitset>
#include <cmath>
using namespace std;
int main(){
const int sieve_size = 1024;
bitset<sieve_size> sieve;
sieve.flip();
@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 / 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 / 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 / Parser.h
Created June 24, 2018 16:28
Json Parser in C++ with Libcurl and Jsoncpp
#ifndef PARSER_H
#define PARSER_H
#include <iostream>
#include <string>
#include <curl/curl.h>
#include <jsoncpp/json/json.h>
#include <jsoncpp/json/reader.h>
#include <jsoncpp/json/writer.h>
@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;