text:
Q: How make text moving from left to right in Android? I use this code to make text move and it moves correctly from right to left.
Nevertheless, I want to make the text in TextView move from left to right.
Here is my current code:
<TextView
    android:id="@+id/mylinenews"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="5"
    android:ellipsize="marquee"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true"
    android:singleLine="true"

    android:text="textmoving textmoving textmoving textmoving textmoving textmoving textmoving textmoving textmoving textmoving "
    android:textColor="#fff"
/>

How can I modify this code so the text moves from left to right?

A: Use below xml code in anim folder under res :
<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fillAfter="true">

   <translate
        android:fromXDelta="-3%p"
        android:toXDelta="3%p"
        android:duration="1200" />
</set>

And, just add this to your textview :
yourTextView.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.move));

A: If you want to shake the text than In Your Activity Use
Animation shake = AnimationUtils.loadAnimation(YourActivity.this, R.anim.shake);
            YOUR_TEXT_VIEW.startAnimation(shake);

Create a folder name anim in res i.e. res..> anim and create two xml in anim folder
1) shake.xml
2) cycle.xml
In Your shake.xml  write
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="0" android:toXDelta="20" android:duration="7000"
    android:interpolator="@anim/cycle" />

and in your cycle.xml write
<?xml version="1.0" encoding="utf-8"?>
<cycleInterpolator xmlns:android="schemas.android.com/apk/res/android" android:cycles="10" />

Enjoy Animated Text in android text view :)

A: Left to right animation:
    TranslateAnimation animation = new TranslateAnimation(0.0f, 0.0f, 0.0f, 1500.0f); // new TranslateAnimation (float fromXDelta,float toXDelta, float fromYDelta, float toYDelta)

    animation.setDuration(1500); // animation duration
    animation.setRepeatCount(1); // animation repeat count
    animation.setFillAfter(false);
    your_view .startAnimation(animation);//your_view for mine is imageView

Repeated animation (for eg. left to right and right to left):
    TranslateAnimation animation = new TranslateAnimation(0.0f, 0.0f, 0.0f, 1500.0f); // new TranslateAnimation (float fromXDelta,float toXDelta, float fromYDelta, float toYDelta)
    animation.setDuration(1500); // animation duration
    animation.setRepeatCount(4); // animation repeat count
    animation.setRepeatMode(2); // repeat animation (left to right, right to left)

    animation.setFillAfter(true);
    your_view .startAnimation(animation);//your_view for mine is imageView

A: I know i am a too late to answer but the simplest way is to add to your textview in the xml file
android:layoutDirection="rtl"

A:      animation.setDuration(1500); // animation duration
                           animation.setRepeatCount(4); // animation repeat count
                           animation.setRepeatMode(2); // repeat animation (left to right, right to left)
 animation.setFillAfter(true);
                        textview.startAnimation(animation);

A: The working code for the moving textview left to right is
TextView tv2 = (TextView) findViewById(R.id.textscroll);
TranslateAnimation animation = new TranslateAnimation(0.0f, 1500.0f, 0.0f, 0.0f); // new TranslateAnimation (float fromXDelta,float toXDelta, float fromYDelta, float toYDelta)

animation.setDuration(7500); // animation duration, change accordingly
animation.setRepeatCount(1); // animation repeat count
animation.setFillAfter(false);
tv2 .startAnimation(animation);//your_view for which you need animation


text:
Q: How do I avoid returning null data using form in reactJS?Check Back-end Code also, Experts give me answer When I try to type data into reactJs form through the API, the console returns null.
When I refresh the page on the backend CodeIgniter, it then displays the key values in the form of null.
How can I fix the problem data so that the console does not return null when I input through a reachJS form.
For instance, when I type in browser http://localhost/API/UserController/users, it returns null on every   response of the reactJs form as follows:
{"user_id":"119","UserName":null,"user_email":null,"Password":null,"CreatedDate":"0000-00-00 00:00:00","Status":null,"Role":null,"VendorId":null}

When I check the code in
 http://localhost/API/UserController/insertUsers, only the insertUser controller returns null.
Any input in regards to the problem would be appreciated.
My database code is:
CREATE TABLE `users`(
    `user_id` int(11) NOT NULL,
    `UserName` varchar(255) DEFAULT NULL,
    `user_email` varchar(40) DEFAULT NULL,
    `Password` varchar(1000) DEFAULT NULL,
    `CreatedDate` datetime DEFAULT NULL,
    `Status` int(11) DEFAULT NULL
    `Role` varchar(255) DEFAULT NULL,
    `VendorId` int(11) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

My Usermodel in CodeIgniter is:
class Usermodel extends CI_Model
{

public function get_users(){
    $query = $this->db->select("*")
              ->from("users")
              ->get();
    return $query;
}
public function insert_users($data){
    $this->UserName = $data['UserName'];
    $this->user_email=$data['user_email'];
    $this->Password =$data['Password'];
    $this->CreatedDate=$data['CreatedDate'];
    $this->Status=$data['Status'];
    $this->Role = $data['Role'];
    $this->VendorId=$data['VendorId'];
    $this->db->insert("users",$this);
}
}

My UserController Controller in insertUsers Method is:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
header('Access-Control-Allow-Origin: *');
if($_SERVER['REQUEST_METHOD']==='OPTIONS'){
    header('Access-Control-Allow-Methods:GET,PUT,POST,DELETE,OPTIONS');
    header('Access-Control-Allow-Headers:Content-Type');
    exit;
}
class UserController extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->model("usermodel","us");
    }
    public function users(){
        $query = $this->us->get_users();
        header("Content_Type:application/json");
        echo json_encode($query->result());
    }
    public function insertUsers(){
        $data = array(
            'UserName'      =>$this->input->post('UserName') ,
            'user_email'    =>$this->input->post('user_email'),
            'Password'      =>$this->input->post('Password'),
            'CreatedDate'   =>date("l jS \of F Y h:i:s A"),
            'Status'        =>$this->input->post('Status'),
            'Role'          => $this->input->post('Role'),
            'VendorId'      => $this->input->post('VendorId'),
        );
        $query =$this->us->insert_users($data);
        header("Content_Type:application/json");
        echo json_encode($query);
    }
}

Additionally, I fetch the API using reactJS, and when the user writes any data in form, it returns null in response Register.js as follows:
import React, { Component } from 'react';
import { Button, Card, CardBody, CardFooter, Col, Container, Form, Input, InputGroup, InputGroupAddon, InputGroupText, Row } from 'reactstrap';

class Register extends Component {
  constructor(props){
    super(props);
    this.state = {
      user_id:'',  Username:'', Password:'', user_email:'',CreatedDate:'',Status:'',Role:'',VendorId:'',
    }
    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }
    handleChange(event){
    const state = this.state;
    state[event.target.name] = event.target.value;
    this.setState(state, () => console.log(state));
    // console.log(state); state get undefined
    }

handleSubmit(event){
    event.preventDefault();
    fetch('http://localhost/API/UserController/insertUsers',{
      method:'POST',
      headers:{
        'Content-Type':'application/json',
        'Accept':'application/json'
      },
      body:JSON.stringify({
        user_id :this.state.user_id,
        Username:this.state.Username,
        Password:this.state.Password,
        user_email:this.state.user_email,
        CreatedDate:this.state.CreatedDate,
        Status:this.state.Status,
        Role: this.state.Role,
        VendorId:this.state.VendorId,
      })
    })
      .then(res =>res.json() )
      .then(data => console.log(data))
      .catch(err => console.log("show me error that cannot be specify",err))
  }
  render() {
    return (

        <Container>
          <Row className="justify-content-center">
            <Col md="9" lg="7" xl="6">
              <Card className="mx-4">
                <CardBody className="p-4">
                  <Form action="http://localhost/API/UserController/users" method="post" onSubmit={this.handleSubmit}>

Register

Create your account

                    <InputGroup className="mb-3">
                      <InputGroupAddon addonType="prepend">
                        <InputGroupText>

                        </InputGroupText>
                      </InputGroupAddon>
                      <Input required  type="text" name="UserName" value={this.state.UserName} onChange={this.handleChange} placeholder="Username" autoComplete="username" name="Username"  />
                    </InputGroup>
                    <InputGroup className="mb-3">
                      <InputGroupAddon addonType="prepend">
                        <InputGroupText>@</InputGroupText>
                      </InputGroupAddon>
                      <Input required  type="text" placeholder="User email" name="user_email" value={this.state.user_email} onChange={this.handleChange} autoComplete="email" />
                    </InputGroup>
                    <InputGroup className="mb-3">
                      <InputGroupAddon addonType="prepend">
                        <InputGroupText>

                        </InputGroupText>
                      </InputGroupAddon>
                      <Input required  type="password" placeholder="Password" value={this.state.Password} onChange={this.handleChange} name="Password" autoComplete="new-password" />
                    </InputGroup>
                    <Button color="success" block>Create Account</Button>
                  </Form>
                </CardBody>
                <CardFooter className="p-4">
                  <Row>
                    <Col xs="12" sm="6">
                      <Button className="btn-facebook mb-1" block>facebook</Button>
                    </Col>
                    <Col xs="12" sm="6">
                      <Button className="btn-twitter mb-1" block>twitter</Button>
                    </Col>
                  </Row>
                </CardFooter>
              </Card>
            </Col>
          </Row>
        </Container>

    );
  }
}

export default Register;

A: CodeIgniter does not return data or a result set when you perform write operations like insert or update on a database, it returns a boolean instead (true/false).
Thus why you're getting null, the value of $query here
$query = $this->us->insert_users($data);

Will be true if the operation is successful, else will be false.
Use an if statement to check if true and return $data instead
echo json_encode($data);

You can checkout CI (CodeIgniter)'s documentation on queries here
https://www.codeigniter.com/user_guide/database/queries.html
I also suggest you use an encryption algorithm to encrypt your password.

A: Usermodel
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Usermodel extends CI_model {

  public function get_users()
  {
    $this->db->where('is_active', 1);
    $query = $this->db->get('users');
    return $query->result();
  }

  public function insert_users($formData)
  {
    $this->db->insert('users', $formData);
    return $this->db->insert_id();
  }
}

My UserController Controller in insertUsers Method is:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class UserController extends CI_Controller {
  public function __construct()
  {
    parent::__construct();
    $this->load->model('Usermodel');
  }

  public function users()
  {
    header("Access-Control-Allow-Origin: *");
    $users = $this->Usermodel->get_users();

    $this->output
      ->set_content_type('application/json')
      ->set_output(json_encode($users));
  }

  public function insertUsers()
  {
    header("Access-Control-Allow-Origin: *");
    header("Access-Control-Request-Headers: GET,POST,OPTIONS,DELETE,PUT");

    $formdata = json_decode(file_get_contents('php://input'), true);

    if( ! empty($formdata)) {

      $UserName = $formdata['UserName'];
      $user_email = $formdata['user_email'];
      $Password = $formdata['Password'];

      $userData = array(
        'UserName' => $UserName,
        'user_email' => $user_email,
        'Password' => password_hash($Password,PASSWORD_DEFAULT),
         'is_active' => 1,
        'created_at' => date('Y-m-d H', time())
      );

      $id = $this->Usermodel->insert_users($userData);

      $response = array(
        'status' => 'success',
        'message' => 'User Register successfully'
      );
    }
    else {
      $response = array(
        'status' => 'error'
      );
    }

    $this->output
      ->set_content_type('application/json')
      ->set_output(json_encode($response));
  }
}

Register.js code store data in database now
import React, { Component } from 'react';
import { Button, Card, CardBody, CardFooter, Col, Container,Alert, Form, Input, InputGroup, InputGroupAddon, InputGroupText, Row } from 'reactstrap';
class Register extends Component {
  constructor(props){
    super(props);
    this.state = {
      Username:'',
      user_email:'',
      Password:'',
      error:null,
      response:{},
    }
    this.onFormSubmit = this.onFormSubmit.bind(this);
    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }
    handleChange(event){
    const name  = event.target.name;
    const value = event.target.value;

    this.setState({
      [name]: value
    });
    }

    handleSubmit=(event)=>{
     event.preventDefault();
     this.onFormSubmit(this.state);
     this.setState(this.state);

    }
    onFormSubmit(data){
      const apiUrl = "http://localhost/API/UserController/insertUsers";
      const myHeaders = new Headers();
      myHeaders.append('Content-Type','application/json');
      const options = {
        method:'POST',
        body:JSON.stringify(data),
        myHeaders
      };
      fetch(apiUrl,options)
        .then(res => res.json() )
        .then(result =>{
          this.setState({
           response:result,
         });
        })
        .then(error=>{
          this.setState({
            error
          });
        });

        this.setState({
        Username:'',
        user_email:'',
        Password:''
        });
    }
  render() {
    return (

        <Container>
          <Row className="justify-content-center">
            <Col md="9" lg="7" xl="6">
              <Card className="mx-4">
                <CardBody className="p-4">
                  <Form onSubmit={this.handleSubmit}>

Register

Create your account

                    <InputGroup className="mb-3">
                      <InputGroupAddon addonType="prepend">
                        <InputGroupText>

                        </InputGroupText>
                      </InputGroupAddon>
                      <Input   type="text" name="UserName" value={this.state.UserName} onChange={this.handleChange} placeholder="Username" autoComplete="username"   />
                    </InputGroup>
                    <InputGroup className="mb-3">
                      <InputGroupAddon addonType="prepend">
                        <InputGroupText>@</InputGroupText>
                      </InputGroupAddon>
                      <Input   type="text" placeholder="User email" name="user_email" value={this.state.user_email} onChange={this.handleChange} autoComplete="email" />
                    </InputGroup>
                    <InputGroup className="mb-3">
                      <InputGroupAddon addonType="prepend">
                        <InputGroupText>

                        </InputGroupText>
                      </InputGroupAddon>
                      <Input   type="password" placeholder="Password" value={this.state.Password} onChange={this.handleChange} name="Password" autoComplete="new-password" />
                    </InputGroup>
                    <Button color="success" block>Create Account</Button>
                  </Form>
                </CardBody>
                <CardFooter className="p-4">
                  <Row>
                    <Col xs="12" sm="6">
                      <Button className="btn-facebook mb-1" block>facebook</Button>
                    </Col>
                    <Col xs="12" sm="6">
                      <Button className="btn-twitter mb-1" block>twitter</Button>
                    </Col>
                  </Row>
                </CardFooter>
              </Card>
            </Col>
          </Row>
        </Container>
                  {this.state.response.status === 'success' &&

<Alert variant="info">{this.state.response.message}</Alert>
}
                            {this.state.error &&
Error: {this.state.error.message}
}

    );
  }
}
export default Register;

redpajama_set_name: RedPajamaStackExchange


text:
Q: Xamarin Android - Picasso Out of Memory - Holding references to ImageView? I'm building an Android app using Xamarin, and using Picasso v2.5.2.1.
With a new Activity I've recently created, I've noticed that it gets OOM after a while.
I think I've narrowed it down after creating the simplest version possible. One Activity that loads an image into a small ImageView (the initial Activity did a lot more than this), and when you click the image in creates a new fullscreen Activity that displays the image.
using Android.App;
using Android.Content;
using Android.OS;
using Android.Views;
using Android.Widget;
using Square.Picasso;

namespace PopDb_Android
{
    [Activity()]
    public class AdminItemImageActivity : Activity
    {
        protected override void OnCreate( Bundle savedInstanceState )
        {
            base.OnCreate( savedInstanceState );

            Window.RequestFeature( WindowFeatures.NoTitle );
            Window.AddFlags( WindowManagerFlags.Fullscreen );

            SetContentView( Resource.Layout.AdminItemImage );

            ImageView ivItem = FindViewById<ImageView>( Resource.Id.ivItem );

            string imageUrl = Intent.Extras.GetString( "ImageUrl" );
            Picasso.With( this )
                .Load( imageUrl )
                .Fit()
                .CenterInside()
                .MemoryPolicy( MemoryPolicy.NoCache, MemoryPolicy.NoStore )
                .NetworkPolicy( NetworkPolicy.NoCache, NetworkPolicy.NoStore )
                .Into( ivItem );
        }
    }
}

The other Activity is pretty much the same - loads an image from a URL and displays with Picasso, then when you click on it, it loads the above Activity. I disabled the caching in Picasso just to make sure this wasn't the problem.
Other questions I've seen about this often related to loading too many images, or images that are too big. However in this little example I'm only loading one small image (~104KB jpg, 300*400, so ~0.45MB when in memory?).
I've monitored the heap with Android Device Monitor, and noticed that if you go in/out of fullscreen view a bunch of times, the heap goes up a lot, but even after forcing a GC, it doesn't go back down. After dumping out the heap and looking at it in the Eclipse Memory Analyser, I see the biggest objects on the heap are the ImageViews, the number equals the amount of times I went in/out of fullscreen. So the app seems to be holding onto the references of these ImageViews for some reason.

If I continue going in/out of the fullscreen Activity, eventually the image will stop displaying and then it'll crash with OOM somewhere.
I'm at a loss on where to go with this now. Am I just doing something stupid, or could it be something else?
Thank you.


text:
Q: how to implement "contains" function in Mysql4.x? i have a keywords table,and i want to check a String contains keyword or not.
String str="aaabbbccc";

TableName:keywordTable
field:id keyword
-------------------
1 ee
2 bbb
3 xx
..
------------------

i run this sql (in mysql 4.1):
select * from `keywordTable` where contains(`keyword`,"aaabbbccc");

return a syntax error
how to implement it? (in mysql 4.1 and 4.0)
thanks :)

A: select *
from `keywordtable`
where  'aaabbbcccc' like CONCAT('%',`keyword`,'%')

A: select *
from `keywordtable`
where `keyword` like '%aaabbbcccc%'

the only problem is, that it searches case-insensitive, so AAAAAABBBCCCCCCCCDDD will also be matched
edit. i misread, you want to match the other way round. do this instead:
select *
from `keywordtable`
where 'aaabbbcccc' like '%'+`keyword`+'%'

mysql also understands like in reversed order


text:
Q: Adding a pattern fill to a black and white column graph in Highcharter I have come across the following guide for adding pattern fills for https://jkunst.com/highcharter/articles/modules.html
I would like to have the first column as a solid column and then patterns added to the remaining three columns
With the first set of code i get the following error <Error in FUN(X[[i]], ...) :  'options' must be a fully named list, or have no names (NULL)>
With the second set of code i get a title, the x axis title and the legend key with no data on the graph
Is there an error in my code that i have missed?
'''
Column_with_stripe<-highchart() %>%
  hc_chart(type ="column") %>%
  hc_title(text = "A") %>%
  hc_add_dependency("modules/pattern-fill.js") %>%
  hc_add_theme(hc_theme_tufte()) %>%
  hc_legend(align = "Right", verticalAlign = "top", floating = TRUE,borderRadius = 10 , backgroundColor = "white" , borderWidth = 1, layout = "vertical", x=50, y =-5)%>%
  hc_legend(enabled = TRUE) %>%
  hc_xAxis(categories = c('Day 1-7', 'Day 7-14', 'Day 14-21', 'Day 21-28', 'Day 28-35', 'Day 35-42'), tickmarkPlacement = "on") %>%
  hc_yAxis(title = list(text = "Catch of fly per week")) %>%
  hc_plotOptions(line = list (datalabels = list(emabled = TRUE), enableMouseTracking = FALSE))%>%
  hc_plotOptions(area = list(fillColor = list(pattern = list(path = list(d = 'M 0 0 L 10 10 M 9 -1 L 11 1 M -1 9 L 1 11',strokeWidth = 3),width = 10,height = 10,opacity = 0.4))))%>%
  hc_series(list (name = "Var1", data = c(5,8,25,10,28,15)),
        list (name = "Var2", data = c(4,5,1,6,4,3),color= 'white',fillColor = list(pattern = list(color='black')),
        list (name = "Var3", data = c(0,35,18,38,19,18),color= 'white',fillColor = list(pattern = list(color='black')),
        list (name = "Var4", data = c(6,8,29,52,33,48),color= 'white',fillColor = list(pattern = list(color='black'))))))
Column_with_stripe

'''
Column_with_stripe_2 <-highchart() %>%hc_chart(type ="column") %>%
  hc_title(text = "A") %>%
  hc_add_dependency("modules/pattern-fill.js") %>%
  hc_add_theme(hc_theme_tufte()) %>%
  hc_legend(align = "Right", verticalAlign = "top", floating = TRUE,borderRadius = 10 , backgroundColor = "white" , borderWidth = 1, layout = "vertical", x=50, y =-5)%>%
  hc_plotOptions(
    area = list(fillColor = list(pattern = list(path = list(d = 'M 0 0 L 10 10 M 9 -1 L 11 1 M -1 9 L 1 11',strokeWidth = 3),width = 10,height = 10,opacity = 0.4))))%>%
  hc_legend(enabled = TRUE) %>%
  hc_xAxis(categories = c('Day 1-7', 'Day 7-14', 'Day 14-21', 'Day 21-28', 'Day 28-35', 'Day 35-42'), tickmarkPlacement = "on") %>%
  hc_yAxis(title = list(text = "Catch of fly per week")) %>%
  hc_plotOptions(line = list (datalabels = list(emabled = TRUE), enableMouseTracking = FALSE))%>%
  hc_add_series(list (name = "Var1", data = c(5,8,25,10,28,15))%>%
  hc_add_series(list (name = "Var2", data = c(4,5,1,6,4,3), color= '#000',fillColor = list(pattern = list(color = '#000'))))%>%
  hc_add_series(list (name = "Var3", data = c(0,35,18,38,19,18), color= '#000',fillColor = list(pattern = list(color = '#000'))))%>%
  hc_add_series(list (name = "Var4", data = c(6,8,29,52,33,48), color= '#000',fillColor = list(pattern = list(color = '#000'))))
Column_with_stripe_2

A: So, there might be a better way, but I looked at Highcharts documentation online and came up with the code posted below.
Link: https://www.highcharts.com/docs/chart-design-and-style/pattern-fills
Code:
Column_with_stripe<-highchart() %>%
  hc_chart(type ="column") %>%
  hc_title(text = "A") %>%
  hc_add_dependency("modules/pattern-fill.js") %>%
  hc_add_theme(hc_theme_tufte()) %>%
  hc_legend(align = "Right", verticalAlign = "top", floating = TRUE,borderRadius = 10 , backgroundColor = "white" , borderWidth = 1, layout = "vertical", x=50, y =-5)%>%
  hc_legend(enabled = TRUE) %>%
  hc_xAxis(categories = c('Day 1-7', 'Day 7-14', 'Day 14-21', 'Day 21-28', 'Day 28-35', 'Day 35-42'), tickmarkPlacement = "on") %>%
  hc_yAxis(title = list(text = "Catch of fly per week"))%>%
  hc_plotOptions(line = list (datalabels = list(emabled = TRUE), enableMouseTracking = FALSE)) %>%
  hc_series(list(name = "Var1", data = c(5,8,25,10,28,15), color=list(pattern=list(color="black")))) %>%
  hc_add_series(name = "Var2", data = c(4,5,1,6,4,3),color= list(pattern=list(path='M 0 0 L 10 10 M 9 -1 L 11 1 M -1 9 L 1 11', width=2, height=7, color='green')),fillColor = "transparent") %>%
  hc_add_series(name="Var3", data = c(0,35,18,38,19,18),color=list(pattern = list(path='M 0 0 L 10 10 M 9 -1 L 11 1 M -1 9 L 1 11', width=5, height=5, color='#f00')), fillColor="transparent")
Column_with_stripe

Maybe this will get you closer to what you're looking for.
-nate


text:
Q: Fatal singnal11 and webview doesnt load properly I'm trying to load a webpage in a webview but the screen is stuck on loading on the page. It opens the website but after the loading it should display the content - but instead of that I'm experiencing continuous loading. Also sometimes istead of the app to start it crashes with this from logCat:
02-18 21:25:12.780: D/dalvikvm(9079): GC_CONCURRENT freed 101K, 81% free 488K/2560K, paused 0ms+0ms
02-18 21:25:12.790: D/jdwp(9079): Got wake-up signal, bailing out of select
02-18 21:25:12.790: D/dalvikvm(9079): Debugger has detached; object registry had 1 entries
02-18 21:25:13.040: D/dalvikvm(9103): Late-enabling CheckJNI
02-18 21:25:13.040: I/ActivityManager(310): Start proc com.example.testbrowser for activity com.example.testbrowser/.MainActivity: pid=9103 uid=10079 gids={3003}
02-18 21:25:13.270: D/TextLayoutCache(9103): Using debug level: 0 - Debug Enabled: 0
02-18 21:25:13.310: D/SurfaceFlinger(138): Release buffer at 0xb9888
02-18 21:25:13.320: D/libEGL(9103): loaded /system/lib/egl/libGLES_android.so
02-18 21:25:13.340: D/libEGL(9103): loaded /system/lib/egl/libEGL_adreno200.so
02-18 21:25:13.380: D/libEGL(9103): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
02-18 21:25:13.380: D/libEGL(9103): loaded /system/lib/egl/libGLESv2_adreno200.so
02-18 21:25:13.990: I/ActivityManager(310): No longer want ch.bitspin.timely (pid 8858): hidden #16
02-18 21:25:14.000: D/OpenGLRenderer(9103): Enabling debug mode 0
02-18 21:25:14.300: I/ActivityManager(310): Displayed com.example.testbrowser/.MainActivity: +1s494ms
02-18 21:25:14.320: A/libc(9103): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)
02-18 21:25:14.510: D/SurfaceFlinger(138): Release buffer at 0xbd670
02-18 21:25:14.730: I/DEBUG(136): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-18 21:25:14.730: I/DEBUG(136): Build fingerprint: 'SEMC/LT18i_1254-2219/LT18i:4.0.4/4.1.B.0.587/tL1_3w:user/release-keys'
02-18 21:25:14.730: I/DEBUG(136): pid: 9103, tid: 9124  >>> com.example.testbrowser <<<
02-18 21:25:14.730: I/DEBUG(136): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
02-18 21:25:14.730: I/DEBUG(136):  r0 00000000  r1 00000001  r2 00348c78  r3 00000000

I've added internet permission to the manifest and this is my class
public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        String url = "http://b2b.snowinstructors.eu/app/snowbook-app/";
        WebView mainWebView = (WebView) findViewById(R.id.webView1);
        WebSettings webSettings = mainWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        mainWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        mainWebView.setWebViewClient(new MyCustomWebViewClient());
        mainWebView.loadUrl(url);
    }

    private class MyCustomWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }
}

A: Please do not call loadUrl inside your implementation of shouldOverrideUrlLoading. This creates a loop.


text:
Q: Html-loader not resolving javascript entry file I'm trying to run a multiple entry web app with webpack 5.
Basically I have multiple entry points with their own HTML/JS/Images et cetera.
The images are used in  tags within the HTML files. Without HTML-loader I was unable to show the images.
Example entry folder:

However, when using HTML-loader I had to include the JS script like this:
<script src="./index.ts"></script>

This is because there is basically no 'index.js' file before building. However, this gives me a runtime error saying I cannot load .ts files and it is being loaded as a video MIME file (I understand a browser cannot load a .ts file).
My question is basically: how can I either load the typescript file when using html-loader, or how can I load 's without html-loader.
Webpack config:
/* eslint-disable no-unused-vars */
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const config = {
    entry: {
        vehicle: './src/cef/vehicle/index.ts',
        progressbar: './src/cef/progressbar/index.ts',
        vehiclemods: './src/cef/vehiclemods/index.ts',
        login: './src/cef/login/index.ts',
    },
    output: {
        path: path.resolve(__dirname, '../client_packages/TYPESCRIPT/cef/'),
        filename: '[name]/index.js',
        publicPath: '/',
    },
    module: {
        rules: [
            {
                test: /\.ts(x)?$/,
                loader: 'ts-loader',
                exclude: /node_modules/,
            },
            {
                test: /\.css$/,
                use: [
                    'style-loader',
                    'css-loader',
                ],
            },
            {
                test: /\.scss$/,
                use: [
                    'style-loader',
                    'css-loader',
                    'resolve-url-loader',
                    {
                        loader: 'sass-loader',
                        options: {
                            sourceMap: true,
                        },
                    },
                ],
            },
            {
                test: /\.html$/i,
                use: [
                    'html-loader',
                ],
            },
            {
                test: /\.png$/i,
                type: 'asset/resource',
            },
            {
                test: /\.(woff|woff2|eot|ttf|svg)$/,
                use: [{
                    loader: 'file-loader',
                    options: {
                        name: '[name].[ext]',
                    },
                }],
            },
        ],
    },
    resolve: {
        extensions: [
            '.tsx',
            '.ts',
            '.js',
            '.scss',
            '.css',
        ],
        alias: {
            '~assets': path.resolve(__dirname, 'src/cef/assets'),
        },
    },
    plugins: [
        new HtmlWebpackPlugin({
            filename: 'vehicle/vehicle.html',
            template: './src/cef/vehicle/vehicle.html',
            chunks: ['vehicle'],
            inject: false,
        }),
        new HtmlWebpackPlugin({
            filename: 'progressbar/progressbar.html',
            template: './src/cef/progressbar/progressbar.html',
            chunks: ['progressbar'],
            inject: false,
        }),
        new HtmlWebpackPlugin({
            filename: 'vehiclemods/vehiclemods.html',
            template: './src/cef/vehiclemods/vehiclemods.html',
            chunks: ['vehiclemods'],
            inject: false,
        }),
        new HtmlWebpackPlugin({
            filename: 'login/login.html',
            template: './src/cef/login/login.html',
            chunks: ['login'],
            inject: false,
        }),
        new CopyWebpackPlugin({
            patterns: [
                {from: './src/cef/login/images', to: 'images/'},
            ],
        }),
    ],
    devServer: {
        contentBase: './',
        port: 9000,
        historyApiFallback: true,
    },
};

module.exports = config

;


text:
Q: How do i fix this program in python? I am having trouble with a program; I need to find out how to add all the numbers in the input
w = 0
v = str(w)
x = input('Enter the expenses: ')
y = x.split()
for x in y:
    v = v + x
print(v)

I need to figure out how to add multiple numbers in the input as a example

Enter the expenses: 10 2 5 15

and it should be 32.

A: You need to convert everything to a numerical type, e.g. int. You are currently adding strings:
v = 0
x = input('Enter the expenses: ')
y = [int(i) for i in x.split()]
for x in y:
    v = v + x
print(v)

A: In your code, v and x are string, so you are doing string concatenation here, rather than numeric addition.
w = 0
v = str(w)
x = raw_input('Enter the expenses: ')
y = x.split()
for x in y:
    v = v + x
print(v)

Output:
Enter the expenses: 10 20 30 40
010203040

Make item int  first.
I would solve it this way, using map and sum:
str_input=raw_input('Enter the expenses: ')
lst=str_input.split()
print sum(map(int,lst))

You can't simply concatenate them with + sign. Use format,like below:
print "${0}".format(sum(map(int,lst)))


text:
Q: phpmyadmin error: the mysql extension is missing i'm getting the following error:
phpMyAdmin - Error
 The mysql extension is missing. Please check your PHP configuration.

when i try to access phpmyadmin from my IE browser: localhost/phpmyadmin/index.php
The mysql command line client is also running when im trying to access phpmyadmin.
phpmyadmin was working perfectly today morning. I tested my signup and login pages of my website and switched the computer off. Then, when I switched it back on, I got the above error. I am using some cookies in my code.
Both the pages on my website accessing the database is giving the following error:
Fatal error: Call to undefined function mysql_query() in C:\websites\cakephp\cake\libs\model\datasources\dbo\dbo_mysql.php on line 613
As suggested on the net, i've already verified that I have php_mysql.dll in /php/ext folder.
extension=php_mysql.dll is there in /php/php.ini. Extension_dir=c:/php/ext.
I have also deleted all the browsing history from internet options.
nothing seems to work. I'm clueless. Does anyone know on what i'm doing wrong?
i've installed the following:
apache2.2, php5.3.8, phpmyadmin3.4.5, mysql5.1.59(for 64 bit), cakephp1.3.12, mongodb
separately not through WAMP or XAMP
i'm running on Windows 7 Professional 64bit.
Thank you in advance.

A: Ok, I finally got it to work. I had to reinstall everthing. And I made sure cookies are enabled in IE referring to the following link http://www.timeanddate.com/custom/cookiesie.html#ie9.
Now everthing works fine. :)


text:
Q: Handling worker death in multiprocessing Pool I have a simple server:
from multiprocessing import Pool, TimeoutError
import time
import os

if __name__ == '__main__':
    # start worker processes
    pool = Pool(processes=1)

    while True:
        # evaluate "os.getpid()" asynchronously
        res = pool.apply_async(os.getpid, ())  # runs in *only* one process
        try:
            print(res.get(timeout=1))             # prints the PID of that process
        except TimeoutError:
            print('worker timed out')

        time.sleep(5)

    pool.close()
    print("Now the pool is closed and no longer available")
    pool.join()
    print("Done")

If I run this I get something like:
47292
47292

Then I kill 47292 while the server is running. A new worker process is started but the output of the server is:
47292
47292
worker timed out
worker timed out
worker timed out

The pool is still trying to send requests to the old worker process.
I've done some work with catching signals in both server and workers and I can get slightly better behaviour but the server still seems to be waiting for dead children on shutdown (ie. pool.join() never ends) after a worker is killed.
What is the proper way to handle workers dying?
Graceful shutdown of workers from a server process only seems to work if none of the workers has died.
(On Python 3.4.4 but happy to upgrade if that would help.)
UPDATE:
Interestingly, this worker timeout problem does NOT happen if the pool is created with processes=2 and you kill one worker process, wait a few seconds and kill the other one. However, if you kill both worker processes in rapid succession then the "worker timed out" problem manifests itself again.
Perhaps related is that when the problem occurs, killing the server process will leave the worker processes running.

A: This behavior comes from the design of the multiprocessing.Pool. When you kill a worker, you might kill the one holding the call_queue.rlock. When this process is killed while holding the lock, no other process will ever be able to read in the call_queue anymore, breaking the Pool as it cannot communicate with its worker anymore.
So there is actually no way to kill a worker and be sure that your Pool will still be okay after, because you might end up in a deadlock.
multiprocessing.Pool does not handle the worker dying. You can try using concurrent.futures.ProcessPoolExecutor instead (with a slightly different API) which handles the failure of a process by default. When a process dies in ProcessPoolExecutor, the entire executor is shutdown and you get back a BrokenProcessPool error.
Note that there are other deadlocks in this implementation, that should be fixed in loky. (DISCLAIMER: I am a maintainer of this library). Also, loky let you resize an existing executor using a ReusablePoolExecutor and the method _resize. Let me know if you are interested, I can provide you some help starting with this package.  (I realized we still need a bit of work on the documentation... 0_0)


text:
Q: Binding onclick in JavaScript without having JS directly in the HTML file Previously, I had this line in my HTML file:
<input type="button" value="1" name="btn1" id="btn1" onclick="showNum(1)" />

This works fine, but I don't want to include the method name in the HTML file. I would like to have something like this in the HTML:
<input type="button" value="1" name="btn1" id="btn1" />

And then I want to bind this button to the method in the JS file. I tried this code and it doesn't work:
window.onload = function() {
    document.getElementById("btn1").onclick = showNum(1);
};

How can I bind btn1 to run showNum(1) using JavaScript?

A: It is also possible to bind a reference to the function, like so:

var showNum = function(){
    alert(this.value);
}
window.onload = function() {
    document.getElementById("btn1").onclick = showNum;
};
<input type="button" value="1" id="btn1" />

A: You need to create a new function that calls showNum() with the argument you want.
window.onload = function() {
    document.getElementById("btn1").onclick = function() {showNum(1);};
};

You can also use the .bind() method to bind the argument.
window.onload = function() {
    document.getElementById("btn1").onclick = showNum.bind(null, 1);
};

A: I can't tell you exactly why it works like this, but if you use an anonymous function with showNum(1); inside of it when assigning to onclick, it works fine.
window.onload = function() {
    document.getElementById("btn1").onclick = function () {
        showNum(1);
    }
};

Also a tip, window.onload can only be used once, so if you have a master page in your site that also needs to run a script when the page starts, it can be overridden. Use a self-starting function like this and then you won't have to worry about that, and you can have as many as you want. Plus it's cleaner and looks nicer (at least to me).
(function () {
    document.getElementById("btn1").onclick = function () {
        showNum(1);
    }
})();

Just make sure it's after the rest of your JS code and HTML, since pages load from the top down.

A: window.onload = function() {
    document.getElementById("btn1").addEventListener('click', ()=>showNum(1));
};

A: showNum instead of showNum(1)
showNum - is handler, but showNum(1) - is result of the execution.
if parameter is required: showNum.bind(this, 1);
Or even better - addEventListener can be used:
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener


text:
Q: Installer for Microsoft Office Add In I am working on a Microsoft Office Add In.
The current installer uses NSIS, but does not provide automatic updates.
I would like to provide either optional or mandatory updates in the most user friendly manner possible. It must work for all versions of Office.
What is the standard/ best way of doing this please?
My research so far has not provided a stand-out option. Best articles I've found listed below:

*

*Article from Scott Hanselmann

*VSTO

*Click Once, though some people seem against it, I'm not sure why?

*NSIS auto updating here and here - not sure if we can get the optional/mandatory option here easily.

*Chocolatey - would prefer to keep everything under my control, so not really an option.

Any pointers much appreciated.
UPDATE - Following the answer, some more references for anyone searching.

*

*Some downsides with clickonce - most of which shouldn't be a problem for me.

*Deploying clickonce on amazon.

*Difference between clickonce and standard installer.

*Clickonce signing here and here.

UPDATE 2: Further to this - Although I like ClickOnce on WPF applications, updates were troublesome when used for an Office Add in. We ended up creating our own.

A: You need to use ClickOnce if you want to implement the auto-update feature. All other ways require to uninstall the add-in first and only then you can install a new version of the software.
The Deploying an Office Solution by Using ClickOnce article describes the required steps in depth for creating ClickOnce installers.


text:
Q: Why is my VS Code live sass compiler settings not compiling my scss file? I have a lot of scss partials so I changed the settings to this: ```{
"es6-css-minify.cssPostfix": "",
"liveSassCompile.settings.autoprefix": [
],
"liveSassCompile.settings.formats": [
    {
        "format": "compressed",
        "extensionName": ".css",
        "savePath": "/wp-content/themes/dawn-child",
    }
],
"liveSassCompile.settings.includeItems": [ "/wp-content/themes/dawn-child/style.scss" ],

}
but this is not compiling scss files in the mentioned folder. I even tried to change the saved path to dawn-child and dawn-child/style.css but neither seemed to work.
I'm using the glenn marks live sass compiler. Is there anything wrong with my settings?

A: Try putting a period in front of the directories:
"savePath": "./wp-content/themes/dawn-child",

And:
"liveSassCompile.settings.includeItems": [ "./wp-content/themes/dawn-child/style.scss" ],

The period indicates the current directory of the .json file you're running.


text:
Q: How can i make an overlay which can see whats on the screen? I want to make an overlay which can analyse the screen and search for specific pictures on it. E.g in a game to see how much your invetory is worth or to count something in a picture.

A: Use OpenCV (with python, I would almost always prefer to do such tasks with python).
But if you have to do it using C#, then you need the C# OpenCV wrapper "Emgu CV".


text:
Q: appengine datastore - filter by string or integer Will a query with a filter over IntegerProperty perform any better than a query with a filter over String Property?
(same indexes)

A: Practically speaking, no. Any difference in the efficiency of comparing different datatypes is insignificant compared to disk access times.


text:
Q: using pie func in python in vscode jupyter notebook #TypeError: pie() missing 1 required positional argument: 'x'
from cProfile import label
from matplotlib import pyplot as plt
d=[75,20,1,2]
l=['n2','o2','c','other']
c=['red','black','blue','green']
plt.pie(data=d,labels=l,colors=c)
plt.title('air comp')
plt.show()

It's showing error when I use pie function. I tried to run it on vscode jupyter notebook extension.


text:
Q: What is the query to check if an attribute in a table existed or not? The question is in the title is clear, I guess.
What/how is the query to check if an attribute in a table existed or not?
I am doing with SQLite.
Thanks in advance.

A: You can interrogate the database with PRAGMA table_info(tablename);. That will return the list of column names, their type, nullable or not, and default value.


text:
Q: Best way to send data from Service to Roomdatabase I'm working on a project where I need to connect to a server to get data and draw markers out of that data on a map, whenever the data changes, I need to update the map with the new positions.
I'm using a Roomdatabase, Livedata to observe the changes and a service that connects to the server and sends any update to the repository. But what would be the best way to go about this?
Thanks in advance
EDIT:
here's my code so far, I'll try to explain the way I envision how it should work as I'm going
first I have a gateway Entity
@Entity(tableName = "gateway_table")
public class Gateway {

    private float temp;
    private float wertX;
    private float wertY;
    private String title;
    private boolean drawn;
    private ArrayList<String> ObjectANames = new ArrayList<>();

    @PrimaryKey(autoGenerate = true)
    private int id;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public float getWertX() {
        return wertX;
    }

    public float getWertY() {
        return wertY;
    }

    public void setWertX(float wertX) {
        this.wertX = wertX;
    }

    public void setWertY(float wertY) {
        this.wertY = wertY;
    }

    public boolean isDrawn() {
        return drawn;
    }

    public void setDrawn(boolean drawn) {
        this.drawn = drawn;
    }

    public float getTemp() {
        return temp;
    }

    public void setTemp(float temp) {
        this.temp = temp;
    }

    public ArrayList<String> getObjectANames() {
        return ObjectANames;
    }

    public Gateway (float wertX, float wertY, String title, boolean drawn, ArrayList<String> ObjectANames){
        this.wertX = wertX;
        this.wertY = wertY;
        this.title = title;
        this.drawn = drawn;
        this.ObjectANames.addAll(ObjectANames);
    }
}

and an Entity ObjectA
@Entity(tableName = "objectA_table")
public class ObjectA {
    private String gateway;
    private String name;
    private boolean drawn;

    @PrimaryKey(autoGenerate = true)
    private int id;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public String getGateway() {
        return gateway;
    }

    public void setGateway(String gateway) {
        this.gateway = gateway;
    }

    public boolean isDrawn() {
        return drawn;
    }

    public void setDrawn(boolean drawn) {
        this.drawn = drawn;
    }

    public ObjectA(String gateway, String name, boolean drawn) {
        this.gateway = gateway;
        this.name = name;
        this.drawn = drawn;
    }

}

Basically each gateway has a position on the map (from the two floats ), a title, a boolean and An arraylist that contains names from the ObjectA.
An ObjectA has a name, a String containing the gateway it's assigned to and a boolean.
So a Gateway can have more than one ObjectA but each ObjectA has only one gateway.
in both of the DAOS I have a method findGateway/ObjectA in which I give the title or the name and I get the gateway or the objectA that has that name back.
this is the Viewmodel :
public class ViewModel extends AndroidViewModel {
    private Repository repository;
    private LiveData<List<ObjectA>> allObjectA;
    private LiveData<List<Gateway>> allGateways;
    private MutableLiveData<SocketService.MyBinder> binderViewModel = new MutableLiveData<>();

    public ViewModel(@NonNull Application application) {
        super(application);
        repository = new Repository(application);
        allObjectA = repository.getAllObjectA();
        allGateways = repository.getAllGateways();

    }

    public void insert(ObjectA objectA) throws InterruptedException {
        repository.insert(objectA);
    }

    public void delete(ObjectA objectA) throws InterruptedException {
        repository.delete(objectA);
    }

    public void deleteAllObjectA() throws InterruptedException {
        repository.deleteAllObjectA();
    }

    public void update(ObjectA objectA) throws InterruptedException {
        repository.update(objectA);
    }

    public ObjectA findObjectA(String ObjectAName) throws InterruptedException { return repository.findObjectA(ObjectAName);}

    public LiveData<List<ObjectA>> getAllObjectA(){
        return allObjectA;
    }

    public void insert(Gateway gateway) throws InterruptedException {
        repository.insert(gateway);
    }

    public void delete(Gateway gateway) throws InterruptedException {
        repository.delete(gateway);
    }

    public void deleteAllGateways() throws InterruptedException {
        repository.deleteAllGateways();
    }

    public void update(Gateway gateway) throws InterruptedException {
        repository.update(gateway);
    }

    public Gateway findGateway(String gatewayDesignation) throws InterruptedException { return repository.findGateway(gatewayDesignation);}

    public LiveData<List<Gateway>> getAllGateways(){
        return allGateways;
    }

    private ServiceConnection serviceConnection = new ServiceConnection() {

        @Override
        public void onServiceConnected(ComponentName name, IBinder iBinder) {
            SocketService.MyBinder binder = (SocketService.MyBinder) iBinder;
            binderViewModel.postValue(binder);
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
            binderViewModel.postValue(null);
        }

    };

    public ServiceConnection getServiceConnection(){
        return serviceConnection;
    }

    public LiveData<SocketService.MyBinder> getMyBinder(){
        return binderViewModel;
    }

}

This is my service:
public class SocketService extends Service {
    //public static final String IP_ADDRESS = "172.17.100.77";
   // public static final int SERVER_PORT = 5566;
    public static final int CONNECTION_STATUS=0;

    private Repository repository;

    private final IBinder myBinder = new MyBinder();

    Thread thread;
    PrintWriter output;
    BufferedReader input;
    Socket socket;

    MediaPlayer player;

    ArrayList<ObjectA> objectAArrayList;

    @Override
    public IBinder onBind(Intent intent) {

        System.out.println("I am in Ibinder onBind method");
        return myBinder;
    }

    public class MyBinder extends Binder {
        public SocketService getService() {
            System.out.println("I am in Localbinder ");
            return SocketService.this;

        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
        repository = new Repository(getApplication());

        player = MediaPlayer.create(getApplicationContext(), Settings.System.DEFAULT_RINGTONE_URI);
        player.setLooping(true);
        player.start();
    }

    private void sendMessageConnected() {
        EventBus.getDefault().post(new IntentServiceResult(CONNECTION_STATUS, "Song is playing"));
    }

    private void sendMessageObjectGone(ObjectA objectA, ObjectA objectAOld) {
        EventBus.getDefault().post(new IntentServiceResult(1, objectA, objectAOld));
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        super.onStartCommand(intent, flags, startId);
        objectAArrayList = new ArrayList<>();
        objectAArrayList.add(new ObjectA("gate3","ObjectA1",false));
        objectAArrayList.add(new ObjectA("gate2","ObjectA2",false));
        objectAArrayList.add(new ObjectA("gate2","ObjectA3",false));
        objectAArrayList.add(new ObjectA("gate4","ObjectA1",false));
        objectAArrayList.add(new ObjectA("gate2","ObjectA1",false));
        objectAArrayList.add(new ObjectA("gate3","ObjectA3",false));
        objectAArrayList.add(new ObjectA("gate3","ObjectA2",false));
        objectAArrayList.add(new ObjectA("gate4","ObjectA3",false));

        thread = new Thread(new connectSocket());
        thread.start();
        return START_STICKY;
    }

    class connectSocket implements Runnable {

        @Override
        public void run() {

            while (player.isPlaying()) {
                sendMessageConnected();

            for (int i = 0; i< objectAArrayList.size(); i++){
                    try {
                        if(repository.findObjectA(objectAArrayList.get(i).getName()) == null){
                            repository.insert(objectAArrayList.get(i));
                            repository.update(objectAArrayList.get(i));

                            Gateway gateway = repository.findGateway(objectAArrayList.get(i).getGateway());
                            gateway.getObjectANames().add(objectAArrayList.get(i).getName());
                            if(repository.findGateway(gateway.getTitle()).isDrawn()){
                                gateway.setDrawn(true);
                                repository.update(gateway);
                            }else{
                                gateway.setDrawn(false);
                                repository.update(gateway);
                            }

                            Thread.sleep(2000);
                        }else {
                            ObjectA objectA = repository.findObjectA(objectAArrayList.get(i).getName());
                            ObjectA ObjectAold = repository.findObjectA(objectAArrayList.get(i).getName());
                            Gateway oldGateway = repository.findGateway(objectA.getGateway());

                            objectA.setGateway(objectAArrayList.get(i).getGateway());
                            repository.update(objectA);
                            Gateway newGateway = repository.findGateway(objectAArrayList.get(i).getGateway());

                            if(repository.findGateway(oldGateway.getTitle()).isDrawn() && repository.findGateway(objectAArrayList.get(i).getGateway()).isDrawn())
                            {
                                sendMessageObjectGone(objectA, ObjectAold);
                            }else
                            {
                                oldGateway.getObjectANames().remove(ObjectAold.getName());
                                newGateway.getObjectANames().add(objectA.getName());
                                repository.update(oldGateway);
                                repository.update(newGateway);
                            }

                            ObjectA objectA1 = repository.findObjectA(objectAArrayList.get(i).getName());
                            objectA1.setDrawn(false);
                            repository.update(objectA1);

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

        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        /*try {
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }*/
        player.stop();
    }
}

I do not have access to the server yet so I'm just running a simulation. I'm starting a player and as long as it's on the service should keep on working.
I initialize at the start some updates to some ObjectA and I go through them while updating the repository each time.
And last but not least the Map Activity, but first I'd like to explain how it's supposed to work. Each Gateway can have multiple ObjectA but on the map only three of them should be drawn next to each gateway. so before drawing a marker I check always if one of the three positions are free.
this is the GatewayMarker Class that has an array of booleans which is used to see which positions are free
public class GatewayMarker extends MapMarker {

    private Gateway gateway;
    private boolean[] posTaken;

    public GatewayMarker(Context context, Gateway gateway, boolean[] posTaken) {
        super(context, gateway.getWertX(), gateway.getWertY(), gateway.getTitle());

        this.gateway = gateway;
        this.posTaken = posTaken;
        setImageResource(R.drawable.gateway_foreground);
    }

    public float getXfirstPos() {
        return gateway.getWertX() + 0.05f;
    }

    public float getYfirstPos() {
        return gateway.getWertY() + 0.05f;
    }

    public float getXSecondPos() {
        return gateway.getWertX() - 0.05f;
    }

    public float getYSecondPos() {
        return gateway.getWertY() + 0.05f;
    }

    public float getXThirdPos() {
        return gateway.getWertX();
    }

    public float getYThirdPos() {
        return gateway.getWertY() - 0.05f;
    }

    public boolean[] getPosTaken() {
        return posTaken;
    }

}

this is the ObjectAMarker
public class ObjectAMarker extends MapMarker {

    private int pos;

    public ObjectAMarker(Context context, float x, float y, String name, int pos) {
        super(context, x, y, name);
        this.pos = pos;
        setImageResource(R.drawable.kuh2_foreground);
    }

    public int getPos() {
        return pos;
    }

}

And the Map Activity
public class MapMarkerActivity extends AppCompatActivity {
    public static final int REQUEST_CONNECTION_STATUS = 0;

    private MapViewExt mapView;
    private TextView textView;
    private EditText textX;
    private EditText textY;
    private Button button;
    private Button buttonDelete;
    private Boolean calledFirstTime = true;
    private Boolean gatewayMoved = false;
    private FrameLayout frameLayout;
    private Observer<List<Gateway>> observerGateways;
    private Observer<List<ObjectA>> observerObjectA;

    private ArrayList<GatewayMarker> gatewayMarkers;
    private ArrayList<ObjectAMarker> ObjectAMarkers;

    private ViewModel viewModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map_marker);

        textX = findViewById(R.id.edit_text_x);
        textY = findViewById(R.id.edit_text_y);
        button = findViewById(R.id.button);
        buttonDelete = findViewById(R.id.button_delete);
        frameLayout = findViewById(R.id.frame_layout_show_barn);
        textView = findViewById(R.id.text_view_connection_mapmarker);

        viewModel = new ViewModelProvider(this, ViewModelProvider.AndroidViewModelFactory.getInstance(this.getApplication())).get(ViewModel.class);

        buttonDelete.setEnabled(false);
        button.setEnabled(false);

        mapView = makeMapView();

        if (mapView != null) {
            mapView.setId(R.id.mapview_id);
            mapView.setSaveEnabled(true);
            frameLayout.addView(mapView);
        }

    }

    private MapViewExt makeMapView() {
        // hier Code to create the map
    }

    private GatewayMarker findGatewayMarker(String title) {
        GatewayMarker gatewayMarker1 = null;
        for (GatewayMarker gatewayMarker : gatewayMarkers) {
            if (gatewayMarker.getName().equals(title)) {
                gatewayMarker1 = gatewayMarker;
            }
        }
        return gatewayMarker1;
    }

    private ObjectAMarker findObjectAMarker(String name) {
        ObjectAMarker objectAMarker = null;
        for (ObjectAMarker objectAMarker1 : ObjectAMarkers) {
            if (objectAMarker1.getName().equals(name)) {
                objectAMarker = objectAMarker1;
            }
        }
        return objectAMarker;
    }

    private ObjectAMarker addNewObjectAMarker(MapViewExt mapView, float x, float y, String name, int pos) {
        ObjectAMarker objectAMarker = new ObjectAMarker(this, x, y, name, pos);
        mapView.addMarker(objectAMarker);
        return objectAMarker;
        //MarkerApiKt.addMarker(mapView, marker, x, y, -0.5f, -0.5f, 0f, 0f);
    }

    private GatewayMarker addNewGatewayMarker(MapViewExt mapView, Gateway gateway) {
        boolean[] posTaken = new boolean[3];
        posTaken[0] = false;
        posTaken[1] = false;
        posTaken[2] = false;
        GatewayMarker gatewayMarker = new GatewayMarker(this, gateway, posTaken);
        mapView.addMarker(gatewayMarker);
        return gatewayMarker;
    }

    @Override
    protected void onResume() {
        super.onResume();
        EventBus.getDefault().register(this);

        gatewayMarkers = new ArrayList<>();
        ObjectAMarkers = new ArrayList<>();

        observerGateways = new Observer<List<Gateway>>() {
            @Override
            public void onChanged(List<Gateway> gateways) {
                for (Gateway gateway : gateways) {

                    if (!gateway.isDrawn()) {

                        if (calledFirstTime || gatewayMoved) {

                            gatewayMoved = false;
                            GatewayMarker gatewayMarker = addNewGatewayMarker(mapView, gateway);
                            gatewayMarkers.add(gatewayMarker);

                            gateway.setDrawn(true);
                            try {
                                viewModel.update(gateway);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }

                            for (int i = 0; i < gateway.getObjectANames().size(); i++) {
                                ObjectAMarker objectAMarker;
                                if (!gatewayMarker.getPosTaken()[0]) {
                                    objectAMarker = addNewObjectAMarker(mapView, gatewayMarker.getXfirstPos(), gatewayMarker.getYfirstPos(), gateway.getObjectANames().get(i), 0);
                                    ObjectAMarkers.add(objectAMarker);

                                    try {
                                        ObjectA objectA = viewModel.findObjectA(gateway.getObjectANames().get(i));
                                        objectA.setDrawn(true);
                                        viewModel.update(objectA);
                                    } catch (InterruptedException e) {
                                        e.printStackTrace();
                                    }

                                    gatewayMarker.getPosTaken()[0] = true;

                                } else if (!gatewayMarker.getPosTaken()[1]) {
                                    objectAMarker = addNewObjectAMarker(mapView, gatewayMarker.getXSecondPos(), gatewayMarker.getYSecondPos(), gateway.getObjectANames().get(i), 1);
                                    ObjectAMarkers.add(objectAMarker);

                                    try {
                                        ObjectA objectA = viewModel.findObjectA(gateway.getObjectANames().get(i));
                                        objectA.setDrawn(true);
                                        viewModel.update(objectA);
                                    } catch (InterruptedException e) {
                                        e.printStackTrace();
                                    }

                                    gatewayMarker.getPosTaken()[1] = true;

                                } else if (!gatewayMarker.getPosTaken()[2]) {
                                    objectAMarker = addNewObjectAMarker(mapView, gatewayMarker.getXThirdPos(), gatewayMarker.getYThirdPos(), gateway.getObjectANames().get(i), 2);
                                    ObjectAMarkers.add(objectAMarker);

                                    try {
                                        ObjectA objectA = viewModel.findObjectA(gateway.getObjectANames().get(i));
                                        objectA.setDrawn(true);
                                        viewModel.update(objectA);
                                    } catch (InterruptedException e) {
                                        e.printStackTrace();
                                    }

                                    gatewayMarker.getPosTaken()[2] = true;
                                    return;
                                }

                            }
                        }

                    } else {
                        GatewayMarker gatewayMarker = findGatewayMarker(gateway.getTitle());
                        for (int i = 0; i < gateway.getObjectANames().size(); i++) {
                            try {
                                if (!viewModel.findObjectA(gateway.getObjectANames().get(i)).isDrawn()) {

                                    if (!gatewayMarker.getPosTaken()[0]) {
                                        ObjectAMarker objectAMarker = findObjectAMarker(gateway.getObjectANames().get(i));
                                        ObjectAMarkers.remove(objectAMarker);

                                        ObjectAMarkers.add(addNewObjectAMarker(mapView, gatewayMarker.getXfirstPos(), gatewayMarker.getYfirstPos(), gateway.getObjectANames().get(i), 0));

                                        try {
                                            ObjectA objectA = viewModel.findObjectA(gateway.getObjectANames().get(i));
                                            objectA.setDrawn(true);
                                            viewModel.update(objectA);
                                        } catch (InterruptedException e) {
                                            e.printStackTrace();
                                        }

                                        gatewayMarker.getPosTaken()[0] = true;
                                    } else if (!gatewayMarker.getPosTaken()[1]) {
                                        ObjectAMarker objectAMarker = findObjectAMarker(gateway.getObjectANames().get(i));
                                        ObjectAMarkers.remove(objectAMarker);
                                        ObjectAMarkers.add(addNewObjectAMarker(mapView, gatewayMarker.getXSecondPos(), gatewayMarker.getYSecondPos(), gateway.getObjectANames().get(i), 1));

                                        try {
                                            ObjectA objectA = viewModel.findObjectA(gateway.getObjectANames().get(i));
                                            objectA.setDrawn(true);
                                            viewModel.update(objectA);
                                        } catch (InterruptedException e) {
                                            e.printStackTrace();
                                        }

                                        gatewayMarker.getPosTaken()[1] = true;
                                    } else if (!gatewayMarker.getPosTaken()[2]) {
                                        ObjectAMarker objectAMarker = findObjectAMarker(gateway.getObjectANames().get(i));
                                        ObjectAMarkers.remove(objectAMarker);
                                        ObjectAMarkers.add(addNewObjectAMarker(mapView, gatewayMarker.getXThirdPos(), gatewayMarker.getYThirdPos(), gateway.getObjectANames().get(i), 2));

                                        try {
                                            ObjectA objectA = viewModel.findObjectA(gateway.getObjectANames().get(i));
                                            objectA.setDrawn(true);
                                            viewModel.update(objectA);
                                        } catch (InterruptedException e) {
                                            e.printStackTrace();
                                        }

                                        gatewayMarker.getPosTaken()[2] = true;
                                    } else {
                                        return;
                                    }
                                }
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }

                    }
                }
                calledFirstTime = false;
            }

        };
        observerObjectA = new Observer<List<ObjectA>>() {

            @Override
            public void onChanged(List<ObjectA> objectAS) {

            }
        };

        viewModel.getAllObjectA().observe(this, observerObjectA);
        viewModel.getAllGateways().observe(this, observerGateways);
    }

    @Override
    protected void onPause() {
        super.onPause();

        List<ObjectA> allKühe = viewModel.getAllObjectA().getValue();
        List<Gateway> allGateways = viewModel.getAllGateways().getValue();

        for (ObjectA objectA : allKühe) {
            objectA.setDrawn(false);
            try {
                viewModel.update(objectA);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        for (Gateway gateway : allGateways) {
            gateway.setDrawn(false);
            try {
                viewModel.update(gateway);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        viewModel.getAllGateways().removeObserver(observerGateways);
        viewModel.getAllObjectA().removeObserver(observerObjectA);
        calledFirstTime = true;

        for (int i = 0; i < ObjectAMarkers.size(); i++) {
            MarkerApiKt.removeMarker(mapView, ObjectAMarkers.get(i));
        }

        ObjectAMarkers.clear();
        for (int i = 0; i < gatewayMarkers.size(); i++) {
            MarkerApiKt.removeMarker(mapView, gatewayMarkers.get(i));
        }
        gatewayMarkers.clear();

        EventBus.getDefault().unregister(this);

    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getconnectionstatus(IntentServiceResult intentServiceResult) throws InterruptedException {
        if (intentServiceResult.getResult() == REQUEST_CONNECTION_STATUS) {
            textView.setText(intentServiceResult.getResultvalue());
        }

        if (intentServiceResult.getResult() == 1) {
            ObjectA objectA = intentServiceResult.getResultObjectA();
            ObjectA objectAOld = intentServiceResult.getResultObjectAOld();
            Gateway gateway = viewModel.findGateway(objectA.getGateway());
            Gateway gatewayOld = viewModel.findGateway(objectAOld.getGateway());

            gatewayOld.getObjectANames().remove(objectAOld.getName());
            gateway.getObjectANames().add(objectA.getName());

            viewModel.update(gatewayOld);
            viewModel.update(gateway);

            ObjectAMarker objectAMarker = findObjectAMarker(objectAOld.getName());
            GatewayMarker gatewayMarker = findGatewayMarker(gatewayOld.getTitle());
            gatewayMarker.getPosTaken()[objectAMarker.getPos()] = false;
            MarkerApiKt.removeMarker(mapView, objectAMarker);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

    }
}

Basically what the problem is, when I open the map Activity it works normally, but let's say I open another Activity on top of the mapActivity and a change occurs in the database, when I get back to the mapActivity I find two instances of the same Marker. I noticed through the Database Inspector that I end up with two of the same String in the ArrayList of the Gateaway Object, which shouldn't happen.
The other Problem is that for now the service is set to make a change and sleep for 2 seconds, this is probably not gonna stay that way but when I do not let it sleep, even when I'm in the Map Activity I do get inconsistencies.
EDIT 2:
Database:
@androidx.room.Database(entities = {ObjectA.class, Gateway.class}, version = 26)
@TypeConverters({Converters.class})
public abstract class Database extends RoomDatabase {

    private static volatile Database instance;

    public abstract ObjectADAO cowDAO();
    public abstract GatewayDAO gatewayDAO();

    public static synchronized Database getInstance(Context context){

        if (instance == null){
            instance = Room.databaseBuilder(context.getApplicationContext(),
                    Database.class,"database")
                    .fallbackToDestructiveMigration()
                    .build();
        }
        return instance;
    }
}


text:
Q: Appending result in list or array python3 I am using python-3.x and I have tow loops first one which is number of runs (3 times) the second one to generate solutions (2 times)
what I want to do is:
Collect the best solution from the second loop and append it to an array or list.
The next run which is the first loop will run the second loop again, and it will collect the best solution from the second loop and append it to the same array or list. Which I will have two solutions in each run the total will be six solutions.
the problem is:
I want to append the "best solution" to same index location for the next run.
in my case, the array will end up with a size of 6, but I want it to be a size of 3 where each index will include two values (best solution)
run 1: result inside the array:
index 0  "The first best solution."
index 1  "The second best solution."
run 2: result inside the array:
index 0  "The first best solution."
                "The first best solution."
index 1  "The second best solution."
              "The second best solution."
If you take a look at the code and the result it will be more clear what I am trying to do?
any advice or help you could provide would be much appreciated
import matplotlib.pyplot as plt
import math
import random
import numpy as np
import pylab
from numpy import median
import os
import subprocess as sp

run = 3
best_solutions = [np.empty(0)]
del best_solutions[0]

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

for i in range (run):

    lower = 300
    upper  = 500

    number_of_solutions = 50
    generate_solutions = 2

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    for ii in range (generate_solutions):
        list_of_solutions = np.random.uniform(lower, upper, number_of_solutions)

        best_solutions.append(min(list_of_solutions))

        lower = lower - 30.4323434
        upper  = upper - 90.634555

    del (number_of_solutions)
    del (lower)

A: better work on nested list like [[1st best answer,1st best answer],[..,..]...]
so you should define an other list in the second run . then append it to the result list . here's the modified code:
for i in range (run):
    lower = 300
    upper  = 500
    number_of_solutions = 50
    generate_solutions = 2
    ####sub list
    first_solution = []
    second_solution = []
    for ii in range (generate_solutions):
        list_of_solutions = np.random.uniform(lower, upper,
        number_of_solutions)
        #### append to the sub_list
        if ii == 1 :
            first_solution.append(min(list_of_solutions))
        if ii == 2 :
            second_solution.append(min(list_of_solutions))
        lower = lower - 30.4323434
        upper  = upper - 90.634555
    del (number_of_solutions)
    del (lower)
#### append the sub_list to best_solutions after closing the loop
best_solution.append(fisrt_solution)
best_solution.append(second_solution)

A: to make it more clear....
if the (i) = 0
if the (ii) = 0
the min(solution) from this loop will be stored in best_solutions in the index 0
if the (ii) = 1
the min(solution) from this loop will be stored in best_solutions in the index 1
if the (ii) = 2
the min(solution) from this loop will be stored in best_solutions in the index 2
and so on......
second run:
if the (i) = 1
if the (ii) = 0
the min(solution) from this loop will be stored in best_solutions in the index 0
if the (ii) = 1
the min(solution) from this loop will be stored in best_solutions in the index 1
if the (ii) = 2
the min(solution) from this loop will be stored in best_solutions in the index 2
and so on......
I hope this will clarify what I want to do!!
I tried to store them by index but it gives me an error:
for i in range (run):
lower = 300
upper  = 500
number_of_solutions = 50
generate_solutions = 2
####sub list
solution = []
for ii in range (generate_solutions):
    list_of_solutions = np.random.uniform(lower, upper, number_of_solutions)
#### append to the sub_list
    solution.append(min(list_of_solutions))
    lower = lower - 30.4323434
    upper  = upper - 90.634555
#### append the sub_list to best_solutions
best_solutions[ii].append(solution[ii]) ############ here I tried to store them by index
del (number_of_solutions)
del (lower)

IndexError: list index out of range !!!????

A: Finally, I find the best way to solve my problem, this the final code that I wrote:
import random
import numpy as np

run = 3
best_solutions = [np.empty(0)]
best_sol_sorted = []
del best_solutions[0]
final_result = [np.empty(0)]
del final_result[0]

for i in range (run):
    lower = 300
    upper  = 500
    number_of_solutions = 50
    generate_solutions = 5

    ####sub list
    solution = []

    for ii in range (generate_solutions):
        list_of_solutions = np.random.uniform(lower, upper, number_of_solutions)

    #### append to the sub_list
        solution.append(min(list_of_solutions))
        lower = lower - 30.4323434
        upper  = upper - 90.634555
    best_solutions.append(solution)

for i in range(generate_solutions):
    for ii in range (run):
        best_sol_sorted.append(best_solutions[ii][i])
    final_result.append(best_sol_sorted)
    best_sol_sorted = []

where the last loop will do the job :)
thanks for every one for giving ideas and advises


text:
Q: Minimize $\mathrm{tr}(XYX^{-1}Y')$ subject to inequality constraints Given $a_1,a_2\in\mathbb{R}$, such that $a_1\geq a_2>0$. Solve the following:
\begin{array}{ll} \text{minimize} & \mathrm{tr}(XYX^{-1}Y')\\\quad X,Y\in\mathbb{R}^{2\times2}\\ \text{subject to} & YY'=\mathrm{diag\{a_1,a_2\}}\\&X>0\end{array}
If we assume $X$ and $Y$ are diagonal matrices, then best we can achieve is $\mathrm{tr}(XYX^{-1}Y')=a_1+a_2$.
I tried to use SVD on $Y$ and other tricks to simplify, but didn't get much.
Edit: $Y'$ is the transpose of $Y$, $X>0$ means $X$ is positive definite.

A: The minimum possible value is $2\sqrt{a_1a_2}$, because
\begin{align}
\operatorname{tr}(XYX^{-1}Y^T)
&=\|X^{1/2}YX^{-1/2}\|_F^2\\
&\ge\sum_{i=1}^2|\lambda_i(X^{1/2}YX^{-1/2})|^2\quad\text{(by Schur triangulation)}\\
&=\sum_{i=1}^2|\lambda_i(Y)|^2\\
&\ge2\prod_{i=1}^2|\lambda_i(Y)|\\
&=2|\det(Y)|\\
&=2\sqrt{a_1a_2}
\end{align}
and equalities hold when $X=\operatorname{diag}(\sqrt{a_2},\sqrt{a_1})$ and $Y=\pmatrix{0&\sqrt{a_1}\\ \sqrt{a_2}&0}$.


text:
Q: Creating lines that connect the centroids of adjacent polygons to one another I have about 10 polygons, and I have added their centroids to the map. I want to create lines connecting the centroids of each adjacent polygon. If polygon 1 borders polygon 2 and 3, I would like a line going from 1 to 2 and from 1 to 3. Hopefully this makes sense, and someone can help me out. Also, I would like to indicate the distances between the centroids.

A: I met the same problem, my solution is create one copy of the polygon first, add one field with the same ID with the centroid points(should be there, don't need to create). Then use the C# arcobjects to judge if the polygons are touched, like this:
ISpatialFilter pSpatialFilter = new SpatialFilterClass();
pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelTouches;

Then record the touched polygons ID, which will be connected to the centroid,
then create fromlist and tolist to record the points, create a new polyline feature class to connect those lines.


text:
Q: Visual Studio for Mac throwing MTOUCH MT0008 error "You should provide one root assembly only" Recently upgraded from Xamarin Studio to Visual Studio for Mac. Trying to build an existing iOS project I'm receiving the following build error:

/Projects/ACME Networks/Alpha Xamarin/iOS/MTOUCH: Error MT0008: You should provide one root assembly only, found 3 assemblies: 'Networks/Alpha', 'Xamarin/iOS/obj/iPhoneSimulator/Debug/device-builds/iphone9.1-10.3/Entitlements.xcent/', '/Projects/ACME Networks/Alpha Xamarin/iOS/bin/iPhoneSimulator/Debug/MyNetApp.iOS.exe' (MT0008) (App)

It appears to me that something in the IDE is getting confused because the path to the solution includes folders that have spaces in them, "ACME Networks" and "Alpha Xamarin".
I've got no clue how to fix this. Tried cleaning and rebuilding.

A: Usually this problem means that you have spaces in the directory names of your project.
Visual Studio for Windows allow us to create projects with spaces in the directory names, but Xamarin or Visual Studio for Mac doesn't. When you copy a project from Windows to Mac, it should work right away as they say. But it doesn't, and this is one of the problems.
You can change the spaces to a different character like "_" or "-" or just remove the spaces.
Be sure to edit yourproject.sln file lines pointing to your .csproj files to the new path and you should be good.


text:
Q: Gauge Gravitation Theory Gauge gravitation theory seems to be a consistent framework for gravity. https://en.wikipedia.org/wiki/Gauge_gravitation_theory
Can anyone here explain how this theory this works, using an example in 2D?


text:
Q: Can the Magento swagger UI also show XML sample data and allow XML requests? We are using the swagger UI at ourshop.example.com/swagger to the the API and generate examples.
While the Magento API perfectly supports XML data (incoming and as result), the swagger UI only allows application/json format.
Is there way to tune the integrated swagger UI to also support XML?


text:
Q: How to measure the width of a character including overshoot I'm trying to measure the width of arbitrary letters. For example, I'm using this to get the width of a letter A:
\settowidth{\letterwidth}{A}

This seems to work fine for all my letters, except for the letter Q, where the tail overshoots the box. I can see this with a framebox:
\documentclass{article}
\usepackage{fontspec}

\setmainfont{EB Garamond}

\begin{document}

\setlength{\fboxsep}{0pt}\fbox{Q}

\end{document}

Running this through Overleaf produces a Q whose tail slightly overflows the box:

(Note that this example isn't super pronounced, because I was trying to use a built-in font that replicates the issue, but it's far more pronounced with the particular custom font I'm using).
How do I reliably draw a box around the whole character, including overshoot?


text:
Q: Google Data Studio Date I'm currently working with CSV data and trying to import into datastudio.
The Date format in CSV is "dd/mm/yyyy hh:mm" EXAMPLE: "12/05/2021 16:30"
When I put data into the data studio
The date came out as "5 DEC 2021" (A date in the future?)
Please, I need help.

A: It is parsing your date in mm/dd/yyyy format (month before the day), which is very common problem.
To avoid this kind of problem, I would say it is a good practice to always use the ISO 8601 format, that means yyyy-mm-dd.
If you can't change the CSV data source, I suggest you to treat the column as a STRING and add a calculated field to parse the string creating a new date field.  Like in this example:
PARSE_DATETIME("%d/%m/%E4Y %H:%M", Your_CSV_Field)  # if the time part is relevant
PARSE_DATE("%d/%m/%E4Y", Your_CSV_Field)            # if the time part is NOT relevant

This way, you can freely use any date format.


text:
Q: Get last row value from PHP ADODB MySQL loop I am trying to get the last row value from my select query.
This is my PHP query using ADODB:
$con->Execute("SET @depos=0");
$con->Execute("SET @total=$openingbalance");
$sql = "SELECT if( credit >0, @depos := credit , @depos := @depos + credit - debit ) AS depos_bal, @total := @total + `credit` - `debit` AS net_bal FROM `table` WHERE `mydate` < '".$monthstarts."' ORDER BY `mydate` ASC, `credit` DESC";
    $ssresults=$con->Execute($sql);
    $fnew = $ssresults->getrows();

    for($i=0;$i<count($fnew);$i++)
    {
        $bal = $fnew[$i]['net_bal'];
    }
 echo $bal;

Here I want to fetch the last row value from the loop.
For example:
 Balance
 ----------
 150.00
 250.00
 350.00
 600.00
 850.52 <----- this is the row I want to fetch from the query.

How can I fetch this? Kindly help!

A: No need of for loop try this:-
$fnew = $ssresults->getrows();

$bal = $fnew[count($fnew)-1]['net_bal'];

 echo $bal;

note:- count give total number of element present in array. and array index start from 0 so count($fnew)-1 give you last record. thanks.


text:
Q: HTTP Status 404 - /SchoolSchedule/ - Eclipse tutorial I am a newbie on web app development and learning Eclipse with Tomcat7.
I followed this tutorial but keep getting HTTP Status 404 -/SchoolSchedule
there is no compiling error.
Can you help to point out what the problem is.
Here is the servlet code:
package org.eclipse.wtp.sample.classschedule;

import java.io.IOException;
import javax.servlet.annotation.WebServlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(urlPatterns={"/ScheduleServlet"})
public class ScheduleServlet extends HttpServlet {

....
                                                                                getServletContext().getRequestDispatcher("/SchoolSchedule.jsp").forward(req, resp);
            //getServletContext().getRequestDispatcher("/SchoolSchedule.jsp").forward(req, resp);;

            doPost(req, resp);
    }

}

And the JSP page has FORM action="/SchoolSchedule/SchoolSchedule.jsp" method="post"
Any help is much appreciated.

A: I'm not really an expert in "Servlets" and so far, the tutorial looks good (maybe it is not updated at all since it is using Java 1.4).
I believe you're inside doPost or doGet method, if not, for sure you have the req and resp variables which are the HttpServletRequest and HttpServletResponse respectively.
Then... I would suggest to replace your commented line
getServletContext().getRequestDispatcher("/SchoolSchedule.jsp").forward(req, resp);

by this one:
req.getRequestDispatcher("/schoolSchedule.jsp").forward(req, resp);

Let me know if this works for you or helps you somehow.
Happy coding!


text:
Q: Can I rewrite this statement "Let $x,y$ $\in$ $5\mathbb{Z}$. prove that $x+y$ $\in$ $5\mathbb{Z}$ ." like this? How to rewrite this problem?
I have a problem. "Let $x,y$ $\in$ $5\mathbb{Z}$. prove that $x+y$ $\in$ $5\mathbb{Z}$ ."
I did try to write this problem in the form of "something is an element of (set builder notation)" like this.
prove that $x+y$ $\in$ {$5\mathbb{Z}  |   $x,y$ \in 5\mathbb{Z}$}
Is it true?

A: Suppose that $x\in 5\Bbb Z$ and that $y\in 5\Bbb Z$.
This means by definition that there exists some integer $k\in \Bbb Z$ such that $x = 5k$ and some $\ell \in \Bbb Z$ such that $y = 5\ell$.
Then $x+y$ can be written as... which is... and so...

 Then $x+y$ can be written as $x+y=5k + 5\ell = 5(k+\ell)$ which is $5$ times an integer and so $x+y$ satisfies the definition of being an element of $5\Bbb Z$.

As for "rewriting the problem", the original $x,y\in 5\Bbb Z$ implies $x+y\in 5\Bbb Z$ is clear enough.  You could also have opted to write this as $5\Bbb Z + 5\Bbb Z \subseteq 5\Bbb Z$ or similar where here we take "$A+B$" to mean $\{a+b~:~a\in A,b\in B\}$

A: You can define $E=\{(x,y)\in 5\mathbb Z\times 5\mathbb Z\mid x+y\in5\mathbb Z\}$
The question resumes to show that $E$ is the whole space, i.e. " does $E=5\mathbb Z\times 5\mathbb Z$ ? " since this happen to be always true.
Conversely with $E^\complement=\{(x,y)\in 5\mathbb Z\times 5\mathbb Z\mid x+y\notin5\mathbb Z\}$ this is equivalent to $E^\complement=\varnothing$.
An alternative writing could be:

*

*let $x\in 5\mathbb Z+5\mathbb Z$, show that $x\in 5\mathbb Z$

*or show $5\mathbb Z+5\mathbb Z\subset 5\mathbb Z$ in pure set notation

And you can rewrite the set (in the set builder notation) $5\mathbb Z+5\mathbb Z=\{a+b\mid a\in 5\mathbb Z,\ b\in 5\mathbb Z\}$


text:
Q: How to check if previous return is the current one? I have the following code:
EDIT
....int l=0
char* FantasiaGameUtils::GetCurrentTask(char *chat_arg)
{ // I know the code looks disgusting but please ignore that as I am only testing now
    static char *szTemp1="";
    for(int i=0; i<loop; i++)
    {
        if(task[i][0]!=0)
        {
            sif (l==0)
            {strcpy(chat_arg, task[i]);
            }
        else
            {strcpy(chat_arg, task[i+1]);
            }
        strcpy(task[i], "");

        if (szTemp1!="")
        {
            MessageBox(0, szTemp1, "szTemp Value", 0);
            MessageBox(0, chat_arg, "Initial Value", 0);
            return chat_arg != szTemp1 ? chat_arg : NULL;
        } else {
            l++;
            szTemp1 = chat_arg;
            MessageBox(0, szTemp1, "szTemp1 Value", 0); // @execute
            return chat_arg;
        }
        }
        strcpy(chat_arg, "");
    }
    return false;
}

EDIT
What I am trying to do is make the return sequence check the previous returned value, and if its not the same as the current one, then return the current value chat_arg, if it is, return NULL.
The purpose of this function is to get the users prompt from the global_chat. An example of a prompt would be !create <game-type> <game-time> <max-players>
This prompt would be individually stored by each word enter (after each space) into the task[][] array, respectively.
From there, this function goes into play. It should copy the current task value (the current word) into the chat_arg variable.
The problem I am experiencing is, for some reason every in my main game loop. The value of chat_arg is kept through-out the game loop. I want to clear this value. I've come up with this method of which I will check if the current value in the function is the same as the previous one and if it is, return NULL (clearing the value), if it's not, then there is no reason to clear the previous value so return the current value.
Might anyone have a better or improved way I can perform this check? Or can anyone PLEASE tell me how I can get the previous returned value from memory and check it against the current value? Thank-you!

A: 1) Add C++ tag to your post, because it is not a pure C code.
for(int i=0; i < loop; i++) // This line will not compile using C compilers.

2) Better return 0 in below line. false does not match to char* you expect.
return false; -> return 0;

My solutions for your problem:
1) Create global variable and your local chat_arg compare to it.
extern char* g_prev_chat_arg = 0;

...

char* FantasiaGameUtils::GetCurrentTask(char *chat_arg)
{
...
    //return chat_arg != /*previous return value*/ ? chat_arg : NULL;
    if (0 == strcmp(chat_arg, g_prev_chat_arg))
    {
        return 0;
    }
    else
    {
        g_prev_chat_arg = chat_arg;
        return chat_arg;
    }
...
}

2) Create local static variable within your function char* FantasiaGameUtils::GetCurrentTask(char *chat_arg)and use it like above,
3) Store somewhere in code last returned value from char* FantasiaGameUtils::GetCurrentTask(char *chat_arg) and then pass it each time when you are calling GetCurrentTask(...)
char* FantasiaGameUtils::GetCurrentTask(const char* prev_chat_arg, char* chat_arg)


text:
Q: How to get the complete URL from URI? I am trying to get the path or a URL I intercept from my app.
Sample URL: http://myapp.com/foo/bar/145
I am trying to get: /foo/bar/145
Uri data = getIntent().getData();
String path = data.getPath() // gives "/"

How can I get /foo/bar/145?

A: .toString() method will return complete url as a simple String, if you need URL instance, then you can use new URL(uriPath.toString()).

A: Try using , Iam able to get /foo/bar/145
uri.getEncodedPath()


text:
Q: onsingletapup from osmdroid calls multiple items I've created an Osmdroid map with makers, but some markers are very close, so when i tap on it, there a lot of "onSingleTapUp called", it's like i'm clicking on all of them in the same time, and i don't see why, even when i can cleary see a blank between two overlay items the listener listen both taps.
        addOverlayItems();
        MyItemizedOverlay itemizedOverlay = new MyItemizedOverlay(context, items, gestureListener);
        map.getOverlays().add(itemizedOverlay);

        private void addOverlayItems(){
        for(int i = 0; i < sparetimes.size(); i++){
        SpareTimeObject sparetime = sparetimes.get(i);
        String title = sparetime.getLeisureTitle();
        String description = sparetime.getLeisureDescription();
        if(title == null){
            title = "Titre a definir";
        }
        if(description == null){
            description = "Description a definir";
        }
        if(sparetime.getLeisureLatitude() != null && sparetime.getLeisureLongitude() != null){
            double lat = Double.parseDouble(sparetime.getLeisureLatitude());
            double lon = Double.parseDouble(sparetime.getLeisureLongitude());
            GeoPoint geoPoint = new GeoPoint(lat, lon);
            MyOverlayItem item = new MyOverlayItem(title, description, geoPoint);

            items.add(item);
        }else{
            Log.i(TAG, "aucune localisation");
        }

    }
}
ItemizedIconOverlay.OnItemGestureListener<MyOverlayItem> gestureListener = new OnItemGestureListener<MyOverlayItem>() {

    @Override
    public boolean onItemLongPress(int arg0, MyOverlayItem arg1) {
        Log.i("onItemLongPress", ""+items.get(arg0).getTitle());
        return false;
    }

    @Override
    public boolean onItemSingleTapUp(int arg0, MyOverlayItem arg1) {
        Log.i("onItemSingleTapUp", ""+arg1.getTitle());
        Intent intent = new Intent(context, SpareTimeCardActivity.class);
        addToIntent(intent, sparetimes.get(arg0));
        context.startActivity(intent);
        return false;
    }

};


text:
Q: Array structure I'm trying to make a little custom vector...
element class, should point to the adress of the next class but with this code
class foo {
private:
    int attr;
public:
    foo(){attr = 10;}
    int get_attr(){return attr;}
    void set_attr(int a){attr =a;}
};

class element_foo {
private:
    foo data;
    element_foo *ptr_next;
public:
    element_foo(){ptr_next = NULL;}
    element_foo(int dat){data.set_attr(dat); ptr_next = NULL;}
    element_foo(int dat, element_foo next){
        data.set_attr(dat);
        ptr_next = &next;
    }
    foo get_data(){return data;}

    element_foo get_next(){return *ptr_next;}

    void print_array(){
        if (ptr_next == NULL) {
            std::cout<< data.get_attr()<<std::endl;
        }
        else {
            std::cout<< data.get_attr()<<std::endl;
            this->get_next().print_array();
        }

    }
};

int main (int argc, char * const argv[]) {
    // insert code here...
    element_foo a1(10);
    element_foo a2(15,a1);
    element_foo a3(20,a2);

    a3.print_array();

    std::cout << "Hello, World!\n";
    return 0;
}

when I print a3, it get to segmentation fault... why? where is my mistake?

A: The error is in this constructor:
element_foo(int dat, element_foo next){
    data.set_attr(dat);
    ptr_next = &next;
}

You are taking the address of a local. ptr_next = &next; Once the function ends, the address is invalid.
What you need to do is to pass next in as a pointer:
element_foo(int dat, element_foo *next){
    data.set_attr(dat);
    ptr_next = next;
}

And change your main to this:
element_foo a1(10);
element_foo a2(15,&a1);
element_foo a3(20,&a2);

EDIT:
Alternatively, you can just pass it by reference:
element_foo(int dat, element_foo &next){
    data.set_attr(dat);
    ptr_next = &next;
}

A: The problem is you are storing a pointer to a temporary object.
'next' is just a copy of a1/a2 you passed in because of copy-by-value. You should use copy-by-reference so that &next refers exactly to the address of a1/a2, not a copy of them.
                     v-------- should use "const element_foo &"
element_foo(int dat, element_foo next){
        data.set_attr(dat);
        ptr_next = &next;
    }

// a2->ptr_next is dangling
element_foo a2(15,a1);

When the above line is executed, a2->ptr_next doesn't not point to a1,
but a temporary local object which has already been destructed.
Thus a2->ptr_next is dangling. Any later access via this pointer has undefined behavior.


text:
Q: SQL Max value of pre-defined rows I have two MySQL tables: MEMBERS and POSTS. I need to make a query that will have following meaning:
Select all USERs that have some (>0) records in POSTS table =>
From them Select a USER who has the biggest ADS value in MEMBERS table.
I tried following thing:
"SELECT * FROM posts WHERE user=(select user from members where ads=(select Max(ads) from members))'

But this has a bug, that when USER with Max value in MEMBERS, has no records in POSTS table - SQL returns empty result.
My guess is that I should tell MySQL to choose Max value not from all rows, but only from pre-defined, but I don't know how to do it and if it's possible.
Can someone help me?

A: Does this work?
   select m.member_id, max(p.ads)
     from members m
     join posts p
       on m.member_id = p.member_id
    group by m.member_id
    order by max(p.ads) desc
    limit 1

A: SELECT m.*
FROM members AS m
WHERE EXISTS
      ( SELECT *
        FROM posts AS p
        WHERE p.member_id = m.member_id
      )
ORDER BY ads DESC
LIMIT 1