text:
Q: using Perl to scrape a website I am interested in writing a perl script that goes to the following link and extracts the number 1975: https://familysearch.org/search/collection/results#count=20&query=%2Bevent_place_level_1%3ACalifornia%20%2Bevent_place_level_2%3A%22San%20Diego%22%20%2Bbirth_year%3A1923-1923~%20%2Bgender%3AM%20%2Brace%3AWhite&collection_id=2000219
That website is the amount of white men born in the year 1923 who live in San Diego County, California in 1940.  I am trying to do this in a loop structure to generalize over multiple counties and birth years.
In the file, locations.txt, I put the list of counties, such as San Diego County.
The current code runs, but instead of the # 1975, it displays unknown.  The number 1975 should be in $val\n.
I would very much appreciate any help!
#!/usr/bin/perl

use strict;

use LWP::Simple;

open(L, "locations26.txt");

my $url = 'https://familysearch.org/search/collection/results#count=20&query=%2Bevent_place_level_1%3A%22California%22%20%2Bevent_place_level_2%3A%22%LOCATION%%22%20%2Bbirth_year%3A%YEAR%-%YEAR%~%20%2Bgender%3AM%20%2Brace%3AWhite&collection_id=2000219';

open(O, ">out26.txt");
 my $oldh = select(O);
 $| = 1;
 select($oldh);
 while (my $location = <L>) {
     chomp($location);
     $location =~ s/ /+/g;
      foreach my $year (1923..1923) {
                 my $u = $url;
                 $u =~ s/%LOCATION%/$location/;
                 $u =~ s/%YEAR%/$year/;
                 #print "$u\n";
                 my $content = get($u);
                 my $val = 'unknown';
                 if ($content =~ / of .strong.([0-9,]+)..strong. /) {
                         $val = $1;
                 }
                 $val =~ s/,//g;
                 $location =~ s/\+/ /g;
                 print "'$location',$year,$val\n";
                 print O "'$location',$year,$val\n";
         }
     }

Update: API is not a viable solution.  I have been in contact with the site developer.  The API does not apply to that part of the webpage.  Hence, any solution pertaining to JSON will not be applicbale.

A: It would appear that your data is generated by Javascript and thus LWP cannot help you. That said, it seems that the site you are interested in has a developer API: https://familysearch.org/developers/
I recommend using Mojo::URL to construct your query and either Mojo::DOM or Mojo::JSON to parse XML or JSON results respectively. Of course other modules will work too, but these tools are very nicely integrated and let you get started quickly.

A: You could use WWW::Mechanize::Firefox to process any site that could be loaded by Firefox.
http://metacpan.org/pod/WWW::Mechanize::Firefox::Examples
You have to install the Mozrepl plugin and you will be able to process the web page contant via this module. Basically you will "remotly control" the browser.
Here is an example (maybe working)
use strict;
use warnings;
use WWW::Mechanize::Firefox;

my $mech = WWW::Mechanize::Firefox->new(
    activate => 1, # bring the tab to the foreground
);
$mech->get('https://familysearch.org/search/collection/results#count=20&query=%2Bevent_place_level_1%3ACalifornia%20%2Bevent_place_level_2%3A%22San%20Diego%22%20%2Bbirth_year%3A1923-1923~%20%2Bgender%3AM%20%2Brace%3AWhite&collection_id=2000219',':content_file' => 'main.html');

my $retries = 10;
while ($retries-- and ! $mech->is_visible( xpath => '//*[@class="form-submit"]' )) {
      print "Sleep until we find the thing\n";
      sleep 2;
};
die "Timeout" if 0 > $retries;
#fill out the search form
my @forms = $mech->forms();
#<input id="census_bp" name="birth_place" type="text" tabindex="0"/>
#A selector prefixed with '#' must match the id attribute of the input. A selector prefixed with '.' matches the class attribute. A selector prefixed with '^' or with no prefix matches the name attribute.
$mech->field( birth_place => 'value_for_birth_place' );
# Click on the submit
$mech->click({xpath => '//*[@class="form-submit"]'});

A: If you use your browser's development tools, you can clearly see the JSON request that the page you link to uses to get the data you're looking for.
This program should do what you want. I've added a bunch of comments for readability and explanation, as well as made a few other changes.
use warnings;
use strict;
use LWP::UserAgent;
use JSON;
use CGI qw/escape/;

# Create an LWP User-Agent object for sending HTTP requests.
my $ua = LWP::UserAgent->new;

# Open data files
open(L, 'locations26.txt') or die "Can't open locations: $!";
open(O, '>', 'out26.txt') or die "Can't open output file: $!";

# Enable autoflush on the output file handle
my $oldh = select(O);
$| = 1;
select($oldh);

while (my $location = <L>) {
    # This regular expression is like chomp, but removes both Windows and
    # *nix line-endings, regardless of the system the script is running on.
    $location =~ s/[\r\n]//g;
    foreach my $year (1923..1923) {
        # If you need to add quotes around the location, use "\"$location\"".
        my %args = (LOCATION => $location, YEAR => $year);

        my $url = 'https://familysearch.org/proxy?uri=https%3A%2F%2Ffamilysearch.org%2Fsearch%2Frecords%3Fcount%3D20%26query%3D%252Bevent_place_level_1%253ACalifornia%2520%252Bevent_place_level_2%253A^LOCATION^%2520%252Bbirth_year%253A^YEAR^-^YEAR^~%2520%252Bgender%253AM%2520%252Brace%253AWhite%26collection_id%3D2000219';
        # Note that values need to be doubly-escaped because of the
        # weird way their website is set up (the "/proxy" URL we're
        # requesting is subsequently loading some *other* URL which
        # is provided to "/proxy" as a URL-encoded URL).
        #
        # This regular expression replaces any ^WHATEVER^ in the URL
        # with the double-URL-encoded value of WHATEVER in %args.
        # The /e flag causes the replacement to be evaluated as Perl
        # code. This way I can look data up in a hash and do URL-encoding
        # as part of the regular expression without an extra step.
        $url =~ s/\^([A-Z]+)\^/escape(escape($args{$1}))/ge;
        #print "$url\n";

        # Create an HTTP request object for this URL.
        my $request = HTTP::Request->new(GET => $url);
        # This HTTP header is required. The server outputs garbage if
        # it's not present.
        $request->push_header('Content-Type' => 'application/json');
        # Send the request and check for an error from the server.
        my $response = $ua->request($request);
        die "Error ".$response->code if !$response->is_success;
        # The response should be JSON.
        my $obj = from_json($response->content);
        my $str = "$args{LOCATION},$args{YEAR},$obj->{totalHits}\n";
        print O $str;
        print $str;
    }
}

A: This seems to do what you need. Instead of waiting for the disappearance of the hourglass it waits - more obviously I think - for the appearance of the text node you're interested in.
use 5.010;
use warnings;

use WWW::Mechanize::Firefox;

STDOUT->autoflush;

my $url = 'https://familysearch.org/search/collection/results#count=20&query=%2Bevent_place_level_1%3ACalifornia%20%2Bevent_place_level_2%3A%22San%20Diego%22%20%2Bbirth_year%3A1923-1923~%20%2Bgender%3AM%20%2Brace%3AWhite&collection_id=2000219';

my $mech = WWW::Mechanize::Firefox->new(tab => qr/FamilySearch\.org/, create => 1, activate => 1);
$mech->autoclose_tab(0);

$mech->get('about:blank');
$mech->get($url);

my $text;
while () {
  sleep 1;
  $text = $mech->xpath('//p[@class="num-search-results"]/text()', maybe => 1);
  last if defined $text;
}

my $results = $text->{nodeValue};
say $results;
if ($results =~ /([\d,]+)\s+results/) {
  (my $n = $1) =~ tr/,//d;
  say $n;
}

output
1-20 of 1,975 results
1975

Update
This update is with special thanks to @nandhp, who inspired me to look at the underlying data server that produces the data in JSON format.
Rather than making a request via the superfluous https://familysearch.org/proxy this code accesses the server directly at https://familysearch.org/search/records, reencodes the JSON and dumps the required data out of the resulting structure. This has the advantage of both speed (the requests are served about once a second - more than ten times faster than with the equivalent request from the basic web site) and stability (as you note, the site is very flaky - in contrast I have never seen an error using this method).
use strict;
use warnings;

use LWP::UserAgent;
use URI;
use JSON;

use autodie;

STDOUT->autoflush;

open my $fh, '<', 'locations26.txt';
my @locations = <$fh>;
chomp @locations;

open my $outfh, '>', 'out26.txt';

my $ua = LWP::UserAgent->new;

for my $county (@locations[36, 0..2]) {
  for my $year (1923 .. 1926) {
    my $total = familysearch_info($county, $year);
    print STDOUT "$county,$year,$total\n";
    print $outfh "$county,$year,$total\n";
  }
  print "\n";
}

sub familysearch_info {

  my ($county, $year) = @_;

  my $query = join ' ', (
    '+event_place_level_1:California',
    sprintf('+event_place_level_2:"%s"', $county),
    sprintf('+birth_year:%1$d-%1$d~', $year),
    '+gender:M',
    '+race:White',
  );

  my $url = URI->new('https://familysearch.org/search/records');
  $url->query_form(
    collection_id => 2000219,
    count => 20,
    query => $query);

  my $resp = $ua->get($url, 'Content-Type'=> 'application/json');
  my $data = decode_json($resp->decoded_content);

  return $data->{totalHits};
}

output
San Diego,1923,1975
San Diego,1924,2004
San Diego,1925,1871
San Diego,1926,1908

Alameda,1923,3577
Alameda,1924,3617
Alameda,1925,3567
Alameda,1926,3464

Alpine,1923,1
Alpine,1924,2
Alpine,1925,0
Alpine,1926,1

Amador,1923,222
Amador,1924,248
Amador,1925,134
Amador,1926,67

A: What about this simple script without firefox ? I had investigated the site a bit to understand how it works, and I saw some JSON requests with firebug firefox addon, so I know which URL to query to get the relevant stuff. Here is the code :
use strict; use warnings;
use JSON::XS;
use LWP::UserAgent;
use HTTP::Request;

my $ua = LWP::UserAgent->new();

open my $fh, '<', 'locations2.txt' or die $!;
open my $fh2, '>>', 'out2.txt' or die $!;

# iterate over locations from locations2.txt file
while (my $place = <$fh>) {
    # remove line ending
    chomp $place;
    # iterate over years
    foreach my $year (1923..1925) {
        # building URL with the variables
        my $url = "https://familysearch.org/proxy?uri=https%3A%2F%2Ffamilysearch.org%2Fsearch%2Frecords%3Fcount%3D20%26query%3D%252Bevent_place_level_1%253ACalifornia%2520%252Bevent_place_level_2%253A%2522$place%2522%2520%252Bbirth_year%253A$year-$year~%2520%252Bgender%253AM%2520%252Brace%253AWhite%26collection_id%3D2000219";
        my $request = HTTP::Request->new(GET => $url);
        # faking referer (where we comes from)
        $request->header('Referer', 'https://familysearch.org/search/collection/results');
        # setting expected format header for response as JSON
        $request->header('content_type', 'application/json');

        my $response = $ua->request($request);

        if ($response->code == 200) {
            # this line convert a JSON to Perl HASH
            my $hash = decode_json $response->content;
            my $val = $hash->{totalHits};
            print $fh2 "year $year, place $place : $val\n";
        }
        else {
           die $response->status_line;
        }
    }
}

END{ close $fh; close $fh2; }

A: I do not know how to post revised code from the solution above.
This code does not (yet) compile correctly.  However, I have made some essential update to definitely head in that direction.
I would very much appreciate help on this updated code.  I do not know how to post this code and this follow up such that it appease the lords who run this sight.
It get stuck at the sleep line.  Any advice on how to proceed past it would be much appreciated!
use strict;
use warnings;
use WWW::Mechanize::Firefox;

my $mech = WWW::Mechanize::Firefox->new(
activate => 1, # bring the tab to the foreground
);
$mech->get('https://familysearch.org/search/collection/results#count=20&query=%2Bevent_place_level_1%3ACalifornia%20%2Bevent_place_level_2%3A%22San%20Diego%22%20%2Bbirth_year%3A1923-1923~%20%2Bgender%3AM%20%2Brace%3AWhite&collection_id=2000219',':content_file' => 'main.html', synchronize => 0);

 my $retries = 10;
while ($retries-- and $mech->is_visible( xpath => '//*[@id="hourglass"]' )) {
 print "Sleep until we find the thing\n";
  sleep 2;
 };
 die "Timeout while waiting for application" if 0 > $retries;

# Now the hourglass is not visible anymore

#fill out the search form
my @forms = $mech->forms();
#<input id="census_bp" name="birth_place" type="text" tabindex="0"/>
#A selector prefixed with '#' must match the id attribute of the input. A selector     prefixed with '.' matches the class attribute. A selector prefixed with '^' or with no     prefix matches the name attribute.
$mech->field( birth_place => 'value_for_birth_place' );
# Click on the submit
$mech->click({xpath => '//*[@class="form-submit"]'});

A: You should set the current form before accessing a field:
"Given the name of a field, set its value to the value specified. This applies to the current form (as set by the "form_name()" or "form_number()" method or defaulting to the first form on the page)."
$mech->form_name( 'census-search' );
$mech->field( birth_place => 'value_for_birth_place' );

Sorry, I am not able too try this code out and thanks for open a question for a new question.


text:
Q: Software to show typed keys on the screen
Just as the capture shows, when you type something using the keyboard, a big label appears at the bottom of the screen showing the keys you typed.
I use Windows & Linux, so I just want to know if there is a similar software to do that?

A: For Linux check Screenkey: https://launchpad.net/screenkey

A: On Windows there is Carnac the Magnificent.

A keyboard logging and presentation utility for presentations, screencasts, and to help you become a better keyboard user.

Install via Chocolatey:
choco install carnac

Or Scoop:
scoop install carnac

Source on GitHub:
https://github.com/Code52/carnac

A: There is Key Jedi

Key Jedi allows learning and training to use keyboard shortcuts. It can be used in presentations, screencasts and videos, as well as when working with someone else on the same machine to teach new shortcuts. It shows a visual list of shortcuts as you type them, no matter what application you work in. It is free, simple and quick to use.

Emphasis mine

redpajama_set_name: RedPajamaStackExchange


text:
Q: Filesystem access through web interface I have an SSH+Samba server so people can access its files from anywhere on the network.
I thought it would be also interesting to provide access through a web interface, so they can access the files even when they don't have access to the VPN or a Samba/SSH client. Something like the Ubuntu One or Dropbox web interface.
The http server could be on the same machine as the SSH+Samba, so it should just provide access to local files and some way to login with their username/password.
Someone knows any software like this?

A: There is the WebDAV protocol. It should be possible to use it to get web access to your data. There are also predefined WebDAV modules for Apache available.

A: WebDAV is the first thing that comes to mind.  You can use something like mod_auth_external to have your users use their same passwords by using PAM to authenticate.  It is a very good idea to run WebDAV over SSL so your users aren't sending passwords in the clear over the Internet.

A: Another solution is to install a script for this. Some examples written in PHP:

*

*osFileManager

*PHPfileNavigator

*Flashcommander
These will offer you a web-based interface, although it may not be as polished as the ones you mention. For these to work, you will of course need a webserver and PHP.


text:
Q: Changes in included file not registering in C I am on Arch Linux. I have tried gcc and cc.
I have quite a strange problem. I have a file included from /usr/include (installed from an Arch package) in a C program like so.
// prog.c
#include <foobar/foobar.h>

When I change it, nothing happens. Let me explain. It includes some C code.
// foobar/foobar.h
int baz = 1, qux = 2;

Recently, it has been updated.
// foobar/foobar.h
int baz = 1, qux = 2, norf = 3;

My test program looks something like what follows.
// prog.c
#include <foobar/foobar.h>
printf ("%d %d %d\n", baz, qux, norf);

output:
error: 'norf' undeclared (first use in this function)

I can duplicate the file in the same directory, name it foobar2.h, and then include that file instead and it outputs:
1 2 3

So the path is not incorrect. I can make a link to the folder, name it foobar2, and include foobar2/foobar.h and it outputs:
1 2 3

So the file is not incorrect.
To confirm that it is not registering changes, I can destroy the foobar folder entirely and try to print just the 2 variables that were originally inside the header. This outputs:
1 2

Clearly something is not updating. The same behaviour is displayed when I try updating the file with enums, functions, or new values for existing items in the file, and include them as the only lines in the file. None of the changes register. The same activity is displayed with gcc and cc. This has been going on a few months now and it still has not resolved itself.

A: When a file does not seem to be updating, it is a good idea to check other places on your system where your compilers search for libraries for identically named folders. In this case, it was in /usr/local/include, where I had a version that I compiled and forgot about entirely.

A: This can be mainly due to the include directory path mismatch. Check out the environment variable that can affect the behavior like C_INCLUDE_PATH , CPATH. Another option would be to check with gcc -I/src/directory foobar.h while compilation that can lead you closer to the problem or use #include "foobar.h" in the code.
In case if there are multiple copies of the program in your system, it is possible that completely different file is used for compilation and execution which can also lead to changes not getting reflected.


text:
Q: What is the best architecture for a Node+react js based enterprise level application..? I am new to Node and react js and i need to build an application using both of them. So i have 2 ways to build this application :

*

*Separate Node and react setup : All frontend development in react js setup with a separate Node js setup for server.

*Combine Node with react js : Integrate react in Node js and build application with this combination.
This application is going to have lots of hits and i want to know which architecture will perform better :
React send request to Node internally (in architecture 1), will it make it slow..??
Please advice..!!

A: Your React app will need to send requests to your Node app anyway, now matter if you combine the two or not.
I always recommend building the frontend and backend separately for few reasons. First, you will need to think about and hopefully document the API that will connect both of those projects, with no ad hoc changes to the backend every time you make changes to the frontend and vice versa. And also you will be able to more easily add other frontends, like a mobile app or a desktop application if you have a well defined API.
But you can also do it the other way and have a more monolithic application that would still consist of frontend and backend parts but more tightly coupled. And whether or not a clear abstraction boundary and loose coupling is an advantage worth putting a little bit more design into the entire project is entirely up to you. It usually pays off after some time when your application gets complex and when you want to add mobile application or other frontends.


text:
Q: Java Attach API: How to set agent properties? The Java Attach API for JDK6 provides a method getAgentProperties() on VirtualMachine:

public abstract Properties getAgentProperties()
        throws IOException
Returns the current agent properties in the target virtual
   machine.  The target virtual machine can maintain a list of
   properties on behalf of agents. The manner in which this is
   done, the names of the properties, and the types of values that
   are allowed, is implementation specific. Agent properties are
   typically used to store communication end-points and other
   agent configuration details. For example, a debugger agent
   might create an agent property for its transport address.
This method returns the agent properties whose key and value is
   a String. Properties whose key or value is not a String are
   omitted. If there are no agent properties maintained in the
   target virtual machine then an empty property list is returned.

(from the Java Attach API)
My question is, how to set these properties on the other side (i.e.
within the JVM where the agent is running) ?
The documentation for the instrument API doesn't talk about this either.

A: On Hot Spot VM you can set agent properties using sun.misc.VMSupport.getAgentProperties().


text:
Q: LINESTRING missing after exploding GeoPandasDataframe with gemgis I have been trying to find what I am actually doing wrong for a day now and can't figure out what the problem with my approach might be. So, a little background is in place:
I have a dataframe with a bunch of coordinates:
index                                    id  x_polygon  y_polygon  \
3      3  13e70e96-2554-49c5-9c2e-4df1beb8efb1      27.03      38.58
3      3  13e70e96-2554-49c5-9c2e-4df1beb8efb1      28.26      38.58
3      3  13e70e96-2554-49c5-9c2e-4df1beb8efb1      28.26      44.38
3      3  13e70e96-2554-49c5-9c2e-4df1beb8efb1      27.03      44.38
3      3  13e70e96-2554-49c5-9c2e-4df1beb8efb1      27.03      38.58
3      3  13e70e96-2554-49c5-9c2e-4df1beb8efb1      28.26      38.58
3      3  13e70e96-2554-49c5-9c2e-4df1beb8efb1      28.26      44.38
3      3  13e70e96-2554-49c5-9c2e-4df1beb8efb1      27.03      44.38
0      0  168bb0ea-3748-42ad-84c3-aa20e62c73b3      32.99      37.25
0      0  168bb0ea-3748-42ad-84c3-aa20e62c73b3      33.57      37.25
0      0  168bb0ea-3748-42ad-84c3-aa20e62c73b3      33.57      44.86
0      0  168bb0ea-3748-42ad-84c3-aa20e62c73b3      32.99      44.86
5      5  5e36fbc5-b5d4-4f32-9f53-d713e389b13d      19.03      45.93
5      5  5e36fbc5-b5d4-4f32-9f53-d713e389b13d      31.39      45.93
5      5  5e36fbc5-b5d4-4f32-9f53-d713e389b13d      31.39      46.52
5      5  5e36fbc5-b5d4-4f32-9f53-d713e389b13d      19.03      46.52

                               edges.id  edges.linkable
3  66689e8c-fd24-4eb1-b46c-b4371d354aff            True
3  66689e8c-fd24-4eb1-b46c-b4371d354aff            True
3  66689e8c-fd24-4eb1-b46c-b4371d354aff            True
3  66689e8c-fd24-4eb1-b46c-b4371d354aff            True
3  e49832f7-af6b-4da3-b2c2-8a66cb16cc39            True
3  e49832f7-af6b-4da3-b2c2-8a66cb16cc39            True
3  e49832f7-af6b-4da3-b2c2-8a66cb16cc39            True
3  e49832f7-af6b-4da3-b2c2-8a66cb16cc39            True
0  ab68fa67-2f46-49cf-b319-8454d5820f9d            True
0  ab68fa67-2f46-49cf-b319-8454d5820f9d            True
0  ab68fa67-2f46-49cf-b319-8454d5820f9d            True
0  ab68fa67-2f46-49cf-b319-8454d5820f9d            True
5  8395d1d1-b676-43a0-92dd-e4038df9549c            True
5  8395d1d1-b676-43a0-92dd-e4038df9549c            True
5  8395d1d1-b676-43a0-92dd-e4038df9549c            True
5  8395d1d1-b676-43a0-92dd-e4038df9549c            True

Here is a dict-version of it:
{'index': {3: 3, 0: 0, 5: 5}, 'id': {3: '13e70e96-2554-49c5-9c2e-4df1beb8efb1', 0: '168bb0ea-3748-42ad-84c3-aa20e62c73b3', 5: '5e36fbc5-b5d4-4f32-9f53-d713e389b13d'}, 'x_polygon': {3: 27.031515, 0: 32.987843, 5: 19.034254}, 'y_polygon': {3: 44.37576, 0: 44.86328, 5: 46.517555}, 'edges.id': {3: 'e49832f7-af6b-4da3-b2c2-8a66cb16cc39', 0: 'ab68fa67-2f46-49cf-b319-8454d5820f9d', 5: '8395d1d1-b676-43a0-92dd-e4038df9549c'}, 'edges.linkable': {3: True, 0: True, 5: True}}

I transform the coordinates into POLYGON objects
geostore_obstacles_geometry = gpd.GeoDataFrame(geometry=geostore_obstacles.groupby(['id']).apply(
    lambda g: Polygon(gpd.points_from_xy(g['x_polygon'], g['y_polygon']))))

geostore_obstacles_geometry = geostore_obstacles_geometry.reset_index()
geostore_obstacles_geometry

which returns:
                                id  \
0  13e70e96-2554-49c5-9c2e-4df1beb8efb1
1  168bb0ea-3748-42ad-84c3-aa20e62c73b3
2  5e36fbc5-b5d4-4f32-9f53-d713e389b13d

                                            geometry
0  POLYGON ((27.03151 38.58253, 28.26146 38.58253...
1  POLYGON ((32.98784 37.25187, 33.56717 37.25187...
2  POLYGON ((19.03425 45.92993, 31.38868 45.92993...

and merge with the original dataframe. The reason I am doint this is that I also want every point as a geometrical obejct POINT:
geostore_obstacles_geometry_with_points = geostore_obstacles_geometry.merge(geostore_obstacles, left_on =['id'],right_on =['id'])
geostore_obstacles_geometry_with_points =geostore_obstacles_geometry_with_points.rename_geometry('geometry_obstacle')
geostore_obstacles_geometry_with_points
geostore_obstacles_geometry_with_geopoints = gpd.GeoDataFrame(geostore_obstacles_geometry_with_points, geometry = gpd.points_from_xy(geostore_obstacles_geometry_with_points['x_polygon'], geostore_obstacles_geometry_with_points['y_polygon']))

which gives:
                               id  \
0  13e70e96-2554-49c5-9c2e-4df1beb8efb1
1  13e70e96-2554-49c5-9c2e-4df1beb8efb1
2  13e70e96-2554-49c5-9c2e-4df1beb8efb1

                                   geometry_obstacle  index  x_polygon  \
0  POLYGON ((27.03151 38.58253, 28.26146 38.58253...      3      27.03
1  POLYGON ((27.03151 38.58253, 28.26146 38.58253...      3      28.26
2  POLYGON ((27.03151 38.58253, 28.26146 38.58253...      3      28.26

   y_polygon                              edges.id  edges.linkable  \
0      38.58  66689e8c-fd24-4eb1-b46c-b4371d354aff            True
1      38.58  66689e8c-fd24-4eb1-b46c-b4371d354aff            True
2      44.38  66689e8c-fd24-4eb1-b46c-b4371d354aff            True

                    geometry
0  POINT (27.03151 38.58253)
1  POINT (28.26146 38.58253)
2  POINT (28.26146 44.37576)

My objective from here is to split all the boundaries of the polygons in its individual edges and the way I found to to this is first by using gemgis and explode the polygons into LINESTRING  objects (which are the boundaries) and then use shapely.os.split to split the linestrings at the points I determined above:
geostore_obstacles_geometry_with_geopoints=geostore_obstacles_geometry_with_geopoints.rename(columns ={'geometry_obstacle':'geometry', 'geometry':'point'})
geostore_obstacles_geometry_with_geopoints['geometry'] = geostore_obstacles_geometry_with_geopoints['geometry'].buffer(0)
geostore_obstacles_geometry_with_geopoints = gemgis.vector.explode_polygons(gdf=geostore_obstacles_geometry_with_geopoints)
def get_side_of_rect(row, linecol="geometry", pointcol="point"):
    return split(row[linecol], row[pointcol])

Full_geometry = (
    geostore_obstacles_geometry_with_geopoints.assign(sides=lambda df: df.apply(get_side_of_rect, axis=1))
)
Full_geometry = Full_geometry.set_geometry('sides')

exploded = Full_geometry.explode(ignore_index=False)
exploded = exploded.reset_index()
Full_geometry = exploded.drop(['geometry'], axis=1)
Full_geometry

level_0  level_1                                    id  index  x_polygon  \
0        0        0  13e70e96-2554-49c5-9c2e-4df1beb8efb1      3      27.03
1        1        0  13e70e96-2554-49c5-9c2e-4df1beb8efb1      3      28.26
2        1        1  13e70e96-2554-49c5-9c2e-4df1beb8efb1      3      28.26
3        2        0  13e70e96-2554-49c5-9c2e-4df1beb8efb1      3      28.26
4        2        1  13e70e96-2554-49c5-9c2e-4df1beb8efb1      3      28.26

   y_polygon                              edges.id  edges.linkable  \
0      38.58  66689e8c-fd24-4eb1-b46c-b4371d354aff            True
1      38.58  66689e8c-fd24-4eb1-b46c-b4371d354aff            True
2      38.58  66689e8c-fd24-4eb1-b46c-b4371d354aff            True
3      44.38  66689e8c-fd24-4eb1-b46c-b4371d354aff            True
4      44.38  66689e8c-fd24-4eb1-b46c-b4371d354aff            True

                       point  \
0  POINT (27.03151 38.58253)
1  POINT (28.26146 38.58253)
2  POINT (28.26146 38.58253)
3  POINT (28.26146 44.37576)
4  POINT (28.26146 44.37576)

                                               sides
0  LINESTRING (27.03151 38.58253, 27.03151 44.375...
1  LINESTRING (27.03151 38.58253, 27.03151 44.375...
2  LINESTRING (28.26146 38.58253, 27.03151 38.58253)
3  LINESTRING (27.03151 38.58253, 27.03151 44.375...
4  LINESTRING (28.26146 44.37576, 28.26146 38.582...

As you see, I have the sides of the polygons. And I can determine those that have only 2 vertices by first calculating the number of vertices of each LINESTRING and then selecting what I want:
Full_geometry = Full_geometry.rename(columns={'id':'id_gondola','edges.id':'edges_id'})

n_vertices=[]

for i, row in Full_geometry.iterrows():
    ls= row.sides.type.startswith("LINE")
    if ls:
        n = 0
        for part in row.sides:
            n += len(part.coords)
    else:
        n = len(row.sides.coords)
    n_vertices.append(n)

Full_geometry["n_vertices"] = n_vertices

Full_geometry_complete = Full_geometry[Full_geometry['n_vertices']==2]
print(len(Full_geometry_complete))
Full_geometry_complete = Full_geometry_complete.drop(['level_0','level_1'], axis=1).drop_duplicates()
Full_geometry_complete = Full_geometry_complete.reset_index()
Full_geometry_complete['part'] = Full_geometry_complete['level_0'].astype(str)

Full_geometry_complete['Facing_sub'] = Full_geometry_complete.id_gondola.str.cat(Full_geometry_complete.edges_id.astype(str), sep='_')
Full_geometry_complete['Facing'] = Full_geometry_complete.Facing_sub.str.cat(Full_geometry_complete.part.astype(str), sep='_')
Full_geometry_complete = Full_geometry_complete.drop(['level_0','id_gondola','edges_id','part','Facing_sub'], axis=1)

But now, if I plot these, I only have half of the edges (they should be rectangles and I should be able to plot any of these sides individually):I would like to know what I am doing wrong and/or have an easier way to get all sides as unique objects.
Grateful for any help!


text:
Q: How to download an entire dynamic page with wget? I'm trying to download a page from a website with the wget command in Linux, what I want to get is the information contained in the html code of the page,  for instance.
I've tried using R's Rvest and Python's beautiful soup for it but it didn't work, so now I'm trying with wget and mostly I get scripts in .css and .js which I can't extract useful information from (as far as I know), so to summarize I would like to extract information of a  from a dynamic site using the wget command.
I've used the arguments -F, -i and some others, bear in mind that I'm fairly new to computer science and Linux in general, so if this question is trivial please explain it nonetheless, thanks.
Also, if necessary I can post what I've done up until now.

A: with VBA and https://phantomjs.org/
sDir = ThisWorkbook.Path
sCmd = "cmd.exe /K cd """ & sDir & """ & phantomjs.exe phm_save.js " & sURL & " > " & sFile
pid = Shell(sCmd, vbHide)

phm_save.js
   var system = require('system');
   var page = require('webpage').create();

   page.open(system.args[1], function(){
       console.log(page.content);
       phantom.exit();
    }
   );


text:
Q: How to only make links html safe and ignore other html tags in Rails I have a requirement where I need to make links clickable in text while keeping any other html tags as text (not html_safe). This means I cannot make the entire text html_safe as that will render the other html tags and I cannot sanitize the text and remove the other html tags. I've seen other websites handle this by making the html_safe links and other text on their own lines. It looks like the following when inspecting the html.

  "This is an "
  https://example.com/
  "other HTML"

What would be the best way to do this in Rails 4?

A: When you call .html_safe on a string your actually getting an object that behaves like a string but is a ActiveSupport::SafeBuffer. When you append a string to a ActiveSupport::SafeBuffer its automatically escaped. Lets say you want to construct a span where the text is user input:
''.html_safe + text +''.html_safe

In this case we are safe against an XXS attack as the user originated text is automatically escaped:
irb(main):004:0> "".html_safe + "" + "".html_safe
=> "<script>alert('You have been haxxored')</script>"

That's what happens automatically when you output a variable in your views as the view is constructed as a ActiveSupport::SafeBuffer. Whenever you output a regular string it will be automatically escaped thus its secure by default.
Of course there is always going to be a huge number of programmers that just give proceed to give themselves a XSS vulnerability out of ignorance:
# WAAAH! Rails is escaping my tags! Bad rails!
''+ text +''.html_safe

Another way to approach the problem is to use the tag helpers, partials or Nokogiri instead of using string concatenation to construct HTML which in itself is tedious, borderline unreadible and error prone.

A: I was able to get this working using the following.
  #module ApplicationHelper
  def url_regexp
    @url_regexp ||= %r{
      (?:(?:https?|ftp|file):\/\/|www\.|ftp\.)
      (?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|
           [-A-Z0-9+&@#\/%=~_|$?!:,.])*
      (?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|
            [A-Z0-9+&@#\/%=~_|$])
    }ix
  end

  #in the view
    <%- "This is a test https://example.com".partition(url_regexp).each do |text| %>
      <%- if text =~ url_regexp %>
        <%= "#{text}".html_safe %>
      <%- else %>
        <%= text %>
    <% end %>


text:
Q: Generating a 3D object (e.g. via Mayavi) and exporting it as 3D image stack (e.g. tiff) My current task is to generate a 3D image space where there are 3D objects (of iso-surfaces) that I designed and export it as an image stack (numpy or tiff).
I came down to using Mayavi to generate 3D iso-surfaces. I know Mayavi is originally designed to provide 3D visualizations on its own, but I would like to find a way that I can export a 3D object to a 3D image stack as in a numpy form of (z,y,x). My initial idea was to iteratively take snapshots of the sliced volume from the Mayavi mlab object along z-axis but I am not sure if there's any option to save a sliced image of an iso-surface as a snapshot.
The best case scenario would be to export a 3D image stack (tiff) exactly from what I see from a Mayavi window. Otherwise, I will take any suggestions to carry out this task in general.
Here's an example code.
import numpy as np
from mayavi import mlab

# Produce some nice data.
n_mer, n_long = 6, 11
pi = np.pi
dphi = pi/1000.0
phi = np.arange(0.0, 2*pi + 0.5*dphi, dphi, 'd')
mu = phi*n_mer
x = np.cos(mu)*(1+np.cos(n_long*mu/n_mer)*0.5)
y = np.sin(mu)*(1+np.cos(n_long*mu/n_mer)*0.5)
z = np.sin(n_long*mu/n_mer)*0.5

# Init plot
source = mlab.points3d(x, y, z)

A: You might go for the vtk class vtkImplicitModeller.
E.g.:
import numpy as np
from vedo import Points, Volume

n_mer, n_long = 6, 11
dphi = np.pi/1000.0
phi = np.arange(0.0, 2*np.pi + 0.5*dphi, dphi, 'd')
mu = phi*n_mer
x = np.cos(mu)*(1+np.cos(n_long*mu/n_mer)*0.5)
y = np.sin(mu)*(1+np.cos(n_long*mu/n_mer)*0.5)
z = np.sin(n_long*mu/n_mer)*0.5

source = Points([x, y, z], r=4)
modl = source.implicitModeller(
         distance=0.15,
         res=(60,60,30),
         bounds=(-1.8,1.8,-1.8,1.8,-0.7,0.7),
)
modl.smoothLaplacian().computeNormals()
modl.c("blue9").lw(1).lighting("metallic").show(axes=1)

#######################################################
import vtk
imp = vtk.vtkImplicitModeller()
imp.SetInputData(source.polydata())
imp.SetSampleDimensions(50,50,30)
imp.SetModelBounds(-1.8,1.8,-1.8,1.8,-0.7,0.7)
imp.Update()

vol = Volume(imp.GetOutput())
arr = np.clip(vol.getDataArray(), 0, 1.2)
print(arr.shape)


text:
Q: How to calculate $\lim\limits_{n \to \infty } \left(\frac{n+1}{n-1}\right)^{3n^{2}+1}$? I have $\lim_{n \to \infty } \biggr(\dfrac{n+1}{n-1}\biggr)^{3n^{2}+1}$
and I use this way: $\lim_{n \to \infty } \frac{n+1}{n-1}=|\frac{\infty}{\infty}|=\lim_{n \to \infty } \frac{1+\frac{1}{n}}{1-\frac{1}{n}}=1$ and $\lim_{n \to \infty } 3n^{2}+1=\infty$
Then $\lim_{n \to \infty } \frac{n+1}{n-1}^{3n^{2}+1}=|1^{\infty}|$
Continue using the formula $\lim_{n \to \infty } (1+\frac{1}{n})^{n}=e$, I decide to limit and get an answer: $\infty$, and it is right.
But for some reason I can imagine $\lim_{n \to \infty } \frac{n+1}{n-1}^{3n^{2}+1}$ how $\lim_{n \to \infty } \frac{n+1}{n-1}=|\frac{\infty}{\infty}|=\lim_{n \to \infty } \frac{1+\frac{1}{n}}{1-\frac{1}{n}}=1$ and $\lim_{n \to \infty } 3n^{2}+1=\infty$ ?
I can't find such a property of limits.

A: To apply your formula, notice that
$$\left(\frac{n+1}{n-1}\right)^{3n^2+1}=\left(1+\frac2{n-1}\right)^{3n^2+1}$$
Let $u=\frac{n-1}2$ or $n=2u+1$,
$$=\left(1+\frac1u\right)^{12u^2+12u+4}=\left(\left(1+\frac1u\right)^u\right)^{12(u+1)}\left(1+\frac1u\right)^4$$
$$\to e^{12(u+1)}\to e^\infty=\infty$$
Thus, the limit is infinite.

A: $$\lim\limits_{n \to \infty } \left(\frac{n+1}{n-1}\right)^{3n^{2}+1}$$
Note the Bernoulli inequality $(1+x)^m\ge1+mx$. Then:
$$\left(\frac{n+1}{n-1}\right)^{3n^{2}+1}=\left(1+\frac{2}{n-1}\right)^{3n^{2}+1}\ge 1+\frac{2(3n^2+1)}{n-1}\ge1+\frac{(2)(3n^2)}{n}=1+6n\to\infty$$

A: Hint
Consider $$a_n=\left( \frac{n+1}{n-1}\right)^{3n^{2}+1}$$ $$\log(a_n)=(3n^2+1)\log\left( \frac{n+1}{n-1}\right)=(3n^2+1)\log\left( \frac{1+\frac 1n}{1-\frac1n}\right)$$ Now, use Taylor for infinitely large $n$ $$\log\left( \frac{1+\frac 1n}{1-\frac1n}\right)=\frac{2}{n}+\frac{2}{3 n^3}+O\left(\frac{1}{n^5}\right)$$

A: Lots of the confusion in OP seems to due to the careless use of the symbol $\infty$.
The symbol $\infty$ is not a real number. One should not do the arithmetic carelessly with it. For instance one should have
$$
\lim_{n\to \infty}\frac{2n}{n}=2,
\quad
\lim_{n\to \infty}\frac{3n}{n}=3.
$$
But if one carelessly use the symbol $\infty$, one would have
$$
\lim_{n\to \infty}\frac{2n}{n}=\lim_{n\to \infty}\frac{3n}{n}=\frac{\infty}{\infty}=1
$$
which is nonsense.

Now go back to the calculation

$$\lim\limits_{n \to \infty } \left(\frac{n+1}{n-1}\right)^{3n^{2}+1}\tag{1}$$

Do you know
$$
\lim_{n\to \infty}\left(1+\frac{1}{n}\right)^n=e?\tag{2}
$$
(1) and (2) are similar:
$$
\left(\frac{n+1}{n-1}\right)^{3n^{2}+1}=\biggr[\biggr(1+\frac{1}{\frac{n-1}{2}}\biggr)^{\frac{n-1}{2}}\biggr]^{\dfrac{2(3n^2+1)}{n-1}}
$$

A: Take logarithms. Then by the Mean Value Theorem there exists $a\in (n-1,n+1)$:
$\displaystyle{\frac{1}{n+1}<\frac{1}{a}=\frac{\ln (n+1)-\ln (n-1)}{(n+1)-(n-1)}=\frac{\ln (n+1)-\ln (n-1)}{2}}$
Thus
$\displaystyle{(3n^2+1)\ln (\frac{n+1}{n-1})>\frac{6n^2+2}{n+1}}$
Since $\displaystyle{\frac{6n^2+2}{n+1}\rightarrow +\infty}$ we conclude that $\displaystyle{(3n^2+1)\ln (\frac{n+1}{n-1})\rightarrow +\infty}$ too. And your problem is solved.


text:
Q: Noob error in Python opening a file I am placing this code into IDLE:
f = open('/Users/alex/Documents/URM8/health.tdf')

I don't understand why I am unable to open it. I get the error:
Traceback (most recent call last):
  File "<pyshell#21>", line 1, in <module>
    f = open('/Users/alex/Documents/URM8/health.tdf')
IOError: [Errno 2] No such file or directory: '/Users/alex/Documents/URM8/health.tdf'

Of course usually the problem is filename. I have checked it lots of times and it is correct.
I 'unlocked' the file (I'm using Mac OSX). Also set write access to Everyone in Mac OSX.
Do i need to set permissions in Bash?
Really appreciate someone telling me what I'm doing wrong!

A: /Users/alex/Documents/URM8/health.tdf cannot be opened because it's not there; the Mac OS UI hides the .txt extension. open('/Users/alex/Documents/URM8/health.tdf.txt') works fine.

A: The problem is not the permissions. If it were, the error message would be different. Is some component of the path a Mac alias to a directory, rather than a directory? If so, Python won't follow it, and will give that error.
Try individual parts of the pathname to see exactly which directory or file Python can't find. You could do this simply using cd in the shell.

A: Are you trying to use a relative path? The leading '/' could be a problem.
You don't specifically define the file mode ("r", "w", etc.) in your open call, you may want to reconsider this.
You could try ls -l on the file to get its permissions.
chmod u+rw <FILE> should give you access.


text:
Q: glitchy access website, freezes for 30-60 sec intermittently asp website with access database freezes for 30-60 seconds intermittently. The site is on an internal 2008 server. About 25 users access the site simultaneously. Is it just the limits of access or can i do something to improve the situation? change any timeout/refresh settings anywhere? or could it be a problem with the network?

A: Are you sure you that no one is viewing data using a sql enterprise program ?
I have noticed that when you do a select whatever from ... query, and you do not commit the transaction (in the viewing program), you can have freezes when accessing the same database using a web site interface (like web pages using asp).
Please specify the database you are using, since that can make a difference.


text:
Q: Failed to connect to: localhost:27017: Connection refused I have installed MongoDB in xampp on Ubuntu using Laravel 5.1. But I always get this error

MongoConnectionException in TestController.php line 19: Failed to
  connect to: localhost:27017: Connection refused

Nor I'm able
I have gone through a lot of questions, but all proved to be trivial solution.
Please help me with this as I'm stuck on it.

A: I think that first thing to do is to ssh on that server and check that mongod process is alive, then try open mongo shell using command - mongo . If all works try telnet on this server and port from your machine ,if there is no errors , read mongo logs


text:
Q: org.hibernate.QueryException: duplicate association path for @ManyToOne Criteria I have two classes which has a relationship between them. These are
com.edfx.adb.persist.Activity:
package com.edfx.adb.persist.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.NaturalId;

@javax.persistence.Entity
@Table(name = "ACTIVITY")
public class Activity extends Entity {

    @Transient
    private static final long serialVersionUID = 4741665931936809028L;

    private String activityId;
    private String activityName;
    private String activityDescription;
    private Customer customer;
    private ActivityType activityType;
    private boolean active;
    private Double mandays;
    private Double price;
    private String manager;
    private List<Participation> participations;

    public Activity() {
        super();
    }

    @NaturalId
    @Column(name = "ACTIVITY_ID", nullable = false)
    public String getActivityId() {
        return activityId;
    }

    public void setActivityId(String activityId) {
        this.activityId = activityId;
    }

    @Lob
    @Column(name = "ACTIVITY_NAME", nullable = false)
    public String getActivityName() {
        return activityName;
    }

    public void setActivityName(String activityName) {
        this.activityName = activityName;
    }

    @Lob
    @Column(name = "ACTIVITY_DESCRIPTION", nullable = false)
    public String getActivityDescription() {
        return activityDescription;
    }

    public void setActivityDescription(String activityDescription) {
        this.activityDescription = activityDescription;
    }

    @ManyToOne
    @JoinColumn(name = "CUSTOMER_ID", nullable = false)
    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    @ManyToOne
    @JoinColumn(name = "ACTIVITY_TYPE_ID", nullable = false)
    public ActivityType getActivityType() {
        return activityType;
    }

    public void setActivityType(ActivityType activityType) {
        this.activityType = activityType;
    }

    @Column(name = "ACTIVE", nullable = false)
    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    @Column(name = "MANDAYS")
    public Double getMandays() {
        return mandays;
    }

    public void setMandays(Double mandays) {
        this.mandays = mandays;
    }

    @Column(name = "PRICE")
    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    @Column(name = "CUSTOMER_SIDE_MANAGER")
    public String getManager() {
        return manager;
    }

    public void setManager(String manager) {
        this.manager = manager;
    }

    @OneToMany(mappedBy = "activity", fetch = FetchType.LAZY)
    @Cascade(CascadeType.SAVE_UPDATE)
    public List<Participation> getParticipations() {
        return participations;
    }

    public void setParticipations(List<Participation> participations) {
        this.participations = participations;
    }
}

com.edfx.adb.persist.ActivityType:
package com.edfx.adb.persist.entity;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;

@javax.persistence.Entity
@Table(name = "ACTIVITY_TYPE")
public class ActivityType extends Entity {

    @Transient
    private static final long serialVersionUID = 2322745769010162801L;

    private String parent;
    private String name;
    private String activityId;

    public ActivityType() {

    }

    @Column(name = "PARENT", nullable = false)
    public String getParent() {
        return parent;
    }

    public void setParent(String parent) {
        this.parent = parent;
    }

    @Column(name = "NAME", nullable = false)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "ACTIVITY_ID", nullable = false)
    public String getActivityId() {
        return activityId;
    }

    public void setActivityId(String activityId) {
        this.activityId = activityId;
    }
}

Both of them extends com.edfx.adb.persist.entity.Entity:
package com.edfx.adb.persist.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.Version;

import org.hibernate.proxy.HibernateProxyHelper;

@MappedSuperclass
public class Entity implements Serializable {

    @Transient
    private static final long serialVersionUID = 7470288121057059283L;

    private Long id;
    private Date createTimestamp;
    private Date lastUpdateTimestamp;
    private Long version;

    public Entity() {
        super();
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", updatable = false, nullable = false, unique = true)
    public Long getId() {
        return id;
    }

    @SuppressWarnings("unused")
    private void setId(Long id) {
        this.id = id;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "CREATE_TIMESTAMP")
    public Date getCreateTimestamp() {
        return createTimestamp;
    }

    public void setCreateTimestamp(Date createTimestamp) {
        this.createTimestamp = createTimestamp;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "LAST_UPDATE_TIMESTAMP")
    public Date getLastUpdateTimestamp() {
        return lastUpdateTimestamp;
    }

    public void setLastUpdateTimestamp(Date lastUpdateTimestamp) {
        this.lastUpdateTimestamp = lastUpdateTimestamp;
    }

    @Version
    @Column(name = "VERSION")
    public Long getVersion() {
        return version;
    }

    @SuppressWarnings("unused")
    private void setVersion(Long version) {
        this.version = version;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        return prime * result + ((getId() == null) ? super.hashCode() : getId().hashCode());
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (obj == null) {
            return false;
        }

        if (!getClass().equals(HibernateProxyHelper.getClassWithoutInitializingProxy(obj))) {
            return false;
        }

        final Entity other = (Entity) obj;

        if (getId() != other.getId()) {
            if (getId() == null) {
                return false;
            }
            if (!getId().equals(other.getId())) {
                return false;
            }
        }

        return true;
    }
}

Now I am using Primefaces datatable to show a List<Activity> in which I have filtering on the field name of ActivityType. ActivityType is associated with Activity by @ManyToOne relationship.
For filtering the List<Activity> I am using:
Criteria criteria = getSessionFactory().getCurrentSession().createCriteria(Activity.class);
criteria.createCriteria("activityType").add(Restrictions.like("name", value.toString(), MatchMode.START));

I am getting:
null: org.hibernate.QueryException: duplicate association path: activityType
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.createAssociationPathCriteriaMap(CriteriaQueryTranslator.java:172) [hibernate-core-4.1.8.Final.jar:4.1.8.Final]
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.<init>(CriteriaQueryTranslator.java:111) [hibernate-core-4.1.8.Final.jar:4.1.8.Final]
    at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:84) [hibernate-core-4.1.8.Final.jar:4.1.8.Final]
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1602) [hibernate-core-4.1.8.Final.jar:4.1.8.Final]
    at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374) [hibernate-core-4.1.8.Final.jar:4.1.8.Final]
    at com.edfx.adb.dao.ActivityDao.loadActivities(ActivityDao.java:54) [classes:]
    at com.edfx.adb.service.ActivityService.loadActivities(ActivityService.java:101) [classes:]

This error is not showing always and never after the first load. After filtering the table for 5-6 time, I am having this error.
I am worried that if the mapping and the criteria is right or not. Any suggestion would be very helpful.

A: I think you need to provide an alias, so you should change your code this way:
Criteria criteria = getSessionFactory().getCurrentSession().createCriteria(Activity.class);

criteria.createCriteria("activityType", "at")
   .add(
       Restrictions.like("at.name", value.toString(), MatchMode.START));


text:
Q: How to call services when moving one ViewModel to another I have LandingPageViewModel with GetHomework Button. If I click on GetHomework Button it takes to HomeworkPageViewModel.
Now the problem is, where to call my service to get Homework data?
In LandingPageViewModels GetHomeworkExecute() method and hold all Homework record in public accessible variable OR use NavigationParameter to pass to the next page then use it in HomeworkPageViewModel(or in other ViewModels if holding record in global variable).
OR
In HomeworkPageViewModels OnNavigatingTo()(act as onload I think) method overridden by INavigatedAware
What is the good way to call the service when moving one ViewModel to another?

A: I'd put it into HomeworkPageViewModel, probably in the constructor (unless it's an async call). Rationale: if the HomeworkPageViewModel can do it (because it does not need additional info), then let it do it. Try not to spread out things, keep your code together.


text:
Q: How to get class instances of generic types in generic methods I have a generic method, how could I get the class of T?
class MyClass
{
    static <T> void foo(T t)
    {
        // how to get T.class
    }
}

t.getClass() gets the most derived class, but T could be a super class so it does not work in case of MyClass.<Collection>foo(new ArrayList()).

A: If you want to keep your signature it is not possible. However, there's a way to solve this by providing the type as a separate argument.
static <T> void foo(T t, Class<T> cls) {
   // use cls
}

Then instead of invoking
MyClass.<Collection> foo(new ArrayList());

you call
MyClass.foo(new ArrayList(), Collection.class);


text:
Q: Possible to svn export and include unversioned files? I would like to export my code from the working svn copy while including all unversioned files. For example, there are uploaded images/config files etc, that I would like included in the export.
How can I achieve this?

A: What do you mean by "export"? You can just use cp -r to copy the directory tree directly, and then remove the .svn directories afterwards: find . -name .svn -type d -exec rm -r '{}' \;

A: I don't know if there's a built in command for that. You could write a script that interprets the output of svn st which will output unversioned files ?   marked/with/a/question/mark.config

A: I know this question is rather old, and is marked as answered. But I found an other way, hope it's useful for other ones
- Create new folder which stores you exported code
- RIGHT DRAG your source repository to newly created folder. Then you will see interesting context menu can help.
Ref : http://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-dug-export.html


text:
Q: ExpressionEngine 2.8.1: in channel form date field gives error I have a grid in my channel form which uses a datefield. This gives the following javascript error in my console:
Uncaught TypeError: Cannot read property 'date_format' of undefined
or in FireFox: EE.date is undefined
Now the datepicker for that field is disabled, and no javascript after gets executed.
EE version: 2.8.1
greets
Rick

A: It sounds like you are affected by this bug that contains the following solution:
Open up system/expressionengine/fieldtypes/date/ft.date.php and look at lines 168-172:
$date_js_globals = array(
    'date_format'       => ee()->localize->datepicker_format(),
    'time_format'       => ee()->session->userdata('time_format', ee()->config->item('time_format')),
    'include_seconds'   => ee()->session->userdata('include_seconds', ee()->config->item('include_seconds'))
);

Replace those lines with these:
$date_js_globals = array(
    'date_format'       => ee()->localize->datepicker_format(),
    'time_format'       => ee()->session->userdata('time_format', ee()->config->item('time_format')),
    'include_seconds'   => ee()->session->userdata('include_seconds', ee()->config->item('include_seconds'))
);

if (REQ == 'CP')
{
    ee()->javascript->set_global('date', $date_js_globals);
}
elseif ( ! ee()->session->cache(__CLASS__, 'date_js_loaded'))
{
    // We only want to set the date global once
    ee()->session->set_cache(__CLASS__, 'date_js_loaded', TRUE);
    ee()->javascript->output('EE.date = '.json_encode($date_js_globals).';');
}

ee()->cp->add_js_script(array(
    'ui' => 'datepicker',
    'file' => 'cp/date'
));


text:
Q: How to view this specific data in page? I am trying to build a blog website as follow:
Category Model
public class Category
    {
        public int CategoryID { get; set; }
        public String CategoryName { get; set; }
        public virtual List
 Articles { get; set; }
    }

Article Model
public class Article
    {
        public int Id { get; set; }
        public string Header { get; set; }
        public string Content { get; set; }
        public byte[] BlogImage{ get; set; }
        public DateTime? CreationDate{ get; set; }
        public int? CategoryID{ get; set; }
        public virtual Category Category { get; set; }
    }

So, how can I send data in ActionResult function and view blog card in page like this image?
public ActionResult Index()
        {
            using (MvcBlogContext context = new MvcBlogContext())
            {
                 // how to code here?
            }
        }

     @foreach (var item in Model)
     {

            // how to view category name here?

     }

     @foreach (var item in Model)
     {

                <div class="post post-widget"
                     // how to view from 2nd to 4th blog here?

     }

Can you help me about this?

A: To answer one of your questions - selecting the first entry and then the rest you could try
@foreach (var item in Model.Take(1))

for the first row, and then
@foreach (var item in Model.Skip(1))

for the rest. It assumes that the data in your model is ordered appropriately.


text:
Q: JavaScript get the last number in a string and replace it with its next I have this string
let str = "c-fl_1"

and I need to replace the last number '1' with its next '2', so the result string will look like:
"c-fl_2"

Also I need to do that with all the strings which follow this format... For example, the string "c-fl_9102" should change to "c-fl_9103".
Currently I am doing this, and working fine
str = str.replace(new RegExp('\\d+$'), (parseInt(str.match(new RegExp('\\d+$'))) + 1).toString());

but I need a more elegant, legible and efficient solution.
Any ideas? Thank you.

A: Using replacer method

let str = "c-fl_1"

let res = str.replace(new RegExp('\\d+$', 'g'), (match) => +match + 1);

console.log(res)


text:
Q: react js localhost working but heroku not working for customer email sending My Localhost500 working but heroku link not to send email and not to show any error =>this is heroku logs --tail message:
2022-05-18T10:43:47.325326+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=7cf77536-632c-4ac5-98e2-51581e723818 fwd="59.153.17.150" dyno=web.1 connect=0ms service=376ms status=304 bytes=183 protocol=https 2022-05-18T10:44:40.680794+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=2eade93e-b6fb-4ee4-b1f1-77902b033b73 fwd="59.153.17.150" dyno=web.1 connect=0ms service=376ms status=304 bytes=183 protocol=https 2022-05-18T10:59:41.498704+00:00 heroku[web.1]: Restarting 2022-05-18T10:59:41.520899+00:00 heroku[web.1]: State changed from up to starting 2022-05-18T10:59:42.111370+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2022-05-18T10:59:42.341468+00:00 heroku[web.1]: Process exited with status 143 2022-05-18T10:59:44.054279+00:00 heroku[web.1]: Starting process with command npm start 2022-05-18T10:59:45.749250+00:00 app[web.1]: 2022-05-18T10:59:45.749261+00:00 app[web.1]: > doctors-portal-server@1.0.0 start 2022-05-18T10:59:45.749261+00:00 app[web.1]: > node index.js 2022-05-18T10:59:45.749261+00:00 app[web.1]: 2022-05-18T10:59:46.203340+00:00 app[web.1]: Doctors app listening on port 54112 2022-05-18T10:59:46.257941+00:00 heroku[web.1]: State changed from starting to up 2022-05-18T11:00:02.530314+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=109507ed-1635-4dbd-a73e-893a73720055 fwd="59.153.17.150" dyno=web.1 connect=0ms service=387ms status=304 bytes=183 protocol=https 2022-05-18T11:00:05.043814+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=2f27c09c-67a9-49f9-948c-c5e4d5b0f38b fwd="59.153.17.150" dyno=web.1 connect=0ms service=374ms status=304 bytes=183 protocol=https 2022-05-18T11:00:07.725084+00:00 heroku[router]: at=info method=OPTIONS path="/%20booking" host=polar-spire-82017.herokuapp.com request_id=18bdc39b-1132-4cf6-93ec-64f4983ec15a fwd="59.153.17.150" dyno=web.1 connect=1ms service=1ms status=204 bytes=301 protocol=https 2022-05-18T11:00:08.034377+00:00 heroku[router]: at=info method=POST path="/%20booking" host=polar-spire-82017.herokuapp.com request_id=a6e48f02-9c60-4a1d-8c43-d0ab42df1dd9 fwd="59.153.17.150" dyno=web.1 connect=0ms service=9ms status=404 bytes=426 protocol=https 2022-05-18T11:15:51.000000+00:00 app[api]: Build started by user wabshahid@gmail.com 2022-05-18T11:16:20.165487+00:00 app[api]: Deploy d3f67e26 by user wabshahid@gmail.com 2022-05-18T11:16:20.165487+00:00 app[api]: Release v10 created by user wabshahid@gmail.com 2022-05-18T11:16:20.425706+00:00 heroku[web.1]: Restarting 2022-05-18T11:16:20.439686+00:00 heroku[web.1]: State changed from up to starting 2022-05-18T11:16:21.000000+00:00 app[api]: Build succeeded 2022-05-18T11:16:21.141158+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2022-05-18T11:16:21.296685+00:00 heroku[web.1]: Process exited with status 143 2022-05-18T11:16:23.006032+00:00 heroku[web.1]: Starting process with command npm start 2022-05-18T11:16:24.768519+00:00 app[web.1]: 2022-05-18T11:16:24.768529+00:00 app[web.1]: > doctors-portal-server@1.0.0 start 2022-05-18T11:16:24.768529+00:00 app[web.1]: > node index.js 2022-05-18T11:16:24.768530+00:00 app[web.1]: 2022-05-18T11:16:25.164573+00:00 app[web.1]: Doctors app listening on port 32190 2022-05-18T11:16:25.279013+00:00 heroku[web.1]: State changed from starting to up 2022-05-18T11:16:26.326344+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=348516c5-34ac-478f-bfe7-cfb72eb3326b fwd="59.153.17.150" dyno=web.1 connect=0ms service=7ms status=404 bytes=424 protocol=https 2022-05-18T11:16:28.015051+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=3073312a-0ca7-4879-9b2c-81ef9647fa5e fwd="59.153.17.150" dyno=web.1 connect=0ms service=387ms status=200 bytes=2506 protocol=https 2022-05-18T11:16:30.555903+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=d29c817e-4191-4885-bf7d-511425192cc3 fwd="59.153.17.150" dyno=web.1 connect=0ms service=381ms status=304 bytes=183 protocol=https 2022-05-18T11:16:37.454635+00:00 heroku[router]: at=info method=OPTIONS path="/%20booking" host=polar-spire-82017.herokuapp.com request_id=22214293-2796-454b-aa06-b037aeb987b3 fwd="59.153.17.150" dyno=web.1 connect=0ms service=1ms status=204 bytes=301 protocol=https 2022-05-18T11:16:37.747749+00:00 heroku[router]: at=info method=POST path="/%20booking" host=polar-spire-82017.herokuapp.com request_id=cc833a59-212b-4a4e-b461-347eab237ff4 fwd="59.153.17.150" dyno=web.1 connect=0ms service=15ms status=404 bytes=426 protocol=https 2022-05-18T11:16:54.559647+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=05da1cdc-1345-4129-a1ed-adcb36d5cafe fwd="59.153.17.150" dyno=web.1 connect=0ms service=383ms status=304 bytes=183 protocol=https 2022-05-18T11:17:01.338332+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=6b0011c2-4367-4f1e-8049-03528482924e fwd="59.153.17.150" dyno=web.1 connect=0ms service=381ms status=304 bytes=183 protocol=https 2022-05-18T11:17:45.822793+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=bc0c137a-380d-4a3a-8312-948050095846 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=304 bytes=183 protocol=https 2022-05-18T11:17:59.192010+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=e51f6fc0-b454-4e63-af9b-abe5e5fd2c38 fwd="59.153.17.150" dyno=web.1 connect=0ms service=381ms status=304 bytes=183 protocol=https 2022-05-18T11:17:59.597926+00:00 heroku[router]: at=info method=OPTIONS path="/%20booking" host=polar-spire-82017.herokuapp.com request_id=df2a851a-e923-4f17-9414-10780671f76e fwd="59.153.17.150" dyno=web.1 connect=0ms service=2ms status=204 bytes=301 protocol=https 2022-05-18T11:17:59.894621+00:00 heroku[router]: at=info method=POST path="/%20booking" host=polar-spire-82017.herokuapp.com request_id=45a349d5-b8ca-450f-9b58-2c047fa1eb91 fwd="59.153.17.150" dyno=web.1 connect=0ms service=5ms status=404 bytes=426 protocol=https 2022-05-18T11:19:12.796151+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=478f8ccf-22fc-434a-b92e-474528fc701d fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=304 bytes=183 protocol=https 2022-05-18T11:19:17.295401+00:00 heroku[router]: at=info method=OPTIONS path="/%20booking" host=polar-spire-82017.herokuapp.com request_id=711d90d0-5a99-4989-b775-7e948112b5e4 fwd="59.153.17.150" dyno=web.1 connect=0ms service=2ms status=204 bytes=301 protocol=https 2022-05-18T11:19:17.595331+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=00baae21-559f-41fc-a630-959b29df5548 fwd="59.153.17.150" dyno=web.1 connect=0ms service=379ms status=304 bytes=183 protocol=https 2022-05-18T11:19:17.602068+00:00 heroku[router]: at=info method=POST path="/%20booking" host=polar-spire-82017.herokuapp.com request_id=45f72d54-82d6-44c3-8848-3fad0656b233 fwd="59.153.17.150" dyno=web.1 connect=0ms service=9ms status=404 bytes=426 protocol=https 2022-05-18T11:19:29.075155+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=02f23e75-a0ba-4f02-bcf6-d194ce93a4ec fwd="59.153.17.150" dyno=web.1 connect=0ms service=382ms status=304 bytes=183 protocol=https 2022-05-18T11:19:33.934887+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=715e934d-17d0-455a-adc3-55d611eae202 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=304 bytes=183 protocol=https 2022-05-18T11:19:40.856019+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=cc46d75d-dab9-40f4-a1b5-d7aa19cf72f3 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=304 bytes=183 protocol=https 2022-05-18T11:20:10.711628+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=dee9f5a8-32ed-4475-8912-741b5d6b64d8 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=304 bytes=183 protocol=https 2022-05-18T11:20:15.093858+00:00 heroku[router]: at=info method=OPTIONS path="/%20booking" host=polar-spire-82017.herokuapp.com request_id=456cc584-b17e-4862-afef-2ef769dcb473 fwd="59.153.17.150" dyno=web.1 connect=0ms service=1ms status=204 bytes=301 protocol=https 2022-05-18T11:20:15.384672+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=30a19b17-420c-4e65-a2a1-f73062efd034 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=304 bytes=183 protocol=https 2022-05-18T11:20:15.419001+00:00 heroku[router]: at=info method=POST path="/%20booking" host=polar-spire-82017.herokuapp.com request_id=5c6cd372-5f7d-4e1b-afbd-76acbf416ff9 fwd="59.153.17.150" dyno=web.1 connect=0ms service=21ms status=404 bytes=426 protocol=https 2022-05-18T11:20:42.367526+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=44f68d1e-c02a-418a-9a5b-cd78779b9b64 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=304 bytes=183 protocol=https 2022-05-18T11:20:48.631398+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=0699440c-5672-496a-960c-843eef7844c8 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=200 bytes=2484 protocol=https 2022-05-18T11:20:50.787560+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=b50f27a1-f8c0-4c57-bbae-5e1b68297be8 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=304 bytes=183 protocol=https 2022-05-18T11:23:27.936238+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=636f0546-e7c0-402f-8877-e4eb415954f9 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=304 bytes=183 protocol=https 2022-05-18T11:23:31.916768+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=c3af435c-04b7-4bbb-86b9-6b0f8547e496 fwd="59.153.17.150" dyno=web.1 connect=0ms service=379ms status=304 bytes=183 protocol=https 2022-05-18T11:23:35.847791+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=ced3e4cd-5aec-498a-8857-778498d87315 fwd="59.153.17.150" dyno=web.1 connect=0ms service=379ms status=304 bytes=183 protocol=https 2022-05-18T11:23:36.688003+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=51c7b27b-1d27-4365-bc9d-1a91b993b561 fwd="59.153.17.150" dyno=web.1 connect=0ms service=379ms status=304 bytes=183 protocol=https 2022-05-18T11:23:42.051207+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=a72a586d-ae54-4358-bfdb-124a1520aa43 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=200 bytes=2462 protocol=https 2022-05-18T11:23:47.988900+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=6816d43c-57f1-40f3-8432-3cdc856d947e fwd="59.153.17.150" dyno=web.1 connect=0ms service=379ms status=304 bytes=183 protocol=https 2022-05-18T11:23:52.172196+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=13b62612-7ab3-493d-b01c-f66c81762273 fwd="59.153.17.150" dyno=web.1 connect=0ms service=379ms status=304 bytes=183 protocol=https 2022-05-18T11:25:52.602425+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=44928f13-913a-432f-a020-316a1762e9da fwd="59.153.17.150" dyno=web.1 connect=0ms service=379ms status=304 bytes=183 protocol=https 2022-05-18T11:25:56.391634+00:00 heroku[router]: at=info method=OPTIONS path="/booking" host=polar-spire-82017.herokuapp.com request_id=ce467915-e981-4735-a575-142ede13d8aa fwd="59.153.17.150" dyno=web.1 connect=0ms service=1ms status=204 bytes=301 protocol=https 2022-05-18T11:25:57.080697+00:00 app[web.1]: sending email 2022-05-18T11:25:57.080801+00:00 app[web.1]: shahidulislam1474@gmail.com 2022-05-18T11:25:57.088364+00:00 heroku[router]: at=info method=POST path="/booking" host=polar-spire-82017.herokuapp.com request_id=f957d1b9-2138-4421-bd12-1e269e4ba24f fwd="59.153.17.150" dyno=web.1 connect=0ms service=400ms status=200 bytes=326 protocol=https 2022-05-18T11:25:57.239924+00:00 app[web.1]: Error: The provided authorization grant is invalid, expired, or revoked 2022-05-18T11:25:57.239925+00:00 app[web.1]: at Request._callback (/app/node_modules/sendgrid/lib/sendgrid.js:88:25) 2022-05-18T11:25:57.239926+00:00 app[web.1]: at Request.self.callback (/app/node_modules/request/request.js:185:22) 2022-05-18T11:25:57.239928+00:00 app[web.1]: at Request.emit (node:events:527:28) 2022-05-18T11:25:57.239929+00:00 app[web.1]: at Request. (/app/node_modules/request/request.js:1154:10) 2022-05-18T11:25:57.239929+00:00 app[web.1]: at Request.emit (node:events:527:28) 2022-05-18T11:25:57.239930+00:00 app[web.1]: at IncomingMessage. (/app/node_modules/request/request.js:1076:12) 2022-05-18T11:25:57.239930+00:00 app[web.1]: at Object.onceWrapper (node:events:641:28) 2022-05-18T11:25:57.239931+00:00 app[web.1]: at IncomingMessage.emit (node:events:539:35) 2022-05-18T11:25:57.239931+00:00 app[web.1]: at endReadableNT (node:internal/streams/readable:1345:12) 2022-05-18T11:25:57.239931+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:83:21) 2022-05-18T11:25:57.770253+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=5b309fb7-be8d-4184-9269-167466d303d4 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=200 bytes=2440 protocol=https 2022-05-18T11:26:14.061775+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=c1da091a-95fa-459c-9be3-5135f6fc5786 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=304 bytes=183 protocol=https 2022-05-18T11:26:19.068600+00:00 heroku[router]: at=info method=OPTIONS path="/booking" host=polar-spire-82017.herokuapp.com request_id=5e34c455-f34f-4ee1-967c-ab9dd3f83401 fwd="59.153.17.150" dyno=web.1 connect=0ms service=1ms status=204 bytes=301 protocol=https 2022-05-18T11:26:19.776726+00:00 app[web.1]: sending email 2022-05-18T11:26:19.776803+00:00 app[web.1]: shahidulislam1474@gmail.com 2022-05-18T11:26:19.778514+00:00 heroku[router]: at=info method=POST path="/booking" host=polar-spire-82017.herokuapp.com request_id=79834e1e-8843-4684-8f62-85b95bb5936d fwd="59.153.17.150" dyno=web.1 connect=0ms service=412ms status=200 bytes=326 protocol=https 2022-05-18T11:26:19.878142+00:00 app[web.1]: Error: The provided authorization grant is invalid, expired, or revoked 2022-05-18T11:26:19.878143+00:00 app[web.1]: at Request._callback (/app/node_modules/sendgrid/lib/sendgrid.js:88:25) 2022-05-18T11:26:19.878143+00:00 app[web.1]: at Request.self.callback (/app/node_modules/request/request.js:185:22) 2022-05-18T11:26:19.878144+00:00 app[web.1]: at Request.emit (node:events:527:28) 2022-05-18T11:26:19.878144+00:00 app[web.1]: at Request. (/app/node_modules/request/request.js:1154:10) 2022-05-18T11:26:19.878144+00:00 app[web.1]: at Request.emit (node:events:527:28) 2022-05-18T11:26:19.878145+00:00 app[web.1]: at IncomingMessage. (/app/node_modules/request/request.js:1076:12) 2022-05-18T11:26:19.878147+00:00 app[web.1]: at Object.onceWrapper (node:events:641:28) 2022-05-18T11:26:19.878147+00:00 app[web.1]: at IncomingMessage.emit (node:events:539:35) 2022-05-18T11:26:19.878147+00:00 app[web.1]: at endReadableNT (node:internal/streams/readable:1345:12) 2022-05-18T11:26:19.878148+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:83:21) 2022-05-18T11:26:22.038030+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=7e2075e1-c321-47f6-b778-da1102f102d9 fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=200 bytes=2418 protocol=https 2022-05-18T11:26:40.843375+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=e7530428-8656-4fb2-9664-592d4159b7fb fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=304 bytes=183 protocol=https 2022-05-18T11:26:42.855845+00:00 heroku[router]: at=info method=GET path="/available?date=May%2018,%202022" host=polar-spire-82017.herokuapp.com request_id=c219d093-5d90-463d-b5a9-903e5b80685d fwd="59.153.17.150" dyno=web.1 connect=0ms service=380ms status=304 bytes=183 protocol=https

A: use procfile in main Directory and describe web : index.js in Procfile
enter image description here


text:
Q: Using alternative of Library loaded by Java Bootstrap class loader I need use the both jars local_policy.jar and US_export_policy.jar with unlimited key size strength. The JRE comes bundled with versions of the jars, with limited key size strength. But I can't replace the original jars in the $JAVA_HOME/lib/security (insufficient rights), so i need them to override (at runtime?) somehow.
Any ideas?

A: It would appear that you can override the bootstrap classpath with the -Xbootclasspath JVM argument. See the 'Non-standard options' section of this page for more info.


text:
Q: AttributeError: module 'tensorflow' has no attribute 'GraphDef' In attempting to run the following in PyCharm 2017.3.1:
with open('../data/UrbanSound8K/retrained_graph.pb', 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    tf.import_graph_def(graph_def, name='')

I receive the following:
/anaconda/bin/python3 /Users/PycharmProjects/UrbanSound/src/recognize_sound.py
Traceback (most recent call last):
  File "/Users/PycharmProjects/UrbanSound/src/recognize_sound.py", line 12, in <module>
    graph_def = tf.GraphDef()
AttributeError: module 'tensorflow' has no attribute 'GraphDef'

Here is some environment information:
(tensorflow) $ python3 -c 'import tensorflow as tf; print(tf.__version__)'
1.4.0
(tensorflow) $ python -V
Python 3.6.2

Thank you in advance for your help.

A: I resolved it using

python36 -m pip install tensorflow-gpu==1.14

A: use "tf.compat.v1.GraphDef()" instead if you are using tensorflow 2.0

A: disable V2 behavior
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

or use this tf.compat.v1.GraphDef()


text:
Q: Зачем нужен private, если есть public? Я знаю что такое private и что такое public, вопрос в другом. Зачем переменные и методы делать private и ограничивать доступ к ним, если можно сделать их всех public и не думать пригодится тебе они в других скриптах или нет?

A: private нужен именно для того, чтобы кто попало снаружи не мог лазить во внутренние поля класса и произвольно менять их состояние. Да и "подсматривать" тоже не мог. Есть публичные поля и свойства - пожалуйте обращаться к ним. А когда снаружи могут как угодно менять состояние класса, это уже бардак какой-то. Внутреннее состояние и его поддержание в актуальном непротиворечивом состоянии - это внутреннее дело класса.
Как минимум, так гораздо легче искать ошибки в программах, когда у классов есть ограниченное число "точек доступа", которые нужно проверить, чтобы убедиться, что класс работает нужным образом. Если класс "полностью прозрачен" для доступа снаружи, нормально протестировать его - задача не реальная. Нужно проверить все сочетания всех возможных значений всех его полей, это задача просто даже вычислительно часто невозможная.
Простой пример: есть какое-то поле, которое может принимать только положительные значения (например, деньги на банковском счету). Это гарантируется тем, что изменение этого поля делается через сеттер, который проверяет устанавливаемое значение и не даёт ему становиться меньше нуля. Мы всегда можем быть уверены, что значение этого поля будет корректное. А что будет, если это поле будет публично выставлено наружу? Туда кто угодно может записать что угодно. И вся логика работы класса сломается, либо нужно будет делать дополнительные проверки значения этого поля по всему коду класса при работе с этим полем.
В общем, наличие private полей упрощает работу программиста, а не усложняет, как может показаться неопытному программисту.

A: Есть в объектно-ориентированном подходе, да и в принципе есть такое понятие инкапсуляция. В основном у нее 2 функции:

*

*Изолирование

*Снижение сложности

Если мы говорим про снижение сложности, то можно привести пример с автомобилем. Автомобиль устроен очень сложно - скорее всего вы не имеете представления об внутреннем устройстве поршневой группы или соединений лонжеронов, но это не помешает вам сесть в машину и поехать. Вам попросту не нужно знать внутренне устройство и соответственно иметь к нему доступ - этим займутся специально обученные специалисты в специальных помещениях. Считайте эти поля типа privat
И плавно можно перейти к Изолированию. Если вы вдруг захотите для себя открыть эти поля, и заменить двигатель например - это может привести к очень плачевным последствиям. Потому что вы не специалист, у вас нет специального помещения, знаний и т.д. Вы сделаете машину не гарантийным случаем.
Поэтому в больших проектах необходимо использовать инкапсуляцию.


text:
Q: Diminuir tamanho campo Bootstrap Quero diminuir o tamanho do campo mas nao estou conseguindo, alguma ajuda?
segue um print

         IEM9 Preço Médio

         Acesso menor ou igual a 512 kBps

Pessoa Física

Pessoa Jurídica

    UF
<select name="IEM9_F_uf" id="IEM9_F_uf" class="form-control">
<option value>Estados</option>
<option value="<?php echo $estado; ?>" selected ><?php echo $estado; ?></option>
<option value="AC">Acre</option>
<option value="AL">Alagoas</option>
<option value="AM">Amazonas</option>
<option value="AP">Amapá</option>
<option value="BA">Bahia</option>
<option value="CE">Ceará</option>
<option value="DF">Distrito Federal</option>
<option value="ES">Espírito Santo</option>
<option value="GO">Goiás</option>
<option value="MA">Maranhão</option>
<option value="MT">Mato Grosso</option>
<option value="MS">Mato Grosso do Sul</option>
<option value="MG">Minas Gerais</option>
<option value="PA">Pará</option>
<option value="PB">Paraíba</option>
<option value="PR">Paraná</option>
<option value="PE">Pernambuco</option>
<option value="PI">Piauí</option>
<option value="RJ">Rio de Janeiro</option>
<option value="RN">Rio Grande do Norte</option>
<option value="RO">Rondônia</option>
<option value="RS">Rio Grande do Sul</option>
<option value="RR">Roraima</option>
<option value="SC">Santa Catarina</option>
<option value="SE">Sergipe</option>
<option value="SP">São Paulo</option>
<option value="TO">Tocantins</option>
</select>

UF
<select name="IEM9_J_uf" id="IEM9_J_uf" class="form-control ">
<option value>Estados</option>
<option value="<?php echo $estado; ?>" selected ><?php echo $estado; ?> </option>
<option value="AC">Acre</option>
<option value="AL">Alagoas</option>
<option value="AM">Amazonas</option>
<option value="AP">Amapá</option>
<option value="BA">Bahia</option>
<option value="CE">Ceará</option>
<option value="DF">Distrito Federal</option>
<option value="ES">Espírito Santo</option>
<option value="GO">Goiás</option>
<option value="MA">Maranhão</option>
<option value="MT">Mato Grosso</option>
<option value="MS">Mato Grosso do Sul</option>
<option value="MG">Minas Gerais</option>
<option value="PA">Pará</option>
<option value="PB">Paraíba</option>
<option value="PR">Paraná</option>
<option value="PE">Pernambuco</option>
<option value="PI">Piauí</option>
<option value="RJ" >Rio de Janeiro</option>
<option value="RN">Rio Grande do Norte</option>
<option value="RO">Rondônia</option>
<option value="RS">Rio Grande do Sul</option>
<option value="RR">Roraima</option>
<option value="SC">Santa Catarina</option>
<option value="SE">Sergipe</option>
<option value="SP">São Paulo</option>
<option value="TO">Tocantins</option>
</select>

Valor
<input type="text" size="21" maxlength="21"  value="<?php if($valor_iem9_f_a !=NULL){echo formato_numerico($valor_iem9_f_a);} else {echo "0,00";}?>" class="form-control decimal" name="IEM9_F_a" id="IEM9_F_a" title="Preço médio para conexões com velocidade de acesso menor ou igual a 512 kBps">

Valor
<input type="text" size="21" maxlength="21"  value="<?php if($valor_iem9_j_a !=NULL){echo formato_numerico($valor_iem9_j_a);} else {echo "0,00";}?>" class="form-control decimal" name="IEM9_J_a" id="IEM9_J_a" title="Preço médio para conexões com velocidade de acesso menor ou igual a 512 kBps">

A: Você pode diminuir o tamanho das cols, lembrando que o grid do bootstrap possui número máximo de 12 colunas, trocando por um valor de coluna menor ao atual. Caso precise usar um tamanho específico, você pode criar uma classe css e inserir o valor manual, utilizando !important para sobrescrever a classe do bootstrap.

A: Veja o fiddle
Perceba as classes que estão acompanhando a classe form-group. Elas vão definir o tamanho do conteúdo dentro dele, inclusive dos inputs.
Nada te impede de utilizar essas classes dentro dos inputs mesmo, mas sua padronização fica melhor se fizer no elemento pai.
Veja o conceito de grid do bootstrap. Mas basicamente, cada "row" é quebrada em 12 colunas, e você pode definir a quantidade de colunas utilizada para cada intervalo de dispositivo (xs, sm, md, lg). No fiddle, deixei aleatório o tamanho para md, e todos com 12 colunas no xs.

A: Só para complementar as respostas citadas pelos outros colegas, nós podemos também alterar o tamanho dos input e select alterando suas classes form-control (classe nativa do Bootstrap). Veja os exemplos abaixo:

<input class="form-control form-control-lg" type="text" placeholder=".form-control-lg">
<input class="form-control form-control-sm" type="text" placeholder=".form-control-sm">

<select class="form-control form-control-lg">
  <option>Large select</option>
</select>
<select class="form-control">
  <option>Default select</option>
</select>
<select class="form-control form-control-sm">
  <option>Small select</option>
</select>

*

*Onde lg e sm determinam o tamanho dos botões.

A resposta foi baseada na documentação do bootstrap:
Link


text:
Q: Linking errors when trying to compile Fubi This problem is not specific to Fubi, but a general linker issue. These past few days (read as 5) have been full of linking errors, but I've managed to narrow it down to just a handful.
I'm trying to compile Fubi (Full Body Interaction framework) under the Linux environment. It has only been tested on Windows 7, and the web is lacking resources for compiling on a *nix platform.
Now, like I mentioned above,  I had a plethora of linking problems that dealt mostly with incorrect g++ flags. Fubi requires OpenNI and NITE ( as well as OpenCV, if you want ) in order to provide it's basic functionality. I've been able to successfully compile both samples from the OpenNI and NITE frameworks.
As far as I understand, Fubi is a framework, thus I would need to compile a shared library and not a binary file.
When I try to compile it as a binary file using the following command
g++ *.cpp -lglut -lGL -lGLU -lOpenNI -lXnVNite_1_5_2 -I/usr/include/nite -I/usr/include/ni -I/usr/include/GL -I./GestureRecognizer/ -o FubiBin

and I get the output located here. (It's kind of long and I did not want to ruin the format)
If I instead compile into object files (-c flag), no errors appear and it builds the object files successfully. Note, I'm using the following command:
g++ -c *.cpp -lglut -lGL -lGLU -lOpenNI -lXnVNite_1_5_2 -I/usr/include/nite -I/usr/include/ni -I/usr/include/GL -I./GestureRecognizer/

I then am able to use the ar command to generate a statically linked library. No error [probably] occurs (this is only a guess on my end) because it has not run through the linker yet, so those errors won't appear.
Thanks for being patient and reading all of that. Finally, question time:
1) Is the first error regarding the undefined reference to main normal when trying to compile to a binary file? I searched all of the files within that folder and not a single main function exists.
2) The rest of the undefined reference errors complain that they cannot find the functions mentioned. All of these functions are located in .cpp and .h files in the subdirectory GestureRecognizer/ which is a subdirectory of the path I'm compiling in. So wouldn't the parameter -I./GestureRecognizer/ take care of this issue?
I want to be sure that when I do create the shared library that I won't have any linking issues during run-time. Would all of these errors disappear when trying to compile to a binary file if they were initially linked properly?

A: You are telling the compiler to create an executable in the first invocation and an executable needs a main() function, which it can't find. So no, the error is not normal. In order to create a shared library, use GCC's "-shared" option for that. Trying some test code here, on my system it also wants "-fPIC" when compiling, but that might differ. Best idea is to dissect the compiler and linker command lines of a few other libraries that build correctly on your system.
In order to add the missing symbols from the subdirs, you have to compile those, too: g++ *.cpp ./GestureRecognizer/*.cpp .... The "-I..." only tells the compiler where to search when it finds an #include .... I wouldn't be surprised if this wasn't even necessary, many projects use #include "GestureRecognizer/Foo.h" to achieve that directly.
BTW:

*

*Consider activating warnings when running the compiler ("-W...").

*You can split between compiling ("-c") and linking. In both cases, use "g++" though. This should decrease your turnaround time when testing different linker settings.


text:
Q: HTTP PHP Authentication and Android I am working on a website for which I hope to have an application for as well. Because of this, I am creating PHP API's which will go into my Database and serve specific data based on the method/function called.
I want to protect these API's from misuse however, and I plan on implementing Authentication Digest to do so. However one of the OS's I want to support is Android. And I know that a malicious user would be able to reverse engineer the Android app and figure out my authentication scheme.
I am left wondering:

*

*Is there a better way to protect these API's from misuse?

*Is there a way to prevent a malicious user from reverse engineering the app and potentially seeing the source code for it, enabling them to see my authentication scheme?

*If none of these are preventable, then is my only option to have a Username/Password cred specifically for the Android app, and when eventually hacked, change the creds and issue an update for the app?

A: In my opinion, talking about authentication, you could give a look to OAuth | http://oauth.net/.
I've recently implemented a RESTful service (using other techs, .NET/NancyFX). In my case the mobile app needs access to public available content (the same published in companion website).
In a case like mine the real concern wasn't security but some sort of misuse.
I've protected my service using an API Key: http://yourhost.com/api/{api-key}/xyz. Valid keys are stored in a persistent repository (in my case a mysql instance) and checked on every request. This worked great for me.
You may also find this useful too | https://stackoverflow.com/questions/6004068/restful-api-keys-suggestions.


text:
Q: ViewPager2 - fragment layout disappears after multiple swipes via tabs I'm using ViewPager2 which is hosted inside a fragment. On the initial opening of ViewPager2 fragment host everything is loaded and displayed correctly, but when I swipe multiple times (via TabLayout) to the last fragment and go back to the first fragment, its layout is empty/white screen.
The adapter which I'm using is FragmentStateAdapter. Also, I set offscreenPageLimit to a constant value (which is in most cases less than the size of the fragments list in ViewPager2).
This is constructor of my custom FragmentStateAdapter:
pagerAdapter = MyCustomPagerAdapter(requireContext(), childFragmentManager, viewLifecycleOwner.lifecycle)

Since ViewPager2 is using RecyclerView internally, maybe there is some problem with recycling fragments when there are not visible (also considering offscreenPageLimit value).

A: Problem was in by viewBinding() method for getting binding object.
After using standard way of creating binding object everything is working OK.