Skip to content

Instantly share code, notes, and snippets.

View dallaylaen's full-sized avatar

Konstantin S. Uvarin dallaylaen

View GitHub Profile
@dallaylaen
dallaylaen / date.pl
Last active August 27, 2019 17:05 — forked from Ovid/date.pl
Partial desription of a date matching regex yyyy-mm-dd
#!/usr/bin/env perl
use strict;
use warnings;
use Test::Most;
my %days = (
28 => qr/0[1-9]|1[0-9]|2[0-8]/,
29 => qr/0[1-9]|[12][0-9]/,
30 => qr/0[1-9]|[12][0-9]|30/,
@dallaylaen
dallaylaen / nested-try-return-destroy.t
Created July 31, 2018 08:42
Syntax::Keyword::Try bug: DESTROY via return in a nested try block wreaks havoc on the outer try block
#!/usr/bin/env perl
=head1 DESCRIPTION
Executing a DESTROY block while returning from a nested try block has weird side effect
on the outer try block.
This may seem like a weird & unreachable case, but actually every Moo[se] module
has nonempty destructor.
@dallaylaen
dallaylaen / foo.pl
Created June 27, 2018 13:47
require a script w/o side effects
#!perl
use strict;
use warnings;
return 1 if caller; # before parsing args, output, input etc
print foo(); # side effect!
sub foo {
@dallaylaen
dallaylaen / gist:4ad939aed806153fd05368dcbb2b8b34
Created June 14, 2018 09:54
Assert::Refute - a unified testing and assertion tool (preview)
Unit tests are great. They show that the code was actually designed
to a given spec.
[Runtime](https://metacpan.org/pod/PerlX::Assert) [assertions](https://metacpan.org/pod/Devel::Assert)
are great. They show that the code is actually running the way it
was designed when applied to real data.
[Design by contract](https://metacpan.org/pod/Class::Contract) is
a great concept, but it's a bit of an overkill for most projects.
@dallaylaen
dallaylaen / nyt.pm
Last active February 5, 2023 11:13
Nytprof for PSGI code
package nyt;
use strict;
use warnings;
=head1 NAME
nyt - Decorate existing code with Devel::NYTProf (for PSGI)
=head1 SYNOPSIS
@dallaylaen
dallaylaen / ruslat.pl
Last active September 28, 2017 15:55
Decode russian words entered in wrong layout
#!/usr/bin/perl
# If you use `xbindkeys` + `xsel`, here's how to make use of this script
# (it should be chmod +x and in your path, obviously)
#
# "xsel -o | ruslat.pl | xsel -i"
# Mod4 + q
#
# This maps the Super key (aka Win) + Q to this script and transcodes
# text in the clipboard
class Contract {
var log: List[Pair[Int,String]] = List()
var count = 0
var failed: List[Int] = List()
var lock = false
// MUTATORS
def refute( cond: Option[Any], message: String ): Boolean = {
modif
count += 1
#!/bin/sh
getmod () {
curl -A "curl; used by https://metacpan.org/author/KHEDIN" \
-XPOST https://fastapi.metacpan.org/v1/release/_search -d '{
"size": 5000,
"fields": [ "author", "name" ],
"filter": {
"and": [

§ Введение в зависимо-типизированные алгебры

§§ Обыкновенные и матричные алгебры

Алгебры описываются в терминах грамматики и отношений взаимозаменяемости. В обыкновенных алгебрах (таких как моноид, группа, решётка, кольцо, поле) мы выделяем ровно один тип грамматических сущностей, но вообще говоря типов может быть много (напр. Существительное, Прилагательное, Глагол).

Чтобы ознакомиться с обозначениями, рассмотрим к примеру определение моноида:

                       a : M    b : M

–———– ——————— ————————————————

@dallaylaen
dallaylaen / new.pm
Last active December 25, 2016 09:38
A funny module to abbreviate perl one-liners
package new;
use strict;
use warnings;
our $VERSION = 0.01;
=head1 NAME
new - shortens require Foo; Foo->new(...) to just one call