Skip to content

Instantly share code, notes, and snippets.

def replaceAccents(l):
"""
replace greek accents
"""
l = l.lower()
rDict = {'ά':'α','ό':'ο','ύ':'υ','ϋ':'υ','ΰ':'υ','έ':'ε','ί':'ι',
'ϊ':'ι','ΐ':'ι','ή':'η','ώ':'ω','ς':'σ'}
retStr = ''
for x in l:
retStr += (x if x not in rDict else rDict[x])
from fractions import Fraction
def fromrepeating(r):
if type(r) == int:
return(Fraction(r,1))
if type(r) == float:
return(Fraction(int(str(r).replace('.','')),10**(len(str(r))-str(r).index('.')-1)))
if type(r) != str:
return(None)
if 'r' not in r:
try:
"""
github.com/dimnikolos
2019
"""
import re
import scholarly
with open('citescount.html','w',encoding='utf-8') as resf:
#cites.txt is your bibliography/reference in a text file
#a line per reference
from microbit import *
def showEL(greekLetter):
greekLetters = {"Α": Image("09900:90090:99990:90090:90090"),
"Β": Image("99900:90090:99900:90090:99900"),
"Γ": Image("99990:90000:90000:90000:90000"),
"Δ": Image("09900:90090:90090:90090:99990"),
"Ε": Image("99990:90000:99900:90000:99990"),
"Ζ": Image("99990:00900:09000:90000:99990"),
from fractions import Fraction
def mixed(k):
m = int(k)
f = k-m
if m == 0:
return(str(f))
if f == 0:
return(str(m))
return(str(m) + " " + str(f))
import math
def einaiTetragwnos(x):
if math.sqrt(x) == int(math.sqrt(x)):
return(True)
else:
return(False)
for a in range(-3,3):
for b in range(-3,3):
for g in range(-3,3):
@dimnikolos
dimnikolos / mouLyphs.py
Last active February 13, 2018 07:56
Ομόηχα
#Συναισθήματα χαράς και λείπεις
#Μου λύπης!
#@dnikolos
removeProblems = {
"ου":"ΟΥ",
"ού":"ΟΎ",
"αυ":"ΑΥ",
"αύ":"ΑΎ",
"ευ":"ΕΥ",
"""
computing partial sums
for a multiplication
"""
def updict(v,p,d):
if p in d:
d[p].append(v)
else:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
999^2&=(999^2 - 1) + 1\\
999^2&=(999^2 - 1^2) + 1\\
&=(999-1)(999+1) + 1\\
&=998\cdot 1000 + 1\\
&=998000 + 1\\
&=998001
@dimnikolos
dimnikolos / sameFunctions.py
Last active April 26, 2017 08:08
Frequency distribution of processes
import csv
import sys
csv.field_size_limit(sys.maxsize)
#allBlocks.csv is from https://github.com/TUDelftScratchLab/ScratchDataset
with open('allBlocks.csv','r') as rawcsv:
reader = csv.DictReader(rawcsv,fieldnames =[
'projectID', 'scriptCoordinates', 'scriptIndex',
'stageSpriteindication', 'spriteName', 'indentation',
'blockIndex', 'blockType', 'parameters'])