Skip to content

Instantly share code, notes, and snippets.

View sharifulin's full-sized avatar

Anatoly Sharifulin sharifulin

View GitHub Profile
MOJO_MAX_REDIRECTS=0 perl -Mojo -E 'say h(shift)->headers->location' http://yandex.ru
@sharifulin
sharifulin / gist:3852390
Created October 8, 2012 13:00
Applifto Smart Banners code for any site
<!-- Applifto Smart Banners code, insert after <body> -->
<script type="text/javascript" src="http://www.applifto.ru/info/smart-banners.js"></script>
<!-- Baby DJ Smart Banners code, insert after <body> -->
<script type="text/javascript" src="http://www.applifto.ru/info/smart-banners.js?name=babydj"></script>
@sharifulin
sharifulin / gist:3828619
Created October 3, 2012 17:57
Smart Banners and etc metas are rocks!
perl -Mojo -E 'say g(shift, {"User-Agent" => "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25"})->dom->find("meta")' \
https://mobile.twitter.com/sharifulin
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="app-id=333903271, app-argument=twitter://user?screen_name=sharifulin, affiliate-data=partnerId=30&amp;siteID=UkOLawSuc90" name="apple-itunes-app" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" id="viewport" name="viewport" />
#!/usr/bin/env perl
use common::sense;
use lib qw(../.. /tk/lib /tk/mojo2/lib);
use ojo;
use Util;
use Unicode::Normalize 'NFD';
use Data::Dumper;
my $conf = {
$list = [
grep {
my $what;
$what->{retweet} = !!$_->{retweeted_status};
$what->{reply } = !!$_->{in_reply_to_user_id_str};
$what->{tweet } = !$what->{retweet} && !$what->{reply};
warn qq(It's tweet "$what->{tweet}", reply "$what->{reply}", retweet "$what->{retweet}": $_->{text}\n);
my $yes;
@sharifulin
sharifulin / gist:1789638
Created February 10, 2012 13:21
Mojo::DOM bug
#!/usr/bin/env perl
use strict;
use lib 'lib';
use Mojo::DOM;
use Test::More tests => 9;
my $dom = Mojo::DOM->new('<div> <ul> <li> Text <ul> <li>abc </li>def </ul> </li> </ul> </div>');
my $find;
use Mojolicious::Lite;
get '/tasks' => sub {
my $self = shift;
$self->stash(
tasks => [
map { [ split /\s+/ ] }
split /\n/, qx(ps axh -o comm,stat,\%cpu,nice,pid,rss,user)
]
@sharifulin
sharifulin / lj2posterous.pl
Created August 8, 2011 10:00
Export LJ posts to Posterous through API using Mojolicious
#!/usr/bin/env perl
use common::sense;
# BEGIN { $ENV{MOJO_USERAGENT_DEBUG}++ };
use Mojo::IOLoop;
use Mojo::UserAgent;
use Mojo::Util 'b64_encode';
use MongoDB;
@sharifulin
sharifulin / lj_export.pl
Created August 8, 2011 09:51
Export LJ posts to MongoDB using Mojolicious
#!/usr/bin/env perl
use common::sense;
use Mojo::IOLoop;
use Mojo::UserAgent;
use MongoDB;
use Data::Dumper;
my $ua = Mojo::UserAgent->new;
@sharifulin
sharifulin / gist:1130735
Created August 7, 2011 20:10
Mojolicious Daemon
# сходу написал так, но завелось только на 3000 (дефолтном порту)
app->start('daemon', '--listen http://*:5000');
# затем так
app->start('daemon', listen => 'http://*:5000');
# посмотрел Mojo::Server::Daemon
app->start('daemon', listen => ['http://*:5000']);
# и даже так попробовал