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 / 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
package ScriptLock;
use strict;
use FindBin;
use Fcntl ':flock';
my $fh;
sub import {
return if $fh;
@olegwtf
olegwtf / gist:baef2307ca788fb3b67e
Created November 5, 2015 19:01
phantomjs 2.0 cookies file
[General]
cookies="@Variant(\0\0\0\x7f\0\0\0\x16QList<QNetworkCookie>\0\0\0\0\x1\0\0\0R\0\0\0Pproselytize=1; expires=Thu, 20-Jul-2017 23:55:55 GMT; domain=.rambler.ru; path=/\0\0\0sdv=gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA:1446749791; expires=Thu, 31-Dec-2037 23:55:55 GMT; domain=www.rambler.ru; path=/\0\0\0qdvr=gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA:1446749791; expires=Thu, 31-Dec-2037 23:55:55 GMT; domain=.rambler.ru; path=/\0\0\0Slv=1446749791; expires=Thu, 31-Dec-2037 23:55:55 GMT; domain=www.rambler.ru; path=/\0\0\0Qlvr=1446749791; expires=Thu, 31-Dec-2037 23:55:55 GMT; domain=.rambler.ru; path=/\0\0\0`ruid=AQAAAF+mO1bL2cucAaRzAQB=; expires=Thu, 31-Dec-2037 23:55:55 GMT; domain=.rambler.ru; path=/\0\0\0^_ym_uid=1446749756746775785; expires=Tue, 03-May-2016 18:55:56 GMT; domain=.rambler.ru; path=/\0\0\0_yandexuid=1324906701446749792; expires=Sun, 02-Nov-2025 18:56:32 GMT; domain=.yandex.ru; path=/\0\0\0\x38yabs-sid=874183021446749792; domain=mc.yandex.ru; path=/\0\0\0\x82__cfduid=d34a4990c9b7e37763b27835bb89eca34144674
use strict;
use IO::Socket;
my $serv = IO::Socket::INET->new(Listen => 10, LocalPort => 8080)
or die $@;
my $header = join(
"\r\n",
"HTTP/1.1 200 OK",
"Server: nginx/1.0.4",
@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) = @_;
diff --git a/lib/Mojo/Server/Prefork.pm b/lib/Mojo/Server/Prefork.pm
index 1052111..96c33f5 100644
--- a/lib/Mojo/Server/Prefork.pm
+++ b/lib/Mojo/Server/Prefork.pm
@@ -78,8 +78,12 @@ sub run {
local $SIG{INT} = local $SIG{TERM} = sub { $self->_term };
local $SIG{CHLD} = sub {
while ((my $pid = waitpid -1, WNOHANG) > 0) {
- $self->app->log->debug("Worker $pid stopped.")
- if delete $self->emit(reap => $pid)->{pool}{$pid};
@olegwtf
olegwtf / gist:f1aa01e5e33f2c49bbc5
Created January 20, 2015 12:16
sharepoint: get folder items
CamlQuery camlQuery = new CamlQuery();
camlQuery.FolderServerRelativeUrl = cFolder.ServerRelativeUrl;
List list = ctx.Web.Lists.GetById(listGuid);
ctx.Load(list);
ctx.ExecuteQuery();
var items = list.GetItems(camlQuery);
ctx.Load(items);
ctx.ExecuteQuery();
foreach (ListItem i in items)
@olegwtf
olegwtf / gist:ebfc9dcadb98eafe2216
Created December 16, 2014 10:45
IO::Socket::IP bug
use strict;
use IO::Socket::IP;
use Socket 'IPPROTO_TCP';
use IO::Select;
my ($err, @res) = Socket::getaddrinfo("www.google.com", 80, {protocol => IPPROTO_TCP});
die $err if $err;
my $ip = IO::Socket::IP->new(Blocking => 0, PeerAddrInfo => \@res) or die $@;
my $sel = IO::Select->new($ip);
use strict;
use blib;
use Net::DNS_A;
for (1..10_000) {
Net::DNS_A::lookup("localhost");
}
sleep;