Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

jellisii2's scratchpad

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


<script type="text/javascript" src="// +n.js"></script> <script type="text/javascript" src="// +p/3.2.0/js/bootstrap.min.js"></script> <script type="text/javascript" src="// +ighlight.js/8.2/highlight.min.js"></script> <script type="text/javascript" src="//"> +</script>


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] #); }


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


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


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 }


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 INNER JOIN db1.questionnaire_quest_choice ON (db1.questionnaire_quest_ INNER JOIN db1.questionnaire ON ( +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 INNER JOIN db2.i_users_sections ON (db1.local_ltiprovider_user.sourcei INNER JOIN db2.course_sections ON ( +sections.course_section_id) INNER JOIN ON ( +d) where AND db1.questionnaire_question.deleted="n" group by;


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>


Installing redmine 2.3.x on Ubuntu 12.04.

Add the following repo:

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:


$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' };


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.


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.


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";


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 as 'Id', u.username as 'Username', u.first_name as 'First_name', u.last_name as 'Last_name', 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 like findme; END $$


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'}";


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 +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 = ''; $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 Can't connect to at script/ 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 -x -o mech_test.exe

-x is supposed to execute the program so pp can sort out what exactly it needs, per

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?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2015-09-01 12:10 GMT
Find Nodes?
    Voting Booth?

    My preferred temperature scale is:

    Results (7 votes), past polls