Skip to content

Instantly share code, notes, and snippets.

View olegwtf's full-sized avatar

Oleg olegwtf

  • reg.ru
  • Russia, Novosibirsk
View GitHub Profile
@olegwtf
olegwtf / pgolf.pl
Created April 17, 2012 17:38
Perl Golf
$i++%50||++$j&mkdir($f="folder$j")&($i=1),rename$_,"$f/$i"for<*>
@olegwtf
olegwtf / gmail-rm.pl
Created February 25, 2019 10:49
Script to remove messages by label from gmail via IMAP
use strict;
use warnings;
use Net::IMAP::Simple;
use constant {
LOGIN => 'xxx@gmail.com',
PASSWORD => '123',
MAILBOX => 'Label', # folder to delete from, some label may be used here
TRASH => '[Gmail]/&BBoEPgRABDcEOAQ9BDA-', # trash folder name for ru users, should be '[Gmail]/Trash' for en
};
# image at the center of the video
# https://stackoverflow.com/questions/10918907/how-to-add-transparent-watermark-in-center-of-a-video-with-ffmpeg
ffmpeg -i small.mp4 -i avatar.png -filter_complex "overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -codec:a copy output.mp4
# with transparency
# https://stackoverflow.com/questions/38753739/ffmpeg-overlay-a-png-image-on-a-video-with-custom-transparency
ffmpeg -i small.mp4 -i avatar.png -filter_complex "[1:v]format=argb,colorchannelmixer=aa=0.5[zork];[0:v][zork]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -codec:a copy output.mp4
# text
# https://stackoverflow.com/questions/17623676/text-on-video-ffmpeg
@olegwtf
olegwtf / gist:c9c5a266352cba73dc5b
Last active January 20, 2018 09:58
Mojo::UserAgent progress bar
BEGIN { $ENV{MOJO_MAX_MESSAGE_SIZE} = 1024**3 }
use strict;
use Mojo::UserAgent;
$| = 1;
my $ua = Mojo::UserAgent->new;
$ua->on(start => sub {
my ($ua, $tx) = @_;
@olegwtf
olegwtf / mojolicious_fork.pl
Created March 19, 2012 06:05
Mojolicious fork
use Mojolicious::Lite;
use POSIX;
get '/' => sub {
my $child = fork();
unless (defined $child) {
die "fork(): $!";
}
elsif ($child == 0) {
package ScriptLock;
use strict;
use FindBin;
use Fcntl ':flock';
my $fh;
sub import {
return if $fh;
use strict;
package JUNOS::Config::Parser;
sub new {
my ($class, %cb) = @_;
bless \%cb, $class;
}
sub parse {
@olegwtf
olegwtf / gist:7734836
Last active December 29, 2015 22:09
Coro based socks server through another socks server
use strict;
use Coro::PatchSet 0.04;
BEGIN {
package IO::Select;
use Coro::Select;
use IO::Select;
}
use IO::Socket::Socks qw(:constants :DEFAULT);
use Coro;
use Coro::Socket;
@olegwtf
olegwtf / gist:7478457
Created November 15, 2013 03:05
Mojolicious and AnyEvent
use strict;
use Mojo::Reactor::EV;
use v5.10;
BEGIN {
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::EV';
$ENV{MOJO_IOLOOP_DEBUG} = 1;
}
use Mojo::IOLoop;
use Mojo::UserAgent;
use AnyEvent::HTTP;
@olegwtf
olegwtf / gist:7464791
Last active December 28, 2015 07:29
Mojolicious & IO::Async
use strict;
use v5.10;
BEGIN {
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
$ENV{MOJO_IOLOOP_DEBUG} = 1;
}
use Mojo::IOLoop;
use Mojo::UserAgent;
use Net::Async::HTTP;
use URI;