Skip to content

Instantly share code, notes, and snippets.

View cynovg's full-sized avatar

Novgorodcev Cyrill cynovg

View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
use AnyEvent::HTTP::LWP::UserAgent;
use Data::Dump;
use Time::HiRes;
STDOUT->autoflush;
#!/usr/bin/env perl
use Modern::Perl;
my @natural = separator(10_000_000);
say scalar @natural;
sub separator {
my $number = shift;
my %hash = map { $_ => 1 } 1..$number;
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use DBI;
use Digest::SHA qw/sha1/;
use Data::Dump;
Tracking memory leaks:
Devel::Arena - sv_stats() returns arena structures used for SV allocation
* Devel::Cycle - find_cycle($ref) returns all cycles found in $ref and the perl variables they point to
Devel::Gladiator - walk Perl variable arena
Devel::Leak - deprecated by Devel::LeakTrace::Fast
Devel::LeakTrace - deprecated by Devel::LeakTrace::Fast
* Devel::LeakTrace::Fast - prints leaked SV's and line numbers at END.
Data::Structure::Util - has_circular_ref($ref) returns ref to link in $ref that is circular or false.
Test::LeakTrace - no_leaks_ok(), etc.
@cynovg
cynovg / .perltidyrc
Created July 26, 2017 07:07 — forked from francismhw/.perltidyrc
Perl Best Practices .perltidyrc Perl::Tidy
# PBP .perltidyrc file
-l=78 # Max line width is 78 cols
-i=4 # Indent level is 4 cols
-ci=4 # Continuation indent is 4 cols
-st # Output to STDOUT
-se # Errors to STDERR
-vt=2 # Maximal vertical tightness
-cti=0 # No extra indentation for closing brackets
-pt=1 # Medium parenthesis tightness
#!/usr/bin/env perl
#===============================================================================
use Modern::Perl '2015';
use utf8;
use Benchmark qw(:all);
my @array = sort { $a <=> $b } ( 1 .. 10_000 );
my @numbers = ( -1, 0, 1, 5, 500, 5000, 10_000, 11_000 );
package MyApp::Accessor;
sub new {
my $class = shift;
my $self = {};
bless $self, $class;
$self->_init(@_) if @_;
#!/usr/bin/env perl
use Modern::Perl '2015';
use utf8;
use Carp qw/confess/;
use IO::Socket::IP;
use URI;
my $host = 'www.perlmonks.org';
#!/usr/bin/env perl
use Modern::Perl '2015';
use utf8;
use Carp qw/confess/;
use URI;
use IO::Socket::IP;
use IO::Poll qw/POLLIN POLLOUT POLLERR POLLHUP/;
use Errno qw/EWOULDBLOCK/;