Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

jellisii2's scratchpad

by jellisii2 (Friar)
on May 18, 2011 at 18:30 UTC ( #905538=scratchpad: print w/ replies, xml ) Need Help??

2015-02-07

if ($foohash->{$key} > $dbhash->{$key}) { # if any of these are greater, go ahead and update print "An update to $key has occured!\n"; print("to " . $foohash->{$key} . " from " . $dbhash->{$key} . "\n" +); #$dbh->do( # "update daily_urls set $key = " . $foohash->{$key} . # "where id = " . $check->[0]->[0] #); }

output:

An update to bytes has occurred! to 1988574506.81257 from 1988574506.81257 An update to bytes has occurred! to 1161805289.10036 from 1161805289.10036 An update to bytes has occurred! to 287736468.69037 from 287736468.69037

2014-02-06

SELECT distinct date as d, (select sum(bytes) from daily_url where date like d and url like 'long/path/to/foo/%') from daily_url limit 20;

date is varchar, could be int(10) as it's an epoch timestamp for that day.

bytes is varchar, could be float, but it would have to be pretty big.

daily_url is varchar

2014-01-22

sub package_on_usual_location($) { my $file = shift; my ($top, $subdir, @rest) = splitdir $file; defined $subdir or return 0; !@rest # path is at top-level of distro || $subdir eq 'lib'; # inside lib }

2013-11-22

explain select db1.questionnaire_question.content AS 'question content +', db1.questionnaire_quest_choice.content AS 'choice content', avg(db1.questionnaire_response_rank.rank) AS 'average rank' from db1.questionnaire_response_rank INNER JOIN db1.questionnaire_question ON (db1.questionnaire_response_r +ank.question_id=db1.questionnaire_question.id) INNER JOIN db1.questionnaire_quest_choice ON (db1.questionnaire_quest_ +choice.question_id=db1.questionnaire_question.id) INNER JOIN db1.questionnaire ON (db1.questionnaire.id=db1.questionnair +e_question.survey_id) INNER JOIN db1.local_ltiprovider ON (db1.questionnaire.course=db1.loca +l_ltiprovider.courseid) INNER JOIN db1.local_ltiprovider_user ON (db1.local_ltiprovider_user.t +oolid=db1.local_ltiprovider.id) INNER JOIN db2.i_users_sections ON (db1.local_ltiprovider_user.sourcei +d=db2.i_users_sections.id) INNER JOIN db2.course_sections ON (db2.course_sections.id=db2.i_users_ +sections.course_section_id) INNER JOIN db2.courses ON (db2.courses.id=db2.course_sections.course_i +d) where db2.courses.id=167 AND db1.questionnaire_question.deleted="n" group by db1.questionnaire_quest_choice.id;

2013-09-17

use strict; use warnings; use XML::Twig; my $twig = XML::Twig->new(pretty_print => "indented"); $twig->parse('<foo/>'); my $root = $twig->root(); foreach my $i (qw(bar baz qux)) { my $inserted = $root->insert($i); $inserted->set_atts({bark => 'woof'}); my $second_inserted = $root->insert($i . 'second_tag'); $second_inserted->set_atts({type => 'deep'}); } $twig->print;
I expect the return to be:
<foo> <bar bark="woof"/> <barsecond_tag type="deep"/> <baz bark="woof"/> <bazsecond_tag type="deep"/> <qux bark="woof"/> <quxsecond_tag type="deep"/> </foo>
I'm getting the following:
<foo> <quxsecond_tag type="deep"> <qux bark="woof"> <bazsecond_tag type="deep"> <baz bark="woof"> <barsecond_tag type="deep"> <bar bark="woof"/> </barsecond_tag> </baz> </bazsecond_tag> </qux> </quxsecond_tag> </foo>

2013-06-17

Installing redmine 2.3.x on Ubuntu 12.04.

Add the following repo:

https://launchpad.net/~ondrej/+archive/redmine

The easy way to do this is by adding the ppa using add-apt-repository.

sudo apt-get install python-software-properties sudo add-apt-repository ppa:ondrej/redmine

After you have that repo installed, you can use this tutorial: http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_on_Ubuntu_step_by_step

2013-06-05

$VAR1 = { 'source' => '[path def]', 'git_server' => 'git://trident.classroom24-7.lan', 'permissions' => '0665', 'target_group' => 'www-data', 'rename' => 'gttest', 'target_owner' => 'www-data', 'target' => '.', 'preserve' => [ [ 'moodlite_config.php', 'not_moodlite_config.php' ] ], 'title' => 'moodlite' }; $VAR2 = { 'source' => '[path def]', 'permissions' => '755', 'target_group' => 'eellis', 'target_owner' => 'root', 'rename' => 'notmoodlite', 'target' => '.', 'preserve' => [ $VAR1->{'preserve'}[0] ], 'title' => 'moodlite/copy1' };

2013-05-23

The following assumes you're using gitolite on a remote server.

#!/bin/bash # to add repos for redmine, do the following: # git clone --bare git@[server]:[repo] # then add two stanzas here to get updates echo "Running [repo]" cd /path/to/repo.git /usr/bin/git fetch origin '+refs/heads/*:refs/heads/*' -v cd ~
Set the above in a cron (I have it run every 5 minutes) and all of your updates get pulled so Redmine can see them.

2013-04-19

Given the tables as follows:

courses - id - short_name - long_name i_courses_accreditors - id - courses_id - accreditors_id accreditors - id - name

Any given course can have multiple accreditors. I would like to return a single row with all accreditors for each course. I suspect either group_concat or concat_ws will come into play, but I can't put all the magic together yet.

2013-04-05

use strict; use warnings; my $string = "\n\nThis is a string"; my $start_time = time(); my $times = 9999999999999; for (my $i = 0; $i == $times; $i++){ my $result = reverse($string); $result = reverse(chomp($string)); } my $end_time = time(); print "Double reverse = " . ($end_time - $start_time) . " seconds\n"; $start_time = time(); for (my $i = 0; $i == $times; $i++){ my $result = $string; $result =~ s/\n//; } $end_time = time(); print "regex = " . ($end_time - $start_time) . " seconds";

2013-03-29

CREATE PROCEDURE `sp_DBR`(email_to varchar(50), global_filter varchar( +50)) BEGIN declare findme varchar(50) default '%'; IF CHAR_LENGTH(global_filter) >= 1 THEN set findme = concat('%', global_filter, '%'); END IF; select u.id as 'Id', u.username as 'Username', u.first_name as 'First_name', u.last_name as 'Last_name', u.email as 'Email', from_unixtime(u.last_login) as 'Last login', from_unixtime(u.reg_date) as 'Reg date', u.organization as 'Organization' from moodlite.users u where u.id like findme; END $$

2013-03-21

use strict; my $VAR1 = { 'wizard' => { 'spell' => 4, 'ppd' => 10, 'breath weapon' => 9, 'pp' => 7, 'rsw' => 5 }, 'warrior' => { 'spell' => 6, 'ppd' => 3, 'breath weapon' => 4, 'pp' => 4, 'rsw' => 5 }, 'rogue' => { 'spell' => 7, 'ppd' => 9, 'breath weapon' => 12, 'pp' => 8, 'rsw' => 6 } }; my $stat = 'spell'; my $smallest; foreach my $class (keys $VAR1) { my $val = $VAR1->{$class}->{$stat}; if (!$smallest) { $smallest->{'class'} = $class; $smallest->{'val'} = $VAR1->{$class}->{$stat}; } else { if ($smallest->{'val'} > $VAR1->{$class}->{$stat}) { $smallest->{'class'} = $class; $smallest->{'val'} = $VAR1->{$class}->{$stat}; } } } print "Smallest value for $stat is in class $smallest->{'class'}, with + value $smallest->{'val'}";

2012-12-07

I'm having a similar problem on ActivePerl 5.14.2 and have made it to this point with troubleshooting:

Sample code:

use strict; use warnings; use WWW::Mechanize; # LWP complains if this isn't included with the packaged executable. # This may be because I'm on Win32. At any rate, PP isn't smart enoug +h # to know it's needed, so I include it here to make packaging easier. use Encode::Byte; # WWW::Mechanize debugging # per http://search.cpan.org/~mstrout/WWW-Mechanize/lib/WWW/Mechanize/ +FAQ.pod#How_do_I_figure_out_why_$mech-%3Eget%28$url%29_doesn%27t_work +? use LWP::Debug qw(+); # by default, PP picks Net::SSLeay # It appears to test for IO::Socket::SSL first and use it if it's avai +lable. # use Crypt::SSLeay; # use IO::Socket::SSL; my $mech = WWW::Mechanize->new(); my $url = 'http://google.com'; $mech->get($url); if ($mech->success() == 1) { print "yay"; } else { die "Can't fetch $url"; }

I have verified that the site is reachable from a browser on my machine.

In the example above, I'm using a non-SSL site. It works both packaged and unpackaged as expected.

Altering the URL to try and talk https is where the problem starts to show.

Unpackaged, the script works as expected.

Packaged the problem rears its head: Error GETing https://google.com: Can't connect to google.com:443 at script/mech_test.pl line 17.

So the problem definitely lies within the idea that something that's required is not being packaged by pp. The problem is that the documentation states that if you want to use SSL, you use either Crypt::SSLeay or IO::Socket::SSL, which we can explicity include, but it doesn't alter the result.

How I'm using pp: pp mech_test.pl -x -o mech_test.exe

-x is supposed to execute the program so pp can sort out what exactly it needs, per http://search.cpan.org/~autrijus/PAR-0.85_01/script/pp#OPTIONS.

Digging through the packed executable, it appears that both IO::Socket::SSL and Crypt::SSLeay are included with the output, so the the safe assumption is that one of those has a missing depenancy that it's not yelling about.

Crypt::SSLeay documentation

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2014-11-26 18:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (172 votes), past polls