text:
Q: I have a json string . how can i break this in code , message and status code // this is body.
OTP_BODY": "{"code":0,"status_code":"SUCCESS","message":"Generated One Time Password Successfully"}"

A:  var jsonObject = JSON.parse(otp_body)

This will give you an object.
You can access code, status_code and message as
     jsonObject.code , jsonObject.status_code and jsonObject.message


text:
Q: Web scrape not returning full html I am attempting to scrape 'https://www.kaggle.com/kernels' in order to return all of the title names on the site, but I am running into an issue where the container for this detail 'div data-reactroot' is not being pulled into the scraped data.
import urllib
from bs4 import BeautifulSoup

kaggle = 'https://www.kaggle.com/kernels'
data = urllib.request.urlopen(kaggle).read()
htmlparse = BeautifulSoup(data, 'html.parser')
print(htmlparse.findAll("div", {"class" : "block-link block-link--bordered"}))

Is there an error in my code or is there some sort of block on the site preventing me from scraping this data?

A: As Elis Byberi wrote, the problem is really that you are attempting to get data before data is rendered from backend. You can get content of page after backend worked by using phantomjs. You can find small tutorial here

A: The data you want is fetched by JavaScript in json format each time you request the page. You can fetch it from "https://www.kaggle.com/kernels.json?sortBy=hotness&group=everyone&pageSize=20&after=439354&language=all&outputType=all" like this.
import requests
import json
source = requests.get("https://www.kaggle.com/kernels.json?sortBy=hotness&group=everyone&pageSize=20&after=439354&language=all&outputType=all")
json_obj = source.json()
for a in json_obj:
    print (a["title"])

Outputs:
2004-2005 Landfalling Hurricanes animation
Visualization of StockData
Generating Sentences One Letter at a Time
Decoding the Sexiest Job of 21st Century!!
Novice to Grandmaster
Analysis  on Pokemon Data
ROC Curve with k-Fold CV
Japan Bulgaria trade playground
Bootstrapping and CIs with Veteran Suicides
Replicating "Did I do that?" paper analyses with R
Social Progress Index and World Happiness Report
SVM+HOG On ColourCompositeImage
Low- level students
PyTorch Speech Recognition Challenge (WIP)
Loans -getting Insights
Exploring Youtube Trending Statistics EDA
3 Simple Steps (LB: .9878 with new data)
Titanic: Neural Network using Keras
Feature Engineering
Why do employees leave and what to do about it

The only thing you will have to change is the "after" query string parameter which in my request was 439354 but you could set it to 0 to get the first records.
You could also change the amount of records returned by changing the "pageSize" query string parameter e.g. "https://www.kaggle.com/kernels.json?sortBy=hotness&group=everyone&pageSize=5&after=0&language=all&outputType=all"
Outputs:
Data ScienceTutorial for Beginners
Data visualization and investigation
Spooky NLP and Topic Modelling tutorial
20 Years Of Games Analysis
NYC Taxi EDA - Update: The fast & the curious

Or an example with urllib:
import urllib.request
import json
kaggle = "https://www.kaggle.com/kernels.json?sortBy=hotness&group=everyone&pageSize=5&after=0&language=all&outputType=all"
data = urllib.request.urlopen(kaggle).read()
json_obj = json.loads(data.decode("utf-8"))
for a in json_obj:
    print (a["title"])

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to parse mysql_fetch_row into JSON object I have the following code:
<?php
include 'db.php';
$con = mysql_connect($host,$user,$pass);
$dbs = mysql_select_db($databaseName, $con);

$tableName = "tbl_title";
$result = mysql_query("SELECT id, fld_title FROM $tableName");

$data = array();
while ( $row = mysql_fetch_row($result) )
{
    //$data[] = $row;
    //$data['item'][] = $row;
    //$data['item'][] = $row['id'].value;
    $id = $row['id'];
    $fld_title = $row['fld_title'];
    $data = array( "id" => $id, "fld_title" => $fld_title);

    //echo $row['id'] . " " . $row['fld_title'];
            //echo '<option value="'.$row->id.'">'.$row->fld_title.'</option>';
}
echo json_encode( $data );
    //  echo $row[0] . " " . $row[1];
?>

I am trying to return the results in a formatted way, however, even though I get results from the query, $id and $fld_title don't get set to a value.  What am I missing?

A: There's no need to reference each column. $row is an array already. I've changed to using mysql_fetch_assoc because that one gives named columns.
$data = array();
while ( $row = mysql_fetch_assoc($result) )
{
    $data[] = $row;
}
echo json_encode( $data );

A: $data = array();
while ( $row = mysql_fetch_row($result) )
{
    $data[] = array( "id" => $row['id'] ,"fld_title" => $row['fld_title']);
}
var_dump(json_encode( $data ));

Updated

Get it by id:(I guess it unique)
 $data = array();
    while ( $row = mysql_fetch_array($result) )
    {
        $data[$row['id']] = array( "id" => $row['id'] ,"fld_title" => $row['fld_title']);
    }
    var_dump(json_encode( $data ));

A: You probably want this within the loop:
$data[] = array( "id" => $id, "fld_title" => $fld_title);

instead of:
$data = array( "id" => $id, "fld_title" => $fld_title);

So that one array per row is appended onto the output data array or you'll only output the last item.

A: why fetching row when you can fetch associative array form the result directly so that you dont have to do extra coding to format the data.
USE
mysql_ fetch_ assoc function to get those values.
and one more thing: fetchin row will give you only numerical keys not associative keys.
and now ENJOY ;)


text:
Q: Can I map a protected ICollection using EF6 code first mappings? Given the class:
public class User
{
    public int Id { get; protected set; }
    protected virtual ICollection<Role> UserRoles { get; set; }

    public IEnumerable<Role> Roles
    {
        get { return new ReadOnlyCollection<Role>(UserRoles.ToArray()); }
    }
}

How can I map the the UserRoles using EF6 code-first mappings? I don't want to expose any of the ICollection features outside of my entity. I also do not want to pollute my domain model with persistence information. I would like it to stay persistence agnostic. That means attributes are out.

A: Maybe this post can help you - though it's EF 6 alpha, so I don't know if it's still applicable.
In essence, you can define a custom convention in your OnModelCreating() method that takes all non-public fields and includes them in your model (code fragment taken directly from linked page):
public class MyContext : DbContext
{
    // DbSets etc. defined here

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder
        .Entities()
        .Configure(c =>
            {
                var nonPublicProperties = c.ClrType.GetProperties(BindingFlags.NonPublic|BindingFlags.Instance);

                foreach (var p in nonPublicProperties)
                {
                    c.Property(p).HasColumnName(p.Name);
                }
            });
      }
}

A: I figured out how to do this using reflection. Here is the gist of it:
internal class UserMapping : EntityTypeConfiguration<User>
{
    public UserMapping()
    {
        ToTable("Users");
        HasKey(u => u.Id);
        Property(u => u.Id)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
            .HasColumnName("UserID");

        var userType = typeof (User);
        var propertyInfo = userType.GetProperty("UserRoles", BindingFlags.NonPublic | BindingFlags.Instance);
        var parameter = Expression.Parameter(typeof (User), "u");
        var property = Expression.Property(parameter, propertyInfo);
        var funcType = typeof (Func<,>).MakeGenericType(userType, typeof (ICollection<Role>));// propertyInfo.PropertyType);
        var lambda = Expression.Lambda(funcType, property, parameter);

        ((ManyNavigationPropertyConfiguration<User, Role>)GetType().GetMethod("HasMany")
            .MakeGenericMethod(typeof(Role))
            .Invoke(this, new object[] { lambda }))
            .WithMany()
            .Map(m =>
            {
                m.MapLeftKey("UserId");
                m.MapRightKey("RoleId");
                m.ToTable("UserRoles");
            });
        }
    }
}

Much love to @darkgray for this answer here:
How to convert PropertyInfo to property expression and use it to invoke generic method?


text:
Q: Sum of chi-square and sum of Gaussians I came up to a point where I needed to add a $\sum_{i=0}^{100}(X_i^2)$, and the $\sum_{i=0}^{100}(X_i)$ where $X_i$ are iid $N(0,1)$. Now, I know that the first term is a chi squared RV with n degrees (n being the number of Gaussian RVs), which can be further approximated to a $N(100,200)$. Similarly, the second term is also $N(0,100).
Can I say something about the statistical relationship between the two? I feel that they are uncorrelated, but not independent.
Is there a way to prove their uncorrelatedness,(in)dependence?
Lastly, would the sum still be a Gaussian, and can I write the expression for its variance?
Thanks.

A: Well you can simply develop the formula:
$$ \textstyle \text{cov}(\sum X_i^2,\sum X_i) = \sum \mathbb E(X_i^3) = 0.   $$
Also they are not independant as
$$ \textstyle E(\sum X_i^2 (\sum X_i)^2) \neq \mathbb E (\sum X_i^2) \mathbb E (\sum X_i)^2.$$
The sum is asymptotically Gaussian if you renormalize it (that is if you use that $(\sum X_i^2 - n)/\sqrt n \approx \mathcal N(0,1)$. You get from Cramer's theorem
$$ \textstyle \frac 1 {\sqrt n} (\sum (X_i^2 + X_i) -n ) \overset{d}{\longrightarrow} \mathcal N( 0,3).  $$


text:
Q: zlib.output_compression breaks PDF downloads in Magento When i turn on zlib.output_compression, pdf generation in Magento is failing. How can i turn zlib.output_compression off within .htaccess for PDF files only ?
In PHP I could implement this.
if(ini_get('zlib.output_compression')) {
    ini_set('zlib.output_compression', 'Off');
}

Can I do something similar in .htaccess for PDF files only ?


text:
Q: How to modify by loading and saving the same xml file I have a problem with modifying xml file when i first load and then save it with same file path and name. Below is my code. The error is "Access to the path C:\MyApp\Web.config is denied. If i change the path of the xdoc.Save to be different from xdoc.Load, then it will be ok. What is your recommandation to solve this problem? If possible, i need to modify the existing xml file(meaning xml file for loading and saving is the same path).
XmlDocument xdoc = new XmlDocument();
xdoc.Load(@"C:\\MyApp\\Web.config");
XmlNode xn = xdoc.SelectSingleNode("//configuration/MyProvider");
XmlElement el = (XmlElement)xn;
el.SetAttribute("defaultProvider", "MyCustomValue");

xdoc.Save(@"C:\\MyApp\\Web.config");

Thanks in advance.

A: I would expect this to be fine if you have write access to web.config to start with, and if nothing else is using it. (It was certainly fine in a test I just ran.) I suspect it's more likely that another process is already using the file (or the same process but some other code within it), or that you simply don't have write access to the file.


text:
Q: How to convert time to time format in logstash I want to ask that how to convert below time formats in logstash.
9:48:42 to 09:48:42
9:8:42 to 09:08:42
9:48:2 to 09:48:02
9:8:2 to 09:08:02

Thanks for answering

A: I have solved my question with this way;

Creating input codec plugin and check if it starts without "0" then
put it in front of the message (event) with ruby


text:
Q: Exchange 2010 with DAG - problems with communication I've got 2 Exchange servers running HUB, CAS and MBX with DAG, 2 servers being Active Directory, 1 witness server and 1 TMG server. They are split evenly between 3 Hyper-V servers:

Server 1

*

*Exchange 1

*Ad 1

*Witness (I should move it to 3rd)

  Server 2

*

*Exchange 2

*Ad 2

  Server 3

*

*TMG

Before that they were all on one server. This is test environment that went live due to total failure at our mail provider.
The problem is ping to Exchange 1 or Exchange 2 or DAG IP occasionally is very high or even loosing packets, dropping RDP connections etc. Ping between AD1 and AD2 or TMG is fine. Just everything that comes/goes to/from change1/Exchange2 is high (normally it's 1-2ms (while AD1 to AD2 is less then 1ms) and it likes to jump to 1000ms or loosing packets from time to time. It's very intermittent, it even sometimes reported problems with DAG or witness file share because of network issue but the problems even occurred on one Hyper-V server (between AD1,Exchange1,Witness). The network is very simple - one VLAN for that network and everything else on those Hyper-V machines is separated into other VLAN's.
Is it normal that the ping is higher then 1ms in LAN network? Also DAG IP seems to be attached to only one server at the time. When that server goes down it switches that IP to other server. How to diagnose this very basic network configuration?

A: Seems like I've missed that the Exchange servers for some reason have LAN as Legacy Network Adapter in Hyper-V. After changing to Normal Network Card in Hyper-V everything works. Something to be aware of and to check when things go weird :-)


text:
Q: Keras: val_loss decreases while loss increases I set up a model in keras (in python 2.7) to predict the next stock price in a particular sequence.
The model I used is shown below (edited to fit this page):
model = Sequential()
model.add(Dense(5, input_shape=(1, 1)))
model.add(LSTM(5, return_sequences=True))
model.add(Dense(1))
model.add(Activation("linear"))
model.compile(loss="mse", optimizer="Nadam", metrics=["mape"])
predict = model.fit(X, Y, epochs=epochs, verbose=1, validation_split=0.2,
                    callbacks=[checkpoint_maker], shuffle=True,
                    batch_size=count / 10 * 8)

However, when I ran the model, I found that val_mean_absolute_percentage_error decreases while the mean_absolute_percentage_error increases.
Here is the graph I managed to generate after 1000 epochs.

Notice that the blue line is going up while the orange line is going down.
I have no idea why.
I've read on some sources that if the loss is decreasing and the val_loss is increasing it means that:

(the) model is over fitting, that (it) is just memorizing the training data - https://stats.stackexchange.com/a/260346

So does that mean, that in my case, the model is "under fitting"?
P.S. Code and files

A: Although a bit late, I had a similar problem.
In my case, the problem was my data generator. I added noise to an image in the form of randomly chosen columns. However, the generator accumulated the noise. Each epoch contained more and more noise.
I only used this data augmentation on the training data.
If you see something similar, check your generator.


text:
Q: how to change variable name when converting jar to DLL? Basically when i am converting an AAR to DLL there is same method name and variable name present in java code.
Means java class is implementing interface runnable, so default method of runnable is run. And also the class contain same name as run of boolean .
I think changing variable name is much more convenient than changing a method name which is implemented by interface.below is java code inside my jar:
public class Tailer
  implements Runnable
{
.....
private volatile boolean run = true;
......
......

protected boolean getRun()
  {
    .....
    ....
    return this.run;
  }

public void run()
  {
    ....
    ....
  }

}

I have used following code and it is not working.
<attr path="/api/package[@name='org.apache.commons.io.input']/class[@name='Tailer']/field[@name='run']"
      name="propertyName">runvariable</attr>


text:
Q: Peticion a php con ajax tengo un problema que no he podido resolver, al enviar una peticion desde un pagina web con AJAX la peticion es enviada pero al ejecutarse la rutina en php no ejecuta la funcion porque aparentemente no recibe los datos, y genera un error "Undefined index" en mi archivo php
este es el Select que llama a la funcion
<select class="selec1" Name="Menu1" id="MenuRub" onchange= "EnviarInfo(2);">
esta funcion es la que envia los datos
<script src="../js/jquery-3.6.0.js"></script>
<script type="text/javascript">
    function EnviarInfo(CodFuncion){
        var MenuRub=document.getElementById("MenuRub");
        var Id=MenuRub.selectedIndex;

        var Parametros={
            "CodigoFuncion":CodFuncion,
            "IdAgrupamiento":Id
        };

        $.ajax({
            data:Parametros,
            type:"POST",
            url:"CatalogoProd.php",
            async:false

        })
    }
</script>

y por ultimo este es el código de mi archivo CatalogoProd.php
$Inicio=new CatalogoProductos();

if (isset($_POST)){

    switch($_POST["CodigoFuncion"]){
      case 1:

        break;
      case 2:
        $DatosRub=$Inicio->ConsultaSeleccionAgrupamiento($_POST["IdAgrupamiento"]);
        break;
      default:
    }
  }

el problema es que en el php genera el error Undefined Index;

A: he seguido investigando una solucion a mi problema, logre resolverlo modificando las llamadas del proyecto, y en la pagina principal las referencias a al archivo php que carga el select, e esta forma al seleccionar la primer opción creo un nuevo select con las opciones que recupere de la base de datos


text:
Q: java.sql.SQLException: Access denied for user 'root'@'localhost' without any info about "Using password" I'm trying to connect my spring app with mysql db that is at the same server as app.
When i'm start my app i catch error "java.sql.SQLException: Access denied for user 'root'@'localhost'"
I found many solutions about "java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)" and "java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)" but in my case where isn't any info about "Using password" in logs.
I found about "Using password" this:
① (using password: YES): The user name is not obtained
② (using password: NO): the password is not obtained
What mean my error?
My root user has all privileges and i can connect to db using it from command line.
My pom.xml:
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/web_blog_db
spring.datasource.username=root
spring.datasource.password=*mypass*
spring.jpa.show-sql=true
server.error.whitelabel.enabled=false

log:
java.sql.SQLException: Access denied for user 'root'@'localhost'
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.23.jar!/:8.0.23]
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.23.jar!/:8.0.23]
        at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:833) ~[mysql-connector-java-8.0.23.jar!/:8.0.23]
        at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:453) ~[mysql-connector-java-8.0.23.jar!/:8.0.23]
        at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[mysql-connector-java-8.0.23.jar!/:8.0.23]
        at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[mysql-connector-java-8.0.23.jar!/:8.0.23]
        at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-3.4.5.jar!/:na]
        at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358) ~[HikariCP-3.4.5.jar!/:na]
        at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[HikariCP-3.4.5.jar!/:na]
        at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477) ~[HikariCP-3.4.5.jar!/:na]
        at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560) ~[HikariCP-3.4.5.jar!/:na]
        at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-3.4.5.jar!/:na]
        at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-3.4.5.jar!/:na]
        at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:176) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1224) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1255) ~[hibernate-core-5.4.29.Final.jar!/:5.4.29.Final]
        at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.5.jar!/:5.3.5]
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.5.jar!/:5.3.5]
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.5.jar!/:5.3.5]
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.5.jar!/:5.3.5]
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1845) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.5.jar!/:5.3.5]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.5.jar!/:5.3.5]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.5.jar!/:5.3.5]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.4.jar!/:2.4.4]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:769) ~[spring-boot-2.4.4.jar!/:2.4.4]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) ~[spring-boot-2.4.4.jar!/:2.4.4]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) ~[spring-boot-2.4.4.jar!/:2.4.4]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) ~[spring-boot-2.4.4.jar!/:2.4.4]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1313) ~[spring-boot-2.4.4.jar!/:2.4.4]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring-boot-2.4.4.jar!/:2.4.4]
        at ru.rodichev.webBlog.WebBlogApplication.main(WebBlogApplication.java:10) ~[classes!/:0.0.1-SNAPSHOT]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[webBlog-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:107) ~[webBlog-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[webBlog-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[webBlog-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]


text:
Q: Pairwise cosine similarity I'm a little confused when I read this paper:Pairwise Document Similarity in Large Collections with MapReduce
http://www.umiacs.umd.edu/~jimmylin/publications/Elsayed_etal_ACL2008_short.pdf
In this paper, the author seems didn't consider word only appears in one document, but according to the definition of cosine similarity, we need to consider this situation, right?
The material I used is this: https://www.dropbox.com/s/nctb66hh84ab32c/postings-Reuters-data
The java code I used is this: https://www.dropbox.com/s/aklviixup4uulmu/CosineSimilarity.java
And the results I generated is this: https://www.dropbox.com/s/ea6ov7l7yut7yfj/part-00000
In the results, I see a lot of 1's and even number bigger than 1. I think it's kind of weird, could someone help me find out the reason? Thanks.


text:
Q: How do I retrieve value from mysql database into the infowindow in google map? How do I retrieve value from mysql database and display in infowindow according to the markers?
Example first marker, info window should show "A"..For now, it shows everything. How do I do this? Please guide me through. Thanks!

A: The argument for retrieve that contains the info is i not info
marker.info = new google.maps
.InfoWindow ({content: 'No. of people who choose this location: '+ i});
//------------------------------------------------------------------------^

Related to the comments:(apply a different marker for the highest values)
Put this right after  var info = <?php echo json_encode($infoWindow); ?>;

max=Math.max.apply(null,info);

it will define a variable max with the highest item of info as value.
Now you can use this value for a conditional marker:
marker.setIcon('http://maps.google.com/mapfiles/ms/icons/'+
                  ((i==max)?'red':'green')+'-dot.png');


text:
Q: ReactJS Webapp - background changed after inputting This is my background before I input something:
before input
And after input:
after input the background somehow changed unintentionally.
Here is my code:
<div
  style={{
    height: window.innerHeight,
    backgroundImage: `url(${mobileBackground})`,
    backgroundSize: "cover",
    backgroundPosition: `0% 0%`,
    backgroundRepeat: "no-repeat",
  }}
  className={`flex flex-col items-center ${styles.root}`}
>
...
</div>


text:
Q: Moving the input file with c++ I want to be able to enter any file in MoveFile() and it will move the file to this folder: C:\folder\fl.txt. When I enter MoveFileA("C:\\fl.txt", "C:\\folder\\fl.txt"); Then everything works, but I need to move the first file (the one that is fl.txt) to folder ...
How can this be implemented so as not to always enter the file name (C:\folder\fl.txt) so that it auto inputs it?
Here is my code:
#include <iostream>
#include <string>
#include <Windows.h>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main() {
    MoveFileA("C:\\fl.txt", "C:\\folder\\fl.txt");
    cout << "Operation Succesful" << endl;
    cout << endl;
    system("pause");
}

I need something like:
int main() {
    int path_a;
    cin >> path_a;
    MoveFileA("path_a", "C:\\folder\\path_a");
    cout << "Operation Succesful" << endl;
    cout << endl;
    system("pause");
}

A: Perhaps you are looking for something like this:
#include <iostream>
#include <string>
#include <cstdlib>
#include <Windows.h>
using namespace std;

int main() {
    string filename;
    cin >> filename;
    if (MoveFileA(("C:\\"+filename).c_str(), ("C:\\folder\\"+filename).c_str()))
        cout << "Operation Successful" << endl;
    else
        cout << "Operation Failed" << endl;
    cout << endl;
    system("pause");
}

Though, if you are using C++17 or later, you might consider a pure C++ solution using std::filesystem::rename() instead of the Windows-specific MoveFileA() function, eg:
#include <iostream>
#include <string>
#include <filesystem>
#include <system_error>
#include <cstdlib>
using namespace std;
namespace fs = std::filesystem;

int main() {
    fs::path filename;
    cin >> filename;

    fs::path root("C:\\");
    error_code ec;

    fs::rename(root / filename, root / "folder" / filename, ec);
    if (ec)
        cout << "Operation Failed" << endl;
    else
        cout << "Operation Successful" << endl;
    cout << endl;
    system("pause");
}


text:
Q: Unable to read a parquet file using using pyspark.pandas I am working on replacing the pandas library with pyspark.pandas but I am facing lot of issues. One of them is mentioned below -
The code is working perfectly fine with -
import pandas as pd
df = pd.read_parquet(path, columns=column_names, **kwargs)

But when I tried to read the same file with pyspark.pandas -
import pyspark.pandas as ps
df = ps.read_parquet(path, columns=column_names, **kwargs)

I am getting the below FileNotFound error:
[ERROR][run]Un unanticipated error occurred: [WinError 2] The system cannot find the file specified
Traceback (most recent call last):
df = ps.read_parquet(path, columns=column_names, **kwargs, index_col=False)
File "C:\lib\site-packages\pyspark\pandas\namespace.py", line 851, in read_parquet
psdf = read_spark_io(path=path, format="parquet", options=options, index_col=index_col)
File "C:\lib\site-packages\pyspark\pandas\namespace.py", line 744, in read_spark_io
sdf = default_session().read.load(path=path, format=format, schema=schema, **options)
File "C:\lib\site-packages\pyspark\pandas\utils.py", line 471, in default_session
spark = SparkSession.builder.appName("pandas-on-Spark").getOrCreate()
File "C:\lib\site-packages\pyspark\sql\session.py", line 269, in getOrCreate
sc = SparkContext.getOrCreate(sparkConf)
File "C:\lib\site-packages\pyspark\context.py", line 483, in getOrCreate
SparkContext(conf=conf or SparkConf())
File "C:\lib\site-packages\pyspark\context.py", line 195, in __init__
SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
File "C:\lib\site-packages\pyspark\context.py", line 417, in _ensure_initialized
SparkContext._gateway = gateway or launch_gateway(conf)
File "C:\lib\site-packages\pyspark\java_gateway.py", line 99, in launch_gateway
proc = Popen(command, **popen_kwargs)
File "C:\lib\subprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\lib\subprocess.py", line 1435, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
Exiting...


text:
Q: Jenkins & GitHub Enterprise Servers API endpoint error - requires POST TL;DR: This is a bug. There is a bug report. https://issues.jenkins-ci.org/browse/JENKINS-54051
I am trying to set up the API endpoint for Jenkins to know how to communicate with a GitHub Enterprise Server.
I am working behind a corporate proxy (though the error persists whether or not I have the proxy turned on) and my enterprise github has a custom CA cert that I think I've installed, but in either case I don't think that's the issue since I can't even connect it to the normal github api either. Here the is the error I am getting:

This error is for any endpoint, including https://github.myenterprise.com/api/v3 and https://api.github.com/ and even https://google.com. I can access these 3 sites through firefox without errors, and the github ones display the JSON stuff that I think I should get:
{
  "current_user_url": "https://api.github.com/user",
  "current_user_authorizations_html_url": "https://github.com/settings/connections/applications{/client_id}",
  "authorizations_url": "https://api.github.com/authorizations",
  ...
}

If I google "This URL requires POST" there are only 3 results, none of which relate to Jenkins. I have very limited API / HTML / REST experience and have no idea what to try to fix this.

A: It does look like this is a bug or mismatch between the latest versions of the github-branch-source plugin (v2.3.6) and the github plugin (v1.29.1). From a quick triage it looks like the affected call is https://github.com/jenkinsci/github-branch-source-plugin/blame/5646416554d58fe224be382baa021df1b601f302/src/main/java/org/jenkinsci/plugins/github_branch_source/Endpoint.java#L154 and the related changeset at https://github.com/jenkinsci/github-branch-source-plugin/commit/22d3383002274bc3f4368534eba2b5c852e78b39. This should be raised with the maintainers of the plugins concerned, unfortunately I'm off on holiday and don't have time to do this, but just posting my findings here to help the community in the meantime.
I don't advise this, but a workaround is to downgrade to the previous versions of the plugins: git 3.9.0, github 1.29.0 and github-branch-source 2.3.4 (only a good idea if your network is airgapped). Those plugin versions contains the serverside request forgery bugs so beware.


text:
Q: How to find last month modified files in linux? I need to find files modified in the last month in one directory and copy to another directory, but with this command I only find the ones modified in last 31 days, not in the last month.
/usr/bin/find $SOURCE_DIR -maxdepth 1 -type f -name 'files*.pdf' -mtime -31 -exec cp -p {} $DEST_DIR`date +"%B_%Y"` \;
I need files modified last month for example: files modified in January, in February , ...Any suggestion?

A: @SmileDeveloper is on the right track, but it actually turns out to be pretty tricky:
$ cd "$(mktemp --directory)"
$ touch --date="$(date --date="$(date --rfc-3339=date | cut --characters=-7)-01 - 1 day" --rfc-3339=second)" last-day-of-last-month
$ touch --date="$(date --date="$(date --rfc-3339=date | cut --characters=-7)-01 - 1 second" --rfc-3339=second)" end-of-last-month
$ touch --date="$(date --rfc-3339=date | cut --characters=-7)-01" start-of-current-month
$ touch --date="$(date --date="$(date --rfc-3339=date | cut --characters=-7)-01 + 1 month - 1 second" --rfc-3339=second)" end-of-current-month
$ touch --date="$(date --date="$(date --rfc-3339=date | cut --characters=-7)-01 + 1 month" --rfc-3339=second)" start-of-next-month
$ stat --printf '%y\t%n\n' ./* | sort --key=1
2020-06-30 00:00:00.000000000 +1200 ./last-day-of-last-month
2020-06-30 23:59:59.000000000 +1200 ./end-of-last-month
2020-07-01 00:00:00.000000000 +1200 ./start-of-current-month
2020-07-31 23:59:59.000000000 +1200 ./end-of-current-month
2020-08-01 00:00:00.000000000 +1200 ./start-of-next-month
$ find . -mindepth 1 -newermt "$(date --rfc-3339=date | cut --characters=-7)-01 - 1 second" -not -newermt "$(date --rfc-3339=date | cut --characters=-7)-01 + 1 month - 1 second"
./end-of-current-month
./start-of-current-month

Basically the last command gives you the range from the last second of last month (exclusive) to the last second of the current month (inclusive). If you want absolute precision that probably gets even uglier, because find doesn't seem to have a way to select an inclusive start datetime and exclusive end datetime, unlike most programming languages.
Hopefully you don't have to worry about time zones within all this as well!

A: Current month (from first day)
/usr/bin/find $SOURCE_DIR -maxdepth 1 -type f -name 'files*.pdf' -newermt "$(date +%y-%m-1)" -exec cp -p {} $DEST_DIR`date +"%B_%Y"` \;

First day of last month to now:
/usr/bin/find $SOURCE_DIR -maxdepth 1 -type f -name 'files*.pdf' -newermt "$(date -d "$(date +%y-%m-1) - 1 month" +%y-%m-%d)" -exec cp -p {} $DEST_DIR`date +"%B_%Y"` \;

First day of last month to last day of last month:
/usr/bin/find $SOURCE_DIR -maxdepth 1 -type f -name 'files*.pdf' -newermt "$(date -d "$(date +%y-%m-1) - 1 month" +%y-%m-%d)" -not -newermt "$(date +%y-%m-1)" \;

EDIT:
Do not use mtime, because mtime search for files that are modified in 24*n, and does not start at the beginning of the day.

A: I seem to use find -printf a lot for these things.
$ which month_files
month_files () {
        find . -type f -printf "%TY-%Tm\t%p\n" | grep ^$1 | cut -f2
}

# example run on my ~/.cache directory
$ month_files 2020-05 | wc
   1007    1007   49917

Now you can process those files however you like.  For example,
mkdir /target/2020-05
month_files 2020-05 | xargs -d"\n" -I % cp % /target/2020-05/

The -I will force -L 1 (one execution per line).  Specifically for the cp command, you can get better efficiency by using
month_files 2020-05 | xargs -d"\n" cp --target-directory /target/2020-05/

I'm assuming none of the filenames have a newline in them.  I don't really hold with that kind of nonsense on my systems, I mean spaces and some special characters are one thing, newlines are quite another.  (Or, with apologies to Ian Fleming, "spaces are happenstance; special characters are coincidence, newlines are enemy action"!)


text:
Q: Implement 3 dot menu to a fragment Hi guys i want to create 3 dot action bar menu at fragment level, the condition is i want to show that menu at just 1 fragment not on all and if i make them at my main activity, Then i can't hide them so that's why i need to make them at fragment level. so, far i have tried this code on my fragment
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getActivity().getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // toggle nav drawer on selecting action bar app icon/title
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }
    switch (item.getItemId()) {
        case R.id.sync:
            Toast.makeText(this, "Sync data...", Toast.LENGTH_SHORT).show();
            return true;
    }
    return super.onOptionsItemSelected(item);
}

But its saying the method "onCreateOptionsMenu"  doesn't override from its super class.
It look like I'm miss something very basic, don't know what it is.
Thanks

A: Try like this
menu_filter.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools" >

    <item
        android:id="@+id/action_filter"
        android:title="@string/filter"
        android:orderInCategory="10"
        android:icon="@drawable/filter"
        app:showAsAction="ifRoom" />

</menu>

OnCreate Method of fragment
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setHasOptionsMenu(true);
    }

onCreateOptionsMenu
@Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.menu_filter.xml, menu);  // Use filter.xml from step 1
    }

onOptionsItemSelected
@Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if(id == R.id.action_filter){
            //Do whatever you want to do
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

I hope it might help you !

A: Put an ImageButton on fragment's layout with "3 dots" drawable. Then use PopupMenu to show the menu when that ImageButton is clicked. I hope the following answer given by Shylendra helps you: https://stackoverflow.com/a/21329225/7010102

A: Remove override annotation because it doesn't allow you to do so.Or try to use different xml menu resource to overcome this problem.Say main_menu is for your MainAcitivty and main_frag1 for your Fragment.

A:     // Todo Three Dots Code.....
    @Override
    public void onPrepareOptionsMenu(Menu menu) {

    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        menu.clear();
        inflater.inflate(R.menu.minu_filter, menu);
        menu.findItem(R.id.action_enter_manually).setVisible(true);
        menu.findItem(R.id.action_validation_report).setVisible(false);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if(id == R.id.action_enter_manually){
            Log.e("keshav","Enter Manually");
            Intent i=new Intent(getActivity(), EnterManually.class);
            startActivity(i);
            //Do whatever you want to do
            return true;
        }
        if(id == R.id.action_validation_report){
            Log.e("keshav","Enter Manually 7128");
            Intent i=new Intent(getActivity(), DateWiseReportActivity.class);
            startActivity(i);

            //Do whatever you want to do
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

----------------------------------------------------------------
                       menu_filter.xml
----------------------------------------------------------------

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <item
        android:id="@+id/action_enter_manually"
        android:icon="@mipmap/enter_manualy_48"
        android:orderInCategory="10"
        android:title="Enter Manually"
        app:showAsAction="collapseActionView" />

    <item
        android:id="@+id/action_validation_report"
        android:icon="@drawable/done"
        android:orderInCategory="10"
        android:title="Validation Report"
        app:showAsAction="collapseActionView" />

</menu>


text:
Q: Regex expression to match C language numbers I am trying to match numbers in Qt for syntax highlighting, and I am trying the following regexes:
"[^a-fA-F_][0-9]+" // For numbers.
"[^a-fA-F_][0-9]+\\.[0-9]+" // For decimal numbers.
"[^a-fA-F_][0-9]+\\.[0-9]+e[0-9a-fA-F]+" // For scientific notation.
"[^a-fA-F_]0[xX][0-9a-fA-F]+" // For hexadecimal numbers.

But the text is matching, for example, [1024, and highlighting the [ too. I wanted to highlight only the 1024 part.
Another problem is that the regex highlights when I type aoe2 and when I type aoe25. I don't want to highlight the number when it is preceded by letters or underscores, because then it would be an identifier.
How can I solve that?

A: Well it matches [ because of this statement:
[^a-fA-F_]
This will match anything that is not the letters A-F(any case) or an underscore

Why aren't you just matching the digits if that is what you want ?
For integers:         \b\d+
For decimal numbers:  \b\d+.\d+
For scientific:       \b\d+e\d+
For hexadecimal:      \b[\dA-Fa-F]+

Also as @Jan Dvorak mentions you can use word boundaries \b, to make sure your matches begin at the beginning of a word (or number). See example here: http://regex101.com/r/kC6dK3


text:
Q: Will browsers in Ubuntu touch support flash? Will the Ubuntu Touch browsers support flash?
Are they the same as the full desktop versions? I would love to be able to see flash content.

A: At the UDS Web Browser Application for touch devices session, it was stated that Flash will not be supported on Ubuntu Touch.

A: Ubuntu tablet applications (including browsers) will basically be adapted versions of the Desktop applications. So, if there is a build of Flash for your processor architecture (I'm not so certain ARM tablets get flash any more, though the Google Chrome Books of course get flash, but using Pepper), you will be able to run flash in your Ubuntu tablet browser.

A: Flash will not be supported in the Ubuntu Touch web browser by default.
This would require a specific build of flash for the target architecture with hardware acceleration. This is usually provided by OEMs, so unless they have a real interest in supporting flash, I don't see that happening.
Instead Ubuntu Touch is committed to providing a first-class HTML5 experience. Hopefully modern websites don't use flash anymore, in favour of open standards.


text:
Q: AsyncTask not starting after device rotate even after object re-creation I have a REST server that spits out data from a remote ADC, and I need to graph the data just for presentation. I used AsyncTask to move the data aquisition off of the main thread to prevent NetworkOnMainThreadException. I wrote this:
package inostiot.inostiot;

// imports

public class MonitorActivity extends AppCompatActivity {

    private GraphWorker worker;

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        worker.cancel(true);
        outState.putBundle("state", worker.prepareResume());
        outState.putBoolean("resuming", true);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_monitor);

        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        String ip = extras.getString("ip");

        LineChart chart = (LineChart) findViewById(R.id.chart);

        XAxis x = chart.getXAxis();
        YAxis y = chart.getAxisLeft();

        // More chart setup here, ignore

        if (savedInstanceState != null) {

            boolean resuming = savedInstanceState.getBoolean("resuming", false);

            if (resuming) {
                worker = new GraphWorker(this, ip, chart, true);
                worker.resume(savedInstanceState.getBundle("state"));
                worker.execute();
            }

        } else {
            worker = new GraphWorker(this, ip, chart, false);
            worker.execute();
        }
    }
}

class GraphWorker extends AsyncTask<Void, Object, Void> {

    private LineChart chart;
    private boolean resuming;
    private boolean running = true;
    private String ip;
    private Activity parent;

    private ArrayList<ADCPort> ports;
    private ArrayList<WalkingDataset> walkingDatasets;
    private ArrayList<LineDataSet> lineDataSets;

    GraphWorker(Activity parent, String ip, LineChart chart, boolean resuming) {

        this.parent = parent;

        if (!resuming) {
            ports = new ArrayList<>();
            walkingDatasets  = new ArrayList<>();
            this.ip = ip;
        }

        this.chart = chart;
        this.resuming = resuming;
        lineDataSets = new ArrayList<>();

    }

    @Override
    public Void doInBackground(Void...params) {

        ADC adc = new ADC(ip);

        if (!resuming) {

            if (!adc.auth()) throw new RuntimeException("Server invalid!");

            ports.add(new ColoredADCPort(0, "#FF0000"));
            walkingDatasets.add(new WalkingDataset(10));

            // More ports are initialized here, just copy-paste an
            // color change

        }

        while (running) {

            try {

                ports = adc.readPorts(ports);
                publishProgress((Object)ports);

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            } catch (ADCException e) {
                e.printStackTrace();
                break;
            }

        }

        return null;

    }

    void resume(Bundle data) {
        this.ports = (ArrayList<ADCPort>) data.getSerializable("ports");
        this.walkingDatasets = (ArrayList<WalkingDataset>) data.getSerializable("walkingDatasets");
        this.ip = data.getString("ip");
        this.chart.invalidate();
    }

    Bundle prepareResume() {
        Bundle data = new Bundle();
        data.putSerializable("ports", ports);
        data.putSerializable("walkingDatasets", walkingDatasets);
        data.putString("ip", ip);
        return data;
    }

    @Override
    protected void onProgressUpdate(Object... values) {

        ArrayList<ADCPort> ports = (ArrayList<ADCPort>) values[0];

        lineDataSets.clear();

        for (int i = 0; i < ports.size(); i++) {

            ColoredADCPort port = (ColoredADCPort) ports.get(i);
            WalkingDataset dataset = walkingDatasets.get(i);

            dataset.add(port.getValue());

            LineDataSet lineDataSet = new LineDataSet(dataset, String.format(Locale.ENGLISH, "Sensor %d", i));
            lineDataSet.setCircleColor(Color.parseColor(port.getColor()));
            lineDataSet.setColor(Color.parseColor(port.getColor()));
            lineDataSet.setDrawValues(false);

            lineDataSets.add(lineDataSet);

        }

        final LineData data = new LineData();

        for (LineDataSet set : lineDataSets) {
            data.addDataSet(set);
        }

        chart.setData(data);
        chart.postInvalidate();

        super.onProgressUpdate();
    }

    public void stopRunner() {
        this.running = false;
    }

}

There is a LineChart from MPAndroidCharts on the Activity, and the AsyncTask is supposed to update the UI with the new chart data that it gets from the server. However, after a device rotation and after the resume() method of GraphWorker is called to restore the object state, and after calling execute(), doInBackground() is never called or being run. Why?

A: I need to stop the previous worker before starting another.
In sequential processing all Async tasks run in a single thread and thus have to wait before the previous task ends. If you need to execute code immediately, you need tasks to be processed in parallel in separate threads.
So, adding running=false in prepareResume to stop the previous worker solves this issue.


text:
Q: Tomcat v8.5 não inicializa, apresenta o erro: A child container failed during start Estou fazendo um trabalho de faculdade, um crud simples com JSF2, Hibernate, Primefaces e CDI. Porem no momento que vou inicializar o projeto no Tomcat tenho o seguinte erro:
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TrabalhoFaculdade]]

Segue log completo do erro:

ago 27, 2017 1:53:35 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTÊNCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:TrabalhoFaculdade' did not find a matching property.
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server version:        Apache Tomcat/8.5.20
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server built:          Aug 2 2017 21:35:49 UTC
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server number:         8.5.20.0
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Name:               Linux
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Version:            4.9.0-3-amd64
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Architecture:          amd64
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Java Home:             /usr/lib/jvm/jdk-oracle/jre
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Version:           1.8.0_131-b11
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Vendor:            Oracle Corporation
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_BASE:         /home/christiano/Documentos/Trabalho/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_HOME:         /home/christiano/apache-tomcat-8.5.20
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.base=/home/christiano/Documentos/Trabalho/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.home=/home/christiano/apache-tomcat-8.5.20
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dwtp.deploy=/home/christiano/Documentos/Trabalho/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=/home/christiano/apache-tomcat-8.5.20/endorsed
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dfile.encoding=UTF-8
ago 27, 2017 1:53:35 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFORMAÇÕES: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
ago 27, 2017 1:53:35 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["http-nio-8080"]
ago 27, 2017 1:53:35 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAÇÕES: Using a shared selector for servlet write/read
ago 27, 2017 1:53:35 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["ajp-nio-8009"]
ago 27, 2017 1:53:35 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAÇÕES: Using a shared selector for servlet write/read
ago 27, 2017 1:53:35 PM org.apache.catalina.startup.Catalina load
INFORMAÇÕES: Initialization processed in 1837 ms
ago 27, 2017 1:53:35 PM org.apache.catalina.core.StandardService startInternal
INFORMAÇÕES: Starting service [Catalina]
ago 27, 2017 1:53:35 PM org.apache.catalina.core.StandardEngine startInternal
INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/8.5.20
ago 27, 2017 1:53:36 PM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TrabalhoFaculdade]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:939)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TrabalhoFaculdade]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    ... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@28578a16]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4860)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4992)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@4acd9788]
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:721)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 9 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature)
    at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:113)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
    ... 12 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method)
    at java.util.zip.ZipFile.access$1400(ZipFile.java:60)
    at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:717)
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:419)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at sun.misc.IOUtils.readFully(IOUtils.java:65)
    at java.util.jar.JarFile.getBytes(JarFile.java:425)
    at java.util.jar.JarFile.getManifestFromReference(JarFile.java:193)
    at java.util.jar.JarFile.getManifest(JarFile.java:180)
    at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:111)
    ... 13 more

ago 27, 2017 1:53:37 PM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:939)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:656)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:947)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more

ago 27, 2017 1:53:37 PM org.apache.catalina.startup.Catalina start
GRAVE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:656)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:947)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more

ago 27, 2017 1:53:37 PM org.apache.coyote.AbstractProtocol pause
INFORMAÇÕES: Pausing ProtocolHandler ["http-nio-8080"]
ago 27, 2017 1:53:37 PM org.apache.coyote.AbstractProtocol pause
INFORMAÇÕES: Pausing ProtocolHandler ["ajp-nio-8009"]
ago 27, 2017 1:53:37 PM org.apache.catalina.core.StandardService stopInternal
INFORMAÇÕES: Stopping service [Catalina]
ago 27, 2017 1:53:37 PM org.apache.coyote.AbstractProtocol destroy
INFORMAÇÕES: Destroying ProtocolHandler ["http-nio-8080"]
ago 27, 2017 1:53:37 PM org.apache.coyote.AbstractProtocol destroy
INFORMAÇÕES: Destroying ProtocolHandler ["ajp-nio-8009"]

Será que alguém pode me dar uma ajuda?
Segue o pom.xml:
  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.TrabalhoFaculdade</groupId>
        <artifactId>TrabalhoFaculdade</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <packaging>war</packaging>
        <dependencies>
            <dependency>
                <groupId>org.glassfish</groupId>
                <artifactId>javax.faces</artifactId>
                <version>2.3.0</version>
            </dependency>
            <dependency>
                <groupId>org.primefaces</groupId>
                <artifactId>primefaces</artifactId>
                <version>5.1</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>4.3.10.Final</version>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.6</version>
            </dependency>
            <dependency>
                <groupId>org.jboss.weld.servlet</groupId>
                <artifactId>weld-servlet</artifactId>
                <version>2.2.9.Final</version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>

A: O erro na verdade é mais embaixo:
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method)
    at java.util.zip.ZipFile.access$1400(ZipFile.java:60)
    at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:717)
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:419)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at sun.misc.IOUtils.readFully(IOUtils.java:65)
    at java.util.jar.JarFile.getBytes(JarFile.java:425)
    at java.util.jar.JarFile.getManifestFromReference(JarFile.java:193)
    at java.util.jar.JarFile.getManifest(JarFile.java:180)
    at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:111)
    ... 13 more

Como você está utilizando o Maven, as vezes (muito dependendo da rede e situações adversas), um JAR do seu artifactory local pode vir quebrado (alguns bytes foram corrompidos durante a transferência do repositório remoto).
Uma dica para descobrir qual JAR está apresentando problemas:

*

*Adicionar um breakpoint na classe JarFile.java:425 (linha 425)

*Caindo no breakpoint apresentando problema, na classe pai ZipFile você pode conferir o nome através da propriedade name
Para forçar o download do artefato novamente, você deve ir ao ser artifactory local, deletar a pasta relacionada ao artefato, e realizar o build do projeto novamente (clean install).
Caso esta abordagem não funcione, o JAR ainda apresente problemas, você pode instalar o JAR localmente a partir de um artefato. Esta segunda abordagem deve ser utilizada em ÚLTIMO CASO, visto que você terá que instalar o JAR também no artifactory da sua empresa geralmente.

A: Faça o seguinte, deixe que o maven gerencie o projeto e não o eclipse. Para isso, adicione a seguinte configuração no pom.xml
<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Depois de adicionar essa configuração, se necessário, faça um Maven Update. Se ainda não resolver, exclua o projeto do Eclipse. Depois entre na pasta do projeto e remova as pastas e arquivos do Eclipse. Volte a Eclipse e importe o projeto pela opção Maven > Exists Maven Project. Isso deve resolver.


text:
Q: How to get user id session in prestashop 1.6.1.3 the field name of user id is id_customer and I'm using prestashop 1.6.1.3
I already tried on this
 $id = $this->context->customer->id_customer;

this
$id = (int)$this->context->cookie->id_customer;

this
if ($this->context->customer->isLogged()) {

  echo $this->context->customer->id_customer;
}
else{
echo 'Not LoggedIn';
}

and this
   $id_customer = null;
    if ($this->context->customer->isLogged()) {
        // code to execute if i am logued
         $id_customer = $this->context->customer->id;
    }

but it's not working ..., can someone help me?
thx
*also if you have a tpl function to get id session, let me know.

A: Instead of calling $this which depends of the controller / module you're working with. You can call directly the singleton Context object like this:
if (Context::getContext()->customer->id)
{
    $id_customer = Context::getContext()->customer->id;
}
else
{
    $id_customer = false;
}


text:
Q: Asterisk Installation On Server (Boot issue,boot: command shown instead of root user login) Good day guys.I need fast help please i am going mad already.I am installing asterisk with freepbx on my server.All goes good,installation is done,but instead of going to CMD and asking me to login as root user,asterisk gone myself to again same installation screen.I am using tutorial on official docs from here
Asterisk installation
Anyway if i press esc on my server,it goes to CMD but with BOOT: as command and i have no clue how to ssh to my server with this.
From link above the 12th part do not happen to me...What i should do?

A: I am sorry im slow.....I had to remove the attached ISO on the server side ....What a lack of logic....


text:
Q: How to prove $\sum\limits_{i =1}^{26} \frac{a_i}{\sum_{j =0}^{i} a_j^2} \leq \sqrt{26}$ Given arbitrary real numbers $a_i$,
Prove that
$$\sum_{i =1}^{26} \frac{a_i}{\sum_{j =0}^{i} a_j^2} \leq \sqrt{26}$$
where $a_0 = 1$
So it will look like:
$$\frac{a_1}{(1+a_{1}^2)} + \frac{a_2}{(1+ a_{1}^2 + a_{2}^2)} + \cdots + \frac{a_{26}}{(1+ a_1^2+ \cdots + a_{26}^2)}$$

A: Here is a proof for the more general inequality
$$
  \sum_{i=1}^n \frac{a_i}{1 + \sum_{j=1}^i a_j^2} \leq \sqrt{n}.
$$
where $a_1, \ldots, a_n$ range over $\mathbb{R}$. The method is a little cumbersome so I would be interested in a more direct proof.
I assume this problem comes from a math competition and would be interested to know its source.
Let $S_n$ denote the sum. Clearly we can assume that each $a_i \geq 0$, as otherwise we could increase $S_n$ by swapping the sign of one of the variables. Now make the change of variables
$$
  a_i = t_i \sqrt{1 + a_1^2 + \cdots + a_{i-1}^2}
$$
for each $i$ so that
$$
  \frac{a_i}{1 + \sum_{j=1}^{i-1} a_j^2 + a_i^2} = \frac{1}{\sqrt{1 + \sum_{j=1}^{i-1} a_j^2}} \frac{t_i}{1 + t_i^2}
$$
and furthermore
$$
  \frac{1}{\sqrt{1 + \sum_{j=1}^{i-1} a_j^2}} = \prod_{j=1}^{i-1} \frac{1}{\sqrt{1 + t_j^2}}.
$$
Now we have
$$
  S_n = \sum_{i=1}^n \frac{t_i}{1 + t_i^2} \prod_{j=1}^{i-1} \frac{1}{\sqrt{1 + t_j^2}}.
$$
Grouping terms, we get
$$
  S_n = \frac{t_1}{1 + t_1^2} + \frac{1}{\sqrt{1 + t_1^2}} \left( \frac{t_2}{1 + t_2^2} + \frac{1}{\sqrt{1 + t_2^2}} \left( \cdots \right)\right)
$$
We therefore define $f : [n] \to \mathbb{R}^+$ inductively by
$$
  f(n) = \max_{t_n \geq 0} \frac{t_n}{1 + t_n^2}
$$
and
$$
  f(k) = \max_{t_k \geq 0} \frac{t_k}{1 + t_k^2} + f(k+1) \frac{1}{\sqrt{1 + t_k^2}}.
$$
Then we have $S_n \leq f(1)$ (and in fact, $f(1) = \max_{t_1, \ldots, t_n} S_n$).
Note that if $M$ is an upper bound for $f(k+1)$, then
$$
  \max_{t_k \geq 0} \frac{t_k}{1 + t_k^2} + M \frac{1}{\sqrt{1 + t_k^2}}
$$
is an upper bound for $f(k)$. It therefore suffices to show that
$$
  f(k) \leq \sqrt{n+1-k}
$$
inductively in $k$, starting at $n$.
We have the base case
$$
  f(n) = \max_{t_n \geq 0} \frac{t_n}{1 + t_n^2} \leq \frac{1}{2}.
$$
It therefore suffices for us to show
$$
  \frac{t}{1 + t^2} + \sqrt{m} \frac{1}{\sqrt{1 + t^2}} \leq \sqrt{m+1}
$$
for every $m \geq 1$ uniformly in $t \geq 0$. With the trivial bound
$$
  \frac{t}{1 + t^2} \leq \frac{t}{\sqrt{1 + t^2}}
$$
it suffices to show
$$
  \frac{t + \sqrt{m}}{\sqrt{1 + t^2}} \leq \sqrt{m+1}.
$$
Squaring, it suffices to show
$$
  \frac{t^2 + 2 t \sqrt{m} + m}{1 + t^2} \leq m + 1
$$
Or, equivalently,
$$
  t^2 + 2 t \sqrt{m} + m \leq m + 1 + (m + 1) t^2
$$
or
$$
  2 t \sqrt{m} \leq 1 + m t^2.
$$
But this is the AM-GM inequality for the pair $(1, mt^2)$, and the proof is complete.
Note that the method of proof showed that the inequality is not sharp for any $n$.

A: Suppose that $n$ is a positive integer and that $x\in \mathbb{R}^{n+1}$.  By the Cauchy-Schwarz inequality, we have
$$\sum_{k=0}^n |x_k| \le \left(\sum_{k=0}^n x^2_k\right)^{1/2}
 \left(\sum_{k=0}^n 1\right)^{1/2} = \sqrt{n+1}\|x\|  $$
Dividing we get
$$\sum_{k=0}^n {|x_k|\over {\|x\|^2}} \le {\sqrt{n+1}\over \|x\|}$$
Since the first coordiante of your vector is 1, you have $\|x\|\ge 1$.
From this I am able to obtain
$$ \sum_{k=0}^n {|x_k|\over {\|x\|^2}} \le \sqrt{n+1}$$
Perhaps you can sharpen this.


text:
Q: (X,Y,Z) Coordinate tracking in QGIS I am working on a Python script which will give me the x,y and depth coordinates in QGIS. I have depth as an attribute of the raster layer. My objective is to get a status bar which shows x,y and the depth coordinate when the mouse is at a certain point of the canvas. The code I have used is:
from qgis.gui import *
from PyQt4.QtGui import QAction, QMainWindow, QApplication
from PyQt4.QtCore import SIGNAL, Qt

class MyWnd(QMainWindow):
  def __init__(self,layer):
    QMainWindow.__init__(self)
    self.statusBar().showMessage(u"x:-,y:-")
    self.canvas = QgsMapCanvas()
    self.canvas.setCanvasColor(Qt.white)

    self.canvas.setExtent(layer.extent())
    self.canvas.setLayerSet([QgsMapCanvasLayer(layer)])

    self.setCentralWidget(self.canvas)

    actionZoomIn = QAction("Zoom in", self)
    actionZoomOut = QAction("Zoom out", self)
    actionPan = QAction("Pan", self)

    actionZoomIn.setCheckable(True)
    actionZoomOut.setCheckable(True)
    actionPan.setCheckable(True)

    self.connect(actionZoomIn, SIGNAL("triggered()"), self.zoomIn)
    self.connect(actionZoomOut, SIGNAL("triggered()"), self.zoomOut)
    self.connect(actionPan, SIGNAL("triggered()"), self.pan)

    self.toolbar = self.addToolBar("Canvas actions")
    self.toolbar.addAction(actionZoomIn)
    self.toolbar.addAction(actionZoomOut)
    self.toolbar.addAction(actionPan)

    # create the map tools
    self.toolPan = QgsMapToolPan(self.canvas)
    self.toolPan.setAction(actionPan)
    self.toolZoomIn = QgsMapToolZoom(self.canvas, False) # false = in
    self.toolZoomIn.setAction(actionZoomIn)
    self.toolZoomOut = QgsMapToolZoom(self.canvas, True) # true = out
    self.toolZoomOut.setAction(actionZoomOut)

    self.pan()

  def zoomIn(self):
    self.canvas.setMapTool(self.toolZoomIn)

  def zoomOut(self):
    self.canvas.setMapTool(self.toolZoomOut)

  def pan(self):
    self.canvas.setMapTool(self.toolPan)

  def eventFilter(self,source,event):
    if event.type()==Qt.Event.MouseMove:
      if event.buttons()==Qt.NoButton:
        pos=event.pos()
        x=pos.x()
        y=pos.y()
        p=selfcanvas.getCoordinateTransform().toMapCoordinates(x,y)
        self.statusBar().showMessage(u"x:%s,y:%s" %(p.x(),p.y()))
      else:
        pass
    return QMainWindow.eventFilter(self,source,event)

This file I have saved as mywnd.py in the Python27 folder
Then in Python console in QGIS I use:
import mywnd

w=mywnd.MyWnd(qgis.utils.iface.activeLayer())
w.show()

This gives me my active layer but I still can't figure out how to get the values of x and y in the statusbar. I also am not very good at Python.

A: Some notes
An event filter...
... needs to be installed or it's never going to be called
def __init__(self):
    ...
    self.installEventFilter(self)

The event types...
... are enumerated in QEvent::Type, so you need to use QEvent.MouseMove.
Mouse tracking ...
... is disabled by default (for performance reason), so you need to explicitly enable it if you want to receive move events it in the event filter even when no button is clicked
self.setMouseTracking(True)

Code style
New style connections are better
Use something like
self.actionZoomIn.triggered.connect(self.zoomIn)

Wildcard imports
... are discouraged.
You are already doing things correctly for from PyQt4.QtGui import xxx. Do the same for the qgis imports. Do not use from qgis.gui import * but instead
from qgis.gui import QgsMapCanvas, QgsMapToolPan, etc.


text:
Q: java.lang.NoClassDefFoundError: org/xml/sax/helpers/DefaultHandler I dont know anymore what to do. I am sitting on this problem since 3 days.
I have an OSGi-Bundle and in this bundle I create an ExportOperation:
    public void createExportOperation(IProject project, IPath buildLocation, IPath exportLocation) throws CoreException{
        try {
            FeatureExportInfo exportInfo = this.initExport(buildLocation, exportLocation, project);
            exportInfo.qualifier = AdvancedFeatureExportOperation.getDateQualifier();

            Job job = new AdvancedFeatureExportOperation(exportInfo, "Project Deployment");
            job.setUser(true);
            job.setRule(ResourcesPlugin.getWorkspace().getRoot());
            job.schedule();

        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

AdvancedFeatureExportOperation is only a wrapper and extends org.eclipse.pde.internal.core.exports.FeatureExportOperation
If I run my bundle within eclipse (OSGi HostConsole) it works. But if I start the bundle separate in OSGi only, I get after 10mins in one of the last steps of the export operation the following error in my logs:
    !ENTRY org.eclipse.core.jobs 4 2 2022-09-22 20:24:07.425
!MESSAGE An internal error occurred during: "Project Deployment".
!STACK 0
java.lang.NoClassDefFoundError: org/xml/sax/helpers/DefaultHandler
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:638)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:613)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:574)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:638)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:613)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:574)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:464)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at org.eclipse.pde.internal.build.site.BuildTimeFeatureFactory.parseBuildFeature(BuildTimeFeatureFactory.java:79)
    at org.eclipse.pde.internal.build.site.BuildTimeFeatureFactory.createFeature(BuildTimeFeatureFactory.java:50)
    at org.eclipse.pde.internal.build.site.BuildTimeSite.createFeature(BuildTimeSite.java:469)
    at org.eclipse.pde.internal.build.site.compatibility.FeatureReference.getFeature(FeatureReference.java:39)
    at org.eclipse.pde.internal.build.site.BuildTimeSite.resolveFeatureReferences(BuildTimeSite.java:327)
    at org.eclipse.pde.internal.build.site.BuildTimeSite.findFeature(BuildTimeSite.java:296)
    at org.eclipse.pde.internal.build.site.BuildTimeSite.findFeature(BuildTimeSite.java:288)
    at org.eclipse.pde.internal.build.BuildScriptGenerator.generateFeatures(BuildScriptGenerator.java:252)
    at org.eclipse.pde.internal.build.BuildScriptGenerator.generate(BuildScriptGenerator.java:127)
    at org.eclipse.pde.internal.core.exports.FeatureExportOperation.doExport(FeatureExportOperation.java:256)
    at org.eclipse.pde.internal.core.exports.FeatureExportOperation.doExport(FeatureExportOperation.java:223)
    at org.eclipse.pde.internal.core.exports.FeatureExportOperation.run(FeatureExportOperation.java:107)
    at com.iisy.solvatio.studio.deployment.wizards.AdvancedFeatureExportOperation.run(AdvancedFeatureExportOperation.java:24)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.ClassNotFoundException: org.xml.sax.helpers.DefaultHandler cannot be found by org.eclipse.equinox.p2.publisher.eclipse_1.1.200.v20130516-1953
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    ... 45 more

I have installed exact the same bundles like they are installed in eclipse. Alle dependencies are fullfiled. I even downloaded extra org.everit.osgi.bundles.org.apache.xmlcommons.full-1.4.1-20150918.jar where org.xml.sax.helpers.DefaultHandler will be exported and in the manifest of my bundle I habe this one as Require-Bundle.
It dostn work but in eclipse I dont need extra bundles either. And because I was so desperate I even changed the manifest-file for the bunlde org.eclipse.equinox.p2.publisher.eclipse manually so org.everit.osgi.bundles.org.apache.xmlcommons.full will be listed as Require-Bundle.
But no chance, du you have any idea what is the problem or how I could track down the issue? Thank you very much for every help!

A: The solution was to add:
-Dorg.osgi.framework.system.packages.extra=javax.*,org.xml.sax,org.xml.sax.helpers -Dorg.osgi.framework.bootdelegation=javax.*,org.xml.sax,org.xml.sax.helpers

... for OSGi-Start in shell. In Eclipse it works because they are not so strickt.
I found the solution after reading: https://developer.ibm.com/articles/osgi-demystified-part-2-unraveling-java-and-osgi-class-loader-problems/


text:
Q: Connected set cannot be written as the union of numerable proper connected separated sets. Is there a proof or a counterexample to such an affirmation?
For example, we know that no finite union of proper connected sets is connected.
Can it happen that given any connected set, and given a numerable collection of proper connected separated subsets of X, that X is equal to the union of such a collection?
In other words, given a connected set $X$, is $X$ is always bigger than any union of proper connected separated sets?

A: Let $X$ be any countably infinite set, with the cofinite topology.

Then $X$ is connected, and also, $X$ is the countable union of its singleton subsets, which are proper connected sets.

Also, any two distinct singletons sets are separated.


text:
Q: How can my button's position be centered without any kind of "margin cheat"? How can I place my button in the center without any kind of "margin cheat" (for example setting margin-left: 525px;)?
HTML

H1 tag

        Products

CSS
    .bannerButton {
    border: 2px solid #fff;
    color: #fff;
    font-weight: 300;
    font-family: 'Raleway';
    font-size: 20px;
    display: inline-block;
    background-color: rgb(63, 127, 191);
    padding: 18px 60px 18px 50px;
    margin-bottom: 50px;
    margin-top: 50px;
    position: relative;
    margin-left: 525px;
}
.bannerButton:hover {
    text-decoration: none;
    background: #eaf;
    color: #fff;
}

I've tried making it sit in the center but it didn't work out so well without me setting margin-left; 525px;, which in my case, centers the button under the text, please help me remove this "margin cheat" and do it in the right way.

A: The a act like text it means when you give text-align:center; to its parent, it will be placed in center of its parent.
You don't need to give margin to the a element. You can use text-align:center;.

#bannerContainer
{
  text-align:center;
}

    .bannerButton {
    border: 2px solid #fff;
    color: #fff;
    font-weight: 300;
    font-family: 'Raleway';
    font-size: 20px;
    display: inline-block;
    background-color: rgb(63, 127, 191);
    padding: 18px 60px 18px 50px;
    margin-bottom: 50px;
    margin-top: 50px;
    position: relative;
}
.bannerButton:hover {
    text-decoration: none;
    background: #eaf;
    color: #fff;
}

H1 tag

        Products

A: If you set the position of the button to absolute, give it a set width, and add this it should center:
left: 50%; right: 50%;

A: Have you try this:
Products

I am not sure whether it is helpful to you..


text:
Q: How to access field name with space in Cloud Function? The example code is below:
exports.updateUser = functions.firestore
    .document('users/{userId}')
    .onUpdate((change, context) => {
      // Get an object representing the document
      // e.g. {'First Name': 'Marie', 'age': 66}
      const newValue = change.after.data();

      // ...or the previous value before this update
      const previousValue = change.before.data();

      // access a particular field as you would any JS property
      //const name = newValue.name; //How does one accesses 'FIRST NAME'

      // perform desired operations ...
    });

If 'FIRST NAME' is replaced by 'name' it is easy, but my data comes from somewhere else where I have no control on the field names. So the field descriptions have spaces between. How do I read them please?

A: You need to use brackets notation of property accessor for that:
newValue["First Name"]

In the object[property_name] syntax, the property_name is just a string or Symbol. So, it can be any string, including '1foo', '!bar!', or even ' ' (a space).


text:
Q: Python - transfer files in the same network using shutil I'm moving a .txt file between two servers (Ubuntu and Windows) in the same network.
The following code doesn't show any errors but it doesn't work:
def transfer_files_task():

    source_path = r"/root/airflow/testdoc"
    dest_path = f"192.168.xxx.xx\Doc-Share\Logger Output"
    filename = r"/test.txt"
    filenamew = f"\test.txt"
    shutil.copyfile(source_path + filename, dest_path + filenamew)

A: Change your function to this:
import os, ntpath, posixpath

def transfer_files_task():
     source_file = posixpath.join("/", "root", "airflow", "testdoc", "test.txt")
     dest_file = ntpath.join("192.168.xxx.xx", "Doc-Share", "Logger Output", "test.txt")
     assert os.path.exists(source_file), f"{source_file} does not exists"
     shutil.copyfile(source_file, dest_file)

A small explanation: leave python format your paths, it will save you from many errors. If you do not do that, you have to know how strings work, what characters should be escaped, how to format a path on linux and windows, etc.
Also, a side note about the use of r and f prefix for strings:

*

*r stands for raw and it roughly means that you don't have to escape special characters like the backspace. Consequently, r"\tab" == "\\tab" and print(r"\tab") gives \tab while print("\tab") gives     ab

*f stands for format and is the new way of formatting strings in py36+. It is used as follows:

name="john"
print(f"hello {name}")
# hello john

Finally, you might want to check this post: Cannot copy file from a remote machine using shutil


text:
Q: conditionally change widget type in django form I have the following simple form:
class ContactEmailForm(forms.ModelForm):

    subject = forms.ChoiceField(choices=SUBJECT_TYPES)

    class Meta:
        model = ContactEmail
        fields = ('name', 'email', 'subject', 'message',)

I want to conditionally change the subject field between a choice field and text input field.
How can I do this?

A: This could be accomplished by overriding the __init__ function within your ContactEmailForm class.
class ContactEmailForm(forms.ModelForm):

    subject = forms.ChoiceField(choices=SUBJECT_TYPES)

    def __init__(self, *args, **kwargs):
        super(ContactEmailForm, self).__init__(*args, **kwargs)
        if YOURCONDITION:
            self.fields['subject'] = forms.CharField()

    class Meta:
        model = ContactEmail
        fields = ('name', 'email', 'subject', 'message',)


text:
Q: Styled-component object can't observe mobx changes I would like an HOC generated by styled-components to re-render when one of its properties get changed. I'm using MobX for change detection.
This doesn't respond to changes, I think I understand why. The question is if there is a simple workaround to make it work.
const DemoComponent = observer(styled.div`
  background-color: ${props => props.myObject.myObservableIsTrue ? 'red' :
'green'};
`);

A: It's hard to tell by this little snippet, but one of my guesses would be you are not injecting any store, so currently, no store is being connected to your component.
here's a simple example of how I used styled-components with mobx if it helps:
EDITED:
I've updated the code example.
Do you know the Container / Presentational pattern?
This was the missing link.
In order to keep your renders as little as possible
you need to separate your stateful component from each other.
Spread them across a Container component (aka Dumb Components)
This way you separate state concerns and render only the component with the changed state.
UPDATED:
https://codesandbox.io/s/zxx6o2pq3l

A: Sorry!!! A bit of a hack job, but attempt to bring your entire code inside the @inject("store") class:
import React from "react";
import { observer, inject } from "mobx-react";
import styled, { css } from "styled-components";

@inject("store")
@observer
export default class OtherComponent extends React.Component {

  render() {
    const MyWrapper = (store) => {
      const Wrapper = styled.div`
  border: 1px solid black;
  display: flex;
  justify-content: space-between;
  color: ${({ color }) => color};
  border: 2px solid ${({ color }) => color || "black"};
  padding: 10px;
  margin-bottom: 10px;
`;
      return (
        <Wrapper {...store}>
          styled-component
        <button onClick={store.changeColor}>change color</button>
        </Wrapper>
      );
    }
    const { store } = this.props;
    return (
      <div>
      {
          MyWrapper(store)
      }
      </div>
    );
  }
}

Mobx is actually read like this: @inject("store") @observer export default class...
So it really an extension of an extended component; only wrapped variables will apply!


text:
Q: How to get distinct of one column and sum of another column in SQL? I have a Query
select b.*  from TABLE a, TABLE b
  where
    a.hdr_pk_id = b.hdr_fk_id
      and a.hdr_pk_id in (select bonus_pk_id
    from BONUS_TABLE
        where
            STATUS='I'
            and TYPE=2
            )) ;

returns sample data:
empno empname amount
1     a       100
2     b       200
3     c       300
1     a       400
2     b       100
3     c       200

I need distinct empno and sum(amount)
Eg How can i get the data like
empno empname amount
1     a       500
2     b       300
3     c       500

A: SELECT b.empno, b.empname, SUM(amount)
FROM TABLE a, TABLE b
WHERE a.hdr_pk_id = b.hdr_fk_id
  and a.hdr_pk_id in (select bonus_pk_id
  from BONUS_TABLE
    where
        STATUS='I'
        and TYPE=2))
GROUP BY b.empno, b.empname;

A: I am not sure but try
 select distinct b.* ,sum(b.amount) over (partition by empname) from TABLE a,TABLE b
   where
  a.hdr_pk_id = b.hdr_fk_id
  and a.hdr_pk_id in (select bonus_pk_id
  from BONUS_TABLE
    where
        STATUS='I'
        and TYPE=2
        )) ;


text:
Q: justify-self css property does not produce a desired effect justify-self is not working. Why?
html

css
.container {
  display: flex;
  justify-content: center;
  background: yellow;
}

.container * {
  width: 10px;
  height: 10px;
  background: green;
  border: 2px solid red;
}

.a {
  justify-self: start;
}

jsfiddle
I would expect the first element to be aligned to left since it has class a and class a specifies justify-self: start, but that does not happen. Why?
As I was informed in comments flexbox does not support the justify-self property. Then how could I position two of children in middle of the parent and one child stick to the left side of the parent using for example grid?

A: You don't need grid for this.
Flexbox is made for one dimensional layouts and Grid is made for two dimensional layouts.
You can do this in multiple ways. Michael_B explained this very good in this similar question center-and-right-align-flexbox-elements


text:
Q: How do I include a video in metatags through my wordpress site? I'm trying to use this code to ask if the post is a video if so it would add the video meta-tags needed to display a playable video on facebook. The result is that it dosnt call the_content(); an example post from my site: http://associate.graymafia.com/old-spice-remix/
<?php if( get_post_format() == 'video' ) {
echo '<meta property="og:video" content="';
the_content();
echo '" />';
echo        '<meta property="og:video:height" content="640" />';
echo        '<meta property="og:video:width" content="385" />';
echo        '<meta property="og:video:type" content="application/x-shockwave-flash" />';

} else {

} ?>

The content is just the url of the video.

A: the_content() is a WordPress core function and is used to echo out the whole HTML of the post, and can only be used inside the loop. What you want in your og:video meta tag instead is your video's URL. If you have defined your own function the_content() then you just need to rename it.