Skip to content

Instantly share code, notes, and snippets.

View adusak's full-sized avatar

Adam Melkus adusak

View GitHub Profile
@adusak
adusak / lsystem.py
Last active August 6, 2016 14:04
L-System iterpreter
from python.common.Turtle import Turtle
class Lsystem:
def __init__(self, original_seq, rules, axioms):
self.parsed_seq = []
self.original_seq = original_seq
self.rules = rules
self.axioms = axioms
self.turtle = Turtle()
@adusak
adusak / svg.py
Last active August 29, 2015 14:19
Class wraping svg construction
import sys
import math
class Svg:
def __init__(self, size=(-1, -1)):
self.__svg_string = "<?xml version=\"1.0\"?>\n<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\""
self.max_x = -sys.maxsize
self.max_y = -sys.maxsize
self.min_x = sys.maxsize
@adusak
adusak / line.py
Last active August 6, 2016 14:04
Class representing a line with some helper functions for operations with lines
import math
class Line:
def __init__(self, x1, y1, x2, y2, draw=True):
self.x1 = x1
self.x2 = x2
self.y1 = y1
self.y2 = y2
self.draw = draw
@adusak
adusak / pi_calculation.py
Last active October 11, 2015 10:55
PI aproximations
import time
from decimal import *
import random
import math
from mpmath import mp
time_max = 2
@adusak
adusak / star.py
Last active May 27, 2018 21:03
star
from python.common.line import Line
from python.common.svg import Svg
def star(density=30, size=100):
svg = Svg((size, size))
for i in range(density):
for j in range(2):
svg.add_line(
@adusak
adusak / Weather.hs
Created April 11, 2015 10:57
Commandline utility to get weather from openweathermap.org written in haskell
{- |
This is the fourth assignment for IB016, semester spring 2015.
Name: Adam Melkus
UID: 374010
== Obtaining weather information from http://openweathermap.org
This time your task is to implement download and processing of weather data
from <http://openweathermap.org>. Following it partially filled program, which
already contains some data type definitions, 'main', argument parsing, and
@adusak
adusak / du.hs
Last active August 29, 2015 14:18
du utility implemented in haskell
{- | This is the third assignment for IB016, semester spring 2015.
Name: Adam Melkus
UID: 374010
== Implementing du
In this assignment you will be implementing simplified version of Unix
utility @du@. This utility can be used to detect filesystem usage by
files and directories. Your task is for the first time to implement whole
compilable module, including commandline handling.
@adusak
adusak / convex_hull.py
Last active August 29, 2015 14:17
Generates points and creates their convex hull with the option to do if for all the points generated
from operator import itemgetter
from python.common import line as ln
from python.common.polygon import Polygon
from python.common.svg import Svg
from python.less5.generate_points import generate_points
def less(a, b):
return a < b
@adusak
adusak / triangulation.py
Last active August 6, 2016 14:04
Triangluation
import random
from python.common import line as ln
from python.common.svg import Svg
from python.less5.generate_points import generate_points
def triangulate(number_of_points, canvas_size, sort=True, name="triangulation", gauss=False):
svg = Svg()
points = generate_points(number_of_points, canvas_size, gauss)
@adusak
adusak / line_intersections.py
Last active August 6, 2016 14:04
Code to generate number of same length lines and find their intersections
from math import radians, cos, sin
import random
from python.common.svg import Svg
from python.less5.generate_points import generate_points, point_in_bounds
from python.common import line as ln
def generate_lines(n, length, canvas_size, gauss=False):
lines = []