Skip to content

Instantly share code, notes, and snippets.

View geoangelotti's full-sized avatar

Geo Angelopoulos geoangelotti

  • Rewe International
View GitHub Profile
@geoangelotti
geoangelotti / cyclic-iterator.go
Created January 15, 2024 15:53
Go Cyclic Iterator
package main
import "fmt"
func main() {
slice := []string{"ena", "dyo"}
iterator := cyclicIterator(slice)
for i := 0; i < 10; i++ {
fmt.Println(iterator())
@geoangelotti
geoangelotti / cli.py
Created September 22, 2023 15:02
Click tutorial
import pprint
import click
import json
'''
@click.group(<name>) creates a command that instantiates a group class
a group is intended to be a set of related commands
@click.argument(<argument name>) tells us that we will be passing an argument
and referring to that argument in the function by the name we pass it
@click.pass_context tells the group command that we're going to be using
@geoangelotti
geoangelotti / 1897.apl
Last active November 7, 2022 08:44
1897. Redistribute Characters to Make All Strings Equal
solve ← ∧/0=(≢ |⊢∘≢ ⌸∘∊)
#lang racket
(require 2htdp/image)
(define(serp d)
(if (zero? d)
(triangle 1 'solid 'green)
(above (serp (sub1 d))
(beside (serp (sub1 d))
(serp (sub1 d))))))
#!/bin/bash
echo "Enabling ipv4 forwarding (cleaning old rules)"
# flushing old rules -- USE WITH CARE
iptables --flush
iptables --table nat --flush
# MASQUERADE each request form the inside to the outer world
iptables -t nat -A POSTROUTING -j MASQUERADE
# enable IPv4 packet forwarding in the kernel
echo 1 > /proc/sys/net/ipv4/ip_forward
#!/bin/env python
import sys
import random
f = open(sys.argv[1], "r")
people = f.readlines()
people = list(map(lambda person: person.replace('\n', ''), people))
identifiers = list(range(len(people)))
random.shuffle(identifiers)
@geoangelotti
geoangelotti / hopping.c
Last active October 25, 2019 11:06
ECE NTUA Computer Languages (Γλώσσες Προγραμματισμού) hopping Dynamic Programming Algorithm.
#include <stdio.h>
#include <stdlib.h>
//Declare infinite limit for the DP array
//all the valid answers in the DP array are NUMBER % 1000000009 so smaller than this number
#define limit 1000000010
int N, K, B;
//Steps you can take
int *Steps;
@geoangelotti
geoangelotti / skitrip.c
Last active June 6, 2019 20:08
ECE NTUA Computer Languages (Γλώσσες Προγραμματισμού) skitrip Greedy Algorithm.
#include <stdlib.h>
#include <stdio.h>
//Structure to save Height and Position of each station
struct station_struct {
long height;
long position;
};
//Quicksort comparator