Skip to content

Instantly share code, notes, and snippets.

View antonmedv's full-sized avatar

Anton Medvedev antonmedv

View GitHub Profile
@antonmedv
antonmedv / ✔︎
Last active January 26, 2026 17:29
ʕっ•ᴥ•ʔっ I do have more than six projects!
@antonmedv
antonmedv / asciitree.js
Last active December 2, 2025 17:26
JavaScript function to print ASCII Tree
/**
* (c) 2014 Anton Medvedev
*
* SELECT_________________
* / \ \
* .___ FROM JOIN
* / \ | / \
* a city_name people address ON
* |
* =___________
@antonmedv
antonmedv / game-of-life.js
Created October 15, 2023 10:34
Game of Life in JavaScript
let
p = s => process.stdout.write(s),
esc = (...x) => x.map(i => p('\u001B[' + i)),
{columns, rows} = process.stdout,
[w, h] = [columns, rows * 2],
i = w * h,
s = Array(w * h).fill(false),
cx = Math.floor(w / 2) - 6, cy = Math.floor(h / 2) - 7,
seed = Date.now() % 3
@antonmedv
antonmedv / DotNotation.php
Last active August 11, 2022 13:47
Dot notation for access multidimensional arrays.
<?php
/**
* Dot notation for access multidimensional arrays.
*
* $dn = new DotNotation(['bar'=>['baz'=>['foo'=>true]]]);
*
* $value = $dn->get('bar.baz.foo'); // $value == true
*
* $dn->set('bar.baz.foo', false); // ['foo'=>false]
*
@antonmedv
antonmedv / ActiveRecord.php
Created October 22, 2017 07:43
Facade in Symfony
<?php
namespace AppBundle\Entity;
use AppBundle\DependencyInjection\Container;
class ActiveRecord extends Container
{
protected static function getDoctrine()
{
<?php
$c='
<?php
$c=\'%s\';
printf($c, addslashes($c));';
printf($c, addslashes($c));
@antonmedv
antonmedv / table.js
Created September 14, 2020 14:18
fx snippet for table output on JSON
global.table = (json) => {
let Table = require('cli-table3')
let table = new Table({head: Object.keys(json[0])});
table.push(...json.map(Object.values))
return table.toString()
}
@antonmedv
antonmedv / parser.go
Created September 23, 2018 13:39
Parser example (GoWayFest 2018)
package main
import (
"fmt"
"os"
"regexp"
"strings"
)
type token = string
@antonmedv
antonmedv / find.js
Created December 12, 2018 05:49
Search Snippet
global.find = re => json => [...find(json, re)]
function* find(v, regex, path = '') {
if (regex.test(path)) {
yield path
return
}
if (typeof v === 'undefined' || v === null) {
return
@antonmedv
antonmedv / Flyspeck.js
Last active November 26, 2019 07:01
Simple and Small Dependency Injection Container inspired by Pimple.
/*
* Flyspeck is Dependency Injection Container.
*
* Copyright (c) 2014 Anton Medvedev
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished