Skip to content

Instantly share code, notes, and snippets.

@jeacom25b
jeacom25b / curry_decorator.py
Last active October 1, 2020 05:09
a simple curry decorator
from functools import wraps
from inspect import signature
def curry(func):
if not callable(func):
raise TypeError('argumment must be callable')
sig = signature(func)
@jeacom25b
jeacom25b / parsers.py
Last active April 17, 2020 23:33
A parser combinator prototype.
import re
class Color:
"""
colors defined as escape sequences for fancy output.
easy to use but dont work on all terminals
https://en.wikipedia.org/wiki/ANSI_escape_code
"""
@classmethod
from random import randint, shuffle, choice, random
from collections import defaultdict
from math import log10
import time
import re
import os
SEQ_LENGTH = 10
POPULATION = 100
REPETITION_PENALITY = 0.9
'''
Created by Jeacom
This is a experimental utility module for constructing and concatenating regular expressions
such that we can reuse them to build more complex regexes out of simpler ones. all hidden behind
a readable python interface so we don't have to read things like this:
(?:(?:(?:struct|enum)[ \t]+)?\b[a-zA-Z][a-zA-Z\d]*[ \t]+(\b[a-zA-Z][a-zA-Z\d]*))
instead we read things like this:
@jeacom25b
jeacom25b / sqrt
Created September 11, 2019 22:01
def sqrt(num):
root = num
for i in range(100000):
root *= (num / (root * root) + 1) / 2
return root
@jeacom25b
jeacom25b / draw_lines_3d.py
Last active November 9, 2021 23:08
Utility module for blender 2.8, a line renderer for visual debugging and line drawing.
'''
Created by Jeacom
This is a utility module for drawing lines in the 3D viewport on Blender 2.8
using the GPU Api
The idea is to get rid of messy draw functions and data that is hard to keep track.
This class works directly like a callable draw handler and keeps track of all the geometry data.
'''
c = [a * sum([b for b in range(10) if (b + 1) % 2]) for a in range(10)]
print(c)
#infinite for loop
b = [1,2]
for i in range(len("loops")):
for a in b:
b.append(a)
print (a)
c = [1,2] * 5
#never reaches#