atsider

u/atsider




r/perl6•

I am experimenting with executing some subroutine for all the elements in a list. The first thing I tried was hyper/race

for race (^6) {
    sleep 1;
    say $_;
}

however it executes sequentially. For me the solution was to use Promises as

await (^6).map: {
    start {
        sleep 1;
        say $_;
    }
}

My questions are:

  • Why hyper/race is not working as I intend?
  • Why we have both methods if they are almost equivalent?
87

r/matrixdotorg•

Hi, I recently upgraded my server from old raspbian stable to buster. Even after upgrading, my server was working ok.

However, after resetting the machine today, the server starts but after approximately 6 minutes every of the requests time out and it becomes unresponsive, so I cannot even connect with any client.

This is the typical time out in the logs:

synapse.http.site - 203 - WARNING - PUT-94 - Error processing request <XForwardedForRequest at 0x71f91350 method='PUT' uri='/_matrix/federation/v1/send/1564141142951' clientproto='HTTP/1.1' site=8008>: <class 'twisted.internet.error.ConnectionDone'> Connection was closed cleanly.

Any hints about how to try to see what i

50

r/cpp_questions•

I thought that instancing a template with any other thing that a value or a type yielded a partial template specialization —another template, not an object.

However, I have seen code like this

template<class T>
class mytemplate{
public:
  T *p;
};

int main(){
  // Note that "class _" does not exist! 
  mytemplate<class _> mt = mytemplate<class _>();
}

where one can instance an object with an undefined class type (class _). The code compiles and runs.

Inspecting with the debugger, I can see that the compiler automatically generates an empty class type class::main::_.

The question is: what is the name of this behavior? and wh

59

r/perl•

In the process of renewing a scraping script, I decided to replace WWW::Mechanize by Mojo::UserAgent. All is good until I have to fill a form in order to login: while the former uses

my $resp = $agent->submit_form(
    form_number => 1,
    fields => {
    strLogin => $user,
    strPwd => $passwd,
    });

in the documentation of Mojo::UserAgent, all the POST example methods are always called directly passing the parameters. This is a bit more inconvenient, since I have to take into account all the details of the form I am filling (for example looking if the form is POST or GET).

Are there any other solutions or this is just the way it work

510

r/perl•

My system has 5.24, and I was surprised that I could not find find2perl.

After searching for answers, I think that it was removed around 5.20, but I am not sure why and what the replacement to that useful script could be.

Anyone knows about this?

75


r/emacs•

I am starting to use projectile-mode, and I was under the impression that this mode helps you by issuing commands over the files owned by a project.

However when I grep over the files of a git repository, C-c p s g, all the files under the directory are considered, instead of only those tracked by git. This is not very convenient to me, since the grep command is considering backup files, object files, etc.

Can this be fixed or am I too optimistic about this package?

Edit: fixed command invocation.

114

r/ProgrammerTIL•

One of the Perl's strengths is to be able to write text filters in a few lines, for example

# Shell one-liner:
# Adds 1 to all the numbers in the files
perl -i -wnle 'print $_+1' numbers1.txt numbers2.txt numbers3.txt ...

That is roughly equivalent to write in code

while(<>){ # Iterate over all lines of all the given files
    print $_ + 1; # Take the current line ($_) and print it to STDOUT
}

Anything written to STDOUT will replace the current line in the original file.

Fortunately, Python has a module that mimics this behavior as well, fileinput.

import fileinput

for line in fileinput.input(inplace=True):
    print(int(line) + 1)

In j

1213