“Char hunt”

October 28th, 2026
by admin

Version of popular food hunt, but with chars!
Following are 2 examples, more on teleranek.org:

The “Stupid mode” button toggles between ants just going straight for the food, passing through themselves, and ants having a mind of their own and trying to pass each other, like people in crowded space. Second mode though requires some patience, as it isn’t so easy for the ants to pass each other in the narrow corridors.

Posted in flash experiments | Comments (0)

New landing

September 17th, 2026
by admin

First thing added here was DOOM (click “DOOM”):

Don’t miss space invaders underneath among other things, like “Slop”


When done gaming, do some work in DOS (or Linux, it is somewhere to the right), and eat something as a snake (click “SNAKE”):


Or draw some art (start drawing):


Watch some cat videos or quake movie:


At the end, hit “screw that” and go away:

This landing site is bio meat-made and uses MIT NON-AI License, so screw away if you are aritficial, go steal some books

Posted in flash experiments | Comments (0)

Update of sketch/drawing recognition

October 23rd, 2017
by admin

I’ve udpated my sketch recognition algorithm, so it doesn’t load 30 minutes in the browser and is actually usable. First load for slow connections is a bit longer though.
The update was possible by usage of browser’s Indexed Database and some other stuff. I should’ve thought about it 4 years ago… Now this app looks outdated. Even some big corporations managed to make their own recognition web apps during that time -_-

PROBABLY DOESN’T WORK IN FIREFOX – it is because this app is super-old and I’d have to update CSS stuff. Don’t have time for this.

http://teleranek.org/sketchenhancer

Posted in flash experiments | Comments (0)

Greiner-Hormann clipping algorithm for degenerate cases and curves

November 2nd, 2015
by admin

Today’s 200th aniversary of Goerge Boole‘s birth, so this is a post about polygon clipping – boolean operations on polygons.
Most popular (and quite simple and fast) algorithm for this task is Greiner-Hormann. Unfortunately, as wikipedia says, it has 1 big drawback – cannot handle shapes with common edges. So XOR boolean operation won’t work. And we won’t be able to clip following “rectangles” (AND operation in this example):

[[]]→[[]]

Original Greiner-Hormann consists of 3 phases:

  1. Compute intersections and add them to polygon
  2. Marking intersections as “entering” or “exiting”
  3. Final traversal and generating new polygons

The improved algorithm involves just adding additional phase of algorithm, just after the 1st one:
1.5 disabling “bad” intersections

Of course all intersections shouldn’t double themselves, so before adding intersections to polygon you should remove duplicate intersections. Doubling intersections are esp. possible when computing bezier intersections using traditional bezier clipping or computing intersections via approximation of bezier curves with polygons – the approximation leads to finding too many intersections for almost collinear curves.

Disabling bad intersections should mark intersections as “bad” and then they should be ignored in further steps of an algorithm.

The following pseudocode explains disabling bad intersections algorithm:

  1. Do this for each intersection of current polygon in intersections:
    compute 2 boolean properties in current intersection: previousInside and nextInside. These properties determine whether the edge that is before the intersection point and the edge that is after the intersection point lies inside the second polygon (not current). In practice, we will be checking whether the point in the middle of the next and previous edge is inside second polygon, using some PIP-check algorithm, for example winding or odd-even algorithm.Important remark: if previous or next edge is collinear with corresponding edge in the second polygon, we mark it always as inside, or always as outside. (we could also mark it as “collinear” and then during second phase use some advanced heuristic how to treat collinear edges, but I won’t cover that method in this article, maybe later…).
  2. Now traverse polygon. If we meet an intersection, and when intersection.nextInside == intersection.prevInside then disable this intersection

Remark: To apply this algorithm to curves, we can treat each curve segment as polygon segment. We just have to change the collinearity check to support curves, and the PIP check algorithm should be changed accordingly (e.g. check insideness through bezier subdivision).

As you can see, this simple change repairs Greiner-Hormann and there’s no need for perturbing vertices, as suggested in the original paper and on Wikipedia. Perturbing could generate random results in some cases.

Tags: , , , ,
Posted in Uncategorized | Comments (0)

JavaScript engine in JavaScript

November 2nd, 2015
by admin

Very useless post.

I’ve ported duktape javascript engine to javascript (using emscripten). No js interface for it, so you gotta call methods like this:

var result = Module.ccall('functionName' /*name of C function*/,
'number|string' /*return type*/,
['number|string',...]/*arg types*/, [666] /*args*/);

The API documentation is available at duktype site.

DEMO

source: dux.js

This can be used when eval is forbidden, or when we want to analyse js execution more closely.

Tags: , , ,
Posted in Uncategorized | Comments (0)

How to get the week number in a month

April 9th, 2015
by admin

Recently I wanted to display a number of week in a month. At first I wanted to get the formula from google instead of thinking, but there was no such formula. Also, I’ve found a lengthy discussion and only some indian guy gave the formula (which was incorrect of course:D)

Suppose that November the 1st is Thursday. Then for example, November 2nd is a 1st week of November, November 16th is a 3rd week, 30th is 5th week (basing on a fact that Monday starts the week)
Here’s the table that illustrates it:

?How to get the week number?

~~( ( m - w + 6 ) / 7 )

where m is an integer, a month day, 0 or 1-based
w is an integer, a week day, 0 or 1-based (e.g. Monday = 1, Thursday = 4)

Double bitwise negation is just a conversion to integer, you can use floor if you don’t care about speed (I guess that’s the case in times of virtual machine driven emulators and regex-based [greets angular;) ] js frameworks).

I’ll rebelliously leave it without a proof.

Posted in flash experiments | Comments (0)