Skip to content

Instantly share code, notes, and snippets.

View shoorick's full-sized avatar
🔍
Looking for new job as backend of fullstack web developer

Alexander Sapozhnikov shoorick

🔍
Looking for new job as backend of fullstack web developer
View GitHub Profile
#!/usr/bin/perl
print STDERR "Press ^C to exit\n";
my $cmd_line = 'wc ' . join ' ', @ARGV;
my $out;
while (1) {
$out = `$cmd_line`;
chomp $out;
print "\cM$out";
sleep 1;
@shoorick
shoorick / compress_kate's_html.pl
Created May 11, 2010 18:04
Compressor for HTML generated by kate
#!/usr/bin/perl -pw
use strict;
s{#([[:xdigit:]])\1([[:xdigit:]])\2([[:xdigit:]])\3}{#$1$2$3}g;
s{<(b|i|em|strong)></\1>}{}gi;
s{</(b|i|em|strong)><\1>}{}gi;
@shoorick
shoorick / gpsout.pl
Created May 11, 2010 18:29
Print out GPS coordinates from images
#!/usr/bin/perl -wl
use strict;
=head1 DESCRIPTION
Print out GPS coordinates from images
=head1 AUTHOR
Alexander Sapozhnikov
@shoorick
shoorick / diff-colorizer
Created July 16, 2010 08:55
Diff colorizer
#!/usr/bin/perl -n
use Term::ANSIColor;
print colored( $_, 'red' ) and next if /^</;
print colored( $_, 'green' ) and next if /^>/;
print colored( $_, 'bold blue' ) and next if /^[\d,]+[acd][\d,]+$/;
print;
=head1 NAME
@shoorick
shoorick / README
Created December 11, 2010 14:44
Gettext example with Locale::TextDomain
Example if gettext usage via Locale::TextDomain
How to use:
0. cd po && make
1. ../example/1.pl
or
env LANGUAGE=ru ../example/1.pl
or
@shoorick
shoorick / 2_td.pl
Created December 13, 2010 09:15
Mojolicious::Lite with Mojolicious::Plugin::Textdomain example
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
$self->render(
'template' => 'index',
'count' => int rand 33,
);
@shoorick
shoorick / 3_td.pl
Created December 13, 2010 15:44
URL-driven language choosing example with Mojolicious::Lite and Mojolicious::Plugin::Textdomain
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
$self->render(
'template' => 'index',
'count' => int rand 33,
);
@shoorick
shoorick / MyApp-Model-DBI.pm
Created December 23, 2010 13:46
DBI model for Catalyst with UTF-8 support
package MyApp::Model::DBI;
use strict;
use warnings;
use base 'Catalyst::Model::DBI';
# skipped some configuration statements
__PACKAGE__->config(
'dsn' => 'dbi:mysql:' . $config->{'sql'}->{'database'} . ':' . $config->{'sql'}->{'host'},
@shoorick
shoorick / list-png-not-symlink
Created May 3, 2011 10:26
List regular PNG
@shoorick
shoorick / tab-separated-fields-as-pod-list.sh
Created August 19, 2011 05:35
Print field list from tab-separated file as POD-formatted list
head -n 1 tab-separated.txt \
| perl -na -F'\t' \
-e 'map { printf "=item %d\n\n%s / %s\n\n", $i++, chr(0x40+$i), $_ } @F '