text:
Q: Set the corner radius of the content border I want to have a window with the border radius of the content border is 5. Exactly like on the picture:

How can I do this With C# and WPF ? Is there any way to do this with Windows API?

A: WPF is rendered in standard operating system windows, if you need to change that style you have to change the so called windows chrome. The basic is to create a transparent hosting window and draw all inside it by using WPF so you can drive whatever you want and of course the corner radius too, have a look here for an example. Something more complete in this article.
If you want to search yourself, the keywords wpf custom chrome would help.

A: I found how to do this work :
First I needed WindowsAPICodePack, I download it from http://archive.msdn.microsoft.com/WindowsAPICodePack/
  After downloading it, I Extracted it and found the necessary DLLs in /binaries folder . There are two DLLs I I needed :

Microsoft.WindowsAPICodePack.dll
Microsoft.WindowsAPICodePack.Shell.dll

Then I created an WPF Application in Visual Studio (.NET 3.5), And added these two dlls in my application

Right click on refrences in Solution Explorer tab > Add Refrence

then I changed the MainWindow XAML codes :

<WindowsAPICodePackShell:GlassWindow x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WindowsAPICodePackPresentation="clr-namespace:Microsoft.WindowsAPICodePack.Controls.WindowsPresentationFoundation;assembly=Microsoft.WindowsAPICodePack.Shell"
xmlns:WindowsAPICodePackShell="clr-namespace:Microsoft.WindowsAPICodePack.Shell;assembly=Microsoft.WindowsAPICodePack.Shell"
Title="WPF AeroGlass Demo" Height="300" Width="300" Loaded="GlassWindow_Loaded">
<Border CornerRadius="10" Background="Gray"></Border>
</WindowsAPICodePackShell:GlassWindow>

And my MainWindow.xaml.cs codes :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.WindowsAPICodePack.Shell;

namespace WpfApplication1
{
    ///
    /// Interaction logic for MainWindow.xaml
    ///
    public partial class MainWindow : GlassWindow
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void GlassWindow_Loaded(object sender, RoutedEventArgs e)
        {
            SetAeroGlassTransparency();
        }
    }
}

And When I run the app :


text:
Q: How to perform Public Key Encryption with RSA using C++ I am trying to implement asymmetrc encryption into a project. My end goal is to implement  EVP Asymmetric Encryption and Decryption of an Envelope but for now I am going to stick with the basics.  I am rather new to openssl so please forgive me if there is an obvious answer to this question.
Currently I am following this tutorial here: Simple Public Key Encryption with RSA and OpenSSL
I plan to transmit the RSA public key over a network to a seperate client which will encrypt a message with the generated public key. The encrypted message will then be sent back to the server for decryption.
I am having trouble with encrypting only using the public key instead of using the keypair. For obvious reasons, I don't want to transmit the keypair over the network.
Here is the code that I have so far:
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/err.h>
#include <stdio.h>
#include <string.h>

#define KEY_LENGTH  2048
#define PUB_EXP     3
#define PRINT_KEYS
#define WRITE_TO_FILE

int main(void) {
    size_t pri_len;            // Length of private key
    size_t pub_len;            // Length of public key
    char   *pri_key;           // Private key
    char   *pub_key;           // Public key
    char   msg[KEY_LENGTH/8];  // Message to encrypt
    char   *encrypt = NULL;    // Encrypted message
    char   *decrypt = NULL;    // Decrypted message
    char   *err;               // Buffer for any error messages

    // Generate key pair
    printf("Generating RSA (%d bits) keypair...", KEY_LENGTH);
    fflush(stdout);
    RSA *keypair = RSA_generate_key(KEY_LENGTH, PUB_EXP, NULL, NULL);

    // To get the C-string PEM form:
    BIO *pri = BIO_new(BIO_s_mem());
    BIO *pub = BIO_new(BIO_s_mem());

    PEM_write_bio_RSAPrivateKey(pri, keypair, NULL, NULL, 0, NULL, NULL);
    PEM_write_bio_RSAPublicKey(pub, keypair);

    //SEND KEY TO CLIENT HERE

    //FAKE CLIENT RECIEVE
    RSA *keypair2 = NULL;
    PEM_read_bio_RSAPublicKey( pub, &keypair2, NULL, NULL);

    // Get the message to encrypt
    printf("Message to encrypt: ");
    fgets(msg, KEY_LENGTH-1, stdin);
    msg[strlen(msg)-1] = '\0';

    // Encrypt the message using public key only
    encrypt = malloc(RSA_size(keypair2));
    int encrypt_len;
    err = malloc(130);
    if((encrypt_len = RSA_public_encrypt(strlen(msg)+1, (unsigned char*)msg, (unsigned char*)encrypt,
                                         keypair2, RSA_PKCS1_OAEP_PADDING)) == -1) {
        ERR_load_crypto_strings();
        ERR_error_string(ERR_get_error(), err);
        fprintf(stderr, "Error encrypting message: %s\n", err);
        goto free_stuff;
    }

    #ifdef WRITE_TO_FILE
    // Write the encrypted message to a file
        FILE *out = fopen("out.bin", "w");
        fwrite(encrypt, sizeof(*encrypt),  RSA_size(keypair), out);
        fclose(out);
        printf("Encrypted message written to file.\n");
        free(encrypt);
        encrypt = NULL;

        // Read it back
        printf("Reading back encrypted message and attempting decryption...\n");
        encrypt = malloc(RSA_size(keypair));
        out = fopen("out.bin", "r");
        fread(encrypt, sizeof(*encrypt), RSA_size(keypair), out);
        fclose(out);
    #endif

    //SEND MESSAGE BACK TO CLIENT FOR DECRYPT

    // Decrypt it
    decrypt = malloc(encrypt_len);
    if(RSA_private_decrypt(encrypt_len, (unsigned char*)encrypt, (unsigned char*)decrypt,
                           keypair, RSA_PKCS1_OAEP_PADDING) == -1) {
        ERR_load_crypto_strings();
        ERR_error_string(ERR_get_error(), err);
        fprintf(stderr, "Error decrypting message: %s\n", err);
        goto free_stuff;
    }
    printf("Decrypted message: %s\n", decrypt);

    free_stuff:
    RSA_free(keypair);
    BIO_free_all(pub);
    BIO_free_all(pri);
    free(pri_key);
    free(pub_key);
    free(encrypt);
    free(decrypt);
    free(err);

    return 0;
}

How could I achieve encrypting data only using the public key rather than the whole keypair?
Thanks

redpajama_set_name: RedPajamaStackExchange


text:
Q: I can't add a logo to my website. It takes up the entire page. Please help me HTML

Home

Services

About

Contact

I'm trying to add a logo to my website. The logo fills the screen. I can't adjust its size.HTML codes like this.

A: It is difficult to answer without seeing the stylings and I see you haven't provided a proper code.
Just give the img tag a width and a height and position the div wrapping it correctly.
Something like this,

div {
    position:relative;
    text-align:center;/* Add This*/
}

I suggest you to refer the following,
Positioning a div
Inserting an img
Good luck mate!


text:
Q: Using libnetfilter_queue, a reinjected packet dosnt affect change, However inject copy of the packet succeeds. Why? I am using in libnetfilter_queue library.
I need to change the dest ip in the packet. I change the dest ip and reinject the packet:
nfq_set_verdict(qh, id, NF_ACCEPT,size, originalPacket);
but change didn't take affect.
However if i change the packet, copy it to new char array and call to set verdict with the copied array than the change take affect.
Am i doing something wrong?
Thank you

A: need to use NF_REPEAT verdict to reinject packet to the
same chain. Using NF_ACCEPT verdict injects packet to the subsequent
chain. But for this purpose you should mark packets to avoid loop,
i.e.:
iptables -t raw -A PREROUTING -p tcp -m tcp --dport 80 -m mark !
--mark 0x1/0x1 -m tcp -j NFQUEUE
iptables -t raw -A PREROUTING -p tcp -m tcp --dport 80 -m mark --mark
0x80/0x80 -m tcp ACCEPT # altered packets
iptables -t raw -A PREROUTING -p tcp -m tcp --dport 80 -m mark --mark
0x1/0x1 -m tcp ACCEPT # rest


text:
Q: Understanding Try/Finally Suppressed Exceptions I'm learning Exceptions and I found out that you can have suppressed ones.
I read many examples on stackoverflow but still, they don't work as they are supposed to in the "try/finally" case:
public class MultipleExceptionsExample {

   static class IOManip implements Closeable{
       @Override
       public void close() {
           throw new RuntimeException("from IOManip.close");
       }
   }

   public static void main(String[] args) {
       try(IOManip ioManip = new IOManip()){
           throw new RuntimeException("from try!");
       }catch(Exception e){
           throw new RuntimeException("from catch!");
       }finally{
           throw new RuntimeException("from finally!");
       }
   }
}

As many explain, with all lines I should get: "java.lang.RuntimeException: from finally!" (Yes I do)
Removing finally block I should get: "java.lang.RuntimeException: from catch!" (Yes I do)
Removing catch block I should get:
Exception in thread "main" java.lang.RuntimeException: from try!
    Suppressed: java.lang.RuntimeException: from IOManip.close

And I never do! Why? What am I missing?
By removing the catch block I should see the try message, but I get this instead:
Exception in thread "main" java.lang.RuntimeException: from finally!
    at it.core.MultipleExceptionsExample.main(MultipleExceptionsExample.java:18)

Thanks a lot.

A: A return or throw in a finally block causes any other returned (or thrown) result to be ignored.
Don't return or throw in a finally block, unless you really know what you're doing.
It should be noted that Java Throwables have a notion of "suppressed" exceptions: you can invoke addSuppressed on a Throwable that you have caught; this is done automatically with a try-with-resources block, if an exception occurs in the body and whilst closing the resource; but this does not happen for a throw in a finally block.

A: It is because finally block would always execute. It doesn't matter if you catch the exception or not. To understand it better try the code bellow:
public static void main(String[] args) {
    try (IOManip ioManip = new IOManip()) {
        System.out.println("Try!");
        throw new RuntimeException("from try!");
    } finally {
        System.out.println("Finally!");
    }
}

Remember that it is not a good practice to return or throw from the finally block, and you should avoid doing that.


text:
Q: spring boot {"error":"invalid_client","error_description":"Bad client credentials"} I created a small spring boot authorization server, but it doesn't work:
My SecurityConfig:
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    public void configureGlobal(final AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
                .withUser("user").password("user").roles("ROLE");
    }

    @Override
    @Bean
    public AuthenticationManager authenticationManagerBean() throws Exception {
        return super.authenticationManagerBean();
    }
}

My AuthorizationServer:
@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {

    @Autowired
    private AuthenticationManager authenticationManager;

    @Override
    public void configure(final AuthorizationServerEndpointsConfigurer endpoints) {
        endpoints.tokenStore(tokenStore())
                .authenticationManager(authenticationManager);
    }

    @Override
    public void configure(final ClientDetailsServiceConfigurer clients) throws Exception {
        clients.inMemory()
                .withClient("client")
                .secret("clientpassword")
                .scopes("read", "write")
                .authorizedGrantTypes("password")
                .accessTokenValiditySeconds(3600);
    }

    @Bean
    public TokenStore tokenStore() {
        return new InMemoryTokenStore();
    }

My ResourceServer:
@Configuration
@EnableResourceServer
@EnableWebSecurity
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http
                .sessionManagement()
                .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                .and().authorizeRequests()
                .antMatchers("/oauth/token")
                .permitAll()
                .anyRequest()
                .authenticated();
   }
}

With this curl
curl -i -v -X POST -H 'Content-Type: application/x-www-form-urlencoded' -k http://localhost:8080/oauth/token -H 'Authorization: Basic Y2xpZW50OmNsaWVudHBhc3N3b3Jk' -d 'grant_type=password&client_id=client&user=user&password=user'

Y2xpZW50OmNsaWVudHBhc3N3b3Jk is base64 encoded client:clientpassword
I get this error:
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> POST /oauth/token HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Type: application/x-www-form-urlencoded
> Authorization: Basic Y2xpZW50OmNsaWVudHBhc3N3b3Jk
> Content-Length: 60
>
* upload completely sent off: 60 out of 60 bytes
< HTTP/1.1 401
HTTP/1.1 401
< Cache-Control: no-store
Cache-Control: no-store
< Pragma: no-cache
Pragma: no-cache
< WWW-Authenticate: Form realm="oauth2/client", error="invalid_client", error_description="Bad client credentials"
WWW-Authenticate: Form realm="oauth2/client", error="invalid_client", error_description="Bad client credentials"
< X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
X-XSS-Protection: 1; mode=block
< X-Frame-Options: DENY
X-Frame-Options: DENY
< Content-Type: application/json
Content-Type: application/json
< Transfer-Encoding: chunked
Transfer-Encoding: chunked
< Date: Wed, 13 May 2020 18:42:17 GMT
Date: Wed, 13 May 2020 18:42:17 GMT

<
* Connection #0 to host localhost left intact
{"error":"invalid_client","error_description":"Bad client credentials"}* Closing connection 0


text:
Q: Complex Limit $\lim_{z \rightarrow i} \frac{z^3 + i}{|z| - 1}$ I wish to determine whether the limit $L = \lim_{z \rightarrow i} \frac{z^3 + i}{|z| - 1}$ exists. Noticing it to be of the form $0/0$, I separate the expression into its real and imaginary parts:
$$L = \lim_{(r, \theta) \rightarrow (1, \pi/2)} \frac{(re^{i\theta})^3 +i}{r-1} = \lim_{(r, \theta) \rightarrow (1, \pi/2)} \frac{r^3(\cos(3\theta) + i\sin(3\theta)) + i}{r-1} = \lim_{(r, \theta) \rightarrow (1, \pi/2)} \left(\frac{r^3\cos(3\theta)}{r-1} + i\frac{r^3\sin(3\theta) + 1}{r-1}\right)$$, but I am still stuck with the $0/0$ indeterminate form. How might I evaluate this limit?

A: If $t\in\Bbb R$,$$\operatorname{Re}\left(\frac{(t+i)^3+i}{|t+i|-1}\right)=\operatorname{Re}\left(\frac{t^3+3it^2-3t}{\sqrt{t^2+1}-1}\right)=\frac{t^3-3t}{\sqrt{t^2+1}-1},$$and$$\lim_{t\to0^+}\frac{t^3-3t}{\sqrt{t^2+1}-1}=\lim_{t\to0^+}(t^2-3)\frac t{\sqrt{t^2+1}-1}=-\infty.$$

A: If the limit existed, it would need to be the same via any path of $z$ to $i$.
Using the path $z=it,\;t\in(0,1)$, and using the difference of two cubes formula, we find (as $t\to 1$): $$f(z)=f(it)=(-i)(t^2+t+1) \to -3i.$$
But using the path $z=i+t,\;t>0,$ and introducing the factor $1+\sqrt{t^2+1},$ we find (as $t\to 0$):
$$|f(z)|=|f(i+t)|= \left| \frac{(1+\sqrt{t^2+1})(t^2+3it-3)}{t} \right| \to \infty.$$

A: I'd rather translate to complex variable $h:=z-i\to0$:
$$\frac{z^3 + i}{|z|-1}=\frac{(i+h)^3+i}{|i+h|-1}=\frac{-3h+o(h)}{\sqrt{a^2+(1+b)^2}-1}$$
hence there is no limit as $(a,b)\to(0,0)$. This is because there are sequences with various limits, depending on the relative speed of convergence of $a$ and $b$. E.g.:
For $z_n=i+\frac1n$,
$$\frac{z_n^3+i}{|z_n|-1}\sim\frac{-3/n}{1/(2n^2)}=-6n\to-\infty.$$
For $z_n=i+\frac{1+i}n$,
$$\frac{z_n^3+i}{|z_n|-1}\sim\frac{-3(1+i)/n}{1/n}=-3(1+i).$$


text:
Q: onCommand.addListener not working in my chrome extension I am currently developing a chrome extension, only, I am facing a problem since onCommand.addListener is not working in my background.js file. My manifest.json file looks like this:

{
  "manifest_version": 3,
  "name": "Copy",
  "version": "1.0.0",

  "permissions": [
    "storage",
    "activeTab",
    "scripting"
  ],
  "background": {
    "service_worker": "js/background.js"
  },

  "commands": {
    "run-foo": {
      "suggested_key": {
        "default": "Ctrl+Shift+Y",
        "mac": "Command+Shift+Y"
      },
      "description": "Run \"foo\" on the current page."
    },
    "_execute_action": {
      "suggested_key": {
        "windows": "Ctrl+Shift+Y",
        "mac": "Command+Shift+Y",
        "chromeos": "Ctrl+Shift+U",
        "linux": "Ctrl+Shift+J"
      }
    }
  }
}

And my background.js file in the js folder looks like this:

console.log('test');

chrome.commands.onCommand.addListener(function(command){
    if(command === 'run-foo'){
      sendResponse({data: window.getSelection().toString()});

      console.log('copié !!!');
      let copieText = 'je suis le texte copié';
    }
});

chrome.commands.onCommand.addListener(function(command) {
  console.log('onCommand event received for message: ', command);
});

But my console only returns the test, even if I press Ctrl-C several times.
Thank you in advance


text:
Q: Как описать в doctrine orm id genarator при Только изучаю doctrine-orm. Можно ли как то описать такую генерацию первичного ключа в postgresql?
create sequence requests.seq_uuid
    increment by 1
    minvalue 1
    maxvalue 9223372036854775807
    start 1
    cache 1
    no cycle;

create or replace function requests.uuid() returns uuid
as $$
begin
    return ('0000000000000000' || lpad(to_hex(nextval('requests.seq_uuid')), 16, '0'))::uuid;
end;
$$ language plpgsql;

create table requests.request (
    id uuid not null default requests.uuid(),

    request text,
    constraint request_pk primary key (id)
);

A: Необходимо создать свой класс, унаследованный от AbstractIdGenerator:
<?php

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Id\AbstractIdGenerator;

class MyIdGenerator extends AbstractIdGenerator
{
    public function generate(EntityManager $em, $entity)
    {
        return $em->getConnection()->executeQuery('select requests.uuid() as uuid;')->fetchOne();
    }
}

И создать класс entity со следующим определением первичного ключа:
<?php

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="requests.request")
 */
class Request
{
    /**
     * @ORM\Id
     * @ORM\Column(type="guid")
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class="MyIdGenerator")
     */
    private $id;

    ...


text:
Q: Can SHOW TABLE STATUS query performance on MySQL be improved ? - Amazon RDS I have a fairly large database on the Amazon Relational Database Service (RDS) running on MySQL 5.1.57.  There are 900+ tables, so that running the "SHOW TABLE STATUS" query can take up to 30 seconds.
We have an integration with the UPS Worldship software connecting through ODBC.  It seems that this software running the SHOW TABLE STATUS; query before every function, such that clicking a button requires a 45 second wait.  We had the same database running prior to the new year on dedicated hardware, and we didn't have this problem.
My questions are these:

*

*Is there a way to improve the performance of this query ?

*What might be causing such a problem ?

A: You may want to disable the variable innodb_stats_on_metadata.
According to the MySQL Documentation on innodb_stats_on_metadata

When this variable is enabled (which is the default, as before the
  variable was created), InnoDB updates statistics during metadata
  statements such as SHOW TABLE STATUS or SHOW INDEX, or when accessing
  the INFORMATION_SCHEMA tables TABLES or STATISTICS. (These updates are
  similar to what happens for ANALYZE TABLE.) When disabled, InnoDB does
  not update statistics during these operations. Disabling this variable
  can improve access speed for schemas that have a large number of
  tables or indexes. It can also improve the stability of execution
  plans for queries that involve InnoDB tables.

Since you are using Amazon RDS, ask your DB Administrators to disable it. If your DBs are in a Shared Resource, my condolences...
UPDATE 2012-07-25 14:45 EDT
If you can download the RDS CLI, you can adjust innodb_stats_on_metadata in a customized DB Parameter Group. You will have to do the following:

*

*mysqldump data out of RDS Server

*destroy DB Server Instance

*create DB Server Instance using your custom DB Parameter Group adjusted for innodb_stats_on_metadata

*reimport the mysqldump into new DB Instance

Since Amazon RDS does not give away SUPER privilege, that's the only way to change a GLOBAL static option.
UPDATE 2012-07-27 16:34 EDT
Without SUPER Privilege, you can modify a DB Parameter Group for a given MySQL RDS Instance, and launch a reboot with one of the following:

*

*rds-reboot-db-instance <DBInstanceName>

*Click Reboot Button in the RDS Management Console


text:
Q: Insert empty VIEWS into QGIS from PostgreSQL using PyQGIS The Aim:
I am trying to insert a number of empty VIEWS into QGIS using PyQGIS. These  VIEWS have been created and stored in a PostgreSQL database.
I want to also ensure i can successfully re-open the project at a later date whilst some of the layers are still empty or have become empty. These layers can at times be empty depending on what has been happening recently in the database.
The Problem:
QGIS does not like it when these layers are empty on inserting them, or when attempting to re-open the project. It either fails to insert the empty layer, or it informs the user that they are 'bad layers' and need to be deleted in order to continue. The layers can be inserted successfully when they contain data.
Python code used:
Note: "PlatformID" is the primary key.
uri = QgsDataSourceUri()
uri.setConnection(host, port, db_name, user, password)
uri.setDataSource("Data", "FieldOfViewIndex", "geom", "", "PlatformID")
vlayer = QgsVectorLayer(uri.uri(False), "FieldOfViewIndex", "postgres")
QgsProject.instance().addMapLayer(vlayer)

Common error messages:

WARNING    Geometry type and srid for empty column geom of "Data"."FieldOfViewIndex" undefined.
WARNING    invalid PostgreSQL layer

In the PostgreSQL geometry_columns VIEW, their SRID is 0 and the geometry type is GEOMETRY.

A: You can force the geometry type and projection in the view definition by casting the geometry:
create view tv as
 select geom::geometry(POINT, 4326)
 from myTable;

jgtest=> \d tv
                          View "public.tv"
   Column   |         Type         | Collation | Nullable | Default
------------+----------------------+-----------+----------+---------
 geom       | geometry(Point,4326) |           |          |


text:
Q: Timeline view with JQuery Fullcalendar plugin Is it possible to do a timeline view with the JQuery FullCalendar plugin (http://arshaw.com/fullcalendar/)?  I'm looking to do something like this: http://dhtmlx.com/docs/products/dhtmlxScheduler/sample_timeline.shtml
I like the look of fullcalendar over dhtmlx though.
Thanks!

A: There is a common issue on google code called but it is labeled "resource view" instead of timeline... here is the link "resource view". Maybe it will geve you a place to start... let me know if it helps


text:
Q: Resue previous example in pytest parametrize Consider a parametrized pytest test, which reuses the same complex
example a number of times. To keep the sample code as simple as possible,
I have simulated the 'complex' examples with very long integers.
from operator import add
from pytest   import mark

parm = mark.parametrize

@parm(' left,       right, result',
      ((9127384955, 1,     9127384956),
       (9127384955, 2,     9127384957),
       (9127384955, 3,     9127384958),
       (9127384955, 4,     9127384959),
       (4729336234, 1,     4729336235),
       (4729336234, 2,     4729336236),
       (4729336234, 3,     4729336237),
       (4729336234, 4,     4729336238),
      ))
def test_one(left, right, result):
    assert add(left, right) == result

The first four (and the next four) examples use exactly the same value for left but:

*

*I have to read the examples carefully to realize this

*This repetition is verbose
I would like to make it absolutely clear that exactly the same
example is being reused and save myself the need to repeat the same example many times. (Of course, I could bind the example to a global variable, and use that variable, but that variable would have to be bound at some distant point outside of my collection of examples, and I want to see the actual example in the context in which it is used (i.e. near to the other values used in this particular set) rather than having to look for it elsewhere.
Here is an implementation which allows me to make this explicit using a syntax that I find perfectly acceptable, but the implementation itself is horrible: it uses a global variable and doesn't stand a chance of working with distributed test execution.
class idem: pass

@parm(' left,       right, result',
      ((9127384955, 1,     9127384956),
       (  idem    , 2,     9127384957),
       (  idem    , 3,     9127384958),
       (  idem    , 4,     9127384959),
       (4729336234, 1,     4729336235),
       (  idem    , 2,     4729336236),
       (  idem    , 3,     4729336237),
       (  idem    , 4,     4729336238),
      ))
def test_two(left, right, result):
    global previous_left
    if left is idem: left          = previous_left
    else           : previous_left = left
    assert add(left, right) == result

How can this idea be implemented in a more robust way? Is there some feature built in to pytest that could help?


text:
Q: Recover session EJB I was checking EJB stateful beans, the typical example for using this bean is in a shopping cart.
So in the example what is done is check in HttpSession if the EJB exists, if not, one EJB instance is called and then upload to session using the HttpSessionId as identifier.
So, what is the advantage of using a stateful EJB when I could use a simple POJO to do exactly the same?
I guess the typical answer is that even if the HttpSession goes down the EJB still lives in the server container. If this is true, how can I recover that EJB from the EJB pool? given I don't have the HttpSessionID anymore.
Is there another approach to recover EJB's that are living in a container?

A: The shopping cart of a Stateful EJB hosted within an http session is in my opinion the typical example of something that shouldn't be done for a very simple reason: a shop online purpose is to increase traffic and number of (paying) users. A Stateful bean on the opposite is not recommended with this kind of web site, it doesn't scale.
Stateful Bean are something that should belong to the realm of desktop applications i.e. Swing, JavaFX etc... it has little to do with an www shop online.
Of course keeping things in a session is much lighter than having a Stateful bean holding data.
I cannot think of any trick to recover a Stateful EJB once you loose its reference.
Also, what do you mean with "if the session goes down" ? If you mean because of a server crash, keep in mind that if the EJB resides in the same server then an EJB (Stateless, Stateful, Singleton, etc...) cannot survive a server crash.


text:
Q: How to import locally in a proper way in PyCharm OSX Here's how the directory looks like
├── Caches
│   ├── 11\ Centroids\ representing\ relative\ anchor\ sizes..png
│   ├── 9\ Centroids\ representing\ relative\ anchor\ sizes..png
│   ├── Generated\ anchors\ relative\ to\ sample\ image\ size.png
│   ├── Relative\ width\ and\ height\ for\ 10107\ boxes..png
│   └── data_set_labels.csv
├── Config
│   ├── feature_map.py
│   ├── set_annotation_conf.py
│   └── voc_conf.json
├── Helpers
│   ├── __pycache__
│   │   ├── annotation_parsers.cpython-37.pyc
│   │   └── visual_tools.cpython-37.pyc
│   ├── anchors.py
│   ├── annotation_parsers.py
│   ├── dataset_handlers.py
│   ├── models.py
│   └── visual_tools.py
├── README.md
├── sample_img.png
└── structure_requirements.txt

in dataset_handlers.py I need to import the following:
from ..Config.feature_map import get_feature_map

and in anchors.py I need to import the following:
from .visual_tools import visualization_wrapper

Both imports do resolve in PyCharm or in other words do not have syntax errors however when are run they give the following error:
ImportError: attempted relative import with no known parent package

If I do this:
from visual_tools import visualization_wrapper

the name visual_tools is unresolved however it runs without errors and it imports the requested things
How to be able to make relative imports from .some_module import something without getting errors and being resolved without marking the directory as sources root.


text:
Q: How to properly get System Model in PowerShell and set it as a parameter? I need to use PowerShell to properly get the System Model of a PC and use the model number as a parameter so that I can run tasks specific to the model number.
My code is a little more complex due to the fact that some of the methods returns values like 'Not Available', 'To be filled by O.E.M.'or  'System Product Manufacturer' - in these instances I do not want the $Model parameter to be 'Not Available', 'To be filled by O.E.M.'or  'System Product Manufacturer'.
I have the following, but it doesn't work as desired
    $BaseBoardManufacturer = Get-WmiObject Win32_BaseBoard | Select Manufacturer
if ((-not ([string]::IsNullOrWhiteSpace($BaseBoardManufacturer))) -and ($BaseBoardManufacturer.Manufacturer -ne 'Not Available') -or ($BaseBoardManufacturer.Manufacturer -ne 'System manufacturer'))
    {
        [String]$Manufacturer = ($BaseBoardManufacturer.Manufacturer).ToString()
    }

    $ProductManufacturer = Get-WmiObject -Class:Win32_ComputerSystemProduct | select Vendor
    if ((-not ([string]::IsNullOrWhiteSpace($ProductManufacturer))) -and ($ProductManufacturer.Vendor -ne 'Not Available') -or ($ProductManufacturer.Vendor -ne 'System manufacturer') -or ($ProductManufacturer.Vendor -ne 'To be filled by O.E.M.'))
    {
        [String]$Manufacturer = ($ProductManufacturer.Vendor).ToString()
    }

    $SystemManufacturer = Get-WmiObject -Class:Win32_ComputerSystem | select Manufacturer
    if ((-not ([string]::IsNullOrWhiteSpace($SystemManufacturer))) -and ($SystemManufacturer.Manufacturer -ne 'Not Available') -or ($SystemManufacturer.Manufacturer -ne 'System manufacturer') -or ($SystemManufacturer.Manufacturer -ne 'To be filled by O.E.M.'))
    {
        [String]$Manufacturer = ($SystemManufacturer.Manufacturer).ToString()
    }

    $BaseBoardProduct = Get-WmiObject Win32_BaseBoard | Select Product
    if ((-not ([string]::IsNullOrWhiteSpace($BaseBoardProduct))) -and ($BaseBoardProduct.Product -ne 'Not Available'))
    {
        [String]$Model = ($BaseBoardProduct.Product).ToString()
    }

    $ProductVersion = Get-WmiObject -Class:Win32_ComputerSystemProduct | select Version
    if ((!($ProductVersion.Version -ne 'System Version')) -xor (!($ProductVersion.Version -ne 'To be filled by O.E.M.')) -and (-not ([string]::IsNullOrWhiteSpace($ProductVersion))))
    {
        [String]$Model = ($ProductVersion.Version).ToString()
    }

    $SystemModel = Get-WmiObject -Class:Win32_ComputerSystem | select Model
    if ((-not ([string]::IsNullOrWhiteSpace($SystemModel))) -and ($SystemModel.Model -ne 'System Product Name') -or ($SystemModel.Model -ne 'To be filled by O.E.M.'))
    {
        [String]$Model = ($SystemModel.Model).ToString()
    }

    $SystemManufacturer = Get-WmiObject -Class:Win32_ComputerSystem | select Manufacturer
    if ((-not ([string]::IsNullOrWhiteSpace($SystemManufacturer))) -and ($SystemManufacturer.Manufacturer -ne 'Not Available') -or ($SystemManufacturer.Manufacturer -ne 'System manufacturer') -or ($SystemManufacturer.Manufacturer -ne 'To be filled by O.E.M.'))
    {
        [String]$Manufacturer = ($SystemManufacturer.Manufacturer).ToString()
    }

    if ($Manufacturer -like '*Lenovo*')
    {
        $ProductVersion = Get-WmiObject -Class:Win32_ComputerSystemProduct | select Version
    [String]$Model = ($ProductVersion.Version).ToString()
    }

I want e.g.
    ((!($ProductVersion.Version -ne 'System Version')) -or (!($ProductVersion.Version -ne 'To be filled by O.E.M.')) -and (-not ([string]::IsNullOrWhiteSpace($ProductVersion))))

to return false when the ProductVersion returns 'To be filled by O.E.M.' or 'System Version', but it returns true!
I've tried
    ((!($ProductVersion.Version -ne 'System Version')) -xor (!($ProductVersion.Version -ne 'To be filled by O.E.M.')) -and (-not ([string]::IsNullOrWhiteSpace($ProductVersion))))

and
    if ((-not ($SystemModel.Model -eq 'System Product Name')) -or (-not ($SystemModel.Model -eq 'To be filled by O.E.M.')) -and (-not ([string]::IsNullOrWhiteSpace($SystemModel))))

but I get 'System Version' set as the parameter instead of the Model Number, in other words the argument returns true when it is supposed to return false

A: *

*First, I suggest simplifying your property retrieval commands:

*

*You're using Select-Object to extract a single property from the objects emitted by your Get-WmiObject calls

*Perhaps surprisingly, something like ... | Select Product (short for: ... | Select-Object -Property Product) does not return the values of the input objects' .Product property, it returns a new object for each input object, which is of type [pscustomobject]and itself has a Product property.

*To only extract the property values, use Select-Object's -ExpandProperty parameter instead of the (positionally implied) -Property parameter; e.g.
... | Select-Object -ExpandProperty Product.

*See this post for more information and more efficient alternatives.

*Second, there's a problem with your Boolean logic, explained in the next section.
However, I suggest simplifying your conditional as follows:
# Sample input objects.
@(
  $null
  [pscustomobject] @{ Version = $null }
  [pscustomobject] @{ Version = '' }
  [pscustomobject] @{ Version = 'System Version' }
  [pscustomobject] @{ Version = 'To be filled by O.E.M.' }
  [pscustomobject] @{ Version = '1' }

) | ForEach-Object {

  $ProductVersion = $_

  # Output $true only if $ProductVersion is an object that has
  # a .Version property whose value is neither $null, the empty string
  # nor 'System Version' nor 'To be filled by O.E.M.'
  $ProductVersion.Version -notlike '' -and
    $ProductVersion.Version -notin 'System Version', 'To be filled by O.E.M.'

}

*

*$ProductVersion.Version -notlike '' ensures that the .Version property value is neither $null nor the empty string (and even ensures that $ProductVersion itself is not $null (or the empty string, though that shouldn't happen in your case).

*The -notin operator offers a convenient way of testing whether the LHS string value isn't equal to any of the elements of the RHS array.
Output:
False
False
False
False
False
True

As for what you tried:

((!($ProductVersion.Version -ne 'System Version')) -or (!($ProductVersion.Version -ne 'To be filled by O.E.M.'))

This can be simplified to:
$ProductVersion.Version -eq 'System Version' -or $ProductVersion.Version -eq 'To be filled by O.E.M.'

and is the opposite of what you want, i.e. it returns $true if either of the string values are found.
You could negate the expression as a whole (! and -not are the same operator):
-not ($ProductVersion.Version -eq 'System Version' -or $ProductVersion.Version -eq 'To be filled by O.E.M.')

or use -ne instead of -eq, which requires you to change -or to -and:
$ProductVersion.Version -ne 'System Version' -and $ProductVersion.Version -ne 'To be filled by O.E.M.'

-xor, which returns true only if exactly one operand is $true, isn't called for here, because it requires evaluating both operands, which isn't necessary here.

A:     $BaseBoardProduct = Get-WmiObject Win32_BaseBoard | Where-Object {$_.Product -ne 'Not Available'} | Select-Object -ExpandProperty Product
    if (-not ([string]::IsNullOrWhiteSpace($BaseBoardProduct)))
    {
        $Model = $BaseBoardProduct
    }

    $ProductVersion = Get-WmiObject -Class:Win32_ComputerSystemProduct | Where- Object {$_.Version -ne 'System Version' -and $_.Version -ne 'To be filled by O.E.M.'} | Select-Object -ExpandProperty Version
    if (-not ([string]::IsNullOrWhiteSpace($ProductVersion)))
    {
        $Model = $ProductVersion
    }

    $SystemModel = Get-WmiObject -Class:Win32_ComputerSystem | Where-Object {$_.Model -ne 'System Product Name' -and $_.Model -ne 'To be filled by O.E.M.'} | Select-Object -ExpandProperty Model
    if (-not ([string]::IsNullOrWhiteSpace($SystemModel)))
    {
        $Model = $SystemModel
    }

    $SystemManufacturer = Get-WmiObject -Class:Win32_ComputerSystem | Where- Object {$_.Manufacturer -ne 'Not Available' -and $_.Manufacturer -ne 'System manufacturer' -and $_.Manufacturer -ne 'To be filled by O.E.M.'} | Select-Object -ExpandProperty Manufacturer
    if (-not ([string]::IsNullOrWhiteSpace($SystemManufacturer)))
    {
        $Manufacturer = $SystemManufacturer
    }

    if ($Manufacturer -like '*Lenovo*')
    {
        $ProductVersion = Get-WmiObject -Class:Win32_ComputerSystemProduct |
Select-Object -ExpandProperty Version
        $Model = $ProductVersion
    }

solves my issue!


text:
Q: Add second facet grid or second discrete y-axis label GGPlot2 Suppose I have this dataframe:
library(ggplot2)
library(dplyr)
library(readr)
library(magrittr)
library(tidyr)

df2 <- data.frame(tissue = c("Blood", "Nerve", "Stomach", "Liver", "Blood", "Kidney"),
                  qtl = c("e", "s", "e", "e", "s", "s"),
                  gene = c("gene1", "gene1",
                           "gene2", "gene2",
                           "gene3", "gene4"),
                  value = c(0.4, 0.2, 0.1, 0.9, 0.5, 0.3),
                  second_label = c("label1", "label1", "label1","label1",
                                  "label2", "label2"))

And I plot it as such:
ggplot(df2,
       aes(x=tissue, y=qtl,
           size=value))+
  geom_point()+
  facet_grid(rows = vars(gene),
             scales = "free",
             space='free',
             switch = "y")+
  theme(axis.title.x = element_blank(),
        axis.text.x = element_text(size=8,angle = 90, hjust=1, vjust=0.2),
        axis.title.y = element_blank(),
        axis.text.y = element_text(size=8),
        axis.ticks.y = element_blank(),
        axis.line = element_line(color = "black"),
        strip.text.y.left = element_text(size = 8, angle=0),
        strip.background = element_blank(),
        panel.spacing.y = unit(0.5, "lines"),
        strip.placement = "outside",
        panel.background = element_blank(),
        panel.grid.major = element_line(colour = "#ededed", size = 0.5))

This code yields the plot below (see first image)

However, I want to add a second facet wrap, being the "loci" and place it on the right side of the figure.

Is this possible? I know in facet_grid, you can do it where one variable is the column and the other is the row, but I haven't seen how to do it where both are rows.
I've looked into adding a secondary y-axis with sec.axis but that seems to only be for continuous variables.
Thanks in advance!

A: I highly recommend the ggh4x package (github link here), which can handle this issue nicely via nested facets via facet_nested().  Here, you facet according to df2$gene, but indicate the nesting of those facets happens according to df2$qtl.
Here's an example of code that shows you some basic functionality applied to df2.  Note I changed some strip background formatting to make the faceting more clear.  There's a lot of other options that might work better for you in that package.
p <-
  ggplot(df2, aes(x=tissue, y=qtl, size=value))+
  geom_point()+
  facet_nested(qtl + gene ~ .) +

  theme(axis.title.x = element_blank(),
        axis.text.x = element_text(size=8,angle = 90, hjust=1, vjust=0.2),
        axis.title.y = element_blank(),
        axis.text.y = element_text(size=8),
        axis.ticks.y = element_blank(),
        axis.line = element_line(color = "black"),
        strip.text.y.left = element_text(size = 8, angle=0),
        strip.background = element_rect(fill='white', color="black"),
        panel.spacing.y = unit(0.5, "lines"),
        strip.placement = "outside",
        panel.background = element_blank(),
        panel.grid.major = element_line(colour = "#ededed", size = 0.5))
p


text:
Q: Oracle NVL function not allows second parameter as datetime select nvl(trunc(null),trunc(sysdate)) from dual;

While executing above query i am getting following error
ORA-00932: inconsistent datatypes: expected NUMBER got DATE

look like when i take string or number instead of trunc(sysdate) it run fine.

A: From here:

The first parameter to NVL is determining the expected datatype of the
  returned column, with the trunc function defaulting that to NUMBER
  because it's parameter is NULL. The second parameter to NVL needs to
  match that datatype which it doesn't because it is a date.

SQL> select nvl(trunc(sysdate), sysdate) as mydate from dual;

MYDATE
-------------------
26/05/2006 00:00:00

SQL> select nvl(trunc(null), sysdate) as mydate from dual;
select nvl(trunc(null), sysdate) as mydate from dual
                        *
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected NUMBER got DATE

or you can do like this:
SELECT NVL(TO_DATE(TRUNC(NULL)),SYSDATE) FROM dual;

A: The second parameter must be of the same datatype as the first parameter. The trunc function is overloaded. Apparently when you pass it a null, it interprets the value as a number and returns a number. Any of the following works:
SELECT NVL (NULL, TRUNC (SYSDATE)) FROM DUAL;

SELECT NVL (TRUNC (TO_DATE (NULL)), TRUNC (SYSDATE)) FROM DUAL;

SELECT NVL (TRUNC (CAST (NULL AS DATE)), TRUNC (SYSDATE)) FROM DUAL;

Follow up:
If the variable that is being used is properly defined as a date, then you should not have a problem. As an example, the following runs without error:
DECLARE
   FUNCTION f
      RETURN DATE IS
   BEGIN
      RETURN NULL;
   END f;
BEGIN
   DBMS_OUTPUT.put_line (NVL (TRUNC (f), TRUNC (SYSDATE)));
END;

In order to get an answer that actually solves your problem, I would recommend editing the question to include code that actually demonstrates the problem.


text:
Q: Se me repite la función AJAX varias veces Compañeros, en esta ocación tengo una duda respecto al funcionamiento de AJAX y JQuery.
La primera página (pedir_fichas.php) tiene un código AJAX que me permite enviar datos de varios checkboxes:
$(document).on("click", "#pedido", function(){
        var pedido=$("#formulario").serialize();
        $.ajax({
            type:"POST",
            url:"pedido.php",
            data:pedido,
            success:function(data) {
                alert(data);
            }
        });
    });

Los datos se tomas gracias a un funcionario y se envían a pedido.php:
<?php
include('conexion.php');
$cc=$_POST['cedula'];
if ($_REQUEST['productos']!=""){
    $fecha=date("o-m-d", time());
    if (is_array($_REQUEST['productos'])) {
         while (list($key, $value)=each($_REQUEST['productos'])) {
             $pedido=mysqli_query($mysqli, "INSERT INTO pedidos (fecha_pedido, estado_pedido, doc_in, cod_prod) VALUES ('$fecha', 'Sin observar.','$cc', '$value')");
             if (!$pedido) {
                 echo "Error al realizar el pedido.";
             }else{
                 echo "El pedido se realizó con éxito el pedido.";
             }
         }
     }
 }
 ?>

Los datos llegan perfectamente y se suben a la base datos. El problema es ese, que no se sube un sólo registro, si no que se me duplica varias veces; además de esto, al enviarse los datos pedir_fichas.php se refresca completamente, en vez de quedarse sin modificación. Cuando pedir_fichas es llamdado (mediante AJAX) a inicio.php, al dar click en el botón pedir (para que se envíen los datos, me muestra la página principal, la página de inicio (pero los datos s eme envían correctamente. Quisiera saber cómo evitar eso o resolverlo.
PD: No siempre ocurre, es en ocaciones que este "loop" se muestra, pero siempre me devuelve y se refresca la página.


text:
Q: The ghost of icons past, should I pray to Saint William?
Possible Duplicate:
Why do my shortcut icons get broken on Windows 7?

I am fortnightly (or an approximation thereof) visited by the ghosts of icons, long departed. These apparitions only reveal themselves momentarily after I've logged in then vanish. Returning from whence they came.
I've investigated their history and found no clues as to why they continue to haunt me. I sought out an exorcist but those I found were only qualified to expel spirits of humans and demons. Not one had any experience with digital poltergeists.
Perhaps praying to Saint William of Redmond will improve the Vista before me.
Dost thou agree?

A: It's said that icons which die by violent deletions cannot pass on to the afterlife because they are not at peace. So instead they roam the desktop, haunting the living...
The only way to get rid of digital poltergeists is to appease your 32-bit apparitions by executing a sacrificial Perl script whilst reciting the last 24 digits of pi. Should you be unable to perform the aforementioned ritual, then I suggest you to smite User Profile Hive Cleanup Service (UPHClean).
I don't know if that's your problem, but without further details (what exactly are the icons of? documents? programs? temporary files? system files? did you search for them on your hard drive? check the All Users or Default desktop directory? etc.), it's hard to tell what the problem might be. But I hope you can resolve this issue so that those icons may finally pass on to that great recycling bin in the sky.

A: So, you have Windows Vista, and these are probably icons on the desktop that appear momentarily after login and then disappear.  And it only happens every 2 weeks or so.  Is there anything in your start menu or some task that starts that might be causing this?  I would think something that is trying and failing to completely start might be at fault, but that should happen on every startup.  So, perhaps something that is starting, and trying to do a periodic update is at fault.  Perhaps a registry cleanup will help.
As for praying to Saint William -- that will only work if you pay him well.  If you don't pay the exorcist, your computer is likely to be repossessed!

A: Yes, I certainly agree, praying to Saint William of Redmond will help you learn to keep the ghosts away!
You can tempt to accomplish this astonishing action in this accomodating hall of chat chambers...
Appear liberate to pull up the stakes and leave us a pleasant report to read.

A: Some applications update themselves automatically. Each time they update, they may end up adding back icons to your desktop. Apple applications are notorious for this, but there are many others as well.
What Icons specifically keep reappearing?

A: I want to forestall the ghost of icons from haunting my desktop, hence I prevent any icons from showing...
Utilize your hairy mouse and close any windows except for Windows, then get a menu on your desktop.
From there you can use the astonishing "view" menu to finally un-"show desktop icons"!
May this purple arrow guide you there...

A: Delete your icon cache file, generally located at: C:\Users\MyUserName\AppData\Local\iconcache.db
Then switch your display to 16-bit color and then back to 32-bit. This rebuilds your your icon cache. That is, for each file type, the OS will extract the associated icon data from the appropriate program or library, rather than just using the icon it used last time.


text:
Q: Deinit Called But Object Still in Memory I'm seeing strange behavior with the allocations instrument in Xcode 8 and Swift 2.3. I have an object (A) on which deinit is being called, all but one of the objects that A references are being deallocated (the one that isn't is a separate memory issue as far as I can tell), but the object continues to be listed as "live" and persistent in the allocations instrument. Additionally, when I try to debug it's retains, all I see is:

Note that I've confirmed deinit is being executed by:

*

*Adding a print line to the deinit method

*Adding a breakpoint to the deinit method

*Verifying that other objects that A references are de-allocated, and they receive a release (-1) ref count that claims to happen inside of the A.__deallocating_deinit method

However, for some unknown reason it appears to stick around.

A: After a few more hours of searching I finally managed to (mostly) figure it out.
In this case, I have class A which has 6 properties, one of which is an instance of class B. Class A registers block callbacks with class B. Class B receives events from outside of the main run loop, on a separate NSThread that wasn't properly wrapped in an @autoreleasepool. As a result, Class B was being retained longer than intended, which resulted in its blocks with callbacks to A being retained longer than intended.
The reason I say "mostly" figured it out is because class A registered all those blocks with [unowned self]. For a still unknown reason, that seemed to be enough to allow deinit to be executed, but not enough to actually free the object. Wrapping the other thread in @autoreleasepool allowed the app to release B, which was then enough to release A.


text:
Q: What do elements of the first homology group mean topologically? By Hurewicz theorem we know that $H_1(X)$ is the abelianization of $\pi_1(X)$. Let $X = S_1 \vee S_1$. Mark the the loops ($S_1$) by $a$ and $b$. Then $\pi_1(X) = \langle a,b\mid \;\rangle$ which is a free non-abelian group. After abelianization, $H_1(X) = \langle a,b\mid a+b=b+a\rangle \cong \mathbb{Z} \times \mathbb{Z}$.
Let $F:\pi_1(X) \to H_1(X)$ be a functor, then for example:
$F \circ \pi_1(abaa) = F \circ \pi_1(aaab) = \cdots = H_1(X) = 3a + b$.
Put a point $A$ inside the loop $a$, then winding number of $abaa$ and $aaab$ at $A$ is $3$ which is in fact a coefficient of $a$ in $H_1(X)$. Hence we could think of an element of $H_1(X)$ as a vector of winding numbers of the mapped loop with respect to the points inside the generating loops (i.e. $a$, $b$).
However, this notion seems to me rather artificial and I do not know what this vector actually means, how it can be used. How do you think of elements of $H_1(X)$?

A: Morally, $H_1$ is the abelian free group on cycles, that is, closed curves in the space, modulo the relation of homology: two cycles $a$ and $b$ are homologous if there is an oriented surface in the space whose boundary is $a-b$.
For example, if $a$ is a generator of $H_1(P_{\mathbb R}^1)$ then $2a=0$. This means that there is no surface in the projective plave such that its boundary is the curve $a$, but there is one whose boundary is $a+a$. Probably you know how to exhibit a map $D\to H_1(P_{\mathbb R}^1)$ from the closed disk to the projective place such that the restriction to the boundary of $D$ is twice the generator.
That $a\neq0$, on the other hand, implies that there is no map $D\to P_{\mathbb R}^1$ whose restriction to the boundary is $a$. But this is even more true than that:  there is no surface $\Sigma$ with boundary a circle such that there is a map $\Sigma\to P_{\mathbb R}^1$ whose restriction to the boundary is $a$.


text:
Q: php, error of getting json data I have a webapp on my local server wich is currently using PHP 5.3.8. My webapp works perfect.
Now I am testing the same code on our public host that uses PHP 5.3.3-7 + squeeze9 (no idea of what is squeeze).
The point here is that a simple get of some JSON data in the url doesn't work on the host.
I am using this:
http://webs.myapp.com/print.php?data=[%22O20130718ASDAS460600442%22]

At my local server I am able to get the info in data like this:
$info = json_decode($_GET['data']);
$acompanantes = $info[0];

but I am not able to do the same on the other server. I know that if I update the host server php's to the 5.3.8 99% it will work, but I am afraid that the other things hosted there will stop working as soon as I update it.
Any idea on how should I try to get the data ?? What am I doing wrong ??
Thanks in advance.
PS: both servers use JSON version 1.2.1.


text:
Q: Laravel 5.3 - TokenMismatch, using post method, I don't have a form I found a plethora of links telling me to insert csrf on the form. But what to do when you don't have a form? I use the post method to allow for other apps to post stuff on the database.
public function store(Request $request)
{
    if ($request->isMethod('post')) {
        $solicitation = new Solicitation;
        $solicitation->name = $request->name;
        $solicitation->description = $request->description;
        $solicitation->userid = $request->userid;
        if ($request->hasFile('file')) {
            $request->file('file')->move("uploads", $request->file('file')->getClientOriginalName());
            $solicitation->file = "http://192.168.1.85:3232/uploads/" . $request->file('file')->getClientOriginalName();
        }
        $solicitation->save();
    }
}

And the error:
TokenMismatchException in VerifyCsrfToken.php line 68:

edit
Workaround / Solution
Step 1) Edit the file: VerifyCsrfToken.php (app\Http\Middleware\VerifyCsrfToken.php)
Step 2) Modify the following:
protected $except = [
    'solicitation/*', //INSERT THE NAME OF YOUR ROUTE HERE
];

Enjoy.

A: You can edit the VerifyCsrfToken class in Http\Middleware to exclude routes

A: You should use _token parameter to be sent with request every time you use POST method.

A: You have 2 options: excluding this route from csrf or sending the token with the request. https://laravel.com/docs/5.3/csrf#csrf-excluding-uris

A: It sounds like you're describing an API.
If you're sending the request from a separate Laravel application the tokens won't be congruent.
The solution would be to generate a request signature/token on the external application that your current application is expecting and can verify. You can use Laravel Passport: https://laravel.com/docs/5.3/passport


text:
Q: How to use DataSearch as controlled component from Reactivesearch? I'm new to ReactiveSearch library, and I implemented the DataSearch component with autosuggestion as my in-site SearchBar. I added value and onChange to in order to store the input value as a state, but as soon as I added the value prop, I can't type in the search bar any more. What's wrong?
I also want to know what kind of callback function can I use when I click one of the suggestions to trigger some event, I tried onClick, but it didn't work. Here is my code, any help is appreciated!
import * as React from 'react';
import {
  ReactiveBase,
  DataSearch,
} from '@appbaseio/reactivesearch';

import './SearchBar.scss';

export default class SearchBar extends React.Component {
  constructor(props) {
    super(props);
    this.state = { searchTerm: '' };
  }

  handleInputChange = (event) => {
    this.setState({ searchTerm: event.target.value });
  };

  handleSearch = () => {
  // do something...
  };

  public render() {
    return (
      <React.Fragment>
        <ReactiveBase
          app="rooms,floors,assets"
          url="http://localhost:9200"
          headers={{
            'Access-Control-Allow-Origin': '*'
          }}
          style={{ display: 'inline' }}
        >
          <DataSearch
            componentId="SearchRoom"
            dataField={['roomName', 'roomNumber', 'floorName', 'assetName']}
            placeholder="Search for rooms or assets"
            style={{ width: 500, display: 'inline-block' }}
            fuzziness={1}
            value={this.state.searchTerm}
            onChange={this.handleInputChange}
            //how to trigger handleSearch when I click one of the suggestions?
          />
        </ReactiveBase>
      </React.Fragment>
    );
  }
}

A: onChange returns the updated value it does not return a Synthetic Event. I have updated the Demo of DataSearch component from the docs to use controlled behavior.
I have also added a callback which would get called when you select any suggestion. You can make use of downShiftProps to achieve this.
Check the app here. You can also read more about this props here.
Hope this helps!


text:
Q: Crystal Reports to SSRS I've been using CR for about 2 years now, but I'd like to begin to port some of the reports I've developed in CR over to SSRS.
Anyone know of any guides or how-to's on getting used to designing in SSRS vs. CR?  I'm using Visual Studio 2012, with the Business Intelligence Report Services template.
Just a totally different look than I'm used to.


text:
Q: Hints to deduce convergence of an infinite product to $e^{-x^2}$ on $(0,1)$, and for a numeric series involving number-theoretic functions Exponentiating to get the gaussian $e^{-x^2}$, for $0<x<1$ from the infinite product that satisfies the Möbius function, see the identity (16) from the article Möbius Function from MathWolrd, then I've asked myself

Question 1. Can be proven that the sequence of partial products $$ \left\{ \prod_{k=1}^n  \left( 1-x^k \right)^{\frac{\mu(k)}{k}x} \right\}_{n\geq 1} $$ is uniformly convergent to our gaussian $e^{-x^2}$ on $(0,1)$?  What are your hints?  Many thanks.

I say a proof without using explicitly the identity that I've evoked as main argument in the proof. I believe that our sequence of partial products is uniformly convergent on compact subsets of $(0,1)$, what I would like to learn is how to formalize this claim, I remember Cauchy condition.
I did a second set of calculations inspired in the fact that $\int e^{-x^2}dx=\frac{\sqrt{\pi}}{2}\operatorname{erf}(x)+\operatorname{constant}$.  Combining the Prime Number Theorem with the MacLaurin series expansion of the Error function $\operatorname{erf}(z)$ defined from this MathWorld article for Erf (the examples seems also feasibles for $\operatorname{erfi}(z)$ ). Combining also with a related Dirichlet series. Then walking this way I can deduce identities whose series in my RHS have terms involving particular values of the Riemann Zeta function, for example for $$\frac{\sqrt{\pi}}{2}\sum_{k=1}^\infty\lambda(k)\operatorname{erf}\left(\frac{1}{k}\right)$$ where $\lambda(n)$ is the Liouville function. I would like to know some rigurous proof or reasoning to convice us that previous series is convergent. I believe that the series in our LHS for each of our examples, doesn't converge absolutely.

Question 2. Please, what is your explanation or hints to show that  $$\frac{\sqrt{\pi}}{2}\sum_{k=1}^\infty\lambda(k)\operatorname{erf}\left(\frac{1}{k}\right)$$ does converge? Thanks and good wishes.

My reasoning to get a different example. Since the example seems also feasible with the Möbius function instead Liouville function, and same error function, my justification for this different example was using the ratio test in RHS $$\lim_{n\to\infty}\left|\frac{a_{n+1}}{a_n}   \right|=\lim_{n\to\infty}\frac{2n+1}{(n+1)(2n+1)}\lim_{n\to\infty}\zeta(2n+1)\lim_{n\to\infty}\frac{1}{\zeta(2n+1)}=0\cdot1\cdot1=0<1,$$ and thus our series converges, but as I am saying I would like to know your calculations and reasonings for previous different example in Question 2, to do a comparison.

A: Let us consider $$f\left(x\right)=-\sum_{k\geq1}\frac{\mu\left(k\right)}{k}\log\left(1-x^{k}\right).
 $$ Now for the Möbius inversion for the power series we get $$\sum_{k\geq1}\frac{f\left(x^{k}\right)}{k}=-\log\left(1-x\right)
 $$ hence $f\left(x\right)=x
 $ and so $$\prod_{k\geq1}\left(1-x^{k}\right)^{x\mu\left(k\right)/k}=\exp\left(x\sum_{k\geq1}\frac{\mu\left(k\right)}{k}\log\left(1-x^{k}\right)\right)=\exp\left(-x^{2}\right).
 $$ For the second we may use $$\textrm{erf}\left(x\right)\sim\frac{2x}{\sqrt{\pi}},\, x\rightarrow0
 $$ hence $$\lambda\left(k\right)\textrm{erf}\left(\frac{1}{k}\right)\sim\frac{2}{\sqrt{\pi}}\frac{\lambda\left(k\right)}{k}
 $$ and recalling that $$\sum_{k\geq1}\frac{\lambda\left(k\right)}{k^{s}}=\frac{\zeta\left(2s\right)}{\zeta\left(s\right)}$$ we can conclude.


text:
Q: Are there any double, triple star systems in No Man's Sky? I've only come across single star systems. I'm curious to know if anyone has come across a double star system?
I've seen planets with two moons (albeit quite rare). Any double stars that I can look forward to?

A: There are no multi-star systems in No Man's Sky.
In fact, not only can you only find single star systems, but the "star" of the system is not actually physically present. It's part of the skybox for that system.

A: I found a 3 star system and the stars are red green and blue. With a safe tropical planet.

A: With the release of No Man's Sky: Origins, the most recent major update, systems with multiple stars now exist within the universe!

Some rare systems are now home to multiple stars, creating stunning new patterns in the sky.

[....]
Star System Visuals

*

*Additional stars have been added to the universe.

*Some systems now have binary stars.

*There is a rare chance for a system to have ternary stars.


text:
Q: How to do endless scrolling in recyclerview, in both left and right directions? I have an endless recycler view which I populate with data as scrolling is done. When I scroll right, it works perfectly. Problem is I can't figure out how to scroll left endlessly. If I am able to scroll, only then will I be able to populate the views with data. I have checked many similar queries on stackoverflow but all of them address endless scrolling only in right side direction or downward in the case of vertical recyclerview.
For example, How to implement load more recyclerview in android.
I want load more to get triggered while scrolling in either direction.

A: If you want to create horizontal RecyclerView from left to right add. It's default direction.
LinearLayoutManager layoutManager
    = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);

RecyclerView myList = (RecyclerView) findViewById(R.id.my_recycler_view);
myList.setLayoutManager(layoutManager);

If you want to change the default from right to left use
LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true);
        layoutManager.setReverseLayout(true);

You must choose the direction as you can't set scrolling to both sides . New items will be loaded to left or to right according to what you choose


text:
Q: I'm getting "The process cannot access the file because it is being used by another process" error. Any ideas? So, I created a file and a txt file into the AppData, and I want to overwrite the txt. But when I try to do it, it keeps giving me that error. Any ideas?
            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string setuppath = (path + "\\");
            string nsetuppath = (setuppath + "newx" + "\\");
            Directory.CreateDirectory(nsetuppath);

            string hedef2 = (nsetuppath + "commands.txt");
            File.Create(hedef2);
            StreamWriter sw = new StreamWriter(hedef2);   ----> This is where the error appears.
            sw.WriteLine("Testtest");

A: Just use the using statement when using streams. The using statement automatically calls Dispose on the object when the code that is using it has completed.
        //path to the file you want to create
        string path = @"C:\code\Test.txt";
        // Create the file, or overwrite if the file exists.
        using (FileStream fs = File.Create(path))
        {
            byte[] info = new UTF8Encoding(true).GetBytes("This is some text in the file.");
            // Add some information to the file.
            fs.Write(info, 0, info.Length);
        }

There are many ways of manipulate streams, keep it simple depending on your needs


text:
Q: Sum over the side or Vertical of Pascal's triangle / Infinite Series of Binomial coefficients summed over UPPER index Is there any closed form formula of even an equivalent for this binomial infinite series :
$$
F_k(x) = \sum_{n=k}^{\infty} \binom{n}{k}   x^{n}
$$
in which $|x|<1$ and k is a given integer ?
For example, $F_3(x) = x^3 + 4x^4 +10 x^5 +20 x^6 + 35 x^7 +... $
We all know that $ (1+x)^{n} = \sum_{k=1}^{n} \binom{n}{k} x^{k} $
But it's not the same summation : in the above k is fixed and n varies from k to infinity...
In Pascal's triangle, it's a sum aver a parallel to the side of the triangle, while the classical one goes along its base.

A: Take any $k∈ℕ^+$ and $x∈ℂ$ such that $|x|<1$.
$F_k(x)·(1-x) = \sum_{n=k}^∞ \binom{n}{k}x^n - \sum_{n=k+1}^∞ \binom{n-1}{k}x^n$
$= \sum_{n=k}^∞ \binom{n-1}{k-1}x^n = x·\sum_{n=k-1}^∞ \binom{n}{k-1}x^n$
$= F_{k-1}(x)·x$.
Therefore $F_k(x) = x^k·(1-x)^{-k-1}$, since $F_0(x) = (1-x)^{-1}$. Done.
~ ~ ~
Note that it is inadvisable to use differentiation of power series unless necessary, because it is not rigorous unless you invoke some uniform convergence theorems (which are much more complicated than what I used here). It is also bad to use logarithms because of the issues with branch cuts.
Finally, this is closely related to using the forward difference operator for indefinite summation.

A: If you write the first few terms, you have:
$$S_k(x) = \frac{F_k(x)}{x^k} = \binom k k + \binom{k+1}kx + \binom{k+2}kx^2 + \cdots$$
Which becomes:
$$S_k(x) = 1 + (k+1)x + \frac{(k+1)(k+2)}{2!}x^2 + \cdots$$
So you're looking for the function that:
$$S_k(0) = 1$$
$$S'_k(0) = k+1$$
$$S''_k(0) = (k+1)(k+2)$$
$$S^{(n)}_k(0) = (k+1)(k+2)\cdots(k+n)$$
EDIT
As pointed out in the comments by Robearz, the function we're looking for is simply:
$$S_k(x) = (1 - x)^{-(k + 1)}$$
So:
$$F_k(x) = x^k(1 - x)^{-(k + 1)}$$

A: $$\begin{align*}{T(x)} &= \binom k k + \binom{k+1}kx + \binom{k+2}kx^2 + \cdots\\&=\binom k k + \frac{k+1}{1}\binom{k}kx + \frac{k+2}{2}\binom{k+1}kx^2 + \cdots
\\&=xT(x)+\binom k k + \frac{k}{1}\binom{k}kx + \frac{k}{2}\binom{k+1}kx^2 + \cdots\end{align*}$$
$$\implies (1-x)T(x)=\binom k k + \frac{k}{1}\binom{k}kx + \frac{k}{2}\binom{k+1}kx^2 + \cdots$$
Differentiating both sides
$$\implies (1-x)T'(x)-T(x)= kT(x)$$
$$\implies (1-x)T'(x)= (k+1)T(x)$$
$$\frac{dT(x)}{T(x)}=\frac{(k+1)dx}{1-x}$$
$$\implies \ln(T(x))=-(k+1)\ln(1-x)+C$$
$$\implies T(x)(1-x)^{k+1}=C$$
$T(0)=1$
$$\implies T(x)=\frac1{(1-x)^{k+1}}$$
$$\implies F_k(x)=x^kT(x)=\frac{x^k}{(1-x)^{k+1}}$$


text:
Q: How to query the Canvas using Selenium and Javascript executor? I like to know if its possible to automate this 'graph' which is created on the canvas, if yes, how  to automate it. I have to interact with all the elements on the 'graph or a map like thing' by clicking on an element and dragging the elements and performing other actions like getting the text, etc.
Is this possible in automation using selenium with JavaScript executor, can anyone help.
 i already scour the internet, but didn't find anything useful or which even remotely answer the question i have. if any one can help, please do write an answer. i cannot share the real picture due to security reasons, but this is almost the same not identical.

A: https://www.protractortest.org/#/api?view=ElementArrayFinder.prototype.evaluate
this is what you need. But you need to know variable names (internal logic of the canvas) in order to retrieve data


text:
Q: How to get list of metrics available for HPA? I have GCP cluster which contains GKE application:

I want to scale application using HPA
Based on supporting for metrics
HPA able to read metrics from

*

*metrics.k8s.io (resource metrics)

*custom.metrics.k8s.io(custom metrics)

*external.metrics.k8s.io(external metrics)
How could I check what metrics available? How could try this API  on my own ? Is it possible at all?
P.S.
Based on suggested answer I executed command:
 kubectl get --raw https://MY-KUBE-APISERVER-IP:6443/apis/metrics.k8s.io/v1beta1/namespaces/default/pods

Response is:
{
  "items": [
    {
      "metadata": {
        "name": "prometheus-adapter-69fcdd56bc-2plh7",
        "namespace": "default",
        "selfLink": "/\r\napis/metrics.k8s.io/v1beta1/namespaces/default/pods/prometheus-adapter-69fcdd56bc-2plh7",
        "creationTimestamp": "2020-02-05T10:56:02Z"
      },
      "timestamp": "2020-02-05T10:55:22Z",
      "window": "30s",
      "containers": [
        {
          "name": "prometheus-adapter",
          "usage": {
            "cpu": "15\r\n31939n",
            "memory": "10408Ki"
          }
        }
      ]
    },
    {
      "metadata": {
        "name": "stackdriver-exporter-76fdbc9d8f-c285l",
        "namespace": "default",
        "selfLink": "/apis/metrics.k8s.io/v1beta1/namespaces/default/pods/stackdriver-exporter-76fdbc9d8f-c285l",
        "creationTimestamp": "2020-0\r\n2-05T10:56:02Z"
      },
      "timestamp": "2020-02-05T10:55:22Z",
      "window": "30s",
      "containers": [
        {
          "name": "stackdriver-exporter",
          "usage": {
            "cpu": "79340n",
            "memory": "2000Ki"
          }
        }
      ]
    }
  ],
  "kind": "PodMetricsList",
  "apiVersion": "metrics.k8s.io/v1beta1",
  "metadata": {
    "selfLink": "/apis/metrics.k8s.io/v1beta1/namespaces/default/pods"
  }
}

$ kubectl top pods
NAME                                    CPU(cores)   MEMORY(bytes)
prometheus-adapter-69fcdd56bc-2plh7     2m           10Mi
stackdriver-exporter-76fdbc9d8f-c285l   1m           1Mi

But I still don't see all metrics available for HPA

A: Metrics server exposes metrics via below APIs.

*

*/nodes - all node metrics; type []NodeMetrics

*/nodes/{node} - metrics for a specified node; type NodeMetrics

*/namespaces/{namespace}/pods - all pod metrics within namespace with
support for all-namespaces; type []PodMetrics

*/namespaces/{namespace}/pods/{pod} - metrics for a specified pod;
type PodMetrics
You can view available metrics as below for example
$ kubectl get --raw https://KUBE-APISERVER-IP:6443/apis/metrics.k8s.io/v1beta1
{
  "kind": "APIResourceList",
  "apiVersion": "v1",
  "groupVersion": "metrics.k8s.io/v1beta1",
  "resources": [
    {
      "name": "nodes",
      "singularName": "",
      "namespaced": false,
      "kind": "NodeMetrics",
      "verbs": [
        "get",
        "list"
      ]
    },
    {
      "name": "pods",
      "singularName": "",
      "namespaced": true,
      "kind": "PodMetrics",
      "verbs": [
        "get",
        "list"
      ]
    }
  ]
}

$ kubectl get --raw https://KUBE-APISERVER-IP:6443/apis/metrics.k8s.io/v1beta1/namespaces/default/pods
{
  "kind": "PodMetricsList",
  "apiVersion": "metrics.k8s.io/v1beta1",
  "metadata": {
    "selfLink": "/apis/metrics.k8s.io/v1beta1/namespaces/default/pods"
  },
  "items": []
}

$ kubectl get --raw https://KUBE-APISERVER-IP:6443/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods
{
  "kind": "PodMetricsList",
  "apiVersion": "metrics.k8s.io/v1beta1",
  "metadata": {
    "selfLink": "/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods"
  },
  "items": [
    {
      "metadata": {
        "name": "coredns-bcccf59f-jfl6x",
        "namespace": "kube-system",
        "selfLink": "/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/coredns-bcccf59f-jfl6x",
        "creationTimestamp": "2021-02-17T20:31:29Z"
      },
      "timestamp": "2021-02-17T20:30:27Z",
      "window": "30s",
      "containers": [
        {
          "name": "coredns",
          "usage": {
            "cpu": "1891053n",
            "memory": "8036Ki"
          }
        }
      ]
    },
    {
      "metadata": {
        "name": "coredns-bcccf59f-vmfvv",
        "namespace": "kube-system",
        "selfLink": "/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/coredns-bcccf59f-vmfvv",
        "creationTimestamp": "2021-02-17T20:31:29Z"
      },
      "timestamp": "2021-02-17T20:30:25Z",
      "window": "30s",
      "containers": [
        {
          "name": "coredns",
          "usage": {
            "cpu": "1869226n",
            "memory": "8096Ki"
          }
        }
      ]
    }
  ]
}

You can also use command kubectl top pods which internally calls the above API.
Custom Metrics
These are provided by adapters developed by vendors and what metrics are available will depend on the adapter. Once you know the metrics name You can use API to access it.
You can view available metrics as below and get the metrics name.
kubectl get --raw https://KUBE-APISERVER-IP:6443/apis/custom.metrics.k8s.io/v1beta1

External Metrics
These are provided by adapters developed by vendors and what metrics are available will depend on the adapter. Once you know the metrics name You can use API to access it.
You can view available metrics as below and get the metrics name.
kubectl get --raw https://KUBE-APISERVER-IP:6443/apis/external.metrics.k8s.io/v1beta1

Edit:
You already have Prometheus adapter but if the metric is not exposed as custom metrics to be consumable by HPA then you need to expose the required metrics. Refer to this guide for this.

A: On GKE case is bit different.
As default Kubernetes have some built-in metrics (CPU and Memory). If you want to use HPA based on this metric you will not have any issues.
In GCP concept:

*

*Custom Metrics are used when you want to use metrics exported by Kubernetes workload or metric attached to Kubernetes object such as Pod or Node.

*External Metrics- Metrics sent to Workspaces with a metric type beginning external.googleapis.com are known as external metrics. The metrics are typically exported by open-source projects and third-party providers. More details can be found here.
Stackdriver Monitoring treats external metrics the same as custom metrics, with one exception. For external metrics, a resource_type of global is invalid and results in the metric data being discarded.

As GKE is integrated with Stackdriver

Google Kubernetes Engine (GKE) includes native integration with Stackdriver Monitoring and Stackdriver Logging. When you create a GKE cluster, Stackdriver Kubernetes Engine Monitoring is enabled by default and provides a monitoring dashboard specifically tailored for Kubernetes.

With Stackdriver Kubernetes Engine Monitoring, you can control whether or not Stackdriver Logging collects application logs. You also have the option to disable the Stackdriver Monitoring and Stackdriver Logging integration altogether.
Check Available Metrics
As you are using cloud environment - GKE, you can find all default available metrics by curiling localhost on proper port. You have to SSH to one of Nodes and then curl metric-server $ curl localhost:10255/metrics.
Second way is to check available metrics documentation.
IMPORTANT
You can see available metrics, however to use them in HPA you need deploy Adapters like Stackdriver adapter or Prometheus adapter. In default (version 1.13.11) GKE cluster you have already deployed metrics-server, heapster(deprecated in newer versions) and prometheus-to-sd-XXX. If you would like to use Stackdriver, you would have many config already applied, but if you want to use Prometheus you will need adjust Prometheus operators, adapters, deployments. Details can be found here.
On GKE docs, you can find some tutorials to use HPA with Custom Metrics or with HPA with External Metrics. You can also read about GKE monitoring with Prometheus and Stackdriver, depends on your needs.
As GKE is integrated with Stackdriver you can read article about Enabling Monitoring.


text:
Q: How to import multiple pages into Excel from ESPN I need to import data from ESPN Fantasy Football into Excel. This includes multiple pages and a web query does not work. The URL is http://games.espn.com/ffl/tools/projections?startIndex=0. When you click next, the URL becomes http://games.espn.com/ffl/tools/projections?startIndex=40 and 80 and so on. Basically, the startIndex increments to multiples of 40 when you click on the next page.
This is the code I've user so far modifying the code provided by @Dee and it seems to adding a new worksheet but has no data in it.
 Private Const URL_TEMPLATE As String =
"URL;http://games.espn.com/ffl/tools/projections?startIndex={0}"
Private Const NUMBER_OF_PAGES As Byte = 7

Sub test()
    Dim page As Byte
    Dim queryTableObject As QueryTable
    Dim url As String

    For page = 1 To NUMBER_OF_PAGES
        url = VBA.Strings.Replace(URL_TEMPLATE, "{0}", page * 40)
        Set queryTableObject = ActiveSheet.QueryTables.Add(Connection:=url, Destination:=ThisWorkbook.Worksheets.Add.[a1])
        queryTableObject.WebSelectionType = xlSpecifiedTables
        queryTableObject.WebTables = "14"
        queryTableObject.Refresh
    Next page

End Sub

The end result should be pulling all the columns from each page into a tab in one Excel sheet. Is there a way to do this? Please assist.
Thanks,
J

A: The Id of the table is not 14 but playertable_0. If you need to paste all the data to one single sheet try to use the following modified code. Number of pages is here determined just by guessing. You will have to add some more code to prove if e.g. the Next element is present on the page and do it in do-loop or just simply guess the number of pages. HTH
Option Explicit

Private Const URL_TEMPLATE As String = _
 "URL;http://games.espn.com/ffl/tools/projections?startIndex={0}"
Private Const NUMBER_OF_PAGES As Byte = 20
Private Const TableId As String = "playertable_0"

Sub test()
    Dim page As Byte
    Dim queryTableObject As QueryTable
    Dim url As String
    Dim ws As Worksheet
    Dim target As Range
    Dim lastRow As Long

    Set ws = ThisWorkbook.Worksheets.Add
    Set target = ws.[a1]
    lastRow = 1

    For page = 0 To NUMBER_OF_PAGES
        url = VBA.Strings.Replace(URL_TEMPLATE, "{0}", page * 40)

        Set queryTableObject = ActiveSheet.QueryTables.Add( _
            Connection:=url, _
            Destination:=target)

        With queryTableObject
            .BackgroundQuery = False ' Run the query synchronously
                                     ' to be able to compute the last row
            .WebSelectionType = xlSpecifiedTables
            .WebTables = TableId
            .Refresh
        End With

        lastRow = ws.Cells.Find( _
            what:="*", _
            SearchDirection:=xlPrevious, _
            SearchOrder:=xlByRows) _
            .Row

        Set target = ws.Cells(lastRow + 1, 1)
        target.Select
    Next page
End Sub

A: Give this a go. I hope it will fix all the issues you are having.
Sub Espn_Data()
    Const URL = "http://games.espn.com/ffl/tools/projections?startIndex="
    Dim http As New XMLHTTP60, html As New HTMLDocument, page As Long
    Dim htmla As Object, tRow As Object, tCel As Object, ws As Worksheet

    For page = 0 To 120 Step 40  '''input the highest number replacing 120 to get them all
        With http
            .Open "GET", URL & page, False
            .send
            html.body.innerHTML = .responseText
        End With

        With ThisWorkbook
            Set ws = .Sheets.Add(After:=.Sheets(.Sheets.Count))
            ws.Name = page
        End With

        Set htmla = html.getElementsByClassName("playerTableTable tableBody")(0)

        For Each tRow In htmla.Rows
            For Each tCel In tRow.Cells
                c = c + 1: Cells(x + 1, c) = tCel.innerText
            Next tCel
            c = 0
            x = x + 1
        Next tRow
        c = 0
        x = 0
    Next page
End Sub

A: The Web Query for ESPN doesn't work any longer with ESPN Fantasy Football... I don't know why as it only returns all of the page info except what is in the table... Don't insult my intelligence, I've tried all of the settings...
I have come to discover that Excel only allows IE 6 as a web browser as you can find this in the 'File/Options/Advanced/General'  "Web Options" then Browsers and then scroll into Target Browsers.... There are your choices for Web Query to obtain Data.... ESPN does not support any of those browsers so like you, we're screwed until EXCEL updates our choices - Yes, I know... It's 2021 :(


text:
Q: CSS Hamburger doesn't spin when expanding sidenav I can't get my ccs made hamburger to open expand/collapse my sidenav, to top it off. If i get it to expand/collapse, then it stops spinning. Please see  codepen demo, thanks for the feedback
I think i made a mistake in the css, but i'm having a hard time tracing the issue. I would really appreciate a second pair of eyes.
HTML

         Item 4
         Item 5
         Link

        <input data-target="#sidebar" class="checkbox-toggle" data-toggle="collapse" type="checkbox">

Bootstrap 4 Dashboard

CSS
#sidebar {
    overflow: hidden;
    z-index: 3;
}
#sidebar .list-group {
    min-width: 300px;
    min-height: 100vh;
}

#sidebar .list-group-item {
    border-radius: 0;
    white-space: nowrap;
}

@media (max-width:768px) {
    #sidebar {
        min-width: 35px;
        max-width: 40px;
        overflow-y: auto;
        overflow-x: visible;
        transition: all 0.25s ease;
        transform: translateX(-45px);
        position: fixed;
    }

    #sidebar.show {
        transform: translateX(0);
    }

    #sidebar::-webkit-scrollbar{ width: 0px; }

    #sidebar, #sidebar .list-group {
        min-width: 35px;
        overflow: visible;
    }
    /* overlay sub levels on small screens */
    #sidebar .list-group .collapse.show, #sidebar .list-group .collapsing {
        position: relative;
        z-index: 1;
        width: 190px;
        top: 0;
    }
    #sidebar .list-group > .list-group-item {
        text-align: center;
        padding: .75rem .5rem;
    }
    /* hide caret icons of top level when collapsed */
    #sidebar .list-group > .list-group-item[aria-expanded="true"]::after,
    #sidebar .list-group > .list-group-item[aria-expanded="false"]::after {
        display:none;
    }
}

.collapse.show {
  visibility: visible;
}
.collapsing {
  visibility: visible;
  height: 0;
  -webkit-transition-property: height, visibility;
  transition-property: height, visibility;
  -webkit-transition-timing-function: ease-out;
  transition-timing-function: ease-out;
}
.collapsing.width {
  -webkit-transition-property: width, visibility;
  transition-property: width, visibility;
  width: 0;
  height: 100%;
  -webkit-transition-timing-function: ease-out;
  transition-timing-function: ease-out;
}

/* hamburger */

/*********************/
.outer-menu {
  position: relative;
  left: 0;
  z-index: 1;
}
.outer-menu .checkbox-toggle {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  cursor: pointer;
  width: 60px;
  height: 60px;
  opacity: 0;
}
.outer-menu .checkbox-toggle:checked + .hamburger > div {
  transform: rotate(135deg);
}
.outer-menu .checkbox-toggle:checked + .hamburger > div:before,
.outer-menu .checkbox-toggle:checked + .hamburger > div:after {
  top: 0;
  transform: rotate(90deg);
}
.outer-menu .checkbox-toggle:checked + .hamburger > div:after {
  opacity: 0;
}
.outer-menu .checkbox-toggle:checked ~ .menu {
  pointer-events: auto;
  visibility: visible;
}
.outer-menu .checkbox-toggle:checked ~ .menu > div {
  transform: scale(1);
  transition-duration: .75s;
}
.outer-menu .checkbox-toggle:checked ~ .menu > div > div {
  opacity: 1;
  transition: opacity 0.4s ease 0.4s;
}
.outer-menu .checkbox-toggle:hover + .hamburger {
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}
.outer-menu .checkbox-toggle:checked:hover + .hamburger > div {
  transform: rotate(225deg);
}
.outer-menu .hamburger {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 60px;
  height: 60px;
  padding: .5em 1em;
  background: rgba(33, 150, 243, 0.75);
  border-radius: 0 0.12em 0.12em 0;
  cursor: pointer;
  transition: box-shadow 0.4s ease;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.outer-menu .hamburger > div {
  position: relative;
  flex: none;
  width: 100%;
  height: 2px;
  background: #fefefe;
  transition: all 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.outer-menu .hamburger > div:before,
.outer-menu .hamburger > div:after {
  content: '';
  position: absolute;
  z-index: 1;
  top: -10px;
  left: 0;
  width: 100%;
  height: 2px;
  background: inherit;
  transition: all 0.4s ease;
}
.outer-menu .hamburger > div:after {
  top: 10px;
}

A: Your codepen doesn't work, jquery should be loaded first.
Anyway, here's my attempt to fix it. View it in full screen mode.
Once jquery is properly loaded, your code works except for the spinning effect because your selector is wrong.
See hamburger & X button section in CSS.

#sidebar {
    overflow: hidden;
    z-index: 3;
}
#sidebar .list-group {
    min-width: 300px;
    min-height: 100vh;
}

#sidebar .list-group-item {
    border-radius: 0;
    white-space: nowrap;
}

@media (max-width:768px) {
    #sidebar {
        min-width: 35px;
        max-width: 40px;
        overflow-y: auto;
        overflow-x: visible;
        transition: all 0.25s ease;
        transform: translateX(-45px);
        position: fixed;
    }

    #sidebar.show {
        transform: translateX(0);
    }

    #sidebar::-webkit-scrollbar{ width: 0px; }

    #sidebar, #sidebar .list-group {
        min-width: 35px;
        overflow: visible;
    }
    /* overlay sub levels on small screens */
    #sidebar .list-group .collapse.show, #sidebar .list-group .collapsing {
        position: relative;
        z-index: 1;
        width: 190px;
        top: 0;
    }
    #sidebar .list-group > .list-group-item {
        text-align: center;
        padding: .75rem .5rem;
    }
    /* hide caret icons of top level when collapsed */
    #sidebar .list-group > .list-group-item[aria-expanded="true"]::after,
    #sidebar .list-group > .list-group-item[aria-expanded="false"]::after {
        display:none;
    }
}

.collapse.show {
  visibility: visible;
}
.collapsing {
  visibility: visible;
  height: 0;
  -webkit-transition-property: height, visibility;
  transition-property: height, visibility;
  -webkit-transition-timing-function: ease-out;
  transition-timing-function: ease-out;
}
.collapsing.width {
  -webkit-transition-property: width, visibility;
  transition-property: width, visibility;
  width: 0;
  height: 100%;
  -webkit-transition-timing-function: ease-out;
  transition-timing-function: ease-out;
}

/* hamburger */

/*********************/
.outer-menu {
  position: relative;
  left: 0;
  z-index: 1;
}
.outer-menu .checkbox-toggle {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  cursor: pointer;
  width: 60px;
  height: 60px;
  opacity: 0;
}
.outer-menu .hamburger {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 60px;
  height: 60px;
  padding: .5em 1em;
  background: rgba(33, 150, 243, 0.75);
  border-radius: 0 0.12em 0.12em 0;
  cursor: pointer;
  transition: box-shadow 0.4s ease;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.outer-menu .hamburger > div {
  position: relative;
  flex: none;
  width: 100%;
  height: 2px;
  background: #fefefe;
  transition: all 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.outer-menu .checkbox-toggle.collapsed ~ .hamburger > div {
  transform: rotate(0deg);
}

.outer-menu .checkbox-toggle + .hamburger > div:before,
.outer-menu .checkbox-toggle + .hamburger > div:after {
  content: '';
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: inherit;
  transition: all 0.4s ease;
}
.outer-menu .checkbox-toggle.collapsed + .hamburger > div:before {
  top: -10px;
}
.outer-menu .checkbox-toggle.collapsed + .hamburger > div:before,
.outer-menu .checkbox-toggle.collapsed + .hamburger > div:after {
  transform: rotate(0deg);
  opacity: 1;
}
.outer-menu .checkbox-toggle.collapsed + .hamburger > div:after {
  top: 10px;
}
/* X button */

.outer-menu .checkbox-toggle + .hamburger > div {
  transform: rotate(135deg);
}
.outer-menu .checkbox-toggle + .hamburger > div:before,
.outer-menu .checkbox-toggle + .hamburger > div:after {
  top: 0;
  transform: rotate(90deg);
}
.outer-menu .checkbox-toggle + .hamburger > div:after {
  opacity: 0;
}
.outer-menu .checkbox-toggle ~ .menu {
  pointer-events: auto;
  visibility: visible;
}
.outer-menu .checkbox-toggle ~ .menu > div {
  transform: scale(1);
  transition-duration: .75s;
}
.outer-menu .checkbox-toggle ~ .menu > div > div {
  opacity: 1;
  transition: opacity 0.4s ease 0.4s;
}
.outer-menu .checkbox-toggle:hover + .hamburger {
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}
.outer-menu .checkbox-toggle.collapsed:hover + .hamburger > div {
  transform: rotate(180deg);
}
.outer-menu .checkbox-toggle:hover + .hamburger > div {
  transform: rotate(225deg);
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>

         Item 4
         Item 5
         Link

        <input data-target="#sidebar" class="checkbox-toggle collapsed" data-toggle="collapse" type="checkbox">

Bootstrap 4 Dashboard


text:
Q: template specialization based on a type's existance I want to implement some functionality if a certain type is defined. The problem is that if the type doesn't exist, the compiler rejects the code as invalid. Something like a template based ifdef. This would be used in a library which doesn't know what the other code includes, and I want to implement functionality automagically if some library is also included. Maybe it's the wrong approach, but I want to know if this can be done without ifdefs with default behavior.
template <typename=std::enable_if<type_exists<some_type>>::type>
void function() {
   // code using some_type
}
template <>
void function() {
   // code using other_type
}

This code would choose the first function if some_type exists, and the second function if some_type is undefined. The code assumes other_type exists.
Another use case would be something like this.
template <typename T, typename=std::enable_if<type_exists<boost::shared_ptr<T>>>::type>
using ptr = boost::shared_ptr<T>;
template <typename T>
using ptr = std::shared_ptr<T>;

To prefer boost pointers IF the user of the library included boost, otherwise fall back to std::shared_ptr.

A: If you want to use Boost (or any other library) only if it is available, you have to use the preprocessor. C++17 comes with a handy __has_include macro. You'd use it like the following:
#if __has_inlcude <boost/shared_ptr.hpp>

#include <boost/shared_ptr.hpp>
template<typename T>
using ptr = boost::shared_ptr<T>;

#else

#include <memory>
template<typename T>
using ptr = std::shared_ptr<T>;

#end

You could also use #if defined(BOOST_VERSION) to support older compilers, but this relies on specific boost headers being already included and is brittle (you risk ptr pointing to different things between translation units)

Here's some standardese (from N4140):

§3.4.3 [basic.lookup.qual]/1:
The name of a class or namespace member or enumerator can be referred
  to after the :: scope resolution operator applied to a
  nested-name-specifier that denotes its class, namespace, or
  enumeration. If a :: scope resolution operator in a
  nested-name-specifier is not preceded by a decltype-specifier, lookup
  of the name preceding that :: considers only namespaces, types, and
  templates whose specializations are types. If the name found does not
  designate a namespace or a class, enumeration, or dependent type, the
  program is ill-formed.

A: Unfortunately, I believe there is no easy way to determine whether a type is defined or not when it is being compiled,  mainly due to dumbness of C++ Preprocessor.
Also, __has_include is not in current C++ standard AND, relying on #if __has_include (<boost/shared_ptr.hpp>) can't solve your problem, because you can't say that if <boost/shared_ptr.hpp> is included your code, then your compiler doesn't have std::shared_ptr.
3 Possible solutions:

*

*if you wants to deal with newer standrad library with boost, consider using <boost/config.hpp>. For example, BOOST_NO_CXX11_SMART_PTR macro will help to determine whether std librry has shared_ptr or not

*You can implement your own macros to check whether a compiler support some library or not, by checking various compiler versions. However, it wont' be easy job due to compiler options. (ex. -std=c++03 vs -std=c++11 of gcc)

*Your toolchain probably can check your compiler's feature and pass it to the compiler using macro. See if configure.ac for autoconf, FindSharedPtr.cmake for CMake.


text:
Q: MessageComposeViewController not calling delegate I've been searching for solutions to my problem without any success...
The app I'm developing lets the user play a small quiz game and send the result as a text message. Everything works fine except when the MessageComposeViewController is suppose to dismiss (on send/cancel).
It seems like the MessageComposeViewController doesn't call the delegate since I don't get the print from the delegate function...
I have a separate class called SendMessage which handles the MessageComposeViewController, when the user click a button "Send" in a ViewController I create an instance of this class and present it.
Part of my ViewController with the send button:
    @IBAction func Send(_ sender: Any) {

    let sendResult = SendMessage()

    if sendResult.canSend() {
        let meddelande = sendResult.createMessage(result: 8, name: "Steve Jobs")
        present(meddelande, animated: true, completion: nil)
    } else {
        alert.addAction(alertButton)
        self.present(alert, animated: true, completion: nil)
    }

}

The class which handles the MessageComposeViewController called SendMessage (I left some irrelevant code out)
    func createMessage(result: Int, name: String) -> MFMessageComposeViewController {

    let meddelande = MFMessageComposeViewController()
    meddelande.messageComposeDelegate = self
    meddelande.recipients = ["PhoneNumber"]
    meddelande.body = name + ": " + String(result)
    return meddelande

}

func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
    print ("F*ck")
    controller.dismiss(animated: true, completion: nil)
}

Grateful for any help!

A: I think you should hold a strong reference to it instead of a local variable
let sendResult = SendMessage()

declare it as instance variable
var sendResult:SendMessage?


text:
Q: Android video stream from url over the videoview or surfaceview There are so many posts on the same topic but no one is giving proper reason for this error, Could some one help me to solving this error.
My code is working fine for SDCARD videos. whenever I try to access it from url it throws this error.
W/MediaPlayer: Couldn't open file on client side; trying server side: java.io.FileNotFoundException: No content provider: http://download.itcuties.com/teaser/itcuties-teaser-480.mp4
E/MediaPlayer: error (1, -2147483648)

I tried several formats and several urls for everything i am getting the same error.
Internet permissions given.
Code:
public class MainActivity extends AppCompatActivity {
VideoView video1;
String url ="http://download.itcuties.com/teaser/itcuties-teaser-480.mp4";
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    video1 = (VideoView) findViewById(R.id.video1);
    video1.setVideoURI(Uri.parse(url));
    video1.setMediaController(new MediaController(this));
    video1.requestFocus();
    Thread view1=new Thread(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_DISPLAY);
            video1.start();
        }
    });
}

}

A: You just need to start your view1 thread. Your code loads the video but doesn't play it. Adding this will solve the issue.
 view1.start();


text:
Q: HTML5 videos do not play when embedded inside of a scrollable iFrame with Safari on iOS With Safari on iOS, videos that are embedded below the fold inside of a scrollable iFrame will not begin playing when tapped. If you tap on the video multiple times, or do a long tap, the video may or may not begin playing. On the contrary, the video will play without issue as long as the video is embedded above the fold.

*

*Here is an example showing a video not working when embedded below
the fold inside of an iframe:
https://d1wlensemu2d8.cloudfront.net/safari-bug/example.html

*Here is an example showing a video working when embedded above the
fold inside of an iframe:
https://d1wlensemu2d8.cloudfront.net/safari-bug/example2.html

*Here are the contents of the iframe from the first example. The video
plays fine when the content is accessed directly:
https://d1wlensemu2d8.cloudfront.net/safari-bug/iframe.html
Until the bug is resolved, one possible work-around may be to extend the height of the iFrame and make its container scrollable. However, this is less than ideal when the content is variably sized and/or contains links to other similarly hosted pages. Can anyone recommend a better solution?
This was tested on iOS 15.4 with an iPhone 12 and iPad Pro (9.7-inch).

A: Here is a reasonable work-around for the time being:
window.addEventListener('touchstart', function(e) {
  e.preventDefault();
});


text:
Q: cast array>> into map> I have a table like
name            string
one_key_value   array<struct<key:string,value:array<string>>
two_key_value   array<struct<key:string,value:array<string>>

and want to convert it to
name            string
one_key_value   map<string,array<string>>
two_key_value   map<string,array<string>>

In presto I use
SELECT name,
MAP(TRANSFORM(one_key_value, kv -> kv.key), TRANSFORM(one_key_value, kv -> kv.value)) AS one_key_value,
MAP(TRANSFORM(two_key_value, kv -> kv.key), TRANSFORM(two_key_value, kv -> kv.value)) AS two_key_value
FROM table_a;

In hive I use
SELECT name,
map(k1,v1) AS one_key_value,
map(k2,v2) AS one_key_value
FROM table_a
lateral view inline(one_key_value) t1 as k1,v1
lateral view inline(two_key_value) t2 as k2,v2;

The count in hive is a lot higher as compared to presto, I guess it's because one key has lot of values and they are being exploded to different rows in hive. Is there a way to make the hive query similar to the presto query.