Skip to content

Instantly share code, notes, and snippets.

@valitnon
valitnon / spider.pl
Created April 19, 2020 14:00 — forked from dnmfarrell/spider.pl
Basic Perl spider using Selenium and headless Chrome
#!/usr/bin/env perl
use strict;
use warnings;
use HTTP::Tiny;
use Getopt::Long 'GetOptions';
use Encode qw(encode decode);
use Parallel::ForkManager;
use PerlIO::gzip;
use Selenium::Remote::Driver;
use Time::HiRes 'sleep';
@valitnon
valitnon / README.md
Created January 25, 2020 14:32 — forked from joyrexus/README.md
Perl one-liners

Hi:

perl -e 'print "hello world!\n"'

A simple filter:

perl -ne 'print if /REGEX/'

Filter out blank lines (in place):

@valitnon
valitnon / client.sh
Created October 13, 2019 03:17 — forked from leonklingele/client.sh
netcat – encrypt transfer with openssl
IP="127.0.0.1"
PORT="8877"
SHARED_SECRET="shared secret"
OPENSSL="/usr/local/opt/libressl/bin/openssl"
OPENSSL_CMD="$OPENSSL enc -a -A -aes-256-gcm"
while IFS= read -r MSG; do
echo "$MSG" | $OPENSSL_CMD -e -k "$SHARED_SECRET"
echo
@valitnon
valitnon / TrueColour.md
Created July 3, 2019 11:17 — forked from XVilka/TrueColour.md
True Colour (16 million colours) support in various terminal applications and terminals

Terminal Colors

There exists common confusion about terminal colors. This is what we have right now:

  • Plain ASCII
  • ANSI escape codes: 16 color codes with bold/italic and background
  • 256 color palette: 216 colors + 16 ANSI + 24 gray (colors are 24-bit)
  • 24-bit true color: "888" colors (aka 16 milion)
@valitnon
valitnon / mojo-app.pl
Created February 12, 2019 11:53 — forked from dex4er/mojo-app.pl
Mojolicious + PAR::Packer without --addfile
#!/usr/bin/env perl
use v5.10;
use strict;
use warnings;
use Mojolicious::Lite;
# Explicit use as a helper for PAR
@valitnon
valitnon / delayed-localStorage.user.js
Created January 9, 2019 20:43 — forked from sekrasoft/delayed-localStorage.user.js
Подменяет localStorage Storage-подобным объектом с сохранением данных в настоящем хранилище.
// ==UserScript==
// @name Отложенная запись в localStorage
// @include http://*/*
// @include https://*/*
// @version 1.0.0
// @grant none
// ==/UserScript==
(function(){
@valitnon
valitnon / window-controller.js
Created January 9, 2019 20:36 — forked from neilj/window-controller.js
Cross-tab window controller
function WindowController () {
this.id = Math.random();
this.isMaster = false;
this.others = {};
window.addEventListener( 'storage', this, false );
window.addEventListener( 'unload', this, false );
this.broadcast( 'hello' );
@valitnon
valitnon / mojo-crawler.pl
Created October 18, 2018 07:20 — forked from creaktive/mojo-crawler.pl
Simple web crawler/scraper implemented using Mojolicious
#!/usr/bin/env perl
use 5.010;
use open qw(:locale);
use strict;
use utf8;
use warnings qw(all);
use Mojo::UserAgent;
# FIFO queue
@valitnon
valitnon / gist:b7fbb1ae26e63befa892c6752524e534
Created October 14, 2018 22:35 — forked from brianmed/gist:8983255
Non-blocking commands with Mojolicious::Lite
use Mojolicious::Lite;
use File::Temp qw(tempfile);
use Proc::Background;
use Fcntl qw(SEEK_SET);
use IO::Handle;
any '/run' => sub {
my $self = shift;
#!/usr/bin/env perl
use Mojolicious::Lite;
use Mango;
use Mango::BSON 'bson_oid';
helper mango => sub { state $mango = Mango->new($ENV{PASTEDB}) };
helper pastes => sub { shift->mango->db->collection('pastes') };
get '/' => 'submit';