Skip to content

Instantly share code, notes, and snippets.

View cfedde's full-sized avatar

Chris Fedde cfedde

  • Loud Noise System Services
View GitHub Profile
@cfedde
cfedde / mount
Created April 2, 2014 21:19
mojo app mount multiplexer
#!/usr/bin/env perl
use Mojolicious::Lite;
#my $basedir = "/home/cfedde/src/";
my $basedir = "/var/www/mojo/";
plugin 'Config';
plugin Mount => ( '/lrn' => "$basedir/lrn_perl_webservice/lrn_query" );
@cfedde
cfedde / gist:9810663
Created March 27, 2014 15:49
The while loop is very slow. What am I doing wrong?
#!/usr/bin/env perl
use Modern::Perl;
use BCV::DB;
use Search::Elasticsearch;
use JSON;
my $DB = BCV::DB->new($ENV{BOOTLOGDB}//'BCVcore');
my $e = Search::Elasticsearch->new( nodes => 'bcvdb02:9200' );
my $index = 'crfbootlogdata';
#!/usr/bin/env perl
use Modern::Perl;
use YAML;
my $line = "08/15/2013, 15:58:47: (1234-567890) Changes made: Service end changed to 9999-12-31 (was 2013-10-12), Payment end changed to 9999-12-31 (was 2013-09-15), Renewal changed to 2013-09-12 (was 9999-12-31), srvid#=33324 modified by: Someguy Testuser (TST)";
my $re = qr|(?x)
(?<date> \d+/\d+/\d+),\s+
(?<time> \d+:\d+:\d+):\s+
\( (?<acct> \d+-\d+) \) \s+
#!/opt/bcv/bin/perl
use Mojolicious::Lite;
plugin 'basic_auth';
get '/' => sub {
my $self = shift;
return $self->render_text('ok')
if $self->basic_auth(
@cfedde
cfedde / gist:8446186
Created January 15, 2014 22:40
Should I expect this XML::Complle::WSDL11 to work?
#!/opt/bcv/bin/perl
use Modern::Perl;
use XML::Compile::WSDL11; # use WSDL version 1.1
use XML::Compile::SOAP12;
system 'wget -O - http://www.webservicex.com/globalweather.asmx?WSDL > globalweather.wsdl';
my $wsdl = XML::Compile::WSDL11->new('globalweather.wsdl');
say for ($wsdl->operations());
#!perl
use Modern::Perl;
use YAML;
local $/;
my %hash = <DATA> =~ /(\w+)\s=\s(\w+)/g;
say Dump \%hash;
__END__
this = that
some = stuff
@cfedde
cfedde / gist:7394148
Created November 10, 2013 05:21
flocking the data handle.
use Fcntl ':flock'; # import LOCK_* constants
unless ( flock DATA, LOCK_EX | LOCK_NB ) {
print STDERR "Found duplicate script run. Stopping\n";
exit(0);
}
...
__DATA__
@cfedde
cfedde / gist:7266511
Last active December 27, 2015 04:19
How can I think about making this kind of query faster?
explain analyze
select to_char(count(bucket)/60.00, '999.99') as cps,
max(max_loss) as max_loss, bucket from summary_5_minute_device_sn
group by bucket
order by bucket;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------
Sort (cost=2063766.71..2063793.82 rows=10844 width=12) (actual time=31076.144..31079.901 rows=24264 loops=1)
@cfedde
cfedde / play.cgi
Created October 29, 2013 20:04
For CosmoSRO
#!/opt/me/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Data::Dumper;
print "Content-Type: text/html\n\n";
@cfedde
cfedde / gist:7093272
Created October 22, 2013 00:27
Not sure what went wrong
$ git clone [email protected]:ingydotnet/example-bash.git
Cloning into 'example-bash'...
X11 forwarding request failed on channel 0
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 17 (delta 2), reused 17 (delta 2)
Receiving objects: 100% (17/17), done.
Resolving deltas: 100% (2/2), done.
18:26:25 cfedde@files:~
$ cd example-bash/