TeamStation AI System Report LATAM IT Salaries 2024
Exploiting the newer perl to improve your plugins
1.
1H.com
1H.com
Exploiting the Newer Perl
to Improve Your Plugins
Marian Marinov - mm@1h.com
Co-founder & CEO of 1H Ltd.
2.
3.
$ $$ $$$ $$ $
If you rate my survey, I'll hook you up with $20 cPCache $$$.
Go to this address to take the survey:
http://go.cpanel.net/b27
and come up to the podium once you've completed it.
4.
5.
cPanel plug-ins with jQuery
#!/usr/bin/perl -w
use strict;
use JQuery::Demo;
use JQuery::CSS;
use CGI;
package main;
my $tester = new JQuery::Demo;
$tester->run;
package JQuery::Demo;
use JQuery::Tabs;
6.
cPanel plug-ins with jQuery
sub start {
my $my = shift;
my $q = new CGI;
$my->{info}{TITLE} = "Tabs";
my $jquery = $my->{jquery};
my @tabs = ("tab 1","tab 2","tab 3","tab 4");
my @texts = ("line 1","line 2","line 3","line4");
7.
cPanel plug-ins with jQuery
my $tab = JQuery::Tabs->new(id => 'myTab',
addToJQuery => $jquery,
tabs => tabs,
remote => 'true',
remoteProgram => 'jquery_tabs_results.pl',
rm => 'myMode',
spinner => 1 );
my $html = $tab->HTML;
$my->{info}{BODY} = qq[<h1>START OF TAB EXAMPLE</h1>$html</div>END OF EXAMPLE</h1>];
}
10.
JavaScript::Packer
#!/usr/bin/perl -w
use strict;
use JavaScript::Packer;
my $packer = JavaScript::Packer->init();
open( UNCOMPRESSED, 'uncompressed.js' );
open( COMPRESSED, '>compressed.js' );
my $js = join( '', <UNCOMPRESSED> );
$packer->minify( js, { compress => 'best' });
print COMPRESSED $js;
close(UNCOMPRESSED);
close(COMPRESSED);
11.
12.
Example with JSON
#!/usr/bin/perl -w
use strict;
use JSON::XS;
my %res = ( 'a' => 'line1', 'b' => 'line2' );
my $json = JSON::XS->new->ascii->pretty->allow_nonref;
print $json->encode(res);
$ ./json-ex.pl
{"a":"line1","b":"line2"}
13.
14.
15.
16.
Gearman client
#!/usr/bin/perl -w
use strict;
use Gearman::Client;
my $client = Gearman::Client->new;
$client->job_servers('127.0.0.1:4730');
$str = "my client has called";
eval {
local $SIG{ALRM} = sub { die 'timeout'; };
alarm(3);
$client->dispatch_background('log_me', $str);
alarm(0);
};
17.
Gearman worker
#!/usr/bin/perl -w
use strict;
use Gearman::Worker;
use POSIX qw(strftime);
$logfile = '/home/hackman/test.log';
open LOG, '>>', $logfile;
select((select(LOG), $| = 1)[0]);
my $logger = sub { ... };
my $w = Gearman::Worker->new;
$w->job_servers('127.0.0.1:4730');
$w->register_function( log_me => $logger );
$w->work while 1;
18.
Gearman setup
# make && make install
# gearmand -d -u gearman -p 4730
# gearman_status.pl
function name queue exec worker
log_me 1 1 1
check_oneh 0 0 1
gather_child 154 72 72
19.
RabbitMQ architecture
RabbitMQ
Queue
Exchange
Server
Server
Queue
Server
29.
Thank you
Please visit us at Booth 23
Marian Marinov - mm@1h.com
Co-founder & CIO at 1H Ltd.
1H.com
1H.com
30.
$ $$ $$$ $$ $
If you rate my survey, I'll hook you up with $20 cPCache $$$.
Go to this address to take the survey:
http://go.cpanel.net/b27
and come up to the podium once you've completed it.
Editor's Notes
\n \n \n \n \n \n
\n \n \n \n \n
\n \n \n \n \n
\n \n \n \n \n
\n \n \n \n \n \n
\n \n \n \n \n @tabs – name of the tabs \n @texts – tabs contents \n \n \n
\n \n \n \n \n header - start of tab example \n footer – end of tab example \n combine this with HTML::Template or Template::Toolkit \n \n \n
\n \n \n \n \n
\n \n \n \n \n
\n \n \n \n \n
\n \n \n \n \n
\n \n \n \n \n
\n \n \n \n \n
\n \n \n \n Who is using gearman: \n LiveJurnal \n Booking.com \n \n Who is using RabbitMQ: \n JPMorgan \n Goldman Sachs \n Cisco \n Novell \n Microsoft \n RedHat \n \n \n \n
\n \n \n \n Premature optimizations are infecting all of us \n \n Wrongly implemented algorithms or usage of things like for/foreach when you can use while are clear performance hogs. \n \n \n