Is there a way to have short names in GFlags? - gflags

I am trying to see if there is a way in gflags to have --server_configure and --sc map to same variable. Is there a way to have a short name for an option?

Found answer
gflags.DEFINE_string('filename', None, 'Input file name', short_name='f')

Related

How to get an element from an output in windows powersheell

I have an output like:
PS C:\Users\parul> $test2
id label region type image status ipv4
21648848 ubuntu-us-west us-west g6-standard-1 linode/ubuntu20.04 offline 173.255.216.222
I need to get the id value only. How to i get this in powershell
Please refine your question. If you are really asking for how to use properties a google search would've done the trick in under 1 minute.. To answer your question:
help about_Variables
$test2.id

Extract Two Value between special characters with Preg_Match

Hello I want to Extract the username and Password value with one preg_match_all
$url='http://xxxxxxxx.com:80/get.php?username=xxxxxx&password=xxxxxx&type=m3u_plus';
I get wiht this explode where i want but i know is more effect with preg_match_all can you show me how.?
$url_ext = parse_url($url);
$username=explode ("&",explode("=",$url_ext['query'])[1]);
$password=explode ("&",explode("=",$url_ext['query'])[2]);
I try with this code but not working
$lotes_fil='~https?://.\=(.+?)&~';
preg_match_all($lotes_fil,$url,$link_pre);
It is better to use parse_url and parse_str like explained here.
But, if you really want a regex, this does the job:
(?<=[?&])([^&=\r\n]+)=([^&=\r\n]+)
preg_match_all('/(?<=[?&])([^&=\r\n]+)=([^&=\r\n]+)/', $url, $matches);
The parameter name is in group 1, the value in group 2
Demo & explanation

Google Spreadsheet function for email tracking

I am trying to learn how to create functions in a Google Spreadsheet that I will be using to track success rate of template emails. Here is the example.
What would the functions be for 'Template Tracking' sheet in C2, D2 and E2?
Essentially if a value exists in 'Email Tracking' column D then count it (if nothing there, then don't) and the create sum in appropriate place on 'Template Tracking' sheet based on 'Template #' in 'Email Tracking' column C.
While still no conclusion about a function, I did find that using pivot tables was a very easy workaround.
Can see how that looks here.
Welcome any further ideas about a function but hope this is helpful to others who might want to use it.

Ignore column in WHERE

Can I ignore some columns in WHERE condition?
SELECT name FROM people
WHERE name LIKE 'Honza' AND surname LIKE 'Novak'
(I recieve the WHERE condition as parametr unable to edit it)
I think the answer here is no, you cannot. You got the where condition and if you can't edit it, it will be processed as is. If you can add to the end you could add an AND and an OR to override, but that's about it.
Can you do some string replacement on the WHERE? E.g.
replace($WHERE, "surname like 'Novak'", "surname like '%'")
If not, you can maybe hack something with a ON SELECT INSTEAD... rule:
http://www.postgresql.org/docs/9.1/static/sql-createrule.html

How to deal with nameless forms on websites?

I would like to write a script that lets me use this website
http://proteinmodel.org/AS2TS/LGA/lga.html
(I need to use it a few hundred times, and I don't feel like doing that manually)
I have searched the internet for ways how this could be done using Perl, and I came across WWW::Mechanize, which seemed to be just what I was looking for. But now I have discovered that the form on that website which I want to use has no name - its declaration line simply reads
<FORM METHOD="POST" ACTION="./lga-form.cgi" ENCTYPE=multipart/form-data>
At first I tried simply not setting my WWW::Mechanize object's form_name property, which gave me this error message when I provided a value for the form's email address field:
Argument "my_email#address.com" isn't numeric in numeric gt (>) at /usr/share/perl5/WWW/Mechanize.pm line 1618.
I then tried setting form_name to '' and later ' ', but it was to no avail, I simply got this message:
There is no form named " " at ./automate_LGA.pl line 40
What way is there to deal with forms that have no names? It would be most helpful if someone on here could answer this question - even if the answer points away from using WWW::Mechanize, as I just want to get the job done, (more or less) no matter how.
Thanks a lot in advance!
An easy and more robust way is to use the $mech->form_with_fields() method from WWW::Mechanize to select the form you want based on the fields it contains.
Easier still, use the submit_form method with the with_fields option.
For instance, to locate a form which has fields named 'username' and 'password', complete them and submit the form, it's as easy as:
$mech->submit_form(
with_fields => { username => $username, password => $password }
);
Doing it this way has the advantage that if they shuffle their HTML around, changing the order of the forms in the HTML, or adding a new form before the one you're interested in, your code will continue to work.
I don't know about WWW::Mechanize, but its Python equivalent, mechanize, gives you an array of forms that you can iterate even if you don't know their names.
Example (taken from its homepage):
import mechanize
br = mechanize.Browser()
br.open("http://www.example.com/")
for form in br.forms():
print form
EDIT: searching in the docs of WWW::Mechanize I found the $mech->forms() method, that could be what you need. But since I don't know perl or WWW::Mechanize, I'll leave there my python answer.
Okay, I have found the answer. I can address the nameless form by its number (there's just one form on the webpage, so I guessed it would be number 1, and it worked). Here's part of my code:
my $lga = WWW::Mechanize->new();
my $address = 'my_email#address.com';
my $options = '-3 -o0 -d:4.0';
my $pdb_2 = "${pdb_id}_1 ${pdb_id}_2";
$lga->get('http://proteinmodel.org/AS2TS/LGA/lga.html');
$lga->success or die "LGA GET fail\n";
$lga->form_number(1);
$lga->field('Address', $address);
$lga->field('Options', $options);
$lga->field('PDB_2', $pdb_2);
$lga->submit();
$lga->success or die "LGA POST fail\n";