Skip to content

Instantly share code, notes, and snippets.

View astynax's full-sized avatar

Aleksei Pirogov astynax

View GitHub Profile
@astynax
astynax / 2019-09-17-carpet.rkt
Created September 17, 2018 19:19
Carpet-like pattern
#lang racket
(require 2htdp/image)
(define (->color c)
(cond [(= c 0) 'indigo]
[(= c 1) 'palevioletred]
[(= c 2) 'moccasin]
[else 'white]))
(define (next-c c) (modulo (+ 1 c) 4))
@astynax
astynax / world.rkt
Created September 26, 2018 10:17
Small world that I made using Racket, 2htdp/planetcute (that uses "Planet Cute" tiles).
#lang racket
(require 2htdp/image)
(require 2htdp/planetcute)
(define world
'((" k"
"T r ,"
",,, t,."
"... ,,.."
"... ...."
{-# LANGUAGE FlexibleContexts #-}
module Main where
import Control.Monad
import Control.Monad.State
import Data.Set
main :: IO ()
main = print $ solution (1, 1) == allBoard
@astynax
astynax / README.md
Last active October 13, 2019 13:44
Simple stack based machine with two stacks.

This machine uses two stacks: for data and for commands.

Each command can extend any of stacks.

Also the language provides a fold function that uses command stack manipulations for recursion.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@astynax
astynax / patterns.lhs
Created June 19, 2020 11:35
Text pattern generating language (make an TUI/CLI app someday).
> mirror = map reverse
> flip = reverse
> beside x = zipWith (++) x x
> above x = x ++ x
> beside = zipWith (++)
> above = (++)
> sq x = let y = mirror x in above (beside x y) (beside y x)
> display $ enlarge $ enlarge $ sq [" a", "b "]
aaaaaaaa
aaaaaaaa
@astynax
astynax / BF.hs
Created July 19, 2021 18:28
A stupid simple BF interpreter
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
module Main where
import Data.Char
import Text.Parsec
import Text.Parsec.String
data Machine = Machine ![Int] !Int ![Int] deriving Show
@astynax
astynax / Basic.kt
Last active November 15, 2021 21:51
Made just for fun the BASIC-like DSL in Kotlin
class Basic {
data class Var(val name: String)
class Let {
infix fun BE(value: Any): Binding = TODO()
}
class Binding {
infix fun MOD(other: Any): Binding = TODO()
}
@astynax
astynax / aiohttp_with_continuations.py
Created May 8, 2024 12:05
An example of stateful handler with geberator based continuations.
import uuid
from aiohttp import web
CONTS = {}
async def handle(request: web.Request) -> web.Response:
k = request.query.get("cont")
@astynax
astynax / Babashka_Scittle_Fullstack.md
Last active October 4, 2024 18:10
Babashka, Scittle, Fullstack!

Для запуска нужна только Babashka!

Установите, передайте .clj-файл в качестве аргумента (bb main.clj).

Когда сервер запустится, откройте http://localhost:8000 в браузере. Приложение работает!