Snippets

Home / Texts

Polyhedral Design with Quadratic GB Patches

Code for my paper on this topic.

Clone the repository with Git:

git clone https://github.com/salvipeter/manifold.git
Last update: 2024.04.10.

Core Forth

An inefficient, minimal, but complete implementation of the Forth 2012 standard. It is mainly written in itself, with a very little language (a dozen words + interpreter) running in a C virtual machine.

Clone the repository with Git:

git clone https://github.com/salvipeter/core-forth.git
Last update: 2024.02.15.

3D Printed Birthday Present

As a present for my dad's 70th birthday, I designed an object that reads as different texts viewed from the axis directions.

The points (centers of the blocks) were generated by a C++ program, ensuring that it is minimal (in the sense that no block can be omitted), and also minimizes the number of "hanging" blocks (i.e., blocks that have nothing directly below them).

Then I had it 3D printed, for which I generated the model with another C++ program

Last update: 2024.02.01.

Solitaire Chess

A Prolog program (htmlized version) for solving ThinkFun's Solitaire Chess problems, and generating new ones. Each puzzle sets a few pieces (of one color) on a 4x4 chessboard, and one has to find the correct series of moves, each one taking a piece, until only one remains.

Last update: 2024.01.12.

BDF Viewer

An AWK script for showing the glyphs in a Glyph Bitmap Distribution Format (BDF) file in the console.

Last update: 2024.01.12.

Advent of Code 2023

My solutions to the Advent of Code 2023 contest, written mainly in Tcl.

Clone the repository with Git:

git clone https://github.com/salvipeter/advent2023.git
Last update: 2023.12.29.

Focal Curve

A Tcl implementation of Paul de Casteljau's focal spline (with a Bézier curve for comparison).

Last update: 2023.11.24.

Interpolating Catmull-Clark Subdivision

A simple geometric progressive interpolation method for any surface defined by a control polyhedron, exemplified by Catmull-Clark surfaces, where this actually converges.

This implementation (using the OpenMesh library) actually computes the surface in each iteration, which is very expensive, but in this way we don't need to know the equation for the final position of the vertices (which is nice, because the CC matrix near the boundary is poorly documented in the literature).

Last update: 2023.10.17.

Applying Constraints to Quadmeshes

Two possible solutions to the problem of modifying a quadmesh such that all quads become planar, but the mesh remains close to the original. One is a regularized Newton method based on a paper by Tang et al., the other is an ICP-like algorithm by Bouaziz et al.

The programs use the OpenMesh library. See a pair of images with flat shading before and after the optimization.

Last update: 2023.10.17.

SVG schedule

An AWK script for generating a (Hungarian) schedule for my family based on a text file. See an example input file and its generated output. (Yes, I could have just used a spreadsheet - but what's the fun in that?)

Last update: 2023.10.08.

SRT Subtitle Shift

An AWK script for shifting the times in a SRT subtitle files with a constant amount.

Last update: 2023.09.18.

Sushi Go Statistics

A Prolog program (htmlized version) evaluating Sushi Go deals for N players. Running thousands of simulations, and assuming that wasabi cards are always used in the best possible way, random hands are worth about 37 points for 3 players, 30 points for 4 players, and 25 points for 5 players.

Last update: 2023.09.13.

URL Redirector

A simple page for remembering and recalling a webpage. See the scripts here (url-saver, url-redirector). Good for sending URLs to our smart TV browser.

Last update: 2023.09.08.

Thai Keymap for Vim

A conversion of the Emacs "thai-kesmanee" input method into a Vim keymap file. Place it in "~/.vim/keymap/", and load with ":set keymap=thai". Note that Vim needs a fixed-width Thai font, like the TlwgTypist font in the TLWG project. Still doubly accented letters (like น้ำ) do not display well.

Last update: 2023.09.05.

IQ Mini

A Prolog program (htmlized version) solving the puzzle game "IQ Mini", along with various experiments, and a graded list of puzzles. The list contains only the positions of the three pins (with 1-1 being the top-left corner), and has a decreasing number of solutions: the first has 126 solutions, while the last only 1.

Conclusions include that

Last update: 2023.08.18.

Block by Block Solver

A Prolog solver (htmlized version) for the puzzle game "Block by Block" by ThinkFun. The models are read from text files, and the solution can be output to VTK files, where the points are furnished with a group number, so they can be colored appropriately with ParaView.

As an example, here's Puzzle 3 with its solution (there is only one other solution, its symmetric counterpart), and also Puzzle 8 which demonstrates that the solver does not care about gravity, so solutions like this are also accepted. For the cube (Puzzle 60), 11520 solutions are found - 48 times the number of unique solutions (240) because of the model's internal symmetries (all 24 rotations and their mirror images are the same).

Here are some of my own problems: corner1, corner2, the letter G, an ukulele, the number 6, and a strange creature.

Last update: 2023.06.08.

LEGO Sculpture Generator

An experiment with my LDNI library to generate a LEGO-block version of a mesh model. Uses only 2x2 blocks, with user-defined resolution. See an example; note that there may be blocks floating in the air etc. With a little more change in the library, it is easy to generate a slice-by-slice output, as well (this example needs roughly 25000 blocks).

Last update: 2023.05.29.

Gold Mine

A literate Prolog solver for the puzzle game "Gold Mine". (Markdown source here.)

Last update: 2023.04.19.

Rainbow Snake Puzzle

A Prolog program (htmlized version) solving my puzzle game "Rainbow Snake", and which I also used extensively to experiment and try out different variants.

Last update: 2023.04.16.

Busy Bugs

A Prolog program (htmlized version) solving the puzzle game "Busy Bugs", along with various experiments, and a bunch of additional puzzles.

I also drew an A4-paper DIY board (you will still need to cut out the 9x9 cm tiles), and compiled a randomized list of puzzles/solutions (in Hungarian). The solutions are the tile names (A/B/C/D) in row-major order, each supplied with the number of clockwise 90-degree rotations.

Last update: 2023.04.15.

Rush Hour

A literate Prolog solver for the puzzle game "Rush Hour". (Markdown source here.)

Last update: 2023.04.10.

Origami Dodecahedron

I have found a nice and simple dodecahedron unit origami on Mathigon, which is of course just an approximation of the regular pentagon. I had three questions:

  1. How good is the approximation (both in terms of angles and edge lengths)?
  2. How should I connect the units to get a stable model without gaps?
  3. How should I choose the colors of the units?

The answers to the first question are shown on my version of the folding diagram. As for the other questions, I wrote a literate Prolog program to find a solution - it seems that there is trade-off between stability and gaplessness. (Markdown source here.)

The version by Miyuki Kawamura (in Polyhedron Origami for Beginners), folded from a square, is similar in complexity, but slightly worse in approximation quality: the top angle is 2 arcsin(4/5) ~ 106.3 degrees, while the others are 90 + 1/2 arcsin(3/5) ~ 108.4 degrees; the pocket sides are 25/104 ~ 0.24, the flap sides are sqrt(10)/13 ~ 0.24, and the bottom side is 3/13 ~ 0.23 units long.

Last update: 2023.03.30.

Direct B-Spline Modification

A small applet for experimenting with a direct B-spline modification algorithm from The NURBS Book. Uses GLUT and my geometry library.

Last update: 2023.02.24.

Noah's Ark Puzzle

A literate Prolog solver for the Katamino-like puzzle game "Noah's Ark". (Markdown source here.)

Last update: 2023.02.15.

Jumping Checkers

A literate Prolog solution to (the generalization of) the classic puzzle of swapping the white and black checkers placed in a single row. (Markdown source here.)

Last update: 2023.02.09.

Alternative Set

The classic game SET uses 81 cards formed by 3 possible values of 4 properties. But what if we had 4 possible values of 3 properties? Then we would have 64 cards instead of 81, and a set would consist of 4 cards. The question is, how many cards should we lay down on the table so that we have similar probabilities of finding a set to those in the original game?

Since the maths is fairly complex, I wrote a Prolog program (htmlized version) to do some Monte-Carlo experiments. Turns out that with the classic cards there is a set in 12 cards with probability ~97%, and almost always in 15 cards. With the alternative set, similar probabilities are achieved with 16 cards (~94%) and 20 cards, respectively.

Last update: 2023.01.27.

Funny Knight

A literate Prolog solution to an interesting problem: visit all squares on a chessboard with a knight, evading those attacked by the opponent's queen. Includes graphical (PDF) output. (Markdown source here.)

The solution, however, is not optimal. There are 10 squares with only 1 valid neighbor (including the starting square). If we also end on such a square, we still have to go out of our way to visit 8 of these, which means that a lower bound is 35 + 8 = 43 steps.

The problem can be converted into a traveling salesman problem by completing the graph, using the shortest path lengths as edge weights (computed by the Floyd-Warshall algorithm). Indexing the goal squares in the order (a1, a3, a4, a6, a7, b1, b2, b4, ...) we can generate an edge weight matrix. Now a TSP solver (such as Concorde) can solve it. Using Dijkstra's algorithm to generate the intervening steps, we can reconstruct the whole path that has only 48 steps! Note that this solves a stricter problem (finds a cycle), so the real optimum may be still lower.

Another trick is to change the distance of the starting square (node 35) from another one to 0, thereby virtually severing the connection. Trying all 35 variations, it turns out that the best is 46 steps long (e.g. by finishing at the bottom-left square, although many other squares are good, as well). This is now truly optimal.

Last update: 2023.01.23.

Spirograph applet

A Tcl/Tk spirograph with sliders to set the radius of the small disk and the position of the hole. See a screenshot.

Last update: 2022.12.29.

Advent of Code 2022

My solutions to the Advent of Code 2022 contest, written mainly in AWK.

Clone the repository with Git:

git clone https://github.com/salvipeter/advent2022.git
Last update: 2022.12.25.

Nielson's patch

A C++ implementation of Nielson's triangular transfinite patch, with mesh interpolation and fullness settings.

Clone the repository with Git:

git clone https://github.com/salvipeter/nielson.git
Last update: 2022.12.22.

Quad fitting

A library & test program for fitting B-spline surfaces on genuine multi-sided patches. Does not work as well as hoped.

Clone the repository with Git:

git clone https://github.com/salvipeter/quadfit.git
Last update: 2022.12.09.

Zheng-Ball patch

A C++ implementation of the Zheng-Ball transfinite patch, with a utility to convert from my .gbp (Generalized Bézier patch) format. See also my writeup on the tessellation.

Clone the repository with Git:

git clone https://github.com/salvipeter/zheng-ball.git
Last update: 2022.11.23.

AquaQ Challenge

My solutions to the AquaQ Challenge contest, written in OCaml.

Clone the repository with Git:

git clone https://github.com/salvipeter/aqua.git
Last update: 2022.11.13.

Quad Viewer

A fork of my 3D framework for viewing a collection of B-spline surfaces with exact normals & curvatures, isolines etc.

Clone the repository with Git:

git clone https://github.com/salvipeter/qds-viewer.git
Last update: 2022.11.10.

Bridge Deal Encoder

There is a simple, near-optimal encoding of any contract bridge deal. This snippet converts to/from BBO's HandViewer applet. Why is it nice?

A bridge deal consists of a distribution of the 52 cards into four hands, which can be done 52! / (13!)^4 ~ 10^29 ways, each of which can be played in 16 ways depending on the dealer and the vulnerability. Since 16 * 52! / (13!)^4 is larger than 2^99 and smaller than 2^100, it can be optimally encoded in 100 bits, or 17 characters in Base64.

In contrast, my encoding is the following:

This is 4 + 52 * 2 = 108 bits, or 18 characters in Base64. Essentially the whole code is converted into a large number, so the first 2 bits correspond to the least significant part of the last character etc. The two 'extra' characters (+ and /) of Base64 are replaced (with . and _) to be able to supply the code to the page in the "code" query for a direct jump to BBO; it also supports the "hands" query where you can list the hands to show. See an example.

Last update: 2022.11.07.

Tetrapod

A tetrapod model created as the combination of implicit surfaces, suitable for 3D printing (see photo). Originally designed in Scheme, the final model is generated by a C++ program using my dual contouring library.

Last update: 2022.09.05.

Crane Cuts

A PostScript program that computes the cutting lines for creating an (in theory) infinite series of cranes from a single paper, as described in Genuine Origami by Jun Maekawa. The tails of all but the last crane need an extra outside reverse fold to double as the head of the next one.

Also in PDF; see a photo of my not-too-neat folding (from a 35cm origami paper).

Last update: 2022.08.01.

Magnifying Glass

A C++ snippet for trying out a a magnifying effect on an image. Keys D/F change the curvature, J/K the glass size, Q quits. Uses GLUT and ImageMagick++.

See a screenshot.

Last update: 2022.06.08.

Fortune's Algorithm

A Tcl implementation of Fortune's algorithm for generating the Voronoi cell structure and Delaunay triangulation of a set of points in the plane. This is for demonstration purposes, with a movable beachline, showing also the circles. See a screenshot.

Last update: 2022.02.20.

Bézier Matrices

Two libraries for computing Bézier-related matrices: (i) Bézier extraction matrices, for getting the control points of a given segment of a B-spline curves, and (ii) reduction matrices, for computing the optimal degree reduction (in an L2-norm sense) while retaining derivatives at the endpoints.

The extraction matrix library is written in C++, using Eigen and my geometry library; there is also a short memo on how to use it.

The reduction matrix library has an implementation in Julia and another one in C. In both cases the computations are exact, using rational bignums (with libGMP in the C version), so it should work even with high degrees.

There is also a library for approximating a high-degree Bézier curve with a lower-degree B-spline, with the given number of segments and continuity. This is just a showcase for the above two libraries.

Clone the repositories (extractions, reduction, approximation) with Git:

git clone https://github.com/salvipeter/bezier-extractions.git git clone https://github.com/salvipeter/bezier-reduction.git git clone https://github.com/salvipeter/bezier-bspapprox.git
Last update: 2022.02.05.

Spiral widget

A quick reconstruction of an animation showing sliders controlling the length and height of a spiral (or, as it was a video for children, a roll cake).

Last update: 2022.01.30.

Tcl GUI with SML Backend

This is a feasibility test for creating a GUI program in Standard ML. The actual GUI part is written in Tcl/Tk, which communicates with the SML backend using sockets. Currently it can do user event driven processing, where pressing a button sends a text message to the backend, which answers with another one. Exiting the GUI program sends an exit message to the backend which also exits cleanly.

Download the server script and the client program.

Last update: 2022.01.28.

PHP Search of the Archive

I wrote my first PHP script to create a tag-based search / top page for the 15th birthday of this archive.

Last update: 2022.01.27.

Water Sort Puzzle Solver

A Prolog program finding solutions to water sort puzzles such as this one using exhaustive search.

Last update: 2022.01.08.

Advent of Code 2015

My solutions to the Advent of Code 2015 contest, written mainly in Common Lisp.

Clone the repository with Git:

git clone https://github.com/salvipeter/advent2015.git
Last update: 2022.01.04.

Advent of Code 2021

My solutions to the Advent of Code 2021 contest, written mainly in Standard ML.

Clone the repository with Git:

git clone https://github.com/salvipeter/advent2021.git
Last update: 2021.12.26.

Advent of Code 2016

My solutions to the Advent of Code 2016 contest, written mainly in Prolog.

Clone the repository with Git:

git clone https://github.com/salvipeter/advent2016.git
Last update: 2021.12.17.

Updated .vimrc

My current .vimrc file and the corresponding file for MacVim, also similar ones for NeoVim (init.vim, ginit.vim), all very minimal.

Last update: 2021.09.11.

Advent of Code 2018

My solutions to the Advent of Code 2018 contest, written in Common Lisp.

Clone the repository with Git:

git clone https://github.com/salvipeter/advent2018.git
Last update: 2021.07.27.

Advent of Code 2017

My solutions to the Advent of Code 2017 contest, written in Standard ML.

Clone the repository with Git:

git clone https://github.com/salvipeter/advent2017.git
Last update: 2021.07.10.

Synacor Challenge

My solution to the Synacor Challenge. The virtual machine is written in C++, other parts are solved using Common Lisp and Prolog.

Clone the repository with Git:

git clone https://github.com/salvipeter/synacor.git
Last update: 2021.06.03.

Isoptic Surfaces

Isoptic surface generation for meshes, based on the PhD dissertation of Ferenc Nagy. Only a simple brute force approach is implemented, using my dual contouring library.

Clone the repository with Git:

git clone https://github.com/salvipeter/isoptic.git
Last update: 2021.05.26.

Jet Fitting Wrapper

A wrapper over CGAL for convenient jet fitting based normal / curvature computation using my geometry library.

Clone the repository with Git:

git clone https://github.com/salvipeter/jet-wrapper.git
Last update: 2021.05.25.

εκ-curves

A Julia implementation of εκ-curves, an extension of κ-curves, where the proximity can be controlled with an extra parameter. The video branch also allows the weight modification for individual points, and it contains the supplementary video available on the Springer website.

Clone the repository with Git:

git clone https://github.com/salvipeter/ekcurves.git
Last update: 2021.05.19.

Curve Fitting and Proximity Curves

Originally started for trying out various cubic and quartic interpolation schemes, this little program also serves as a testbed for proximity curves (see the corresponding paper).

Clone the repository with Git:

git clone https://github.com/salvipeter/quartic.git
Last update: 2021.04.29.

Advent of Code 2019

My solutions to the Advent of Code 2019 contest, written in Prolog.

Clone the repository with Git:

git clone https://github.com/salvipeter/advent2019.git

2023.11.17. Forth implementations for the first half are added.

Last update: 2021.04.28.

L-Systems in PostScript

I have played with Lindenmayer-systems before, but now I made the code more generic, so it is very easy to add new curves. As an example, I included the Sierpiński triangle, the Dragon curve, and six plants from the book "The Algorithmic Beauty of Plants".

Download the source code, or see the PDF version.

Last update: 2021.04.07.

Katamino Solver

A Prolog program that solves all Katamino puzzles. There is a user-friendly interface, and also a convenience function that generates one solution for all problems. Another interesting feature is to look for "split" solutions, like these:

3+9:
p p p|s t t t l l l l y 
p p r|s s t w w z z l y 
r r r|v s t + w w z y y 
c r c|v s + + + w z z y 
c c c|v v v + i i i i i  

5+7:
p p c c c|s s i i i i i 
p p c + c|t s s s w z z 
p r + + +|t t t w w z v 
r r r + l|t y w w z z v 
r l l l l|y y y y v v v  

6+6:
s r r p p p|w l l l l y 
s s r r p p|w w z z l y 
v s r + c c|t w w z y y 
v s + + + c|t t t z z y 
v v v + c c|t i i i i i  
Last update: 2021.02.28.

Interior Editing with Displacement Blends

A fork of my 3D framework for testing some ideas on editing the interior of transfinite interpolation surfaces using displacements multiplied by C-infinity blending functions. See also the related paper.

Clone the repository with Git:

git clone https://github.com/salvipeter/displacement.git
Last update: 2021.02.01.

Dobble Deck Generator

A Dobble deck generator, or equivalently, a finite projective plane generator, written in Prolog (and Julia). There are three algorithms: (i) naive backtracking, (ii) optimized backtracking, and (iii) direct solution for prime orders.

The programs are embedded in a Markdown memo (source), written in Hungarian. It also shows that the Dobble deck lacks 2 cards, while the Dobble Kids deck lacks 1 (the latter is also found by a snippet at the end).

Last update: 2021.01.25.

Color Hexagon Puzzle

A Prolog program that solves the color hexagon puzzle, where 7 hexagons with different colors on each sides have to be arranged in a flower pattern (6 outside 1 inside) in a way that all colors match. There is only one solution (and >200 million arrangements).

Last update: 2021.01.15.

IPIA Implicit Fit

An implementation of the implicit progressive-iterative approximation algorithm of Hamza et al., using my geometry library.

Clone the repository with Git:

git clone https://github.com/salvipeter/ipia.git
Last update: 2021.01.08.

Advent of Code 2020

My solutions to the Advent of Code 2020 contest, written in Nim.

Clone the repository with Git:

git clone https://github.com/salvipeter/advent2020.git
Last update: 2020.12.25.

Popup-Card Generator

A Julia snippet that generates an EPS popup card from an Wavefront OBJ mesh. This is a very basic implementation that still needs manual postprocessing to delete superfluous lines (between faces in the same plane), and mountain/valley folds are not differentiated.

As an example, there is a ziggurat-like temple (object file, manually postprocessed PDF).

Last update: 2020.11.28.

Parabola Curvature Monotonicity

A small Racket applet that demonstrates the criterion for a parabolic arc to have monotonic curvature.

Last update: 2020.10.05.

Vertebra Fit

A small C++ library to fit closed B-spline curves over a set of sampled points, some more important than the others (originally used for fitting vertebra contours).

Clone the repository with Git:

git clone https://github.com/salvipeter/vertebra-fit.git
Last update: 2020.10.05.

DIY LogiFaces Puzzle

Two DIY versions of the LogiFaces puzzle:

First: A short Julia program to generate a 3D-printable LogiFaces set. (The model is in millimeter units; see also a photo.)

Second: A 2D paper version in PostScript printable on A4 paper. There are two designs (changable in the source), see the PDF versions (Design 1, Design 2).

Download the source code, or see the htmlized version.

Last update: 2020.09.22.

Approximate G1/G2 Connections

A lightweight library for connecting B-spline patches with approximate G1/G2 continuity. Uses my geometry library.

Clone the repository with Git:

git clone https://github.com/salvipeter/bspline-connect.git
Last update: 2020.07.01.

MidPoint Patch

An implementation of the MidPoint patch using my geometry library.

Clone the repository with Git:

git clone https://github.com/salvipeter/midpoint.git
Last update: 2020.06.22.

Tensor-Product Conversion of Multi-Sided Patches

Test on converting Kato, Charrot-Gregory and S-patches into tensor-product rational Bézier surfaces. See also the related paper.

Clone the repository with Git:

git clone https://github.com/salvipeter/tensor-conversion.git
Last update: 2020.05.22.

Laser Pointer

A draggable laser pointer, implemented as a transparent window without decorations. Written in Qt.

Clone the repository with Git:

git clone https://github.com/salvipeter/laser-pointer.git

Also, there is an XFCE cursor theme that changes the open hand cursor (displayed by qpdfview) into a laser pointer. Unzip the contents to $HOME/.icons/.

Last update: 2020.03.25.

LispKit Lisp

An implementation of the SECD virtual machine and a LispKit Lisp compiler, based on P. Henderson's Functional Programming - Application and Implementation. There are two versions: one written in Scheme and another in C++. The latter one is more complex, because of the reader and the garbage collector, but it still just around 500 LoC.

Clone the repository with Git:

git clone https://github.com/salvipeter/lispkit.git
Last update: 2020.03.03.

Implicit fitting

A test program in Julia for experimenting with fitting implicit surfaces on a boundary loop of (rational) polynomial curves, and maybe additional constraints. Uses my dual contouring library for generating meshes.

Clone the repository with Git:

git clone https://github.com/salvipeter/implicit-fit.git
Last update: 2020.02.19.

Transfinite library

A C++ library for testing different transfinite interpolation surfaces.

Clone the repository with Git:

git clone https://github.com/salvipeter/transfinite.git
Last update: 2020.02.19.

CSG Testbed

A testbed for playing with implicit surfaces, using my 3D framework and dual contouring library.

Models are built with scripts written in Scheme (Guile), which can be reloaded on-the-fly. See a screenshot of the elliptic blend of two cylinders, and the corresponding script.

Clone the repository with Git:

git clone https://github.com/salvipeter/csg-script.git
Last update: 2020.02.04.

C0 Coons Patch

An implementation of the multi-sided C0 Coons patch, using my geometry library.

Clone the repository with Git:

git clone https://github.com/salvipeter/c0coons.git
Last update: 2020.01.30.

Best Ellipse

A rational quadratic Bézier curve can represent ellipses, when the weight of the central control point is set to a value in (0,1). We like circles, so when the two control edges are the same length, we can set the weight such that the curve will be a circular arc. But what should we do when the edges have different lengths? It should behave continuosly, i.e., if we move a control point a little bit, the curve should remain almost the same.

Here is a JavaScript applet that shows two possible solutions. The circle weight is computed by an angle, and it can be extended to the general case in a straightforward manner (green curve). But one thing we like about circles, is that the ratio of its axes is 1 - so it is a natural idea to minimize the deviation of the major and minor axes, or the (1 - minor/major) function (blue curve).

The second method uses golden section minimization, and the computation involves solving a linear equation system, for which I have used a slightly modified version of the linear-solve library.

Last update: 2020.01.15.

Deck Shuffling

A Julia implementation of the card trick presented in the paper "Trailing the Dovetail Shuffle to its Lair" (D. Bayer & P. Diaconis); reconstructing their results with 1,000,000 Monte Carlo trials and also achieving higher success rates by using a better guessing method (maximizing min(d(i-1,i),d(i,i+1)) instead of d(i-1,i)+d(i,i+1)).

Download the source code, or see the htmlized version.

Last update: 2020.01.12.

Isophote Texture Generation

A small program generating textures for isophote visualization, as used in my sample framework.

Clone the repository with Git:

git clone https://github.com/salvipeter/isophotes.git
Last update: 2020.01.08.

Geometry Library

A minimal library containing the essential tools for geometry processing, such as 2D and 3D points/vectors, triangular meshes, B-spline curves, etc.

Clone the repository with Git:

git clone https://github.com/salvipeter/libgeom.git
Last update: 2019.11.26.

Layered Depth-Normal Image Library

A library for creating a quasi-implicit representation from triangular meshes, with a compact file format. The mesh can be regenerated by cell-based contouring methods (dual contouring is implemented). The LDNI representation can be useful for Boolean operations or as a decimation tool.

Clone the repository with Git:

git clone https://github.com/salvipeter/ldni.git
Last update: 2019.11.26.

Dual Contouring

A minimal C++ library to convert implicit surfaces (isosurfaces of real-valued functions in 3D space) into quadrilateral meshes. It is very basic, because (i) it is not adaptive, (ii) does not use derivatives, and (iii) creates only one point in each cell. Still, the resulting meshes are better quality than those created by marching cubes, and it is quite fast.

Clone the repository with Git:

git clone https://github.com/salvipeter/dual-contouring.git
Last update: 2019.11.18.

Profile fitting

A Julia program for fitting a polyline on an unordered set of noisy points. It also provides methods for fitting segments and circular arcs (still in an early phase).

Clone the repository with Git:

git clone https://github.com/salvipeter/profile-fitter.git
Last update: 2019.11.11.

Blackbox Optimization Library

A library for derivative-free optimization, also known as "blackbox" optimization. There are several implemented methods (Nelder-Mead, Powell, DiRect, MADS, and maybe more to come), and there are also a few tests supplied. All methods are available separately as single C++ files.

Clone the repository with Git:

git clone https://github.com/salvipeter/dfo.git
Last update: 2019.11.04.

Two Optimizations

Two (otherwise unrelated) optimizations using C++/Eigen.

The first fits a sphere with fixed radius on a set of 3D points. Download the source code, or see the htmlized version.

The second one takes a 2D B-spline curve embedded in 3D, and a direction for each control point. Then it computes a translation of the control points in the given directions in such a way that the integral of curvature (actually, the second derivative at discrete points) is minimal. Download the source code, or see the htmlized version.

Last update: 2019.10.29.

Rule 90 and the Sierpiński Triangle

An implementation of the Rule 90 (XOR) linear cellular automata in Julia, resulting in an image similar to the Sierpiński triangle. Also I made a PostScript program of the real triangle with variable size & depth (also in PDF).

Last update: 2019.10.18.

Updated .emacs

My current .emacs file, cleaned up after more time than I would like to admit.

Last update: 2019.04.01.

Biharmonic S-patch

Two experiments with S-patches: (i) hole filling (C0 or G1 boundary constraints, and a special "biharmonic" mask on the interior control points), and (ii) CAD-compatible conversion. See also the related papers.

Clone the repository with Git:

git clone https://github.com/salvipeter/biharmonic-spatch.git
Last update: 2019.01.21.

Circle Approximation with Cubic and Quartic Curves

An HTML5 applet to test two polynomial approximations of the circle as curves with fullness determined by 3 points. The red curve is a cubic approximation (approximating the circle at 68%), and the green one is a quartic (circle approximation at 50%).

Last update: 2019.01.03.

Rotation Matrix Computation

Given 3 planes containing the origin, and 3 lines going through the origin, find the rotation matrix that rotates each line to the corresponding plane. The planes are represented by their (unit) normal vectors, while the lines by their (unit) direction vectors.

Download the source code, or see the Juno notebook version.

Last update: 2018.12.03.

Pig Game Strategies

A simulation to evaluate different strategies for the dice game "Pig". There are also some example players.

Download the source code, or see the htmlized version.

Last update: 2018.11.11.

Obake Meiro [Ghost Maze]

My first C# program - a Gtk# maze generator for my 3-year-old. It also places some random ghosts/monsters on some of the wrong paths. Movement with the arrow keys or the mouse, Esc exits. See a screenshot.

Clone the repository with Git:

git clone https://github.com/salvipeter/obake-meiro.git
Last update: 2018.10.27.

Onitama Cards

A nice and clean (but minimalistic) set of cards for playing Onitama, programmed in PostScript. There is also a board for the game.

Download the PDF versions (cards, board).

Last update: 2018.09.14.

I-patch

A short implementation of I-patches in Julia, based on an old paper of my colleagues. The patch is exported as raw voxel data, visualizable in Paraview (here is a screenshot of an example used in the original article).

Download the source code, or see the htmlized version.

Last update: 2018.09.01.

Minimal Bounding Rectangle

Computation of the minimal bounding rectangle of a 2D point set in Julia, using the convex hull. See a screenshot.

Download the source code, or see the htmlized version.

Last update: 2018.08.13.

Falling Balls

Tried to program the effect seen on BabyTV, where an image is created by falling colored balls. I have used Chipmunk2D for the physics engine. Here is a screenshot and two videos (first, second) of the result.

Download the source code, or see the htmlized version.

When the number of balls is high, the image is not reconstructed properly, which may be because some minimal indeterminism in the Chipmunk2D library.

Last update: 2018.06.17.

Maximum Entropy Library

A C library for evaluating the maximum entropy barycentric coordinates. Uses the the GSL library for optimization. I have also summarized the maximum entropy principle.

Clone the repository with Git:

git clone https://github.com/salvipeter/libmec.git
Last update: 2018.06.16.

Bézier Triangle

This is a minimal C++ library for evaluating Bézier triangles.

Clone the repository with Git:

git clone https://github.com/salvipeter/bezier-triangle.git
Last update: 2018.04.21.

Scanned Dictionary Browser

This is a webpage that shows a given page of a scanned dictionary. It is particularly handy when the scan does not have any OCRed text, or when there are language-specific searching features (e.g. handling alifs with or without hamza as the same letter in Arabic, or handling pointed and unpointed consonants as the same in Hindi). See a screenshot.

It can be tailored to any language by supplying a suitable sorting function, a list of every page's first word, and (of course) the scanned dictionary pages.

Try it with the first 5 pages of McGregor's Hindi-English dictionary, or get the latest with Git:

git clone https://github.com/salvipeter/scanned-dictionary.git
Last update: 2018.03.18.

Concave GB Patch Library

A C++ library for evaluating concave GB patches. Uses the harmonic library, as well as Shewchuk's Triangle.

Clone the repository with Git:

git clone https://github.com/salvipeter/concave-gb.git
Last update: 2018.03.08.

[Bi]Harmonic Coordinates

A C library for computing (discretized) harmonic and biharmonic coordinates.

Clone the repository with Git:

git clone https://github.com/salvipeter/harmonic.git
Last update: 2018.02.09.

Dragon Curve in PostScript

Just a few lines for trying out L-systems.

Download the source code, or see the PDF version.

Last update: 2017.06.21.

Snake Cube in Prolog

Brute force solution of the snake cube problem in Prolog, loosely based on a Haskell pearl article. My version also features puzzle generation (and Japanese output).

Download the source code, or see the htmlized version.

Last update: 2016.06.18.

Yavalath Board

Printable board for the computer-generated board game Yavalath. Rules: like gomoku, but a row of 3 loses, a row of 4+ wins. For 3 players, you have to obstruct the win of the next player, if possible.

Download the board in PDF, or in EPS, where you can tweak its parameters. For example, there is a variation (EPS, PDF) to play with stones instead of pencils.

Last update: 2016.05.12.

Combinatory Logic

A basic evaluator for CL and its meta-language, as described in "Lambda-Calculus and Combinators: An Introduction" (Hindley & Seldin).

Download the source code, or see the htmlized version.

Last update: 2016.05.09.

Dice Probability Computations

A small program calculating the probability that throwing an n-sided die m times will result in a sum larger/smaller than a given value.

Download the source code, or see the htmlized version.

I have also translated the code to PicoLisp as an exercise.

Last update: 2016.02.06.

Age & Weight

A few lines computing the age of my daughter (in days), and displaying a graph of weight vs. age, using Gnuplot.

Download the source code, or see the htmlized version.

Last update: 2016.01.05.

2D Class A Curves

Actually there are two projects. One is about interpolating one curve segment, which can be a Class A Bézier curve or a logarithmic aesthetic curve (or LAC), the other is about interpolating points with a discrete clothoid spline. The former is written in Racket, like before, but the latter is written in Julia, in an attempt to try to create something non-trivial in it.

Clone the repository with Git (Bézier & LAC):

git clone https://github.com/salvipeter/class-a-curves.git

Clone the repository with Git (discrete clothoid):

git clone https://github.com/salvipeter/discrete-clothoids.git
Last update: 2015.11.10.

SICP in Common Lisp

These are my translations of the SICP sample codes to Common Lisp, along with my solutions to the exercises. The file can be loaded in any CL compiler (provided that there is LISPBUILDER-SDL and BORDEAUX-THREADS). The solutions to the exercises can be hidden by an Emacs-Lisp snippet at the end of the file.

Clone the repository with Git:

git clone https://github.com/salvipeter/sicp.git
Last update: 2015.10.06.

Lyapunov Fractals

The Tinkertoy Computer has a chapter on Lyapunov fractals - they look pretty amazing, so I fired up my REPL and here are the results: Lyapunov space, jellyfish, and Zircon Zity.

Download the source code, or see the htmlized version.

Last update: 2015.09.02.

ErBi Input Method

This started as a conversion of SCIM's ErBi input method, but I've soon realized that I didn't really like that version, so this is a somewhat simplified variant, without multi-character combinations, but almost all keys are mapped to different codes.

There is short introduction to this input method (both in Hungarian and in English), there is the list of codes, an Emacs quail package, and even web page where you can try it out for yourself.

I've also created a fork of my WuBi practice project; you can find it on GitHub:

git clone https://github.com/salvipeter/erbi-practice.git
Last update: 2015.08.29.

Typesetting Hindi IPA Symbols in LaTeX

This snippet started as a memo on how to typeset the IPA symbols for the Hindi/Urdu language in LaTeX. There is a nice package called tipa that can handle all IPA characters, but even with its utilities it is quite hard and not very readable.

I have my own transcription system that I use for my grammar notes, so I've written a short Lisp program to convert this to LaTeX code. Text to be converted should be tagged with "HINDIPA", either in inline or in environment style, see the example (LaTeX input, PDF output)."

Download the source code, or see the htmlized version.

Last update: 2015.05.12.

Byl's Automaton

A small self-reproducing automaton, conceived by John Byl in 1989. Its design is similar to Langton's loop, but even simpler, with only 6 states per cell.

I've found this gem in The (New) Turing Omnibus, and implemented it in Lisp using LTK (see a screenshot). At first it didn't work, and eventually I found out that a rule was missing, and the rule orientation was also wrong, even in the original paper.

Download the source code, or see the htmlized version.

I've rewritten the graphics in SDL for comparison, but it isn't much faster.

Spinoff: the Anneal automaton (screenshot).

Last update: 2015.03.07.

Neural Network

A minimal neural network implementation (with 1 hidden layer) learning how to convert polar coordinates to the Cartesian system. Based on the algorithm in The (New) Turing Omnibus.

Download the source code, or see the htmlized version.

Last update: 2015.03.01.

Contract Bridge Tests

A collection of functions to run a few tests concerning auction in contract bridge, such as the average number of losers in a 2NT hand etc.

Download the source code, or see the htmlized version.

Last update: 2015.01.22.

Writing Test

There was a quiz on the net for guessing some of the more exotic writings (like Japanese or Arabic), but it was too easy, so I've rolled my own. All of the writings systems in the quiz are still in use, and there is only one representative language for close families (e.g. there is no Farsi, Urdu or Uyghur, just Arabic).

Try the JavaScript code here.

Last update: 2014.12.31.

Color Clock

There was a page showing what color time would look like if we reinterpreted it as a hex color code, e.g. 08:13:47 => #081347. It was a nice idea, but the resulting colors were all very dark, and not easily distinguishable.

It occurred to me that HSV encoding would be a better fit, because Hue is easy to recognize, so we instantly get a feel of time. Value can be used for minutes, and Saturation for seconds. Also, the conversion should fill the whole spectrum. This is the result of this experiment.

Try the JavaScript code, download the source code, or see the htmlized version.

Last update: 2014.12.19.

Visual Cryptography & Steganography

Visual cryptography is an analog code: two images are created in a way such that no information can be extracted from them, but if we place them on top of each other, a new image (the "plaintext") appears. The "ciphertext" images can carry information, too... For a trivial example, look at this cat and this mouse - when placed on top of each other, result in this image.

A related field in cryptography is steganography, which studies how we can hide information in seemingly normal images. A simple method takes the last two bits of the RGB components (6 bits / pixel), and inserts a Base64-encoded string into it. As an example, I took a photo of my hamster, and encoded Khalil Gibran's "The Prophet" inside it - the text file was first encoded with GPG (password: "hamuhamu"), then converted to Base64 encoding, the result is this image.

Download the source code, or see the htmlized version.

Last update: 2014.10.14.

ICFP2014

My submission to the annual contest of the International Conference on Functional Programming. This time I entered as a single-man team NIL, and I did surprisingly well - 3rd place in the lightning round, and 5th place in the full round.

The task was to write pacman AIs on two different architectures, and to that end, to develop a compiler to these CPUs. The project README and the contest's task specification contain the details.

Clone the repository with Git:

git clone https://github.com/salvipeter/icfp2014.git
Last update: 2014.09.25.

Arabic Dictionary App

An Arabic-English dictionary app for Android written in HTML/JavaScript, using jQuery Mobile and PhoneGap (so other platforms could be generated, as well). This is a rewrite of a Clojure program, you can read about its history here.

The screenshot shows a rendering by the lightweight Midori browser. (This way it can be used as a desktop application, as well.)

Download the Android app or the source code (previous versions are also included). You can also test it here.

Last update: 2014.06.23.

Visualization of the "vision" transformation

A somewhat minimalistic 3D demo showing several aspects of the mathematics of how we see (projections). Uses Qt / QGLViewer for the GUI (see a screenshot).

Download the current version with Git:

git clone https://github.com/salvipeter/3dviz.git
Last update: 2014.03.23.

Arabic Dictionary Reloaded

A Java rewrite of my original Clojure program, written mainly to facilitate the transition to the Android version (soon!). New features include on-the-fly lookup, changable text size, better word boundary handling for English-Arabic queries, and sorting in a somewhat arbitrary, but logical order.

Download the source code or see the htmlized version. For your convenience, there is also a somewhat larger JAR version.

Last update: 2013.11.27.

Nine Men's Morris, 5-row Go Problems, Bridge Deals

A simple Nine Men's Morris game implementation (no computer player) for learning JavaScript / HTML5. As a derivative project, I've modified it to display 5-row go problems, and using the same base I also created a page generating bridge deals for bidding practice over the phone.

Play Nine Men's Morris, solve 5-row go problems, or practice bidding!

git clone https://github.com/salvipeter/malom.git
Last update: 2012.12.23.

Testbed for Pseudo-G2 Curves

This is a feasibility test for a research idea - basically how curves using curved ribbons give better curvature than those using linear ribbons. Two days before the abstract deadline I did not have time for elaborate programming, but I needed a GUI, graphics and some math. Once again, Racket came to the rescue. Using an earlier snippet as a base, I managed to implement this program in a few hours, with all its "bells & whistles" (see screenshot).

Download the source code, or see the htmlized version.

2012.10.09.: This little project got a lot bigger since its first version, and now it has earned its own repository - you can download the latest version with Git:

git clone https://github.com/salvipeter/pseudo-g2.git
Last update: 2012.09.29.

Sample 3D Framework

A minimal 3D framework for creating simple applications (intended for class use). Uses Qt / QGLViewer for the GUI and OpenMesh for the mesh data structure (see a screenshot).

Download the current version with Git:

git clone https://github.com/salvipeter/sample-framework.git
Last update: 2012.04.28.

Marching Squares

Another applet written in Racket - this time a demonstration of the basic marching squares algorithm (without any heuristics), applied for displaying 3rd-degree implicit functions (see a screenshot).

Download the source code, or see the htmlized version.

Last update: 2011.11.11.

Checkers Board in HTML

A minimalistic checkers graphics generator in JavaScript, that should help writing diagrams. Look at an example diagram, or try the generator itself.

Download the whole package in a ZIP file.

Last update: 2011.10.28.

Pythagorean Hodograph Curves

A simple demo for quintic PH curve interpolation, implemented in Racket. Its features include exact arc-length computation and displaying the curve's (explicit rational Bézier) offset curves (see a screenshot).

Download the source code, or see the htmlized version.

Last update: 2011.10.24.

Ngaro Virtual Machine in X86 Assembly

An implementation of the Ngaro Virtual Machine (used by RetroForth) in 32-bit x86 assembly. I always wanted to write a Forth on the "bare metal"... well, this is a first step.

Download the source code, see the htmlized version or get the latest version with Git:

git clone https://github.com/salvipeter/ngaro-asm-x86.git
Last update: 2011.09.08.

White Layer

A simple but useful GIMP script (written in GIMP's Scheme dialect) for adding a white background layer to transparent images (by flattening). It can be used for single or multiple images.

Download the source code or see the htmlized version.

Last update: 2011.08.30.

Congklak

Congklak is an Indonesian variant of the Mancala game family. You can read its rules here (sorry, I don't remember where this file came from...). I've written a simple implementation in Lisp, with a minimalistic GUI that uses LTk (see a screenshot). There is even a basic (minimax) AI opponent, which seems to be quite strong. Actually, as a starting player it always wins (check out the winning moves).

Download the source code or see the htmlized version.

Last update: 2011.08.19.

Whitespace Assembler

A simple assembler for the Whitespace language, with a FOR macro, and of course, the power of Lisp to do other macros later. I've included the solution to the SPOJ/3 problem as an example.

New: A Whitespace solution to the classic FizzBuzz problem - introducing two convenience functions: PRINT-STRING and COND!

Download the source code or see the htmlized version.

Last update: 2011.08.12.

Project Euler Solutions

My solutions to the problems at Project Euler, which I've been doing since 2007.04.14.

These files are encrypted with a CAST5 symmetric cipher. For each file, the password is the solution to the problem; you can decode them with GnuPG. There is also an answer list for my personal use.
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 ... 265 ... 267 ... 277 ... 301 ... 357 ... 493

Note: I've noticed that several problems were altered slightly to be more challenging on modern computers. The passwords reflect the versions published at the time I've solved them.

2008.02.08.: I've reached 100% at last!

2008.02.09.: 5th place.

2008.03.08.: 4th place.

2008.03.15.: 3rd place, my best position to date.

2009.05.10.: Sadly, I don't have time to solve these problems week by week anymore. Still, I hope that I will come back and do a few in my free time.

Last update: 2011.04.23.

Polygon subdivision

A JavaScript demonstration of three trivial subdivision algorithms (Chaikin with two weight sets, and 4-point interpolation). The program was a feasibility test of JS programming using CL-WHO and ParenScript that makes use of advanced widgets, events and macros.

Try the JavaScript code, download the source code, or see the htmlized version.

There is also a (manually) modified version used as a test of the parabola's parametric equation.

Last update: 2011.04.03.

2022.09.28.: Correct end conditions for the Chaikin subdivisions are now implemented.

Delaunay Triangulation

This is a demonstration of the (easiest) incremental approach to Delaunay triangulation, written entirely in PostScript. It uses user-given or random points, generating a sequence of "slides" that explain how this method works. The code may need some polishing, since it was a (relatively) fast hack.

Download the EPS file, a PDF conversion for random data, or see the htmlized source.

Last update: 2011.02.16.

Tools for Language Learning

This includes an Emacs Lisp HTMLizer, that turns a dictionary file into a CSS-driven HTML file, and a word practice software (WPS) that uses the same dictionary file format. There are six versions at present (Latin, Greek, Arabic, Cantonese, Russian and Hebrew), that have small changes as the special properties of the languages differ, as well as one for Yoruba that generates a plain TeX file. There is also a minimalistic (but very effective) flashcard utility for Emacs, with an (even more minimalistic) Clojure translation for the BiDi languages that Emacs cannot display well enough (yet). Both have a "flashdeck" version suitable for long learning lists, that cycle on only a few words at a time.

The basic file format (Latin/Greek) separates the solution and definition by an equal sign (with spaces on both sides):

īnfīrmus, -a, -um = weak

and

ὕπνος, -ου, ὁ = sleep

Since Arabic is written from the right, the definition naturally goes to the left side:

coffee = قَهْوَةٌ

Unicode diacritics are generated for Cantonese from a simplified version of the Yale transcription:

潮州話 : chiuh\ jau~ wa/ = Teochew dialect

In the Russian version the quotation mark shows the place of accent:

рабо"та|ть, ю, ешь = to work

The Hebrew version has a middle column for pronounciation. You can use latin-1 characters to show the place of accent.

חבר = khavér = friend

Finally, Yoruba accents pose no difficulty, only the dots under vowels, that are represented by a simple dot prefix.

.òr.é = friend

You can find sample dictionaries in the text page.

Download the source code of the HTMLizer (Latin, Greek, Arabic, Cantonese, Russian, Hebrew, Yoruba), the WPS (Latin, Russian, Hebrew), the Flashcard (Clojure version with a boot script and its (larger, but stand-alone) JAR version, old version), and the Flashdeck (Clojure version with a boot script and its (larger, but stand-alone) JAR version; also a generic, two-directional version in an all-in-one package containing Clojure and the boot file as well), a sample CSS file (Latin, Greek, Arabic, Cantonese, Russian, Hebrew), or see the htmlized version of the HTMLizer (Latin, Greek, Arabic, Cantonese, Russian, Hebrew, Yoruba), the WPS (Latin, Russian, Hebrew), the Flashcard (Clojure version, old version) and the Flashdeck (Clojure version).

Last update: 2010.11.01.

Linked Lists in Forth

Yet another linked list implementation in Forth, using Lisp-style naming. There is no garbage collection support, but theoretically (with a good library) only a few words have to be changed.

Download the source code, or see the htmlized version.

Last update: 2010.10.31.

Dictionary Opener

A common problem with dictionaries in PDF or Djvu that you cannot search in them for keywords. This utility requires only a small database that can be created in an hour or two, and opens the dictionary at the required place. It is written as a CLISP script, so it is easy to alter the string comparison mechanism as well.

Download the source code, or see the htmlized version.

Last update: 2010.10.07.

Configuration Files

My .emacs file (with my calendar settings in a separate file). It is always under construction. Also, some lisp utilities in my .sbclrc file.

Download the files: .emacs, .emacs (for version 22), .emacs (for version 21), my-calendar, .sbclrc.

Some other configuration files: Midnight Commander (ini, menu, bindings, and of course my skin), FluxBox (keys, menu, startup), .bashrc, .zshrc, .tmux.conf, .vimrc, .Xdefaults, .Xmodmap.

Last update: 2010.09.22.

Mosaic Puzzle Solver

In many computer games, a recurring puzzle is where you have to fill a given area by a set of shapes, which you may or may not rotate. This simple C++ library gives you all solutions in a second. A use example is also supplied, which reads the data in from a file.

Download the whole package.

Last update: 2010.09.12.

Chess Clock

If you don't have any chess clocks around, it is convenient to have a virtual one on your laptop. So I wrote it in Clojure. Nothing fancy, but should be easy enough to use. The key configuration is hard-coded. Read the comments in the source header on how to run / use / configure this handy little script.

Download the source code, or see the htmlized version.

Last update: 2010.04.13.

Swahili Dictionary

A minimal utility to facilitate Swahili word lookups in the Swahili-English dictionary of the fantastic Kamusi Project. You can autoload it from your .emacs file, or use a script to boot emacs as a stand-alone dictionary (see the source for details).

Download the source code, or see the htmlized version.

Last update: 2010.04.12.

Red Discs

Imitating a nice SDL_basic screenshot using PostScript. The result should look like this. It would be more elegant, if I could query the current file name, though.

Download the PostScript file, or see the htmlized version.

I have also rewritten it in Common Lisp using Vecto - it generates a PNG file. See the source in text or in HTML.

Last update: 2010.01.11.

Argument Parsing

I was not satisfied with the lisp clones of getopt, so I've rolled my own. You can insert a function to the argument definition, that will be called with the argument's parameter. This helps doing parsing numbers and other preprocessing stuff. Every option also has a symbolic name, so it is easy to search in the resulting alist. Of course it has all the standard functionality like short and long switches, equal signs and so on.

Download the stable version, or get the bleeding edge with Git:

git clone https://github.com/salvipeter/parse-args.git
Last update: 2009.12.14.

Finite State Machine

A simple FSM, implemented in different languages, using different programming paradigms.

The concatenative Forth version creates a nice and easy-to-use DSL, where you can define states either by explicitly assigning transitions to input values, or by using arbitrary Forth words to choose the next state. There is an HTML version with explanations and examples.

The prototype-based Io version enables you to write arbitrary per-state transition functions in a clear way, without any macro-hacking. Also see the HTML version with some comments and examples.

The Lisp version is a lispy DSL (= lots of parentheses), in a somewhat functional way. The HTML version also contains some notes and examples.

Last update: 2009.12.09.

Mastermind

A (quite trivial) program that guesses the hidden colors in Mastermind, giving an average of 4.6 turns. A minimax search would also be easy to implement (see Knuth); according to Wikipedia, Koyama & Lai have also found a method with an average of 4.34.

Download the source code, or see the htmlized version.

Last update: 2009.10.11.

Langton's Ant

The Langton's Ant cellular automaton, written in PostScript. In the first few lines of the file you can set parameters like the pixel size, the number of iterations and the initial seeds.

Download the PostScript file, or see the htmlized version.

Last update: 2009.10.06.

Chinese Pronounciation Training

One hard thing about Chinese is that every word has an intonation that you should remember. This little Emacs code pops up some tests in the minibuffer, using the CEDICT database.

Download the source code, or see the htmlized version.

Last update: 2009.10.05.

SFView

SFView (Surface Viewer) is a utility that I needed very much - it loads NxM grids of 3d points or NURBS surfaces and displays them in a common OpenGL window. There are several display modes, including slicing map, isophote map and mean curvature map, and it can also take PNG screenshots with transparent background. See a screenshot.

It handles RBN (see CL-NURBS for its specification) and PTS files. The latter one is of the format:

M N Point1-x Point1-y Point1-z Point2-x Point2-y Point2-z ...

I tried to follow the GNU standards while making this, so it has all the standard command line arguments and also a manual page.

Download the source code for version 0.35 or get the latest with Git:

git clone https://github.com/salvipeter/sfview.git
Last update: 2009.07.27.

Automatic Voter

A small program that votes in an infinite loop. One more reason to implement IP checking on your poll.

Download the source code or see the htmlized version.

Last update: 2009.07.27.

Arabic Dictionary

A (yet again) minimalistic dictionary tool written in Clojure. Later I plan to do a full morphological analysis and a better GUI, but it is usable in its current state. The database is the Buckwalter wordlist taken from the Perseus website, converted to text format by this script.

Download the boot script, the database and the source code or see the htmlized version. For your convenience, there is also a somewhat larger JAR version.

Last update: 2009.06.05.

Digits of π

My first Factor program - a straightforward (and very slow) translation of the algorithm in the paper by J. Gibbons: Unbounded Spigot Algorithms for the Digits of Pi. The program conforms to the guidelines of the The Computer Language Benchmarks Game.

Download the source code or see the htmlized version.

Last update: 2009.05.30.

Object-Oriented Programming by Macros

This is a simple example of how an object-oriented system can be created by source substitution (macros), written for a university class. Only the most basic features are supported. I've tried to make it Japanese-friendly by using Japanese symbols for function/macro names.

Download the source code or see the htmlized version.

Last update: 2009.05.25.

Multilingual Bible Lookup

This Emacs snippet looks up a given part of the Bible in the specified languages, using the Multilingual Bible page. This is a result of my frustration that the above site cannot be restricted to a user-defined set of languages and cannot display more than one verse at once.

Download the source code or see the htmlized version.

Last update: 2009.05.20.

Spellcaster Server

A minimal server to play asynchronous Spellcaster. I wrote this because playing Spellcaster by mail clutters my mailbox with one-line messages. It is basically a two-user bulletin board with a secret notepad and hidden message support. See a demo page here.

Download the source code or see the htmlized version. There is also an updated version (source, HTML) for Hunchentoot 1.0.

Note: This code is not thread-safe. With only two users this (hopefully) presents no problems, but still I should add those few lines later...

Last update: 2009.05.07.

QAnyulógus

A program for organizing all the videos, CDs / DVDs at home. It has all the important features like entering new records, modifying, deleting, searching, sorting, printing, but nothing more. Should be simple enough to use. See a screenshot.

QAnyulógus uses Qt4 for the user interface, so it should work on most platforms. Tested under Linux and Mac OS X.

Download the source code of the stable release, or get the development code with Git:

git clone https://github.com/salvipeter/qanyulogus.git
Last update: 2009.02.27.

Coin Flipping Server

This is a web-server version of the algorithm computing the probability for the Project Euler problem 232. The client can enter any "one-liner" algorithm (using a minimal set of Lisp commands) and the computation is done by the server, so one can organize a "who can score higher" competition :).

Download the source code or see the htmlized version. There is also a program computing the probabilities of the "fair" version of the game (htmlized version).

Last update: 2009.02.18.

Clojure/Swing Test

Clojure translation of some Swing examples in the book "Complete Java 2 Certification".

Download the source code or see its htmlized version.

Last update: 2008.11.09.

Cybook Thumbnail Converter

A not too user-friendly utility to convert between PGM and T2B file formats. Using a special four-color GIMP palette you can easily create input images.

Download the source code or see the htmlized version.

Last update: 2008.10.24.

Geek Challenge Solutions

My solutions to the Geek Challenges, mainly using Common Lisp.

These files are encrypted with a CAST5 symmetric cipher. For each file, the password is the solution to the level. You can decode these files with GnuPG. There is also an answer list for my personal use.
01 02 03 04 05 06 07 08 09 10 11 12
Bonus levels:
Bathtime, Big Numbers, The Birds, Bit by Bit, Brute Force, Connectivity, The Evil Pyramid, Fun Sums, Keytone Snooping, Logic Cards, Maximizing a Cone, The Omega Network, QuadTrees, Triangle Paths

Note: The solution to problem 12 (a simple CPU emulation) is my favourite.

Last update: 2008.08.24.

ECL Embedding Test

A minimal test on how to embed Common Lisp code into C/C++ programs (as in, for example, Guile). One test loads a lisp file, evaluates lisp from C++, and also evaluates C++ from lisp. Another test creates a small Gtk GUI in C, where the user can evaluate Lisp expressions.

Download the first one's source code (C++, Lisp) or or see its htmlized version (C++, Lisp); download the source for the Gtk example.

Last update: 2008.06.11.

Grayscale Image Manipulation

Some easy algorithms working on grayscale / binary images (using raw PGM and PBM files) in Lisp... just playing around.
Also some more useful algorithms, written in C++:

Download the C++ source package, the Lisp source code or see its htmlized version.

Last update: 2008.06.09.

Linear Least Squares Example

An example program I wrote for a friend of mine to demonstrate multi-parameter linear least squares approximation using the GSL library. The package also contains HTMLized source code and a documentation that states the problem and explains some simple mathematics behind the solution. Extension of its features is left as an exercise to the reader.

Last update: 2008.05.19.

Starting Forth Solutions

My solutions to the exercises in Starting Forth, with a sample block file.

Last update: 2008.04.20.

Forth Stack Manipulator

Calculates the minimal required (standard) Forth stack manipulation command sequence to reach a stack state from a given initial state. Easily extensible with new commands.

Download the source code or see the htmlized version.

Last update: 2008.04.19.

Simple Tcl Timer

I was searching for a timer function in OpenOffice Impress at a lab meeting, but there was none... so I've written one in Tcl while waiting for my turn.

Download the source code or see the htmlized version.

Last update: 2008.04.15.

Sierpinski Pyramid

A 3d rotating Sierpinski pyramid - originally a programming exercise I made up for my friends. See a screenshot.

The original message divided the problem into four steps, you can download the solution for every step in both Common Lisp and C++.

Last update: 2008.04.09.

Turing Machine Emulator

A short macro to emulate a single-tape Turing machine in Lisp. The states can be defined in a lispy way, and the execution may be displayed by setting a global variable. Run-time errors are checked and reported.

Download the source code or see the htmlized version.

2012.04.25. Added an Erlang version (also in HTML)

Last update: 2008.03.05.

CL-NURBS

A NURBS library in Common Lisp. It handles both curves and surfaces; it can generate PostScript output for curves and VTK files for surfaces. It also has an own file format (RBN) for storing NURBS (as opposed to mesh) data (see here for its specification).

Features include point / vector operations, curve and surface evaluation, derivation, curvature calculation, algorithms for creating continuity between surfaces and fairing with downhill simplex method, knot removal/reinsertion and fitting. See a screenshot.

Download the source code for the stable release or get the development version with Git:

git clone https://github.com/salvipeter/cl-nurbs.git

Note that these packages don't include the fitting library, which is the property of Geomagic, Inc., and because of this, some functions of CL-NURBS cannot be used.

Last update: 2008.02.28.

Python Challenge Solutions

My solutions to the Python Challenges, mainly using Common Lisp, Emacs and Python, but also a few others.

These files are encrypted with a CAST5 symmetric cipher. For each file, the password is the last part of the URL of the next level, without the extensions, e.g. http://www.pythonchallenge.com/some/where.html -> "where". You can decode these files with GnuPG. There is also an answer list for my personal use.
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

The solutions sometimes use some utility functions that can be found here.

(for levels where the solution is a username/password, the code is the concatenation of the two (usernamepassword); for level 20, it is the archive file name of level 21)

Last update: 2008.02.26.

Latin Reverse Engineering

An Emacs Lisp utility that prints the possible interpretations of an inflected latin word. It only has a test database at the moment.

Download the source code or see the htmlized version.

Last update: 2008.02.18.

Fifteen Game Solver

The solution uses a simple backtrack algorithm and returns the best solution, using a user-defined upper limit.

Download the source code or see the htmlized version.

Last update: 2008.01.13.

Email Sender

I've found a Gtk dialog widget utility called "Zenity" a few days ago - this program is written in order to try its features in real use. Note that the SMTP server should be set in the script file.

Download the source code or see the htmlized version.

Last update: 2007.12.02.

GLUT Demos

C++ / GLUT implementation of Bézier curves, Aitken-Lagrange interpolation, B-spline curves and global B-spline curve interpolation.

Download the c++ source code. You can also download a Lisp version of the Bézier curve demo (with only the deCasteljau algorithm, and no popup menu), or see its htmlized version.

Last update: 2007.11.15.

Online TV GUI

This script only invokes MPlayer on a channel selected from a listbox. The list of channels can be configured in a file called channels, which contains a description, an equal sign and then the address of the clip (which may also be a local filename, of course). Done in a few minutes.

Download the source code or see the htmlized version.

Last update: 2007.11.11.

Triangle Strip

Tried my hand at Vtk programming. Just a GUI for viewing a triangle strip, that can be lengthened or shortened using a slider.

Download the source code or see the htmlized version.

Last update: 2007.10.10.

Movie Info

Reads a list of movie titles from the standard input and searches IMDB for details (director, actors, etc). The user can select the appropriate one from a list of titles, and write the data to the standard output. Written in Tcl/Tk.

Download the source code, see the htmlized version or see a screenshot.

Last update: 2007.10.01.

Revolving Door Problem

Imagine a door with four buttons placed simmetrically on a circular panel. You can push one or two buttons at once, but after you've pushed them, the panel revolves to some other position. Every button has an invisible counter attached to it, counting in a modulo n manner. The starting state is unknown, and the door only opens if all buttons have the same counter value. How do you open the door, if n = 2? n= 3? n = 4? This Lisp program answers this question.

Download the source code or see the htmlized version.

Last update: 2007.09.17.

Web Server Test

A first try at Hunchentoot & CL-WHO. This file is a translation of the code in Practical Common Lisp (chapter 26) that uses AllegroServe. It may be a good tutorial if I decide to do some web programming later on.

Download the source code or see the htmlized version.

Last update: 2007.07.16.

XiangQi

The program of "first attempts". First attempt at writing a chess program, first attempt at writing a pure C program, first attempt at using the SDL library, and last but not least, first attempt at using Guile. So the interface is written in C / SDL, while the rules are enforced using Scheme.

There is no artificial intelligence yet, only a random player, but it has all the tools to be extended easily. Since all further enhancements will probably be in Scheme, there is no need for recompilation. It even has a hotkey for reloading the AI Scheme file while running. See a screenshot.

Download the source code.

Last update: 2007.06.21.

Surreal Numbers

Basic operations on surreal numbers (as defined in J.H. Conway's "On Numbers and Games").

Download the source code or see the htmlized version.

Last update: 2007.06.15.

Filesystem Outline Generator

An Emacs Lisp function that generates an Org-mode buffer from the output of the UN*X "tree" command.

Download the source code or see the htmlized version.

Last update: 2007.06.12.

Lisp GUI Tests

Two GUI tests - only a little more complex, than Hello World - using the LTK and Cells-Gtk libraries.

Download the LTK and Cells-Gtk source code, see their htmlized version (LTK, Cells-Gtk) or see a screenshot of the two implementations.

Last update: 2007.05.31.

Meiji Cube

Solver algorithm for the Meiji Caramel Cube Puzzle: Given a cubic box with a side length of 4 units and block pieces of dimension 2x2x1 units, place n pieces in the box in a way that none of them can move. Possible values of n range from 12 to 15.

The program is written in Common Lisp. It finds all possible solutions (mirrored solutions are considered the same) and generates 3D output in VTK file format. Since it uses a pretty dumb algorithm, it is very slow (takes about 3 days to get all the solutions!), but at least it works.

Download the source code, see the htmlized version, download all the solutions in VTK format, or see a screenshot of a 15-piece solution.

Last update: 2007.05.21.

Show Math

Shows a PNG representation of the input LaTeX expression in a new Firefox tab. Useful when creating slides with a lot of equations. Written in Tcl/Tk.

Download the source code or see the htmlized version.

Last update: 2007.05.14.

Head-Tail

This is a solver algorithm for the four-letter game, where you have to find a route of sensible words between two four-letter words by changing one letter at a time. It is played in Hungarian with three phonemes.

Download the Hungarian dictionary, the English dictionary and the source code, or see the htmlized version.

Last update: 2007.04.16.

PostScript Images

Some recursive images generated in Common Lisp: Cantor dust, Koch curve and the Hilbert curve.

Download the source code, or see the htmlized version.

Last update: 2007.04.13.

Dictionary HTMLizer

This Emacs routine converts a CEDICT-style Chinese dictionary file to HTML, using real pinyin.

Download the source code, or see the htmlized version.

Last update: 2007.04.13.

Kanji / Hanzi Cards

Kanji Cards is a simple Tcl/Tk program that helps you memorize kanji. It requires no special font. The package also contains some utilities to convert Shift-JIS files into Kanji lists, and to generate study lists from kanji lists. kanji lists for JLPT4-2 are included as well.

Hanzi Cards is not unlike Kanji Cards, but it works on Chinese (simplified) hanzi, uses external fonts and the list files are in UTF-8 encoding. Its database is very small, but a more complete set is readily available in the CEDICT project.

Download the English version or the Hungarian version of Kanji Cards.

Download Windows binaries of the utilities for the English or the Hungarian version.

Download Hanzi Cards.

Last update: 2007.04.12.

Wubi Practice

The Wubi input method is a quite involved input method for simplified Chinese. While the most widespread pinyin-based approaches are easy to learn, Wubi has the advantage that every character has a (generally) unique, at most 4-digit code, so the user doesn't have to choose the character from a list. There are 4-digit codes for compounds of 2 or more characters, too. The codes are derived in a logical way from basic elements (roots) assigned to the keyboard keys. Wubi may also be better for southern speakers, whose pronounciation differs from the pinyin transcription.

This program has 6 practice modes: roots, 1-, 2-, 3- and 4-key characters and compounds. It measures the speed and accuracy of the learner. I'm not too good at GUI design, so it may have a minimalistic feel about it, but it's useful nonetheless. The program uses SDL and requires no fonts. See a screenshot.

Download the source code or the Windows binary.

Last update: 2007.03.31.

Continuo

My contribution to the Lisp programming contest of the International Lisp Conference 2007. It became 2nd both in speed and in points (in a very close fight with Vladimir Sedach's entry), with additional features like graphical output and head-to-head matches between four different algorithms. Too bad I couldn't attend the conference.

Download the source code or see the htmlized version.

Last update: 2007.03.31.

Pylos

A two-player version of the board game Pylos. Written in Tcl/Tk, no AI at all. See a screenshot.

Download the source code.

Last update: 2007.03.31.

SubTimer

Subtitle timing utility for Linux, written in C++ / Qt3. It can handle text, SubRip and SubStation Alpha files for both input and output, and Ogg files for audio input. It has an easy-to-use interface that enables fast timing. A Tcl/Tk utility is attached for converting MP3 files to Ogg.

SubTimer can also shift the times of a subtitle file, and copy / paste lines with the times changed in a logical way. See a screenshot.

Download from the SourceForge page.

Last update: 2007.03.31.

P-chan Window Climber

This Qt3 / X11 window climber has three positions: grabbing to the left or right side of a window and floating in the air. Unfortunately not all windows behave equally well with this, but GNU Emacs is a stable point for little P-chan :) See a screenshot.

Download the source code.

Last update: 2007.03.31.

Go Music

If Go was music, how would it sound?

This Emacs Lisp snippet is trying to answer this question. The pitch and length of each note is based on the move's position and its distance from the neighboring moves. Requires LilyPond 2.8.1 or greater.

Download the source code, see the htmlized version or listen to a sample.

Last update: 2007.03.31.

Sudoku

A simple Sudoku solver in Common Lisp.

Download the source code or see the htmlized version.

Last update: 2007.03.31.

Horse Animation

Common Lisp routines to generate the "moving greeting card effect", i.e. creating a picture by taking every Nth column in a series of N pictures, then moving a grid where only every Nth column is transparent, thus creating the illusion of a moving image.

Download the source code and the pictures, or see the htmlized version with the result pictures.

Last update: 2007.03.31.

GETTO

Bittorrent file harvester for TV series. Given a configuration file, containing a list of filename patterns and websites, checks if there is a new episode, and downloads the torrent files if there is. Written in Tcl/Tk.

Download the source code, see the htmlized version or see a screenshot.

Last update: 2007.03.31.

Rename

A Tcl/Tk GUI for regexp renaming files in the current directory.

Download the source code or see the htmlized version.

Last update: 2007.03.31.

Copyright (C) 2007-2024 Peter Salvi