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 / 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 / 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 / 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 / add_key.md
Created July 4, 2018 18:11
Add ssh key on Github

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

You will be aksed where you want to save the file. Choose something reasonable

ssh-add [file_location_from_before.pub]

Add your key on github ( User -> settings -> ssh keys ) Check that the key has been added

ssh-add -l

@PanagiotisPtr
PanagiotisPtr / main.c
Last active January 10, 2019 15:29
Simple sockets server wrapper in C
#include <stdio.h>
#define DEBUG
#include "server.h"
int main(int argc, char **argv) {
server s;
server_init(&s, AF_INET, SOCK_STREAM,\
IPPROTO_TCP, 1313, INADDR_ANY);
server_listen(&s, 15);
@PanagiotisPtr
PanagiotisPtr / capture.py
Created December 15, 2018 00:29
Screencapture scrollable page
# This script does use selenium and the firefox webdriver to run
# make sure you setup those first.
from selenium import webdriver
import time
options = webdriver.FirefoxOptions()
options.add_argument("--headless")
driver = webdriver.Firefox(firefox_options=options)
@PanagiotisPtr
PanagiotisPtr / Sort.h
Last active December 31, 2018 19:31
parallel and serialized versions of mergesort in C++
#ifndef SORT_H
#define SORT_H
#include <algorithm>
#include <list>
#include <iterator>
#include <future>
#include <iostream>
@PanagiotisPtr
PanagiotisPtr / Tensor.h
Created December 31, 2018 17:30
Simple n-dimensional array class ( Tensor ) in C++
#ifndef TENSOR_H
#define TENSOR_H
#include <vector>
#include <ostream>
static bool math_indexing = true;
template<typename T, size_t size>
class Tensor {
@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
@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>