Skip to content

Instantly share code, notes, and snippets.

View skaurus's full-sized avatar

Dmitry Shalashov skaurus

View GitHub Profile
@skaurus
skaurus / dockerflix_dns_proxy.rsc
Last active July 18, 2023 18:20
Setup trick77 dockerflix DNS Proxy on MikroTik RouterOS
# Setup https://github.com/trick77/dockerflix on Mikrotik router
:global portallerHosts " \
ipinfo.io, \
hulu.com, \
netflix.com, \
netflix.net, \
mtv.com, \
mtvnservices.com, \
optimizely.com, \
Controller::method {
my $promise = Utils::get_me_promise;
return $promise->then(sub ($inner_promise) {
say 'method outer resolved';
return $inner_promise->then(sub ($something) {
say 'method inner resolved';
render $something;
}, sub {
log_error
}
#!/usr/local/bin/perl
package TestApp;
use Mojolicious::Lite;
use Mojo::Promise;
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new;
#!/usr/local/bin/perl
use 5.026;
use warnings;
use FindBin qw/$RealBin/;
use lib $RealBin . '/../local/lib/perl5', $RealBin . '/../lib';
use Benchmark;
use LWP::Curl;
@skaurus
skaurus / gist:474d55c28e62d150b939eb21b1466b81
Created June 3, 2016 16:53 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
@skaurus
skaurus / hls-fetch-all.pl
Last active April 6, 2016 14:33
Simple perl one-liner to fetch entire HLS stream given master playlist URL
# all files will be fetched to current directory.
# dependencies - curl somewhere in $PATH and URI perl library.
perl -e 'use URI; my $m3u_url = shift or die "provide hls playlist url"; sub get { my $path = shift; my $rel = URI->new($path)->rel($m3u_url); `curl $path --progress-bar --create-dirs -o $rel` // die "getting $path failed!"; return $rel }; sub parse_pls { my ($file, $abs) = @_; open(my $fh, $file); return map { chomp; URI->new_abs($_, $abs) } grep { $_ !~ /^#/ } <$fh> }; my $file = get $m3u_url; my @urls = parse_pls($file, $m3u_url); my %loop; while (my $url = shift @urls) { die "loop detected!" if $loop{$url}++; my $file = get $url; push @urls, parse_pls($file, $url) if ($file =~ /\.m3u8$/) }' 'http://www.streambox.fr/playlists/x36xhzz/x36xhzz.m3u8'
# From a fresh install of squeeze
aptitude install ruby rubygems # Need ruby to use fpm
gem1.8 install fpm --no-ri --no-rdoc
aptitude install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p385.tar.gz
tar -zxvf ruby-1.9.3-p385.tar.gz
cd ruby-1.9.3-p385
rm -rf /tmp/ruby193
@skaurus
skaurus / mojo_ev_test.pl
Created October 16, 2011 14:52
Mojo/EV bug part 2
#!/usr/local/bin/perl
use 5.012;
BEGIN { $ENV{MOJO_POLL} = 0; };
use Mojolicious::Lite;
use AnyEvent::HTTP;
@skaurus
skaurus / gist:1290970
Created October 16, 2011 14:50
Mojo/EV bug part 1
Run server as:
./mojo_ev_test.pl daemon --listen http://localhost:4242 --clients 1
Send requests as:
perl -Mstrict -MAnyEvent::HTTP -MData::Dumper -e 'my $cv = AnyEvent->condvar; http_post("http://localhost:4242/hitme", "", timeout => 10, persistent => 0, sub { my ($b, $h) = @_; warn Dumper $h; $cv->send() }); $cv->recv;'
First request dumps headers fine, consequent requests timeouts.
@skaurus
skaurus / anyevent-proxy.pl
Created September 8, 2011 09:30
AnyEvent HTTP Proxy
#!/usr/bin/perl
# This is HTTP proxy built atop AnyEvent::HTTPD and AnyEvent::HTTP modules.
# I used it to solve some problem but after testing realised that it doesn't solve it entirely.
# So I removed special logic and leave almost plain proxy. With referer forging however :)
#
# Test thoroughly before use!
use strict;
use warnings;