text:
Q: Can I set android launcher icon in Main Activity We always know set android:icon in Manifest can set icon and logo,
android:icon="drawable resource"

Can I set logo icon in Main Activity with Java code?
thanks for help

A: This answer could help you.
Extract from mike yaworski's answer:

Summary:
android:icon="@drawable/ic_launcher" determines your launcher icon, so
  just add images to the drawable folders and change ic_launcher to
  whatever the name of image is that you want to be the icon.
android:label="@string/app_name" determines your "label" so just look
  for app_name (because the label is referenced to @string/app_name) in
  your strings.xml file and change the contents of app_name.


text:
Q: Attach IP to VM instance using Node.js API in Google Cloud How to attach an existing statics IP to a VM using the node.js API?
I can do this using gcloud command, but I can't find where the node API implements this feature on Address and also VM docs

A: The method you need is not available on the Node.js Google Cloud library but you can do it with the REST Compute Engine API using Node.js.
You have two options:

1.- Add a new network configuration.
2.- Update (just partially if you want) the network configuration.

Go down completely in the documentation to see code examples (also in Node.js).

redpajama_set_name: RedPajamaStackExchange


text:
Q: Call a method of a controller from another controller using 'scope' in AngularJS I am trying to call a method of second controller in first controller by using scope variable. This is a method in my first controller:
$scope.initRestId = function(){
        var catapp = document.getElementById('SecondApp');
        var catscope = angular.element(catapp).scope();
        catscope.rest_id = $scope.user.username;
        catscope.getMainCategories();
    };

I am able to set the value of rest_id but I cannot call getMainCategories for some reason. The console shows this error:

TypeError: Object # has no method 'getMainCategories'

Is there a way to call the above method?
Edit:
I used the following approach to load two apps at the same time;
angular.bootstrap(document.getElementById('firstAppID'), ['firstApp']);
angular.bootstrap(document.getElementById('secondAppID'), ['secondApp']);

I could definitely use a service here, but I wanted to know if there are any other options to do the same!

A: The best approach for you to communicate between the two controllers is to use events.
Scope Documentation
In this check out $on, $broadcast and $emit.
In general use case the usage of angular.element(catapp).scope() was designed for use outside the angular controllers, like within jquery events.
Ideally in your usage you would write an event in controller 1 as:
$scope.$on("myEvent", function (event, args) {
   $scope.rest_id = args.username;
   $scope.getMainCategories();
});

And in the second controller you'd just do
$scope.initRestId = function(){
   $scope.$broadcast("myEvent", {username: $scope.user.username });
};

Edit: Realised it was communication between two modules
Can you try including the firstApp module as a dependency to the secondApp where you declare the angular.module. That way you can communicate to the other app.

A: Each controller has it's own scope(s) so that's causing your issue.
Having two controllers that want access to the same data is a classic sign that you want a service.  The angular team recommends thin controllers that are just glue between views and services.  And specifically- "services should hold shared state across controllers".
Happily, there's a nice 15-minute video describing exactly this (controller communication via services):  video
One of the original author's of Angular, Misko Hevery, discusses this recommendation (of using services in this situation) in his talk entitled Angular Best Practices (skip to 28:08 for this topic, although  I very highly recommended watching the whole talk).
You can use events, but they are designed just for communication between two parties that want to be decoupled.  In the above video, Misko notes how they can make your app more fragile.  "Most of the time injecting services and doing direct communication is preferred and more robust".  (Check out the above link starting at 53:37 to hear him talk about this)

A: Here is good Demo in Fiddle how to use shared service in directive and other controllers through $scope.$on
HTML

    <input ng-model="message" >
    <button ng-click="handleClick(message);">BROADCAST</button>

    <input ng-model="message" >

    <input ng-model="message" >

<my-component ng-model="message"></my-component>

JS
var myModule = angular.module('myModule', []);

myModule.factory('mySharedService', function($rootScope) {
    var sharedService = {};

    sharedService.message = '';

    sharedService.prepForBroadcast = function(msg) {
        this.message = msg;
        this.broadcastItem();
    };

    sharedService.broadcastItem = function() {
        $rootScope.$broadcast('handleBroadcast');
    };

    return sharedService;
});

By the same way we can use shared service in directive. We can implement controller section into directive and use $scope.$on
myModule.directive('myComponent', function(mySharedService) {
    return {
        restrict: 'E',
        controller: function($scope, $attrs, mySharedService) {
            $scope.$on('handleBroadcast', function() {
                $scope.message = 'Directive: ' + mySharedService.message;
            });
        },
        replace: true,
        template: '<input>'
    };
});

And here three our controllers where ControllerZero used as trigger to invoke prepForBroadcast
function ControllerZero($scope, sharedService) {
    $scope.handleClick = function(msg) {
        sharedService.prepForBroadcast(msg);
    };

    $scope.$on('handleBroadcast', function() {
        $scope.message = sharedService.message;
    });
}

function ControllerOne($scope, sharedService) {
    $scope.$on('handleBroadcast', function() {
        $scope.message = 'ONE: ' + sharedService.message;
    });
}

function ControllerTwo($scope, sharedService) {
    $scope.$on('handleBroadcast', function() {
        $scope.message = 'TWO: ' + sharedService.message;
    });
}

The ControllerOne and ControllerTwo listen message change by using $scope.$on handler.


text:
Q: MySQL slave database won't start I have a MySQL master slave configuration and the slave is not working anymore. When trying to stop and start again the slave db, I am getting this error:
140530 14:21:23 [Warning] Slave I/O: Notifying master by SET @master_binlog_checksum= @@global.binlog_checksum failed with error: Unknown system variable 'binlog_checksum', Error_code: 1193
140530 14:21:23 [ERROR] Error reading packet from server: Client requested master to start replication from impossible position; the first event 'mysqliv-bin.000142' at 184658851, the last event read from './mysqliv-bin.000142' at 4, the last byte read from './mysqliv-bin.000142' at 4. ( server_errno=1236)
140530 14:21:23 [ERROR] Slave I/O: Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position; the first event 'mysqliv-bin.000142' at 184658851, the last event read from './mysqliv-bin.000142' at 4, the last byte read from './mysqliv-bin.000142' at 4.', Error_code: 1236

Any idea what can be the problem here?

A:
Unknown system variable 'binlog_checksum'

That's because your master is running MySQL 5.5 (or earlier), and the slave is running MySQL 5.6. The binlog_checksum global variable was introduced in 5.6, and the slave is trying to find out if that feature is enabled on the master. But the variable doesn't exist on your master. This shouldn't cause any data loss, and the warning will go away once you upgrade your master.

Client requested master to start replication from impossible position

Sounds like your master crashed before it could write a final "Rotate to next binlog" event at the end of a binlog file. So the slave doesn't know to advance to the next binlog.
You can manually change the slave to read from the next binlog:
mysql> STOP SLAVE;
mysql> CHANGE MASTER TO MASTER_LOG_FILE='mysqliv-bin.000143', MASTER_LOG_POS=4;
mysql> START SLAVE;

But first, double-check that mysqliv-bin.000143 exists on the master with SHOW BINARY LOGS.
The following blog explains in more detail:
http://www.skysql.com/blogs/adam-donnison/client-requested-master-start-replication-impossible-position


text:
Q: multidimensional array Please explain what is the meaning of
foreach ($toplist['children'] as $subkey => $subname)

and where the children come from. I'm confused.

A: Basically $toplist is an array of values. One of those values has been called 'children'.
In this case, the value at position 'children' is itself an array.
Your line of code is telling the computer to loop over each of the values inside the 'children' array and extract the key and value.
$subkey is the key, $subname is the name.
In other words, $toplist['children'][$subkey] == $subvalue

A: The other elements are coming from the $toplist['children'] array which you got to figure out where it is coming from since you have not put in all the needed code for the question. See this about foreach machenism to learn more about it.

his simply gives an easy way to
  iterate over arrays. foreach works
  only on arrays, and will issue an
  error when you try to use it on a
  variable with a different data type or
  an uninitialized variable.

php.net


text:
Q: How to define environment variables in Visual Studio App Center? For my React Native app, in my dev environment, I've a .env.development file that contains environment variables required by my app, like service endpoint urls, library secret keys, environment and log prefixes etc. In my app I'm consuming those using react-native-config.
How can I define these in App Center? I read here that environment variables defined in App Center config are only for build scripts.
Can I define variables required by my app here and use these or do I have to check in my .env.development into my repo (which I'd rather not if there is a way to avoid it!).


text:
Q: Strange behaviour \ang after reinstalling latex After a new install of my computer (Linux Mint 18) I have installed TeX Live, Texmaker and all the necessary packages (like on the previous PC). But when I compile my document I get the following error:
! Undefined control sequence.

The problem is on the \ang{}
For example \ang{180} give me 180180 instead of 180°
I have included the siunitx package with  \usepackage{siunitx} like before.
What could it be?
Here a minimal Code that give me the problem:
\documentclass[12pt]{book}

\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{gensymb}
\usepackage{float}
\usepackage{tikz,pgfplots}
\usepackage{tkz-euclide}
\usepackage{mathtools}
\usetikzlibrary{intersections}
\usepackage{amsmath,amssymb}
\usepackage[makeroom]{cancel}
\usepackage{mathtools}
\usepackage{mdframed}
\usepackage{siunitx}
\usepackage{tkz-euclide}
\usepackage{comment}
\usetikzlibrary{angles,positioning,quotes,decorations.markings}
\usepackage[italian]{babel}
\usetikzlibrary{angles,quotes}
\usetkzobj{all}

\begin{document}

\chapter{Mychapter}
\label{chap:Mychapter}

Some text

\section{Il triangolo}
\label{sec:il triangolo}

\textbf{Caratteristica del triangolo:} La somma degli angoli interni corrisponde sempre a \ang{180}.

\end{document}

Here the error message:
! Undefined control sequence.
\@@_number_in_sign_replace:N ...ign_replace_aux:N
#1\@@_number_in_sign_repla...
l.34 ...oli interni corrisponde sempre a \ang{180}
.
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
[1
] (./MWE.aux) )


text:
Q: 2 users login in 1 form in the CodeIgniter framework (multi level login system) I´m working on a website and there are 2 users that are able to login into my website, both users are different tables in my database:
1. administrator
2. werknemer

For both of those users I have a different login form and login controller function, but what I want is that both users can login in just 1 form.
I just don't know how to do that.
These are the 2 view forms in my login.php view file:
  <?php  echo form_open('index.php/Auth/werknemer_login'); ?>

                    <input class="form-control" name="naam" id="naam" type="text" placeholder="Naam">

                    <input class="form-control" name="wachtwoord" id="wachtwoord" type="password" placeholder="Wachtwoord">

                Wachtwoord vergeten?

                    <button class="btn btn-primary" name="werknemer_login" >Inloggen</button>

            </form>

Administrator inloggen

               <?php  echo form_open('index.php/Auth/administrator_login'); ?>

                    <input class="form-control" name="naam" id="naam" type="text" placeholder="Naam">

                    <input class="form-control" name="wachtwoord" id="wachtwoord" type="password" placeholder="Wachtwoord">

                Wachtwoord vergeten?

                    <button class="btn btn-primary" name="administrator_login" >Inloggen</button>

            </form>

And these are the login controller functions in my Auth.php controllers:
public function administrator_login()
    {
            $this->form_validation->set_rules('naam', 'Naam', 'required');
            $this->form_validation->set_rules('wachtwoord', 'Wachtwoord', 'required|min_length[5]');

            if ($this->form_validation->run() == TRUE) {

                $naam = $_POST['naam'];
                $wachtwoord = ($_POST['wachtwoord']);

                //check gebruiker in database
                $this->db->select('*');
                $this->db->from('administrator');
                $this->db->where(array('naam'=>$naam));
                $query = $this->db->get();
                $administrator = $query->row();

                //Als gebruiker bestaat
                if($administrator->naam)
                {
                    $this->session->set_flashdata("success","U bent nu ingelogd als administrator");
                    //Als er een user is maak session date
                        $_SESSION['administrator_level'] = 1;
                        $_SESSION['administrator_logged'] = TRUE;
                        $_SESSION['naam'] = $administrator->naam;
                        $_SESSION['wachtwoord'] = $administrator->wachtwoord;

                  //link naar werknemer/administrator view pagina
                 redirect("index.php/Welkomadministrator", "refresh");
                }
                $this->session->set_flashdata("success","U bent nu ingelogd");
                }
                else{
                    $this->session->set_flashdata('error','Verkeerde naam of wachtwoord');
                //wanneer er een foutmelding is link weer naar de login pagina
                redirect("" , "refresh");
            }

                  //laad de login pagina
              //    $this->load->view('login');

    }

    // Login code voor de administrator
    public function werknemer_login()
    {
            $this->form_validation->set_rules('naam', 'Naam', 'required');
            $this->form_validation->set_rules('wachtwoord', 'Wachtwoord', 'required|min_length[5]');

            if ($this->form_validation->run() == TRUE) {

                $naam = $_POST['naam'];
                $wachtwoord = ($_POST['wachtwoord']);

                //check gebruiker in database
                $this->db->select('*');
                $this->db->from('werknemer');
                $this->db->where(array('naam'=>$naam));
                $query = $this->db->get();
                $werknemer = $query->row();

                //Als gebruiker bestaat
                 if($werknemer->naam)
                 {
                     $this->session->set_flashdata("success","U bent nu ingelogd als werknemer");
                        //Als er een user is maak session date
                        $_SESSION['werknemer_level'] = 1;
                        $_SESSION['werknemer_logged'] = TRUE;
                        $_SESSION['naam'] = $werknemer->naam;
                        $_SESSION['wachtwoord'] = $werknemer->wachtwoord;
                 }
              //link naar administrator/werknemer view pagina
                 redirect("index.php/Welkomwerknemer", "refresh");

                $this->session->set_flashdata("success","U bent nu ingelogd");
                }

                else{
                    $this->session->set_flashdata('error','Verkeerde naam of wachtwoord');
                //wanneer er een foutmelding is link weer naar de login pagina
                redirect("" , "refresh");
                }
                  //laad de login pagina
                  //$this->load->view('login');
            }

So my question is is there a way to have 2 users login 1 form?

A: Yes there are many ways. One you can add one extra column in login table for role. this reduces one extra table you need. After login you can check what is role of logged in user then redirect him to that page. This is most preferred one.
Second one for one form with two table is first check user entry in admin table if user details are present & correct redirect him to admin page if user details are not there then check other table then redirect to regular user page(if credentials are correct).
Lets say there is no user details in both table then this indicates either that user is not registered or entered wrong id.

A: I noticed a few errors that were documented in the comments. Using the following code you can login both user groups from the same controller while maintaining your current table structure. I would like to add that this will not work out of the box - you will have to use the hash_password() in the model to hash any plain-text passwords you currently have stored in the db - this is for your users safety.
Notice: as per the docs the password field in the db has to allow for an input equal to or larger 255 characters

it is recommended to store the result in a database column that can
  expand beyond 60 characters (255 characters would be a good choice).

Controller:
class Somecontroller extends CI_Controller {

    public function login() {
        $this->form_validation->set_rules('naam', 'Naam', 'required');
        $this->form_validation->set_rules('wachtwoord', 'Wachtwoord', 'required|min_length[5]');
        if ($this->form_validation->run() == false) {
            $this->session->set_flashdata('error', validation_errors());
            redirect('', 'refresh');
        }
        $this->load->model('auth_model');
        $naam = $this->input->post('naam');
        $wachtwoord = $this->input->post('wachtwoord');
        if (($admin = $this->auth_model->get_user($naam, 'administrator')) !== false) {
            if (!$this->auth_model->verify_password($wachtwoord, $admin->wachtwoord)) {
                $this->session->set_flashdata('error', 'Name or password is invalid.');
                redirect('', 'refresh');
            }
            $_SESSION['administrator_level'] = 1;
            $_SESSION['administrator_logged'] = TRUE;
            $_SESSION['naam'] = $admin->naam;
            // Don't store the users password in a session
            //$_SESSION['wachtwoord'] = $admin->wachtwoord;
            $this->session->set_flashdata("success","U bent nu ingelogd");
            redirect('index.php/Welkomadministrator', 'refresh');
        } elseif (($user = $this->auth_model->get_user($naam, 'werknemer')) !== false) {
            if (!$this->auth_model->verify_password($wachtwoord, $user->wachtwoord)) {
                $this->session->set_flashdata('error', 'Name or password is invalid.');
                redirect('', 'refresh');
            }
            $_SESSION['werknemer_level'] = 1;
            $_SESSION['werknemer_logged'] = TRUE;
            $_SESSION['naam'] = $user->naam;
            //$_SESSION['wachtwoord'] = $user->wachtwoord;
            $this->session->set_flashdata("success","U bent nu ingelogd");
            redirect('index.php/Welkomwerknemer', 'refresh');
        } else {
            // we couldn't find the user in either table, they must not exist
            $this->session->set_flashdata('error', 'User does not exist in the system.');
            redirect('', 'refresh');
        }
    }

}

Model:
class Auth_model extends CI_Model {

    /**
     * Gets a user from the db
     *
     * @param mixed $naam
     * @param string $table
     * @return boolean|obj
     */
    public function get_user($naam, $table) {
        $query = $this->db->get_where($table, array('naam' => $naam));
        if ($query->num_rows() > 1) {
            return $query->row();
        }
        return false;
    }

    /**
     * Verifies password matches the hashed password stored in db
     *
     * @param string $password user keyed in password
     * @param string $db_password password from db
     * @return boolean
     */
    public function verify_password($password, $db_password) {
        return password_verify($password, $db_password);
    }

    /**
     * Hashes a password to be stored in db
     *
     * @param mixed $password
     * @return hashed password
     */
    public function hash_password($password) {
        return password_hash($password, PASSWORD_DEFAULT);
    }

}


text:
Q: chrome.webRequest.onBeforeRequest and chrome CSP I have an extension that redirects certain webrequests using the
chrome.webRequest.onBeforeRequest API.
Now since Facebook implemented the CSP Header, the redirects are
fired, but the network tab in chrome just says PENDING request.
So I guess its being blocked.
How can I get around this ???


text:
Q: Can I auto-detach SqlResultSetMapping Entity from EntityManager? I'm using a @SqlResultSetMapping for an @Entity that is purely read-only (and has no backing table in the database). I'm loading tens of thousands of these into memory, so I need to detach the entities from the EntityManager to avoid Hibernate's dirty entity checking when I do work later.
Is there a way to annotate the Entity, or the SqlResultSetMapping, so that the entities are never added to the EntityManager?
Non-persisted entity:
@SqlResultSetMapping(name = "fooMapping", entities = @EntityResult(entityClass = Foo.class))
@Entity
public class Foo {
    @Id
    public Long row_id;
    public String name;
}

Native query:
String sql = "SELECT id AS row_id, friendlyName AS name FROM SomeTable";
Query q = JPA.em().createNativeQuery(sql, "fooMapping");
List<Foo> fooList = q.getResultList();

Current solution:
for (Foo f : fooList) {
    JPA.em().detach(f); // 100x improvement for subsequent DB work
}

// subsequent database work

A: One way to avoid dirty checking is to indicate to hibernate that the query is fetching read-only entities. You can do this in JPA by using query hints
q.setHint("org.hibernate.readOnly",true);

From hibernate doc:

org.hibernate.readOnly : Entities retrieved by this query will be loaded in a read-only mode where Hibernate will never dirty-check them or make changes persistent ( eg. new Boolean(true) ), default to false


text:
Q: How to get value of row in mySQL with specific Value in PHP I am trying to get a value of row with a specific value of a mySQL DB.
This is how my row looks like
row | email     | uuid | device
 1  | me@me.com |xxxxxx|iPhone
 2  | you@me.com|yyyyyy|iPod

So for example I want to get the uuid in row 2, I have the email.
This is how my mysql_query looks like:
$result = mysql_query("SELECT * FROM users WHERE email = '{$email}'");
    echo(mysql_result($result, 0)); #0 is email, but I need uuid, so 1

but I only can get the email.
Does anyone know how to get the uuid?

A: look into switching over to pdo or mysqli_.  but otherwise why not:
 $result = mysql_query("SELECT * FROM users WHERE email = '{$email}'");
 while($row = mysql_fetch_array($result))
 {

      echo $row['uuId'] . "," . $row['email'] . "," . $row['device'] . "<br>";
      //or whatever data you want.
 }

A: You can use
while ($row = mysql_fetch_assoc($result)) {
    echo $row['email'];
    echo $row['uuid'];
    echo $row['device'];

}

BTW start using mysqli_* functions mysql_* functions are deprecated.


text:
Q: Sum of rational numbers The sum of a finite number of rational numbers is of course a rational number, but the sum of an infinite number of rational numbers might be an irrational number.  Can someone give me some intuition why this sum might be irrational?  I just "don't feel it."

A: Dear I am thinking about it because I am also a student of Mathematics.
We know that $e$ is an irrational number.
The value of $e$ is
$$= 1 + \frac{1}{1} + \frac{1}{2!} + \frac{1}{3!} + \ldots$$
$$= 1 + \frac{1}{1} + \frac{1}{2} + \frac{1}{6} + \frac{1}{24} + \ldots$$
$$= 2.7182 \ldots$$ (Irrational Number)
So sum of infinite rational numbers may be irrational.

A: Any irrational number $x$ is the limit of a sequence of rational numbers $a_n$ (take for example the decimal expansion truncated after $n$ decimals, for $n=1,2,3,\dots$). Then
$$x = a_1 + (a_2-a_1) + (a_3-a_2) + \dots$$
is a sum of rational numbers, but it is irrational by construction.

A: Look at this.
So: $3.14159 \dots = 3 + \frac{1}{10} + \frac{4}{10^2} +\frac{1}{10^3} + \frac{5}{10^4}+ \frac{9}{10^5} + \dots$
The above expression is $\pi$.

A: An irrational number is a "gap" inside the rationals. The decimal expansion of any irrational number is an infinite sum converging to it. It gives better and better approximations to the irrational number, which is unfortunately just not "there".
There are many more examples of such limiting constructions. Sometimes you get new objects and sometimes you don't. An example is the delta function which can be approximated using bona fide functions. So there are functions arbitrarily "close" (in some sense) to the delta function, but the delta function itself is just "too good" to be an actual function.
As an aside, if these approximations are good enough, you can prove that the number is transcendental (Legendre's or Roth's theorem).

A: The problem is psychological: you think of the "infinite sum" of rational numbers as an obvious, intuitive concept, but it's not.  It has a precise mathematical meaning, and that precise mathematical meaning only works if you allow the sums to be real numbers (which themselves have a precise mathematical meaning).  The definitions which allow these "infinite sums" to make sense are much less trivial than someone who's never worked through them would think.


text:
Q: Is it possible to use enum's values as value for object key in type declaration? I have enum HealthPlanStatus which was generated by enum HealthPlanStatus. In the end I would like to use enum's keys and values to generate not only status keys for type IHealthPlanResponse but also a title value as enum's values.
export enum HealthPlanStatus {
    Todo = 'To-Do',
    InProgress = 'Working on it',
}
export type IHealthPlanResponse = {
    [status in keyof typeof HealthPlanStatus]: {
        title: string;
    };
};

It gives me strict structure where I have a status key as enum's key (Todo, InProgress...):
type IHealthPlanResponse = {
    readonly Todo: {
        title: string;
    };
    readonly InProgress: {
        title: string;
    };
}

Also I would like to have a title type as enum's values.
For example:
 type IHealthPlanResponse = {
    readonly Todo: {
        title: 'To-Do';
    };
    readonly InProgress: {
        title: 'Working on it';
    };
}

A: Does this work for you?
export enum HealthPlanStatus {
    Todo = 'To-Do',
    InProgress = 'Working on it',
}
export type IHealthPlanResponse = {
    readonly [status in keyof typeof HealthPlanStatus]: {
        title: (typeof HealthPlanStatus)[status];
    };
};

let t: IHealthPlanResponse = {} as any
const status = t.InProgress.title   // -> HealthPlanStatus.InProgress

If you don't like to see the enum 'key' here and want to have the string literal as a type you can change it to this:
export type IHealthPlanResponse = {
    readonly [status in keyof typeof HealthPlanStatus]: {
        title: `${(typeof HealthPlanStatus)[status]}`;
    };
};

let t: IHealthPlanResponse = {} as any
const status = t.InProgress.title   // -> 'Working on it'

A: Amazing approach to use enum in one of type's value.
export enum selectedYearTypeValues {
    'currentYear',
    'All'
}

type Props = {
    selectedYear: keyof typeof selectedYearTypeValues;
    setSelectedYear: (value: keyof typeof selectedYearTypeValues) => void;
}


text:
Q: get all dependencies with versions in spring-context 4.3.6.Release How to get the list of all dependencies with versiosn used in spring-context 4.3.6 Release ? I do see that for spring boot in spring.io page but not for spring-context

A: If you are using maven adding this will resolve all dependencies
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.3.6.RELEASE</version>
    </dependency>

It has following dependencies:

org.springframework:spring-context:4.3.6.RELEASE
  org.springframework:spring-aop:4.3.6.RELEASE
  org.springframework:spring-beans:4.3.6.RELEASE
  org.springframework:spring-core:4.3.6.RELEASE
  commons-logging:commons-logging:1.2
  org.springframework:spring-expression:4.3.6.RELEASE


text:
Q: Declare "container" object from templated template class and variadic templates I need to declare a class which could store different kind of containers. i.e. It would be nice if it could handle std::bitset and std::array.
However, these two classes need a different of template arguments...
Is it possible (and possibly, how) to use templated template classes and variadic templates to declare this kind of class?
Example (but wrong):
template<template <typename..., std::size_t> class Container,
         std::size_t N,
         typename... Args>
class Base_Class
{
    ...
    Container<Args..., N/2> container;
};

The compiler complains that N/2 is not a type. Obviously, for both std::array and std::bitset I need the size to be the last template parameter... Is it possible to code this crazyness?
Thank you!
EDIT:
As far as I am concerned, the main problem is that variadic templates can only be expanded on the right, therefore the variadic parameter must be the last one. Anyone know if there are any plans to allow the following syntax in C++17?
template<typename... Args, typename T>
struct A
{};

A: Anton's answer can be made somewhat less container-specific by using template template parameters for the speciliasations of ResizedContainer:
namespace detail {
    template<typename Container>
    struct ResizedContainer;

    template<template<typename,std::size_t> class Container,
             typename T, std::size_t N>
    struct ResizedContainer<Container<T,N>> {
        using type = Container<T,N/2>;
    };

    template<template<std::size_t> class Container,
             std::size_t N>
    struct ResizedContainer<Container<N>> {
        using type = Container<N/2>;
    };
}

#include <array>
#include <bitset>

template<typename Container>
class Base_Class {
    typename detail::ResizedContainer<Container>::type container;
};

int main() {
    Base_Class<std::array<int,4>> a;
    Base_Class<std::bitset<5>> b;
}

A: Maybe something like this:
namespace detail {
    template<typename Container>
    struct ResizedContainer;

    template<typename T, size_t N>
    struct ResizedContainer<std::array<T, N>> {
        using type = std::array<T, N/2>;
    };

    template<size_t N>
    struct ResizedContainer<std::bitset<N>> {
        using type = std::bitset<N/2>;
    };
}

template<typename Container>
class Base_Class {
    typename detail::ResizedContainer<Container>::type container;
};

int main() {
    Base_Class<std::array<int, 4>> a;
    Base_Class<std::bitset<5>> b;
}


text:
Q: Waiting for response from Telegraf.js user Waiting for user response.  For example, the bot asks the user for his age, he enters it and the bot must catch his answer and send the next question.  How can i do this?

A: You can simply take a look at Telegraf.js documentation to know how.
To wait for a text message and reply, you can do this:
const { Telegraf } = require("telegraf");

const bot = new Telegraf(process.env.BOT_TOKEN); // Your bot api token

// waiting for messages and replying
bot.on("text", (ctx) => {
     ctx.reply("Hello World");
});

bot.start();

To answer to a specific question (Eg: what is your name) you can do something like this:
const { Telegraf } = require("telegraf");

const bot = new Telegraf(process.env.BOT_TOKEN); // Your bot api token

let ask = false;
let name;

bot.on("text", (ctx) => {
     if(ask) {
          name = ctx.message.text;
     } else {
          ask = true;
          ctx.reply("What is your name?");
     }
});

bot.start();


text:
Q: How to send report directly to the printer? I am using Apex 18.2. and ORDS as a printing server.
I have a master-detail page for selling items with a form on a table as the master region and an IG as the detail, joined to each other through assigning the PK to the FK IG's column.
There is another page with a report that can be queried through number of page items to get the documents with items sold in the previously mentioned master-detail page.
Whenever a user creates a document and submit the page, I will need to send the data of that document directly to the printer.
I mentioned the report page because I thought redirecting to it and assigning the PK to the corresponding page item could be a suggestion. But I know that I can create a shared component> report query too. But I do not know how could I send the data directly to the printer in either way.
I do not know if the report type - IR, CR or IG would make a difference. That's why I just referred to "report". But I'd need to know how it could be done with all types of reports.
Here is how a real-world scenario would look like,
You enter a supermarket, buy some items, go to the cashier, pay for what you've bought and get a receipt. The receipt is printed when the cashier saves the invoice.
I know this is not how web apps work, but this is the task I am facing.
I can think of branching to the report page after the invoice is saved and setting the PK value to the corresponding page item in the "search criteria" region to get the corresponding data then execute "window.print()". But there will be two problems then. 1- criteria region would be printed too, unless I hide it with a dynamic action or else. 2- The "print dialog box" of the browser will be displayed.

A: APEX 20.1 added native support for PDF printing of Interactive Grid regions. See this video: https://www.youtube.com/watch?v=e1yIFcEdW_o
If you can't upgrade, or if that support isn't sufficient for your needs, I suggest taking a look at APEX Office Print: https://www.apexofficeprint.com/index.html

A: APEX Office Print(AOP) can provide you the right solution.
Please try out the solution posted in the below link.
http://dgielis.blogspot.com/2020/01/print-pdf-from-oracle-apex-to-local.html
Few more examples:

*

*How to print to an IP printer:
https://www.apexofficeprint.com/ords/aop_web/r/aop_sample_app_web/5034?session=13740999314649

*How to print directly to a zebra printer
https://www.apexofficeprint.com/ords/aop_web/r/aop_sample_app_web/zebra-printer?session=6208952429228
(OR)
https://dgielis.blogspot.com/2020/01/printing-to-local-zebra-printer-from.html
If you are redirected to the Home page,
-> Click on examples in the left side menu.
-> Click on Print(highlighted in yellow).


text:
Q: Type of address and pointers in c I have 2 questions about pointers in c.
1) from my understanding the & returns the memory address of a variable. For example:
int x=10;
int *p=&x;

So I think that the & will return the memory address of x and that memory address is type int* because the variable type of x is int.
Also because the type of the address is  int*  I believe that is the reason that only an int* (and void *) pointer can point in the address (they are the same type).
Any thoughts about that? comments? I don't know if I am correct.
2) It's about the void pointer. I know that the void* pointer can point to any type of variable. For example
int x=10;
void *ptr=&x;

Now I have a function:
void * foo(some parameters)
{
  // just for this example let's say that I return the address of a local variable

  // I know that is wrong to do so because when the foo ends
  // the local variables deallocate

  int k=10;
  void *ptr=&k;
  return ptr;
}

So my pointer is type void but it points to  int* memory address. So ptr will save the address of k and when I return ptr the address of k  is returned which is type int* . But my function is type void*.
What is happening here?

A: According to the C Standard (6.3.2.3 Pointers)

1 A pointer to void may be converted to or from a pointer to any
  object type. A pointer to any object type may be converted to a
  pointer to void and back again; the result shall compare equal to the
  original pointer.

So for example in this code snippet
int x = 10;
void *p = &x;

the expression &x in the right side of the assignment has the type int *. According to the quote it may be converted to pointer of the type void * in the left side of the assignment.

A: 1) Yes all of that is correct.
2) The type of the pointed-at data remains int no matter what kind of pointer that points at it. (This is known as effective type in formal C.) In your example you return a void pointer so that's the type the caller gets. The information of what type it pointed at is lost, from the point you do void *ptr=&k; and onward. This is why void pointers are problematic to use.

A: 1) You are correct
2) It is simply returning a void * that is pointing to k - a local variable. (Any pointers can be cast to void pointers).
You are correct in saying that you should not use the returned value as k no longer exists


text:
Q: unable to assign QQuickText to QString I am trying to dynamically create objects in qml-javascript.The function which creates the object is:
function createSpriteObjects(xPos,yPos,cnt,imgsrc,jsonObject) {
    var title;
    title = jsonObject.matches[cnt].recipeName;
    var component = Qt.createComponent("FlickItem.qml");
    component.createObject(wall.contentItem, {"color":"white", "x":xPos,"y":yPos,"src":imgsrc,"opacity":1,"title":title});
}

The recieving file(FlickItem.qml) has a property string title which is later assigned to the text field of the Text item:
import QtQuick 2.0

Rectangle {
id: name
opacity: 0
property string title: ""
width:100
height:100
color:"white"

property string src: ""

Image {
   id:recipeimages
   source: src
   width:240
   height:160
}
Text {
   id: title
   anchors.bottom: recipeimages.bottom
   anchors.horizontalCenter: recipeimages.horizontalCenter
   anchors.bottomMargin: 5
   color: "white"
   font.pixelSize: 24
   text:title
}

the following error is returned:

unable to assign QQuickText to QString

Any way around this?

A: Rectangle {
id: name
//...
property string title: ""  <------ title
//...
}

Text {
   //...
   id: title   <----- title
   //...
   text:title    <---- which title ?!?!?!
}

The problem is you have a property bound to the title identifier, and an id bound to the title identifier. Based on your output, you are likely trying to assign text from the id (and not the property).
Changing the id of your Text component should solve your problem.


text:
Q: Math Expression on AWS Cloudwatch metrics is not giving expected output I have created two metrics (m1 and m2) on my logs which will give me sum of some filter pattern, I wanted to add math expression in metric to sum these two metrics so I have added SUM([m1,m2]) but it is not giving me actual sum, Please refer below snapshot.

I tried to add expressions as m1+m2 but still no luck. One thing I tried, m1 + 2 is giving me exact sum as 5. Not sure if anything is missing here.
Update (2019-07-18):
Adding stacked snapshot,

A: The SUM() functions sums up values per datapoint. On your last datapoints you have the value 2 for Completed and no value for Failed, so the sum is 2 + 0 = 2. Number widget on the other hand displays the last value returned which for Failed count is 3, but that 3 didn't happen at the last observed time period, it happened before.
You can do few thing here:

*

*Update the metric filter on the logs to emit the value 0 as default if no Failed events are encountered.

*Add a new expression to your graph, FILL(m1, 0), with ID e3 for example, which will give you a continuous line with zeros when there are no failures and the number of failures otherwise. Then you can update your SUM expression to be SUM([m2, e3]).

You can do this on both or your metrics, so you don't have gaps in any of them. This will make the graphing and alarming more consistent and intuitive.


text:
Q: iOS using UIGraphicsGetImageFromCurrentImageContext to detect certain pixels on screen I have a UIView where the user can draw various UIBezierPaths.
I need to analyze the drawn BezierPaths to process certain patterns. I have not found any solution to converting UIBezierPaths to a list of coordinates/points, it seems like this is undoable? It's strange as this data must be stored and used someway to draw the actual paths..
So to bypass this problem i decided to draw the BezierPath with a width of 1px:
[path setLineWidth:1];

And convert my UIView to an UIImage:
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

Then i can identify pixels by getting the color for a certain pixel position at the image:
- (UIColor *)colorAtPixel:(CGPoint)point {
    CGImageRef imageRef = [self CGImage];
    NSUInteger width = CGImageGetWidth(imageRef);
    NSUInteger height = CGImageGetHeight(imageRef);
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    int bytesPerPixel = 4;
    long bytesPerRow = bytesPerPixel * width;
    int bitsPerComponent = 8;

    unsigned char *rawData = (unsigned char*) calloc(height * width * 4, sizeof(unsigned char));

    CGContextRef context = CGBitmapContextCreate(rawData,
                                                 width,
                                                 height,
                                                 bitsPerComponent,
                                                 bytesPerRow,
                                                 colorSpace,
                                                 kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);

    CGColorSpaceRelease(colorSpace);
    CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef);
    CGContextRelease(context);

    // Now your rawData contains the image data in the RGBA8888 pixel format.
    long byteIndex = (bytesPerRow * point.y) + point.x * bytesPerPixel;
    CGFloat red   = (rawData[byteIndex] * 1.0) / 255.0;
    CGFloat green = (rawData[byteIndex + 1] * 1.0) / 255.0 ;
    CGFloat blue  = (rawData[byteIndex + 2] * 1.0) / 255.0 ;
    CGFloat alpha = (rawData[byteIndex + 3] * 1.0) / 255.0;

    byteIndex += 4;
    UIColor *color = [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
    free(rawData);

    return color;
}

Now my issue is that the image generated is blurry, if a draw a straight 1px BezierPath line and convert this to an UIImage, the line has a width of 3x because of it becomming blurry.
How can i solve this? Is there actually no possible way to convert BezierPaths to a list of coordinates?

A: This is due to Anti Alias rendering.
See this question on SO for information on how to turn this of.
I believe that you are better of rendering the beziercurve yourself. It will be faster with a very small memory footprint.

A: You may take a look at this answer from Moritz about using CGPathApply and CGPathApplierFunction.

For each element in the specified path, Quartz calls the applier function, which can examine (but not modify) the element.

That could give you access to the points stored in a UIBezierPath.


text:
Q: \listoffigures not generating I am having an issue with \listoffigures and \listoftables. They are not generating.
Here is what I have so far:
\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{subfig}
\linespread{1.6}
\graphicspath{{Images/}}
\usepackage[a4paper,left=1.5in,top=1in,bottom=1in, right=1in]{geometry}
\usepackage{gensymb}
\usepackage{float}
\usepackage{booktabs}
\usepackage[none]{hyphenat}
\usepackage{tocbibind}
\usepackage{fancyhdr}
\usepackage[toc,page]{appendix}
\usepackage{array}

\begin{document}

\pagenumbering{roman}

\input{abstract}

\chapter*{Dedication}

\chapter*{Acknowledgment}

\tableofcontents

\listoffigures

\listoftables

\chapter{Introduction}
\pagenumbering{arabic}
\setcounter{page}{1}
%\input{Chapters/Chapter1}

\end{document}

and this is how I do my figures:
\begin{figure}
\centering
\includegraphics[scale=0.4]{Images/P66614NCN2.jpg}
\caption[EAN sample]{EAN after some stuff.}
\label{fig:P66614NCN2}
\end{figure}

But for whatever reason, my list of figures and list of tables remains blank. Can't find anything about how to resolve this. Any help?
Here is my file long:
*File List*
report.cls    2014/09/29 v1.4h Standard LaTeX document class
size12.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
inputenc.sty    2015/03/17 v1.2c Input encoding file
utf8.def    2015/09/07 v1.1p UTF-8 support for inputenc
t1enc.dfu    2015/09/07 v1.1p UTF-8 support for inputenc
ot1enc.dfu    2015/09/07 v1.1p UTF-8 support for inputenc
omsenc.dfu    2015/09/07 v1.1p UTF-8 support for inputenc
graphicx.sty    2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
graphics.sty    2014/10/28 v1.0p Standard LaTeX Graphics (DPC,SPQR)
trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
subfig.sty    2005/06/28 ver: 1.3 subfig package
caption.sty    2016/02/21 v3.3-144 Customizing captions (AR)
caption3.sty    2016/05/22 v1.7-166 caption3 kernel (AR)
geometry.sty    2010/09/12 v5.6 Page Geometry
ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
ifvtex.sty    2010/03/01 v1.5 Detect VTeX and its facilities (HO)
ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
geometry.cfg
float.sty    2001/11/08 v1.3d Float enhancements (AL)
booktabs.sty    2005/04/14 v1.61803 publication quality tables
hyphenat.sty    2009/09/02 v2.3c hyphenation utilities
tocbibind.sty    2010/10/13 v1.5k extra ToC listings
fancyhdr.sty
appendix.sty    2009/09/02 v1.2b extra appendix facilities
array.sty    2014/10/28 v2.4c Tabular extension package (FMi)
supp-pdf.mkii
 ***********

A: Because we do not have your used image and the other files you \inputed I changed your given code snippets to a compilable MWE.  With my current version of MiKTeX 2.9 I can compile the MWE without errors.  After the third compile run one will see the table of contents, the list of figures (but not list of tables, because I did not add one).
With the command \listfiles I added you get an list of used packages and version numbers at the end of the log file.  Please compare this list with mine.
MWE:
\listfiles
\documentclass[12pt]{report}

\usepackage[utf8]{inputenc}
\usepackage[demo]{graphicx}
\usepackage{subfig}
\linespread{1.6}
%\graphicspath{{Images/}}
\usepackage[a4paper,left=1.5in,top=1in,bottom=1in, right=1in]{geometry}
%\usepackage{gensymb} % <========================= causes two warnings!
\usepackage{float}
\usepackage{booktabs}
\usepackage[none]{hyphenat} % <============================= Why?
\usepackage{tocbibind}
\usepackage{fancyhdr}
\usepackage[toc,page]{appendix}
\usepackage{array}

\begin{document}

\pagenumbering{roman}

\chapter*{Dedication}
\chapter*{Acknowledgment}

\tableofcontents
\listoffigures
\listoftables

\chapter{Introduction}
\pagenumbering{arabic}
\setcounter{page}{1}
\begin{figure}
  \centering
  \includegraphics[scale=0.4]{Images/P66614NCN2.jpg}
  \caption[EAN sample]{EAN after some stuff.}
  \label{fig:P66614NCN2}
\end{figure}

\end{document}

with the result:

and my list of used packages and version numbers:
 *File List*
  report.cls    2014/09/29 v1.4h Standard LaTeX document class
  size12.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
inputenc.sty    2015/03/17 v1.2c Input encoding file
    utf8.def    2016/02/28 v1.1s UTF-8 support for inputenc
   t1enc.dfu    2016/02/28 v1.1s UTF-8 support for inputenc
  ot1enc.dfu    2016/02/28 v1.1s UTF-8 support for inputenc
  omsenc.dfu    2016/02/28 v1.1s UTF-8 support for inputenc
graphicx.sty    2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
graphics.sty    2016/07/10 v1.0t Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
  pdftex.def    2016/07/10 v0.06j Graphics/color for pdfTeX
infwarerr.sty    2016/05/16 v1.4 Providing info/warning/error messages (HO)
 ltxcmds.sty    2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
  subfig.sty    2005/06/28 ver: 1.3 subfig package
 caption.sty    2016/02/21 v3.3-144 Customizing captions (AR)
caption3.sty    2016/05/22 v1.7-166 caption3 kernel (AR)
geometry.sty    2010/09/12 v5.6 Page Geometry
   ifpdf.sty    2016/05/14 v3.1 Provides the ifpdf switch
  ifvtex.sty    2016/05/16 v1.6 Detect VTeX and its facilities (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
geometry.cfg
   float.sty    2001/11/08 v1.3d Float enhancements (AL)
booktabs.sty    2005/04/14 v1.61803 publication quality tables
hyphenat.sty    2009/09/02 v2.3c hyphenation utilities
tocbibind.sty    2010/10/13 v1.5k extra ToC listings
fancyhdr.sty    2016/09/06 3.8 Extensive control of page headers and footers
appendix.sty    2009/09/02 v1.2b extra appendix facilities
   array.sty    2014/10/28 v2.4c Tabular extension package (FMi)
supp-pdf.mkii
pdftexcmds.sty    2016/05/21 v0.22 Utility functions of pdfTeX for LuaTeX (HO)
ifluatex.sty    2016/05/16 v1.4 Provides the ifluatex switch (HO)
epstopdf-base.sty    2016/05/15 v2.6 Base part for package epstopdf
  grfext.sty    2016/05/16 v1.2 Manage graphics extensions (HO)
kvdefinekeys.sty    2016/05/16 v1.4 Define keys (HO)
kvoptions.sty    2016/05/16 v3.12 Key value format for package options (HO)
kvsetkeys.sty    2016/05/16 v1.17 Key value parser (HO)
etexcmds.sty    2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
 ***********

 )


text:
Q: How do I use conditions in google forms, as I design a form to collect subcategory data Can I use google form to collect multiple answers about an individual or group of individuals.
If the question is : How many people will participate?
And the answer to this is 5 or 6 or 7, (I do not have control over what the answer will be) then google forms will create another set of fields to enter more details about the say 5  people like;
Name:.......... Age:.........
Sex:............   email:.........
Phone number ........
I will then be able to collect all the above details for each person mentioned


text:
Q: Cordova 3.3 plugins do not work I have created a project in the following way, but when I run it in iOS simulator none of the plugins work.
cordova create myApp com.example.myapp myApp
cd myApp
cordova platform add ios
cordova plugin add org.apache.cordova.dialogs
cordova plugin add org.apache.cordova.console
cordova plugin add org.apache.cordova.globalization

Checking the console for navigator.notification for example, returns undefined.

A: Currently there is a bug that requires you to run
cordova build

or specify the platform:
cordova build ios

Before the plugins will work. When you will see the cordova_plugins.js file get populated, you will know the plugins were truly added. Do the same after you remove plugins.
Here's a link to the bug: https://issues.apache.org/jira/browse/CB-5647


text:
Q: Applying an IF condition in Pandas DataFrame I'm using the 2 optional codes to create a new column in my df and include the values wanted as well:
Option 1
cov19.loc[cov19['cases'] <= 10, 'estrats'] = 'Very Low'
cov19.loc[cov19['cases'] > 10 and <= 50, 'estrats'] = 'Low'
cov19.loc[cov19['cases'] > 50 and <= 100, 'estrats'] = 'Medium'
cov19.loc[cov19['cases'] > 100 and <= 1000, 'estrats'] = 'High'
cov19.loc[cov19['cases'] > 1000, 'estrats'] = 'Very High'

Error returned 1:
cov19.loc[cov19['set_of_numbers'] > 10 and <= 50, 'estrats'] = 'Low'
                                            ^
SyntaxError: invalid syntax

Optional code 2
cov19.loc[cov19['cases'] <= 10, 'estrats'] = 'Very Low'
cov19.loc[cov19['cases'] > 10 and cov19['cases'] <= 50, 'estrats'] = 'Low'
cov19.loc[cov19['cases'] > 50 and cov19['cases'] <= 100, 'estrats'] = 'Medium'
cov19.loc[cov19['cases'] > 100 and cov19['cases']<= 1000, 'estrats'] = 'High'
cov19.loc[cov19['cases'] > 1000, 'estrats'] = 'Very High'

Error returned 2
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

A: This is what you would want:
cov19.loc[(cov19['cases'] > 10) & (cov19['cases'] <= 50), 'estrats'] = 'Low'

& here does element-wise AND operation and you wrap the operands to it using parentheses.
Also, a bit more clarification about & vs and :
and is boolean operation where & is bitwise. So, when you want to compute the AND operation between individual components of the objects, use &


text:
Q: dumpbin reporting wrong target architecture for a static library I don't understand why dumpbin is returning x64 when executing the following on the Visual Studio command line:
dumpbin libgmp.lib /HEADERS |more

This is the GMP library compiled under Cygwin 32bit version, with the following build configuration:
./configure --host=i386 ABI=32

The build system compiled and built all the files successfully for the specified host. Yet, dumpbin still reports that the .a or .lib is for 64bit architectures.
Note that the output static library is libgmp.a, but I changed its extension to .lib and linked it with my Visual Studio project with no problems.
Another important note: Linking libgmp.lib with 32bit programs is fine, and produces a PE32 file, as reported by CFF Explorer.
Is it a dumpbin interpretation error, or am I missing something improtant?

A: It appears that there are no 64bit or 32bit static library types. After performing some assertions on the library using objdump and dumpbin, both were reporting correct information.
objdump reported some of the object files to be 64bit and the others 32bits.
dumpbin did the same thing.
The problem boils out from the GMP build system; It embedded both 64bit and 32bit object files into the static library.
Your program will link correctly to 32bit applications as long as you don't use any facilities found in one of the 64bit object files, which explains CFF's output.
In order to fix this problem, you must contact the GMP website.


text:
Q: Get HTML in String Array? How can we display HTML in String Array from strings.xml
please help me!
thanks you very much
jave code:
details.setText(Html.fromHtml(getResources().getString(R.array.GE)));

strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="GE">
<item>
   <![CDATA[១ កាលដើមដំបូងឡើយ ព្រះបានបង្កើតផ្ទៃមេឃ និងផែនដី។]]>
    ២ ឯផែនដីបានខូច ហើយនៅទទេ មានសុទ្ធតែងងឹតនៅគ្របលើជំរៅទឹក ហើយព្រះវិញ្ញាណនៃព្រះក៏រេរានៅពីលើទឹក ៣ នោះព្រះទ្រង់មានព្រះបន្ទូលថា ចូរឲ្យមានពន្លឺឡើង ដូច្នេះ ពន្លឺក៏មានឡើង។ ៤ ព្រះទ្រង់ឃើញពន្លឺនោះក៏យល់ថាជាល្អហើយ រួចទ្រង់ញែកពន្លឺពីងងឹតចេញ ៥ ទ្រង់ហៅពន្លឺថាជាថ្ងៃ ហើយហៅងងឹតថាជាយប់ នោះក៏មានល្ងាចមានព្រឹកឡើង ជាថ្ងៃទី១។
    ៦ បន្ទាប់មក ព្រះទ្រង់មានព្រះបន្ទូលថា ចូរឲ្យមានប្រឡោះនៅកណ្តាលទឹក ដើម្បីញែកទឹកចេញពីគ្នា ៧ ទ្រង់ក៏ធ្វើប្រឡោះនោះ ទាំងញែកទឹកដែលនៅក្រោមប្រឡោះចេញពីទឹកដែលនៅលើប្រឡោះ ក៏មានដូច្នោះ ៨ រួចព្រះទ្រង់ហៅប្រឡោះនោះថាជាមេឃ នោះក៏មានល្ងាចមានព្រឹកឡើង ជាថ្ងៃទី២។
    កំណើតពិភពលោក ៩ បន្ទាប់មក ព្រះទ្រង់មានព្រះបន្ទូលថា ចូរឲ្យទឹកនៅក្រោមមេឃប្រមូលគ្នានៅកន្លែងតែ១ ហើយឲ្យមានទីគោកដុះលេចឡើង នោះក៏មានដូច្នោះ ១០ ទ្រង់ហៅទីគោកនោះថាជាដី ហើយទីទឹកដែលប្រមូលគ្នានោះថាជាសមុទ្រ នោះទ្រង់ក៏ឃើញថាល្អ ១១ រួចទ្រង់មានព្រះបន្ទូលថា ចូរឲ្យដីដុះតិណជាតិឡើង គឺជាពួកស្មៅដែលមានគ្រាប់ និងរុក្ខជាតិមានផ្លែតាមពូជ ដែលមានគ្រាប់ក្នុងផ្លែនោះនៅផែនដី នោះក៏មានដូច្នោះ ១២ ដីក៏ដុះតិណជាតិទាំងឡាយឡើង គឺជាពួកស្មៅដែលមានគ្រាប់តាមពូជ និងរុក្ខជាតិមានផ្លែតាមពូជដែរ ហើយមានគ្រាប់នៅក្នុងផ្លែនោះឯង រួចទ្រង់ឃើញថាល្អ ១៣ នោះក៏មានល្ងាចមានព្រឹកឡើង ជាថ្ងៃទី៣។
    ១៤ បន្ទាប់មក ព្រះទ្រង់មានព្រះបន្ទូលថា ចូរឲ្យមានតួពន្លឺនៅនាផ្ទៃមេឃ ដើម្បីនឹងញែកថ្ងៃចេញពីយប់ សំរាប់ទុកជាទីសំគាល់នៃរដូវ ថ្ងៃ និងឆ្នាំ ១៥ ហើយសំរាប់ជាពន្លឺនៅផ្ទៃមេឃ ដើម្បីបំភ្លឺមកផែនដី នោះក៏មានដូច្នោះ ១៦ ទ្រង់ធ្វើពន្លឺធំជា២តួ ១ដែលធំជាង នោះសំរាប់បំភ្លឺក្នុងពេលថ្ងៃ ហើយ១ដែលតូចជាងសំរាប់បំភ្លឺក្នុងពេលយប់ ក៏ធ្វើឲ្យមានផ្កាយទាំងប៉ុន្មានដែរ។ ១៧ ទ្រង់ដាក់តួពន្លឺទាំងនោះនៅផ្ទៃមេឃ សំរាប់នឹងបំភ្លឺមកលើផែនដី ១៨ ឲ្យមានអំណាចនៅពេលថ្ងៃ និងពេលយប់ ហើយឲ្យញែកពន្លឺចេញពីងងឹត រួចទ្រង់ឃើញថាជាល្អ ១៩ នោះក៏មានល្ងាច មានព្រឹកឡើង ជាថ្ងៃទី៤។
    ២០ បន្ទាប់មក ព្រះទ្រង់មានព្រះបន្ទូលថា ចូរឲ្យមានមច្ឆាជាតិរវើកនៅក្នុងទឹកជាបរិបូរ និងបក្សីជាតិហើរលើដីនៅនាអាកាស ២១ ទ្រង់ក៏បង្កើតអស់ទាំងសត្វសំបើមៗ និងជីវិតទាំងឡាយដែលកំរើក ដែលកើតមានរវិនរវ័ណ្ឌនៅក្នុងទឹកតាមពូជ ហើយអស់ទាំងសត្វស្លាបតាមពូជដែរ រួចទ្រង់ឃើញថាល្អ ២២ ទ្រង់ក៏ប្រទានពរដល់សត្វទាំងឡាយនោះ ហើយមានព្រះបន្ទូលថា ចូរបង្កើតកូនឲ្យចំរើនជាច្រើនឡើង ឲ្យមានពេញពាសនៅក្នុងទឹកសមុទ្រ ហើយឲ្យសត្វស្លាបចំរើនឡើងនៅផែនដីដែរ ២៣ នោះក៏មានល្ងាច មានព្រឹកឡើង ជាថ្ងៃទី៥។
    ២៤ បន្ទាប់មក ព្រះទ្រង់មានព្រះបន្ទូលថា ចូរឲ្យមានចតុប្បាទជាតិកើតមកនៅដីគោកតាមពូជ គឺជាសត្វស្រុកសត្វលូនវារ និងសត្វព្រៃនៅផែនដីតាមពូជ នោះក៏មានដូច្នោះ ២៥ ទ្រង់ក៏ធ្វើសត្វព្រៃនៅផែនដីតាមពូជ សត្វស្រុកតាមពូជ ហើយគ្រប់ទាំងសត្វដែលលូនវារនៅដីគោកតាមពូជ រួចទ្រង់ឃើញថាល្អ ២៦ ទ្រង់ក៏មានព្រះបន្ទូលថា ចូរយើងធ្វើមនុស្សឲ្យដូចជារូបយើង ឲ្យមានភាពដូចយើង ហើយឲ្យមានអំណាចលើត្រីសមុទ្រ សត្វហើរលើអាកាស និងសត្វជើង៤ដែលនៅលើផែនដីទាំងមូល ព្រមទាំងសត្វលូនវារដែលវារនៅលើផែនដីផង ២៧ ទ្រង់ក៏បង្កើតមនុស្សឲ្យដូចរូបអង្គទ្រង់ គឺបានបង្កើតគេឲ្យចំនឹងរូបអង្គទ្រង់នោះឯង ក៏បង្កើតគេឡើងជាប្រុសជាស្រី ២៨ ទ្រង់ប្រទានពរដល់គេ ហើយមានព្រះបន្ទូលថា ចូរបង្កើតកូនឲ្យចំរើនជាច្រើនឡើង ឲ្យមានពេញពាសលើផែនដីចុះ ត្រូវបង្ក្រាបផែនដី ហើយមានអំណាចលើត្រីសមុទ្រ សត្វហើរលើអាកាស និងជីវិតផងទាំងឡាយដែលកំរើកនៅផែនដីផង ២៩ ទ្រង់មានព្រះបន្ទូលថា មើល អញឲ្យគ្រប់ទាំងតិណជាតិមានគ្រាប់ពូជដែលដុះនៅលើផែនដី និងគ្រប់ទាំងរុក្ខជាតិទាំងឡាយដែលកើតផ្លែមានគ្រាប់ពូជ ទុកជាអាហារដល់ឯង ៣០ ហើយអញក៏ឲ្យគ្រប់ទាំងតិណជាតិខ្ចីៗ ទុកជាអាហារដល់អស់ទាំងសត្វនៅលើដី សត្វហើរលើអាកាស និងសត្វលូនវារនៅដី ដែលមានជីវិតទាំងប៉ុន្មានដែរ នោះក៏មានដូច្នោះ ៣១ រួចព្រះទ្រង់ទតគ្រប់ទាំងរបស់ដែលទ្រង់បានធ្វើនោះ ក៏ឃើញថា ទាំងអស់ជាការល្អប្រពៃ នោះក៏មានល្ងាច មានព្រឹកឡើង ជាថ្ងៃទី៦។
</item>
<item>
    ១ ដូច្នេះ ផ្ទៃមេឃ និងផែនដីក៏បានរួចជាស្រេច ព្រមទាំងរបស់សព្វសារពើផង ២ លុះដល់ថ្ងៃទី៧ ការដែលព្រះទ្រង់ធ្វើ នោះបានហើយជាស្រេច ទ្រង់ក៏ឈប់ផ្អាកសំរាកនៅថ្ងៃទី៧នោះ ពីគ្រប់ទាំងការដែលទ្រង់ធ្វើ ៣ ព្រះទ្រង់ក៏ប្រទានពរដល់ថ្ងៃទី៧នោះ ព្រមទាំងញែកទុកជាថ្ងៃបរិសុទ្ធ ពីព្រោះនៅថ្ងៃនោះ ទ្រង់បានឈប់សំរាកពីគ្រប់ទាំងការដែលទ្រង់បានបង្កើតបានធ្វើ។
    ៤ នេះហើយជាដើមកំណើតនៃផ្ទៃមេឃ និងផែនដី ក្នុងកាលដែលបានកើតមក។
    មនុស្សដើមដំបូងបង្អស់
    បុរស និង ស្ត្រី នៅក្នុងសួនអេដែន
    គឺនៅវេលាដែលព្រះយេហូវ៉ាដ៏ជាព្រះទ្រង់បានធ្វើផែនដី និងផ្ទៃមេឃនោះឯង ៥ រីឯនៅផែនដីនោះមិនទាន់មានអ្វីដុះនៅឡើយទេក៏មិនទាន់មានតិណជាតិណានៅវាលដែរ ពីព្រោះព្រះយេហូវ៉ាដ៏ជាព្រះទ្រង់មិនបានបង្អុរភ្លៀងមកលើផែនដីសោះ ហើយក៏គ្មានមនុស្សណានឹងភ្ជួររាស់ដីផង ៦ គ្រាន់តែមានចំហាយឡើងពីដីមកស្រោចស្រប់លើផែនដីប៉ុណ្ណោះ។ ៧ ព្រះយេហូវ៉ាដ៏ជាព្រះទ្រង់យកធូលីដីមកសូនធ្វើជាមនុស្ស ទ្រង់ផ្លុំខ្យល់ដង្ហើមជីវិតបញ្ចូលទៅក្នុងរន្ធច្រមុះ នោះក៏ត្រឡប់ជាមានព្រលឹងរស់ឡើង។
    ៨ រួចព្រះយេហូវ៉ាដ៏ជាព្រះទ្រង់ធ្វើសួនច្បារ១នៅស្រុកអេដែនទិសខាងកើត ក៏ដាក់មនុស្សដែលទ្រង់បានសូនធ្វើឲ្យនៅទីនោះ ៩ ព្រះយេហូវ៉ាដ៏ជាព្រះទ្រង់ក៏ធ្វើឲ្យដីដុះគ្រប់អស់ទាំងដើមឈើដែលគួរពិចពិលរមឹលមើល ហើយសំរាប់ជាអាហារផង ក៏ដាំដើមជីវិតនឹងដើមសំរាប់ដឹងខុសត្រូវនៅកណ្តាលសួនច្បារនោះដែរ ១០ មានទន្លេ១ហូរចេញពីស្រុកអេដែនមកស្រោចសួនច្បារនោះ រួចហូរបែកពីនោះទៅជា៤មុខ ១១ ទី១ឈ្មោះពិសុន គឺជាទន្លេដែលហូរព័ទ្ធស្រុកហាវីឡាដែលមានមាស ១២ មាសដែលមកពីស្រុកនោះជាមាសយ៉ាងល្អ ក៏មានទាំងប្តេល្លាម និងត្បូងអូនីក្សផង ១៣ ទី២ឈ្មោះគីហុន គឺជាទន្លេដែលហូរព័ទ្ធស្រុកគូស ១៤ ទី៣ឈ្មោះហ៊ីដេកែល គឺជាទន្លេដែលហូរចាក់ទៅខាងកើតស្រុកអាសស៊ើរ ហើយទន្លេទី៤ឈ្មោះអ៊ើប្រាត ១៥ ព្រះយេហូវ៉ាដ៏ជាព្រះទ្រង់យកអ័ដាមទៅដាក់នៅក្នុងសួនច្បារអេដែន ឲ្យគាត់ធ្វើការហើយថែរក្សា ១៦ ព្រះយេហូវ៉ាដ៏ជាព្រះទ្រង់បង្គាប់ទៅអ័ដាមថា ឯងនឹងស៊ីផ្លែទាំងអស់ក្នុងសួនច្បារនេះបានតាមចិត្ត ១៧ តែឯត្រង់ដើមដឹងខុសត្រូវ នោះមិនត្រូវឲ្យឯងស៊ីផលឡើយ ដ្បិតនៅថ្ងៃណាដែលឯងស៊ី នោះនឹងត្រូវស្លាប់ជាមិនខាន។
    ១៨ ព្រះយេហូវ៉ាដ៏ជាព្រះទ្រង់មានព្រះបន្ទូលថា ដែលមនុស្សនេះនៅតែម្នាក់ឯង នោះមិនស្រួលទេ អញនឹងធ្វើឲ្យមានម្នាក់ជាជំនួយសំរាប់ជួយវា ១៩ ព្រះយេហូវ៉ាដ៏ជាព្រះទ្រង់បានយកដីមកសូនធ្វើគ្រប់ទាំងសត្វជើង៤ និងសត្វហើរទាំងប៉ុន្មាន រួចក៏នាំមកឯអ័ដាម ដើម្បីឲ្យដឹងជាគាត់នឹងហៅយ៉ាងដូចម្តេច ឯឈ្មោះណាដែលអ័ដាមបានដាក់ឲ្យដល់ជីវិតផងទាំងឡាយ នោះបានសំរេចជាឈ្មោះរបស់សត្វនោះឯង ២០ អ័ដាមដាក់ឈ្មោះឲ្យដល់គ្រប់ទាំងសត្វស្រុក សត្វព្រៃ និងសត្វហើរលើអាកាសទាំងប៉ុន្មានជាស្រេច តែមិនឃើញមានជំនួយណាសំរាប់ឲ្យជួយគាត់សោះ ២១ នោះព្រះយេហូវ៉ាដ៏ជាព្រះទ្រង់ធ្វើឲ្យអ័ដាមដេកលក់ស៊ប់ទៅ រួចទ្រង់យកឆ្អឹងជំនីរគាត់១ ហើយភ្ជិតសាច់ទៅវិញ ២២ រីឯឆ្អឹងដែលព្រះយេហូវ៉ាដ៏ជាព្រះបានយកពីអ័ដាមមក នោះទ្រង់ជបឲ្យកើតឡើងជាមនុស្សស្រី ក៏នាំទៅអ័ដាម ២៣ អ័ដាមក៏ថា នេះហើយជាឆ្អឹងពីឆ្អឹងអញ ជាសាច់ពីសាច់អញ និងត្រូវហៅថា «ស្ត្រី» ពីព្រោះបានយកចេញពីបុរសមក ២៤ ដោយហេតុនោះ បានជាមនុស្សប្រុសនឹងលាចេញពីឪពុកម្តាយខ្លួន ទៅនៅជាប់នឹងប្រពន្ធវិញ ហើយអ្នកទាំង២នោះនឹងត្រឡប់ជាសាច់តែ១សុទ្ធ ២៥ រីឯអ័ដាម នឹងប្រពន្ធគាត់ក៏នៅជាអាក្រាតទទេ ឥតមានសេចក្តីអៀនខ្មាសឡើយ។
</item>
</string-array>
</resources>

A: Please use the following to get the array of html:
String[] arrayHtml= getResources().getStringArray(R.array.GE);

Then set the html to your view:
details.setText(Html.fromHtml(arrayHtml[0]));

UPDATE:
Seems like CData is not supported for a textview. Here is a list of all supported html tags. There might be more though.


text:
Q: How to setup a Web Hook API URL with Post Method
UIB Sandbox Access request.
The webhook URL will be receiving a webhook payload as an input.

A: Get the web hook URL from the application you want to send data
use that URL in webhook section of the application you want to receive data from
choose type of events you want to application to notify you about


text:
Q: Return the sub string How can I use this for x amounts of numbers ? for my approach, its hard coded to 2 substrings. Also is there a better way with less time complexity? There may be a loop hole over here which needs to be fixed about the number of num im passing as I am not using the um parameter at all.

A: Your current approach has a few problems, including a hard-coded maximum number of ngrams, and the fixed ngram size.  In addition, your short variable names and lack of comments do not help explain the code to whoever is reading it.
A simpler solution is to use a map to count the number of times each ngram occurs, and then find the one with the highest count.  That would give rougly N.logN time complexity.  Alternatively unordered_map would be closer to linear time complexity.
There will of course be an edge case where more than one ngram occurs the same highest count.  You would need to decide which of a variety of strategies should be used to resolve that.  In my example, I take advantage of intrinsic ordering of std::map to select the ngram with the lowest sort order.  If using unordered_map, you'd need a different strategy for resolving contention in a deterministic way.
#include <algorithm>
#include <iostream>
#include <map>
#include <string>

std::string ngram(const std::string &input, int num)
{
    if (num <= 0 || num > input.size()) return "";

    // Count ngrams of size 'num'
    std::map<std::string, int> ngram_count;
    for(size_t i = 0; i <= input.size() - num; i++)
    {
        ++ngram_count[input.substr(i, num)];
    }

    // Select ngram with highest count
    std::map<std::string, int>::iterator highest = std::max_element(
        ngram_count.begin(), ngram_count.end(),
        [](const std::pair<std::string, int>& a, const std::pair<std::string, int>& b)
        {
            return a.second < b.second;
        });

    // Return ngram with highest count, otherwise empty string
    return highest != ngram_count.end() ? highest->first : "";
}

int main()
{
    std::cout << ngram("engineering", 2) << std::endl;
    std::cout << ngram("engineering", 3) << std::endl;
    return 0;
}

A: I did it a bit different than paddy, so I thought I would post it. Use std::set. He explains the issue so should get the credit for your answer.
struct test {
    test(const std::string& str) :val(str), cnt(0) {}
    test(const test& thet) { *this = thet; }
    std::string val;
    int cnt;
    friend bool operator < (const test& a, const test& b) { return a.val < b.val; }
};
using test_set_type = std::set<test>;

const test ngram(std::string A, int num) {
    test_set_type set;
    for (auto it = A.begin(); it < A.end() - num + 1; ++it)
    {
        auto found = set.find(std::string(it, it + num));
        if (found != set.end())
            ++const_cast<test&>(*found).cnt;
        else
            set.insert(std::string(it, it + num));
    }
    int find = -1;
    test_set_type::iterator high = set.begin();
    for (auto it = set.begin(); it != set.end(); ++it)
        if(it->cnt > find)
            ++find, high= it;
    return *high;
}

int main() {
    int num = 2;
    std::string word("engineering");
    std::cout << ngram(word, num).val << std::endl;
    return 0;
}


text:
Q: C#, BLE. Why does GetGattServicesAsync hang forever? Is there a work around such as turning off/on BLE? I considered cross posting to the Super User site or similar but don't know how. As you will see this is not just a programming question.
I developed some C# code to communicate with an Onset InTemp thermometer via Bluetooth Low Energy (BLE). It works fine for a long time. I'm able to get beacons (which have the thermometer data) and also connect, get services and characteristics in case I need to get missed data or set parameters on the thermometer. However, after about 8 hours (can be as much as 24 hours) of continuously receiving beacons and connecting, getting historical data, etc., my app hangs on this line:
var gatt = await device.GetGattServicesAsync();

I put lines before and after this line and verified it's clearly hanging on this line. Again, it can be after 8 hours or 24 hours of use. It certainly chugs along just fine for quite a time. Killing and restarting the program is of no help.  It hangs on the first call to:
device = await BluetoothLEDevice.FromBluetoothAddressAsync(args.BluetoothAddress);

Only rebooting the PC fixes the problem. This is not surprising given the messages in the Windows Event Logs before it hangs:

The Bluetooth driver expected an HCI event with a certain size but did not receive it.

It's for this reason that I stated that this might be a SuperUser board question. No matter how badly I programmed my code :), killing the program should get BLE working again. FWIW, I did try disabling/re-enabling BLE through settings before rebooting.
I have found some links to this problem, but nothing very definitive.
I'm also working on writing a smaller, complete program to show the problem.  So far, I can't get example program to fail from which I conclude that either (1) I haven't let it run long enough, or (2) I'm not fully duplicating what is going on with my full program. Perhaps I'm not putting as much pressure on the BLE drivers or I'm not listening for beacons and attempting to connect in the same ratios or with the same timing.
I should say that I see a lot of gripes about Windows implementation of the BLE Host layer and BLE drivers. Unfortunately, I'm stuck with Windows. Nordic also suggested that everything I'm reporting is a "known problem" and using their Nordic dongle will solve the problem. See for example: https://devzone.nordicsemi.com/f/nordic-q-a/65516/using-nrf52840-dongle-as-receiver-client-for-onset-thermometer.
That may well be true, but it would be a lot of work as they have libraries in C++ and Node.JS but not C#.
Any help is greatly appreciated.
Thank you!


text:
Q: Anderson-Darling test - what is adjustment good for I am trying to understand and implement Anderson-Darling test for normal distribution in C++. I've found Octave/Matlab implementation of Anderson-Darling test here, but the critical values differ from values listed at wikipedia.
Authors of mentioned source code had made some kind of adjustment, before they tested the hypothesis. I would like to know for what is this adjustment good for, why is it made?

A: The Anderson-Darling test is a test for a fully specified distribution.
If you use it as a test for normality (without a prespecified mean and variance), the  distribution based on estimated parameters will (almost always) be closer to the data than the true distribution, so tabulated critical values will be too large, resulting in a lower than nominal significance level and lowered power.
The correct distribution of the test statistic under the null needs to take account of this estimation.
This is similar to the relationship between the Kolmogorov-Smirnov and Lilliefors test.
In the case of the A-D, this can be done approximately by an adjustment, as discussed for example in the book Goodness-of-fit Techinques, D'Agostino and Stephens, eds.
The comments in the code you link to not only explicitly discuss this issue (though not especially clearly) -- they also mention the same reference.
It is also discussed in the first paragraph of the Wikipedia link on the Anderson-Darling statistic:

In its basic form, the test assumes that there are no parameters to be estimated in the distribution being tested, in which case the test and its set of critical values is distribution-free. However, the test is most often used in contexts where a family of distributions is being tested, in which case the parameters of that family need to be estimated and account must be taken of this in adjusting either the test-statistic or its critical values


text:
Q: When to use batchSize and limit in mongodb I am little bit confuse in batchSize cursor method and limit.
db.inventory.find().batchSize(10)

and limit
db.inventory.find().limit(10)

What is difference between both the above queries? And when to use batchSize and limit.
Thank you


text:
Q: Nuxt.js routes returning 404 in IIS with IISNODE Just trying to host the nuxt.js and express.js demo in iis with iisnode.
I am getting 404's for the nuxt page routes, but the express api routes are working fine.
All that nuxt does is all express to handle its routes. Not sure why this is not working.
I have set up my web.config with iisnode handler and I have also included the url rewrite config to route everything to the server.prod.js
'use strict';

var Nuxt = require('nuxt');
var app = require('express')();
var host = process.env.HOST || '127.0.0.1';
var port = process.env.PORT || 3000;

app.set('port', port);
// Import API Routes
app.use('/api', require('./api/index'));

// Import and Set Nuxt.js options
var config = require('./nuxt.config.js');
config.dev = !(process.env.NODE_ENV === 'production');

// Init Nuxt.js
var nuxt = new Nuxt(config);
app.use(nuxt.render);

// Build only in dev mode
if (config.dev) {
  nuxt.build().catch(function (error) {
    console.error(error); // eslint-disable-line no-console
    process.exit(1);
  });
}

// Listen the server
app.listen(port, host);
console.log('Server listening on ' + host + ':' + port); // eslint-disable-line no-console

<configuration>
<system.webServer>
   <handlers><add name="iisnode" path="server.prod.js" verb="*" modules="iisnode" /></handlers>
    <rewrite>
      <rules>
        <rule name="myapp">
          <match url="/*" />
          <action type="Rewrite" url="server.prod.js" />
        </rule>
        <!-- Don't interfere with requests for node-inspector debugging -->
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^app.js\/debug[\/]?" />
        </rule>

      </rules>

    </rewrite>
        <directoryBrowse enabled="true" />

        <iisnode devErrorsEnabled="true" debuggingEnabled="true" loggingEnabled="true" nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" />

     <!-- exclude node_modules directory and subdirectories from serving
     by IIS since these are implementation details of node.js applications -->

     <security>
       <requestFiltering>
         <hiddenSegments>
           <add segment="node_modules" />
         </hiddenSegments>
       </requestFiltering>
     </security>

 </system.webServer>
</configuration>

A: IIS Node uses named pipes, therefore the server render api calls on locahost tcp port 80 were failing...
The server-side needs a full url to work.


text:
Q: Function not picking up changed variable, is it not global? So I have a pretty simple quiz made up of 7 select boxes and a submit button. What I'm trying to achieve is to make a warning error pop up if none of the select boxes have been changed, and if they have been changed for it to bring up the score.
I've set up a variable called 'changed' which is false. When one of those select boxes is changed 'changed' becomes true...
This works and I have a console log which shows me its working, however when the submit button is pressed, which calls the function to show the scores or the warning it doesn't seem to recognise that 'changed' has changed to TRUE.
Heres the Jquery...
var changed = false;

$('select').on('change', function () {

var changed = true;
console.log('TRUE');

});

$("#button").click( function(){

var correct = 0;

var selectValue;

var questions = document.getElementsByClassName("question");

var numOfQuestions = questions.length;

for(var i = 0; i < questions.length; i++ ){//begin for loop

//get the value of the select element
selectValue =  questions[i].options[questions[i].selectedIndex].value;

//if the value equals right
if(selectValue === "right"){//begin if then

//increment the correct variable
correct++;

}//end if then

}//end for loop

if(changed === false){
$('#scoreDisplay span').append('WARNING');
}
else{

$('#scoreDisplay span').append(correct);

}
});

you can see it in action here, but you will see it just shows 'WARNING' when you click submit, regardless of whether you've changed any select boxes...  http://gogeye.com/connectquiz/index.html

A: The redefinition of var changed in this event handler:
$('select').on('change', function () {

    // creates a new local variable that is only available inside this function
    var changed = true;
    console.log('TRUE');

});

makes a new local variable that "shadows" and "hides" the changed variable declared in a higher scope.
Remove the var from the one inside your function so it is not creating a new variable of that name, but is instead just setting the higher scoped one:
var changed = false;

$('select').on('change', function () {

    // no var in front of this variable so you are just setting
    // the earlier one, not creating a new one
    changed = true;
    console.log('TRUE');

});

Remember, anytime you declare a variable with var inside a function, it defines a new local variable that is only available within that function.  If that happens to have the same name as a variable in a higher scope, then it overrides that variable name and the interpreter uses the local one instead of the higher scoped one anytime you reference it.
The Javascript interpret does a scope search to resolve a variable reference.  First it looks in the local scope.  If it is found there, then it uses the one it found there.  If it is not found there, it then looks at the next higher scope.  If not found there, it goes up to a higher scope until it gets up to the global scope.  So, the closest scope it finds the variable name in is the one that is used - thus a var or let defined local variable will be used first.

A: remove the 'var' from 'var changed = true'
var changed = false;

$('select').on('change', function () {
  changed = true;
  console.log('TRUE');
});


text:
Q: Role of Mainloops, Event Loops in DBus service This is the standard example of DBus service.
import dbus
import gobject
from dbus import service
# from gi._gobject import MainLoop
from dbus.mainloop.glib import DBusGMainLoop

class DBusServer(service.Object):
    def __init__(self, name, object_path):
        # super(service.Object, self).__init__(name, object_path)
        dbus.service.Object.__init__(self, name, object_path)

    @dbus.service.method("com.test", in_signature='s', out_signature="s")
    def test(self, args):
        return args + " Sent by dbus client"

    @dbus.service.method("com.test", in_signature='s', out_signature="s")
    def foo(self, args):
        return "foo"

bus_loop = DBusGMainLoop(set_as_default=True)
session_bus = dbus.SessionBus()
session_name = service.BusName("com.test", session_bus)
dbus_server = DBusServer(session_name, "/test")

loop = gobject.MainLoop()

try:
    loop.run()
except KeyboardInterrupt:
    loop.quit()

I have questions regarding two mainloops used here
1. What is the role of each mainloop or event loop in this code (if I am using the correct terminology. They both are event loops I guess)
2. If my app is not a GUI app why should I need gobject mainloop or qt   mainloop since that is required to catch user generated events from X11 library (in case of Linux)
3. Why can't I use an infinite loop which does nothing instead of gobject main loop (as follows)
while True:
    pass

A: Below are summarized short answers, see the details at the end for more explanations.
Question 1:
There is only one mainloop being used in the code you posted, the loop = gobject.MainLoop(). Its role is to process events, e.g. D-Bus messages sent to your service.
Question 2:
You need a mainloop in order for your code to not block D-Bus messages coming from outside your service. The dbus-python binding does not have a mainloop implementation so you need to use a mainloop from some other library (which also needs to be one supported by dbus-python, in this case GLib).
Question 3:
An infinite loop like that will never allow for any code other than that particular loop to execute, and there would be no way of receiving D-Bus messages (or any other events).
Details:
Simply put, a mainloop typically processes other events when there is no code currently running in your program. In this case, the nature of D-Bus requires there to be a way for your code to handle events from an external source, i.e. D-Bus messages. This is the reason that you need to have a mainloop. You could base the event processing on a loop you write yourself, as long as you have code in the loop that can process external events. The reason people often use libraries for mainloops is because things tend to grow complex in 'real' applications or systems and it's often more robust to use something which has been tested, used, and improved by others for years (e.g. GLib).
The D-Bus binding dbus-python is implemented in a way that requires an external mainloop to be used, as it does not have its own mainloop implementation. A typical reason for designing a library to use an external mainloop is to let the user of a library decide what mainloop to use, since the mainloop could potentially be used for other things as well (e.g. process other events than D-Bus events). This increases the potential use of the library and reduces the dependencies introduced as a side-effect of using the library.
The library must however support the mainloop of choice which means that there must be some integration provided specifically for each mainloop intended to be used with the library. Typically, the internals of a library like this would be designed to use a class/type that is an abstraction of a mainloop so the code internals doesn't need to know about what mainloop has been integrated. This reduces the amount of code which needs to be mainloop implementation specific within the library.
If you examine the bus_loop object received when doing:
bus_loop = DBusGMainLoop(set_as_default=True)

... you will see that it is an object of type dbus.mainloop.NativeMainLoop which is the mainloop wrapper object in dbus-python.
Now, dbus-python currently only provides an integration for the GLib mainloop so the discussion above becomes a bit theoretical in this case. The way dbus-python integrates a GLib mainloop is to require the user to import and instantiate the GLib mainloop wrapper, like this:
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)

This creates a GLib main context which is later used by a GLib mainloop to process events that dbus-python associates with that context. The last part of the mainloop integration is to require the user to start a GLib mainloop. When you import and run the gobject mainloop, like this:
loop = gobject.MainLoop()
loop.run()

The mainloop will process events from the context created previously. This is the 'link' between the D-Bus binding dbus-python and the GObject binding gobject (which gives access to the GLib mainloop).
Simplified to the extreme, one could say that the context created and set when doing:
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)

is a list of events to process if they appear, and the mainloop created and started when doing:
loop = gobject.MainLoop()
loop.run()

is what makes something check that list. The fact that GLib is used for both things makes it work, again simply put.
If you want to dig further into this, read up on GLib and the GMainLoop and GMainContext and the concepts related to these. Hope this helps.


text:
Q: How to start jQuery toggle collapsed? I'm trying to have a jQuery toggle be collapsed by default.
I have read some other examples, but they weren't quite the same as my setup and I couldn't really figure them out.
This is my HTML:

Options

OPTIONS

and current script:
$('#tgloptions').click(function () {
    $('#options').toggle('fast');
    return false;
});

and jsBin
I managed to get the toggle to work fine. I just want it to not be there on page load and there once clicked.
I played around with adding:
$('#options').collapse("hide")

but couldn't manage to get that bit to work so I removed it.

A: Keep it hidden by adding the line (jsBin):
$('#options').hide();


text:
Q: What can I do when my verilog code worked in Simulation and online debugging with ILA but not barely on FPGA? I am using Verilog to write a quite simple UART send demo. This demo will send out a number after certain seconds. Say the first time it will be 0x00 and the second time it will be 0x01. Every time it will add up one on the previous number.
I used an ila ip core to debug my code and I fixed problems and everything went fine when I had ila in my code. This is what I got in the serial port tool on my PC:

However, after I delete ila in the code. The demo only sent out the number 0x00 and stopped. And I noticed tx is low after sending out 0x00.

I don't know how to continue debugging this code now.
Here is my code:
module uart_send(
    input clk,
    input send_flag,
    input reset,
    input [7:0]data,
    input [2:0]baud_set,
    output reg tx_done,
    output reg tx
    );

    parameter CLK_FREQ = 50000000;

    reg [15:0] baud_cnt;
    reg [15:0] baud;
    reg [3:0] bit_cnt;
/*
ila_0 your_instance_name (
    .clk(clk), // input wire clk

    .probe0(bit_cnt), // input wire [3:0]  probe0
    .probe1(baud_cnt), // input wire [15:0]  probe1
    .probe2(tx_done), // input wire [0:0]  probe2
    .probe3(tx), // input wire [0:0]  probe3
    .probe4(send_flag) // input wire [0:0]  probe4
);*/

    //choose baud rate
    always@(*)
    begin
        case(baud_set)
            0: baud = CLK_FREQ/9600;
            1: baud = CLK_FREQ/115200;

            default: baud = CLK_FREQ/115200;
        endcase
    end

    always@(posedge clk, negedge reset) begin
    if(!reset) begin
        baud_cnt <= 16'h0000;
        bit_cnt <= 4'b0000;
    end
    else begin
        if(baud_cnt == baud-1) begin
            baud_cnt <= 16'h0000;
            bit_cnt <= bit_cnt + 1;
        end
        else
            baud_cnt <= baud_cnt + 1;
    end

    if(!reset) begin
        bit_cnt <= 4'b0000;
    end
    else begin
        if(bit_cnt == 11)
            bit_cnt <= 4'b0000;
    end

    if(send_flag) begin
        if(reset) begin
            case(bit_cnt)
                0: begin tx <= 0; tx_done <= 0; end
                1: tx <= data[0];
                2: tx <= data[1];
                3: tx <= data[2];
                4: tx <= data[3];
                5: tx <= data[4];
                6: tx <= data[5];
                7: tx <= data[6];
                8: tx <= data[7];
                9: tx <= 1;
                10: begin tx <= 1; tx_done <= 1; end

                default: tx <= 1;
            endcase
        end
        else begin
            tx <= 1;
            tx_done <= 0;
        end
    end
    else begin
        tx <= 1;
        tx_done <= 0;
        bit_cnt <= 4'b0000;
        baud_cnt <= 16'h0000;
    end
    end

endmodule

module uart_tx_test(
    input clk,
    input reset,
    output data_out,
    output reg led
    );

    parameter CLK_FREQ = 50000000;

    reg send_flag;
    //reg baud_set;
    reg [7:0] data;
    wire tx_done;

    reg [19:0] div_cnt;
    reg [23:0] led_cnt;
    //reg [19:0] div_limit;

    uart_send u1(
        .clk(clk),
        .send_flag(send_flag),
        .reset(reset),
        .baud_set(3'b001),
        .data(data),
        .tx(data_out),
        .tx_done(tx_done)
    );

    always@(posedge clk, negedge reset) begin
        if(!reset) begin
            div_cnt <= 20'h00000;
            led_cnt <= 24'h00000;
            send_flag <= 0;
            data <= 0;
            led <= 0;
        end
        else begin
            if(div_cnt == 499999) begin
                div_cnt <= 20'h00000;
                data <= data + 1;
                send_flag <= 1;
            end
            else begin
                div_cnt <= div_cnt + 1;
                //send_flag <= 0;
            end

            if(tx_done) begin
                send_flag <= 0;
            end

            if(led_cnt == 9999999) begin
                led_cnt <= 24'h00000;
                led <= ~led;
            end
            else begin
                led_cnt <= led_cnt + 1;
            end
        end
    end
endmodule

A: something wrong with my send_flag signal in the uart_send block, I changed my code and it is ok now.
    module uart_send(
    input clk,
    input send_flag,
    input reset,
    input [7:0]data,
    input [2:0]baud_set,
    output reg tx_done,
    output reg tx
    );

    parameter CLK_FREQ = 50000000;

    reg [15:0] baud_cnt;
    reg [15:0] baud;
    reg [3:0] bit_cnt;

    //choose baud rate
    always@(*)
    begin
        case(baud_set)
            0: baud = CLK_FREQ/9600;
            1: baud = CLK_FREQ/115200;

            default: baud = CLK_FREQ/115200;
        endcase
    end

    always@(posedge clk, negedge reset) begin
        if(!reset) begin
            baud_cnt <= 16'h0000;
            bit_cnt <= 4'b0000;
        end
        else begin
            if(baud_cnt == baud-1) begin
                baud_cnt <= 16'h0000;
                bit_cnt <= bit_cnt + 1;
            end
            else
                baud_cnt <= baud_cnt + 1;
        end

        if(!reset) begin
            bit_cnt <= 4'b0000;
        end
        else begin
            if(bit_cnt == 11)
                bit_cnt <= 4'b0000;
        end

        if(!reset) begin
            tx <= 1;
            tx_done <= 0;
        end
        else begin
            if(send_flag) begin
                case(bit_cnt)
                    0: begin tx <= 0; tx_done <= 0; end
                    1: tx <= data[0];
                    2: tx <= data[1];
                    3: tx <= data[2];
                    4: tx <= data[3];
                    5: tx <= data[4];
                    6: tx <= data[5];
                    7: tx <= data[6];
                    8: tx <= data[7];
                    9: tx <= 1;
                    10: begin tx <= 1; tx_done <= 1; end

                    default: tx <= 1;
                endcase
            end
            else begin
                tx <= 1;
                tx_done <= 0;
                bit_cnt <= 4'b0000;
                baud_cnt <= 16'h0000;
            end
        end
    end
endmodule


text:
Q: no suitable method found to override I checked through possible duplicate but cannot find the answer
I have a interface and in the interface there is 2 methods
void trigger(IOrderBookDisplay orderbook);
void Dispose(bool disposing);

I implemented it implicitly in UserControl1.CS and I got this error
UserControl1.Dispose(bool)': no suitable method found to override
I deleted the
void Dispose(bool disposing);

away and I tried UserControl1:IControl,IDisposable and I got the same error

A: I just had this problem. Don't ask me how, but when I moved my code from the form's Load event into the form's constructor, it went away.


text:
Q: Search a pattern and replace the entire line of a perl module file I have a perl module file. like this :
$release_name       = 'Software Release';
$primary_version    = '1';
$secondary_version  = 'R00.0';
$Main_version   = 'R00.0';

I want to search the Main_version and replace the line to
      $Main_version = R00.1

when i run the script.
I have tried like this. but its not working.
#!/usr/bin/perl -w

use strict;
my $base;
my $file = "/main-dir/work/Myfile.pm";
open(FILE, $file) || die "File not found";
my @base = <FILE>;
close(FILE);
my $item = '$Main_version';
my newitem="R00.1";
foreach $base(@base)
    {
      if($base =~ /$item/){
         $base =~ s/$item/$item='$newitem'/gi;
         print ("Hello, world!\n");
      }
    #else { print $base;}
}
open (BASE, ">$file");
print BASE @base;
close (BASE);

How to search and change the entire line of a perl module? Thanks.

A: Had you used the standard VERSION variable, you could have profited from perl-reversion.
The dollar sign is special in regular expressions, it means "the end of the line". Backslash it, or use quotemeta which could be shortened to \Q in a regex:
$base =~ /\Q$item/


text:
Q: Dialogflow CX - How to clear parameter https://i.stack.imgur.com/uq9Yv.png
https://i.stack.imgur.com/jaPaz.png
https://i.stack.imgur.com/SHIuS.png
How do I get 'number' parameter to clear and output the prompt 'say a number' when I say 'no'?

A: To clear parameters in a session for form filling, you have to set the parameter value in the session to null before transitioning back to a page with form filling.
There are two ways on how to set parameter values to null in a session:

*

*Add the parameters that are needed to be cleared with a null value in the fulfillment parameter presets of an intent/condition route of a page.
a. In your case, you can add the "number" parameter with null value in the fulfillment parameter presets of your "No" intent route of your "Confirm Number" page.

b. When the "No" intent route of the "Confirm Number" page is triggered, the "number" parameter will be cleared in the session and will be transitioned back to the "Insert Number" Page to ask again for the number.

*Set the parameter values to null through fulfillment webhooks. Below is a sample code for reference:
 app.post("/clearnumber", async (request, response) => {
   let params = request.body.sessionInfo.parameters; //get the current parameters in the session
   let message = "\n\n number parameter has been cleared... ";
   console.log("request body:" + request.body);
   console.log(".....number........... :" + params.number);
   params.number = null; // setting the number parameter to null
   console.log("..after.resetting.number........... :" + params.number);
   request.body.sessionInfo.parameters = params; //add the parameter changes in the sessionInfo that will be sent back to the agent
   let fulfillmentResponse = {
     fulfillmentResponse: {
       messages: [{
         text: {
           text: []
         }
       }]
     },
     sessionInfo: request.body.sessionInfo

   };         fulfillmentResponse.fulfillmentResponse.messages[0].text.text.push(message);
   response.json(fulfillmentResponse);
 });

  As you can see in the screenshot below, the results are the same as using parameter presets in the console.


text:
Q: Airflow - No module named 'airflow.contrib.operators.mssql_to_gcs' I found this operator in GitHub https://github.com/apache/airflow/blob/master/airflow/contrib/operators/mssql_to_gcs.py
but when I try to run, I get this error message:
 No module named 'airflow.contrib.operators.mssql_to_gcs'.

What do I need to do to make it work?

A: MsSqlToGoogleCloudStorageOperator was introduced on Apr 22 2019. And it hasn't been released yet. If you want to use it, copy the code and use it as your own plugin.
Reference:
https://github.com/apache/airflow/commits/master/airflow/contrib/operators/mssql_to_gcs.py


text:
Q: How to create columns within an itemize environment? I want to generate a list of the following syntax for a resume.
* <Description of Activity> <empty space> <right aligned date>

Currently I have been using a form such as
\begin{itemize}
\item First Activity \hfill Date 1
\item Second Activity \hfill Date 2
\end{itemize}

This approach works so long as each activity is not very long. If the activity description happens to be too long, the date will wrap poorly. I would like to wrap the activity into a column of its own so that it can wrap to the next line without affecting the date essentially yielding the following
* This is a really long activity that    Date
  spans multiple lines without
  messing up the dates.

I tried nesting a tabular environment, but it didn't work.

A: You can use minipages as in this MWE:

\documentclass{article}
\usepackage{lipsum}
\begin{document}

\begin{itemize}
\item First Activity  ~~ \dotfill ~~ Date 1
\item Second Activity  ~~ \dotfill ~~ Date 2
\item
 \begin{minipage}[t]{8cm}
    This is a really long activity
    that  spans multiple lines without
    messing up the dates.
 \end{minipage}
                   ~~ \dotfill ~~ Date 3

\item
 \begin{minipage}[t]{8cm}
    This is a another long activity
    that spans in more tha one line.
 \end{minipage}
                    ~~ \dotfill ~~ Date 4

\end{itemize}
\end{document}

A: You can place the contents in a tabularx:

\documentclass{article}
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{@{\textbullet\quad}X@{\quad}r@{}}
  First activity & Date 1 \\
  Second activity & Date 2 \\
  \lipsum*[2] & Date 3 \\
  Fourth activity & Date 4
\end{tabularx}
\end{document}

For extending this across page breaks, you could consider ltxtable. This will only break on complete cells.

A: I would set this as a list with the date being set as part of the item label, just offset to the right. Unlike solutions using tables or minipages, using lists allows page breaks mid-item (which is either a feature or not, depending what you want).

\documentclass{article}
\makeatletter
\newenvironment{dateitemize}{%
  \ifnum \@itemdepth >\thr@@\@toodeep\else
    \advance\@itemdepth\@ne
    \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
    \expandafter
    \list
      \csname\@itemitem\endcsname
      {%
      \advance\rightmargin3cm
      \def\makelabel##1{\hss\llap{\textbullet}\rlap{\hbox to \dimexpr\linewidth+\rightmargin+\itemsep\relax{\hss##1}}}}%
  \fi}{%
 \enditemize}

\makeatother
\begin{document}

\noindent X\dotfill X

\noindent X\dotfill X

\begin{dateitemize}
\item[Date 1] First Activity
\item[Date 2] Second Activity
\item[Date 3--Date 4]
    This is a really long activity
    that  spans multiple lines without
    messing up the dates.
\item[Date 4]
    This is a another long activity
    that spans in more tha one line.

\end{dateitemize}
\end{document}