Skip to content

Instantly share code, notes, and snippets.

View paveljurca's full-sized avatar
🎯
Focusing

Pavel paveljurca

🎯
Focusing
View GitHub Profile
@paveljurca
paveljurca / stopwatch.pl
Last active August 29, 2015 14:17
stopwatch test on the particular methods
#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw/time/;
use List::Util qw/reduce/;
###
# finding the max value and its key
# in an associative array
###
@paveljurca
paveljurca / server.pl
Last active October 11, 2015 17:41
HTTP::Server gone evil
package ServCGI;
########################
# NO security! #
# No sense! #
# quick and dirty #
########################
use HTTP::Server::Simple::CGI;
use base qw(HTTP::Server::Simple::CGI);
#!/usr/bin/perl
use 5.010_001;
say 'err' if !eval {
my $x = 3 / 0;
};
# !DANGEROUS! eval
use Test::More tests => 1;
use strict;
use warnings;
use Data::Types qw/:float/;
# module loaded
use_ok('Airport::Data');
# fixture
@paveljurca
paveljurca / csv_search.pl
Last active August 29, 2015 14:18
filter out CSV lines by the values in a specific column
#!/usr/bin/perl
use v5.10.1;
use strict;
use warnings;
use Text::CSV;
#use open qw(:std :utf8);
my $col_look_up = 'id'; #where to look
my @filter_out = ( #what to search
use strict;
use warnings;
use 5.010.1;
my $msg;
my $break = qr/^AMQ\d+/;
while (<DATA>) {
chomp;
if ($break .. $break) {
if (/($break)/) {
use v5.10;
use strict;
use warnings;
use open qw(:std :utf8);
# HTML source code
# grep 'fsl fwb fcb' -i facebook > facebook2
@ARGV = 'facebook2';
#
my @arr;
while (<>) {
use strict;
use warnings;
# Ctrl^Z to stop
for (<DATA>) {next unless /^http/i; open PAGE, "|less";print PAGE `w3m $_ -dump -cols 50`;}
__DATA__
# timeline
http://www.slate.com/articles/technology/cover_story/2017/03/twitter_s_timeline_algorithm_and_its_effect_on_us_explained.html
@paveljurca
paveljurca / gist:01543d2f53088d7afd59
Last active October 11, 2015 16:32
půjčit mlp.cz
#!/bin/bash
# EXAMPLE URL list to scrap
# echo 'http://search.mlp.cz/cz/titul/faunovo-odpoledne-a-jine-basne/56699/|http://search.mlp.cz/cz/titul/podivuhodne-pribehy-z-dob-nedavno-minulych/2750824/|http://search.mlp.cz/cz/titul/zpevy-pastyrske/2430570/|http://search.mlp.cz/cz/titul/kam-odchazis-kraso/2192687/|http://search.mlp.cz/cz/titul/plac-housli/2330679/|http://search.mlp.cz/cz/titul/rethinking-the-university/57801/|http://search.mlp.cz/cz/titul/zapisky-stareho-prasaka/2488292/' > seznam
# BEWARE!
# quick and dirty
# HTTP and I/O wasted
# actual web-scrapping
cat seznam | perl -nE '`wget -qO- $_ 2>/dev/null` =~ m!class="ignac"[^<]+<strong>([^<]+)!sm && say "$1<br>" for split /\|/' > autori.html