Skip to content

Instantly share code, notes, and snippets.

View dallaylaen's full-sized avatar

Konstantin S. Uvarin dallaylaen

View GitHub Profile
#!/bin/sh
#
# Copyright (c) 2007 Andy Parkins
#
# An example hook script to mail out commit update information. This hook
# sends emails listing new revisions to the repository introduced by the
# change being reported. The rule is that (for branch updates) each commit
# will appear on one email and one email only.
#
# This hook is stored in the contrib/hooks directory. Your distribution
@dallaylaen
dallaylaen / password_trainer.pl
Created July 2, 2014 12:33
Learn you new, shiny, random password the hard way
#!/usr/bin/perl -w
use strict;
use Term::ReadKey;
END{ ReadMode(0) };
ReadMode('noecho');
$|=1;
# read password twice
@dallaylaen
dallaylaen / human_likes_comparator.pl
Created July 26, 2014 19:27
Sorting user's wishes in console
#!/usr/bin/env perl
use warnings;
use strict;
$| = 1;
my @data;
while (<>) {
/\S/ or next;
@dallaylaen
dallaylaen / gist:9d108de1d7c8826f3133
Created August 15, 2014 17:31
music tones: guess how many notes should be in one octave
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my $besterr = 1000;
foreach my $i ( 5..100 ) {
my ($err, $notes) = find_all( 2**(1/$i), qw(3/2 4/3 5/4 6/5 9/8) );
next if $err > 1.5*$besterr;
#!/usr/bin/env python
import cgi
class safe:
def __init__(this, text):
this.content = text
def __str__(this):
return safe.current_method(this)
def as_is(this):
@dallaylaen
dallaylaen / todo.t
Last active August 25, 2017 09:01
Make Perl module developer feel bad about untested code
#!/usr/bin/env perl
# This script tests nothing (except the fact that modules load w/o warnings).
# However, it tries to load them all.
# This means that untested modules would also be included into
# code coverage summary, lowering total coverage to its actual value.
# I.e. having a well-covered module and a totally uncovered one will result
# in 50% coverage which is probably closer to truth.
@dallaylaen
dallaylaen / mp3youtube.sh
Last active December 22, 2016 17:13
Convert audio file + cover image into youtubable video file with avconv (as ffmpeg has been removed from Ubuntu 14.04)
#!/bin/sh
PIC=$1
SND=$2
OUT=$3
if [ -z "$SND" ]; then
echo "Usage: $0 <image> <audio> [<video>]"
echo "Default for video is audio renamed to *.mp4"
exit 1
@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

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

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

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

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

                       a : M    b : M

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

#!/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": [