Skip to content

Instantly share code, notes, and snippets.

View papachristoumarios's full-sized avatar

Marios Papachristou papachristoumarios

View GitHub Profile
@papachristoumarios
papachristoumarios / common_identifiers.sh
Last active November 13, 2018 11:01
Common Identifiers in Souce Code Files
#!/bin/bash
# Find common identifiers in .c and .h files
# Author: Marios Papachristou
# Usage: ./common_identifiers.sh 1000 >most_common.txt
find . -type f -name "*.[c\|h]" |
xargs cat |
tr -c 'A-Za-z' \\n |
sort |
uniq -c |
@papachristoumarios
papachristoumarios / transmitters.cpp
Last active November 11, 2018 21:42
Transmitters problem for Algorithms Class 2018-2019
// Transmitters-Receivers Problem for NTUA Algorithms 2018-2019 Class
// Author : Marios Papachristou
// Binary indexed tree implementation taken from
// https://medium.com/@harekrishnamahto18/range-sum-and-update-in-arrays-competitive-programming-82ae5039a16f
#include<bits/stdc++.h>
#define MAXN 1000000
using namespace std;
int b[MAXN];
@papachristoumarios
papachristoumarios / FinalReport_3gm.md
Last active August 9, 2018 11:01
Final Report for GSoC 2018 for Government Gazette text mining, cross linking, and codification - 3gm

Final Report for Google Summer of Code 2018

This is a final report of the work which was done as part of Government Gazette text mining, cross linking, and codification Project (or 3gm for short) using Natural Language Processing Methods and Practices hosted in github.com/eellak/gsoc2018-3gm and 3gm.ellak.gr.

Abstract

This project aims to provide with the most recent versions of each law, i.e. an automated codex via Natural Language Processing (NLP) methods and practices on Greek Legislation, along with additional functionality such as topic modeling for similarity analysis, versioning system in MongoDB, continuous integration tools & scripts and a web application. The accuracy of detecting amendments on Greek Legislation texts was 89%.

A more detailed explanation of the project is l

@papachristoumarios
papachristoumarios / sandbox.py
Last active April 16, 2018 20:55
NBG openAPI Sandbox Wrappers in Typescript/NodeJS and Python
# implementation for NBG openAPI v2.0
import requests, json
class NBGSandbox:
def __init__(self, sandboxid='6916545110343680'):
headers = { 'accept': "text/json" }
@papachristoumarios
papachristoumarios / number_theory.py
Created March 12, 2017 15:57
Some number theory (calculation of a^p % n and primality testing)
from random import randrange
fermat_test = lambda p: pow(randrange(2,p-1), p-1, p) == 1
euclid_gcd = lambda a,b : max([a,b]) if min([a,b]) == 0 else euclid_gcd(min([a,b]), max([a,b]) % min([a,b]))
def miller_rabin(p, k =20):
r = 0
d = p-1
while d % 2 == 0:
d //= 2
@papachristoumarios
papachristoumarios / ply_plotter.py
Created March 12, 2017 15:50
A simple PLY pointcloud plotter in Python with matplotilib and numpy
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
def get_pts(infile):
data = np.loadtxt(infile, delimiter=',')
return data[12:,0], data[12:,1], data[12:,2] #returns X,Y,Z points skipping the first 12 lines
def plot_ply(infile):
@papachristoumarios
papachristoumarios / beautiful_quicksort.py
Last active March 12, 2017 15:51
Beautiful quicksort with functional syntax
#quicksort with lambda
qsort = lambda L: L if len(L) <= 1 else qsort( [ lt for lt in L[1:] if lt < L[0] ] ) + [ L[0] ] + qsort( [ ge for ge in L[1:] if ge >= L[0] ] )
#!/usr/bin/env python2.7
#conflict-free strings using python and numpy
#Marios Papachristou: papachristoumarios@gmail.com
import numpy as np
import time
def generate_conflict_free_string(n, f = lambda x: x):
k = n / 2
a = np.zeros(n)
f = lambda m, *a: sum([10**i*(a[i] - m*a[-i-1]) for i in range(len(a))])
sp = lambda x: [int(y) for y in str(x)]
dom = lambda k: xrange(10**k, 5*10**(k))
X = dom(5)
for m in xrange(2,10):
for x in X:
if f(m, *sp(x)) == 0: print x