text:
Q: Cleaning shapes of polygon layer with overlaps and gaps using ArcGIS Desktop? I have a layer of polygons where the shapes are quite messy with gaps and overlaps, see example:

It's clear that the polygons are supposed to be contiguous and are supposed to roughly follow the streets.
Does anyone know of a pre-made tool, package, script, etc, or programmatic strategy, that would allow me to clean a dataset like this?
I've heard of the Integrate tool
However this does not completely fix this problem since it modifies nodes of the shape all along it's boundary (not just along the sides where there are gaps/overlaps).

A: Here's several options you might explore.  (You might try different tolerance settings on the Integrate tool (use a copy or an edit session since it operates on your layer directly) but the problem often is that a setting big enough to catch the gaps and overlaps does change the layer elsewhere.)

*

*You can roughly replicate the coverage style clean by using the Feature to Line and Point (inside poly option) tools, then using the Feature to Polygon tool with the points providing the attributes.  You need to set a tolerance but you can keep it small enough not to change shapes generally.  Then you can use the Eliminate tool to automate getting rid of the filled in gaps (select for polys with no attributes) and getting rid of overlaps (select for polys under a certain size, it's not perfect).  This doesn't align polys to your streets.

*You could look at the Snap Geoprocessing Tool.  I haven't used it (ET Geowizards has a tool I've used) but look at its help.  You would use it to snap your polys to the streets edge.  You  may need to play around with the distance settings.  You don't have to do the whole layer at once, you can go around in sections, and select just the polys you want to apply the tool to at any time.

*You could use the align to shape tool on the Advanced Editing toolbar.  This is manual but you can cover a lot of ground depending on the layers.  Start editing your polys, start the tool, select a tolerance buffer big enough to catch most of your gaps and overlaps, turn off your polys, then run the tool across your streets layer for as long as you like, turn your polys back on and make sure the tool has them and not the streets selected, then hit align.  Check your results, you may need to play a bit with the buffer.  If good save your results and repeat.  This does align your polys to the streets.


text:
Q: Access locale information What is the most portable way to access locale information?
I'm interested in time locale data, such as month names, day of week names, local time format etc.
Ideally I'd like a POSIX interface, but if it doesn't exist, glibc-specific one will do.
If possible, getting the information about the locale X shouldn't require setting it (using uselocale() or similar).
Calling strftime() many times with all sorts of parameters is considered a hack, not a solution.
If there's nothing better, I'm willing to consider directly parsing glibc's locale files if there's a reliable way to determine their location.

A: nl_langinfo is a POSIX-standard interface for returning that information and appears to have available all of the things that you're looking for.  Sadly, it does require that you call setlocale before calling it.  I don't see an interface that lets you query an arbitrary locale without first making it the current locale.

redpajama_set_name: RedPajamaStackExchange


text:
Q: do i need a bigsmp kernel? i am trying to build a server for one of my customer.
the hardware is a HP ProLiant DL165, with an 8 core AMD Opteron 6128 and 4GB RAM. the server MUST run under Debian 5 (Lenny) due to a software dependency.
the standard Debian kernel does not support the 8 cores of the opteron and i am forced to use the nosmp boot option, which renders the processor quite useless by using only 1 core...
i read somewhere that i need a bigsmp kernel in order for my distro to support the 8 cores. is it true ? where can i find a bigsmp kernel for Debian 5 ? if i can't find a ready-made one, how do i build a bigsmp kernel ? which config options are relevant ?

A: bigsmp kernel is a kernel with PAE (4GB RAM) and SMP. If you not use bigsmp kernel, you will have only one cpu core and only 3.2Gb RAM

A: A 64-bit kernel shouldn't have this problem. It will support all 8 cores. If you're stuck with 32-bit for some reason, the BigSMP kernel is what you'll need to make it work.


text:
Q: Screensaver Hides Desktop we would like to build a screensaver that shows the desktop and the running applications but prevents user input by showing the login screen. The idea was to build a windows app with no window or a transparent window. However, as soon as the screensaver gets activated the desktop and all applications are hidden from the screen.
Is it possible to start the screensaver without hiding the desktop?
Thx,
bja

A: Why can't you just grab an image of the screen when the SS kicks off.  Then use that as the backdrop of your SS.
Vista has a bubbles screen saver that just starts putting bubbles on the screen.  Not sure how they do it.

A: Is it possible for you to implement this as something other than a screensaver? I'm assuming that the Windows API does have a method that allows you to tell how long the computer has been idle (otherwise, how does the stuff that manages screensavers do it?), so if you use that you could just set up your application such that it's continuously running as a background process, and will pop up a modal dialog box (or your idea of a transparent window) or something that prompts for the user's login info when the computer has been idle for a certain amount of time.

A: You are better off just creating a full-screen application with a transparent window that starts up on a timer like a screensaver. The screensaver functionality while similar to what you are doing, functions much differently.

A: As an alternative suggestion, you could always use a service (or background app) to gather the information you want these monitoring tools to display, or even just to grab periodic screenshots of the (hidden) desktop, and then have your screensaver query that app to get the data it needs to display.
That way, you get the benefit (the secure desktop, the usual Windows login sequence, etc.) of a screensaver, but still get to display what you need to.


text:
Q: What are some of the most compelling applications of Talagrand's concentration inequality? Many have praised this inequality as an incredibly awesome one. Can you point out a few problems where this inequality was crucial? I would especially appreciate the applications where the use of this inequality is easy to follow (such as for example, in combinatorics).

A: In communication complexity: it is at the core of one of the proofs of the $\Omega(n)$ lower bound on the randomized communication complexity of Gap-Hamming, a problem that had remained open until 2010 (when it was first shown by Chakrabarti and Regev).

*

*Alexander A. Sherstov, The Communication Complexity of Gap Hamming Distance (2011)


text:
Q: android how to change the app_name dynamically Is it possible to change the app_name value in String.xml?
not just setTitle();
I know there is a difference of languages may have mutiple xml files
but i still want to change the
<string name="app_name">MyApp</string>

to
<string name="app_name">Good</string>

Is there any way to handle this?
thank you

A: Like Ahmad said, there is no way to do this. But just wanted to point out for you that the res folder is a read-only, so you can't write anything to this programmatically like you wanted to.

A: A solution would just to set a variable to equal your app_name string. And then have the ActionBar or whereever you plan on using the app_name string, just replace it with the
variable you defined before.
Then you can change it at will. Just note that if this is for the actionbar you'll have to make sure to update the action bar after the variable changes.


text:
Q: update a value with addition or subtration I am trying to add or even remove a value and update the table with the new value.
Say I have an agent who has 5 points. I do not want to add a new line or over write the existing with a new value of saying another 5 points. I want it to be 5+5 points of 5 - 5 points. then Update the value in the column.
So far I have found
("Insert Into Bee_Sheet(Agents_Name, Points, Date_added)Values(" + AN + "','" + PNumber + "','" + DateTime.Now + "') ON DUPLICATE KEY UPDATE Points=VALUES(Points)-VALUES(PNumber)

but I error out on my AN which is the agent's name we have in AD. Tells me there is a syntax error near their name which we use first.last name scheme. This should not affect the out come.
So my question is what would be the best way to rewrite the SQL command to be able to add or remove a certain amount from a value and then update it?
If you need more information please let me know.

A: For your syntax error: Your query was missing an opening single quote before your "AN" value.
For your actual question about updating the value, it looks like you're on the right track. Assuming, of course, that you do have a unique index or primary key on your Bee_Sheet table. If you don't have an unique index or pkey, then your query will only ever do the insert.
My only suggestion would be that your UPDATE should probably add PNumber to Points, rather than subtract it.
Insert Into Bee_Sheet
    (Agents_Name, Points, Date_added)
Values
    ('" + AN + "','" + PNumber + "','" + DateTime.Now + "')
 ON DUPLICATE KEY
    UPDATE
        Points=VALUES(Points)+VALUES(PNumber)


text:
Q: Space on the bottom of a divbox Could someone tell me how I could have some empty space on the bottom of my divbox so that the text does not touch the borders?
https://i.imgur.com/PRd1yNg.png
My HTML code:

            <% if (restaurant.reviews.length > 0) { %>

            <% for (let review of restaurant.reviews) { %>

<%= review.review %>

<%= review.title %> - <%= review.user.username %>

            <% } %>
            <% } else { %>

No reviews! Be the first one to post a review.

            <% } %>

CSS code:
.main {
    display: flex;
    justify-content: center;
}

.main .outsideRev {
    background-color: rgba(255, 255, 255, 0.5);
    border: 1px black solid;
    height: 35vh;
    width: 80%;
    overflow: auto;
}

.main .outsideRev .reviews {
    padding: 40px;
    padding-top: 20px;
}

A: This is how I will manage.

*

*Add a wrapper div around the container reviews. I would give a class "margin" to it.

First set the display of class outsideRev to flexbox:
.outsideRev {
  display: flex;
}

Then I would add the following the styling to new div.
.margin {
overflow: hidden scroll;
/*   Makes the content scrollable and not overflow. */
  height: 90%;
/*   Given the space at top and bottom of the container. */
  margin: auto 10px;
/*   Giving a top and bottom margin by auto centering the content vertically. */
}

Output
Hope it helps, thank you.


text:
Q: How to calculate the ewm correlation coefs after groupby E.G, I have following csv data (There are more than one group g in practice):
G,T,x,y
g,1,3,4
g,2,4,5
g,3,6,1
g,4,7,2
g,5,8,3
g,6,9,8

I want to calculate the  exponential weighted correlation coefs between x and y of each group. So I expected the result:
G T     namedWhatever
g 1         NaN
g 2    1.000000
g 3   -0.867510
g 4   -0.792758
g 5   -0.510885
g 6    0.413379

which actually can calculated by:
dat.loc['g'].ewm(halflife=3).corr().loc[:, 'x', 'y']
Out[5]:
T
1         NaN
2    1.000000
3   -0.867510
4   -0.792758
5   -0.510885
6    0.413379
Name: y, dtype: float64

What I have tried without luck:
In [3]: dat = pd.read_csv('test.csv').set_index(['G', 'T'])

In [4]: dat.groupby(level='G').transform(lambda x: x.ewm(halflife=3).corr())
Out[4]:
       x    y
G T
g 1  NaN  NaN
  2  1.0  1.0
  3  1.0  1.0
  4  1.0  1.0
  5  1.0  1.0
  6  1.0  1.0

What's the right way to do it? My pandas version is 0.19.2 and python 3.6.

A: The problem is that corr returns the correlation matrix. So when you do ewm.corr it returns a panel.
So you need to extract the extra diagonal components to get the correlation coefficient.
An explicit solution with a loop is:
res = pd.concat([el.ewm(halflife = 3).corr().xs('x', axis = 1).loc['y', :] for key, el in dat.groupby(level = 'G')])

This is clearer if you inspect el.ewm(halflife = 3).corr():
el.ewm(halflife = 3).corr()
Out[54]:
<class 'pandas.core.panel.Panel'>
Dimensions: 6 (items) x 2 (major_axis) x 2 (minor_axis)
Items axis: (g, 1) to (g, 6)
Major_axis axis: x to y
Minor_axis axis: x to y

Following this answer I realised you can avoid the loop by using the expression above but within an apply rather than transform method on the grouped object.
dat.groupby(level='G').apply(lambda x: x.ewm(halflife=3).corr().xs('x', axis = 1).loc['y', :]).T

In both cases, I obtain the expected output:
res
Out[55]:
G  T
g  1         NaN
   2    1.000000
   3   -0.867510
   4   -0.792758
   5   -0.510885
   6    0.413379
Name: y, dtype: float64


text:
Q: Flow type checking a action$ observable Is it possible to flow type check an observable? I am using redux-observable to build out epics that watch for actions to dispatch and, if there is a match, they run some async code. The action$ argument to the epic is an observable, but there seems to be no Observable<> type in Flow. How does one properly assign a flow type to action$?
// @ flow
const fetchApiEpic = (action$) => {
  ...
};

Contents of action$:

A: It's certainly possible to flow type RxJS and redux-observable, but neither library currently provides official type definitions for them so you'd need to find community ones (if they exist) or create your own.
The flow-typed projects contains unofficial type definitions for RxJS v5, but not any for redux-observable. You could use the TypeScript definition for it as a reference, if you wanted to create your own.


text:
Q: ASP/MySQL interaction If I run:

SELECT id_tara,Donation_Type_TARA, Donation_Date_TARA FROM tara_answers  WHERE Donation_Made_TARA =1 AND test_data IS NULL
on MySQL I get:

If I run:

SELECT id_tara, Donation_Type_TARA,Donation_Date_TARA FROM tara_answers WHERE Donation_Made_TARA =1 AND test_data IS NULL

under ASP I get:

I have tried everything to get the "TO" and "O" types to show up - and for the Data to show up.
Here is the ASP line:
     Response.Write(objRec("id_tara") & "   " & objRec("Donation_Type_TARA") & "   " & objRec("Donation_Date_TARA") & "<br />")

I checked the structure for Donation_Type_TARA it's Varchar(2), Null, utf8_unicode_ci. For the date it's Date.
I've run out of things to check. Thaks. Rick

A: The problem was that my Open statement was above the SQL statement. Thus it was opening a different SQL statement which had an error in it. Sorry to have taken your time. Rick


text:
Q: How to prove that $E(X\mid\sigma\,(\mathcal{G},\mathcal{M}))=E(X\mid\mathcal{M})$ if $\mathcal{G}$ is independent of $X$ and $\mathcal{M}$? I want to prove the following:

Let $X\in L^1(\Omega,\mathcal{F},\mathbb{P})$ be a random variable and suppose $\mathcal{G,M}\subset\mathcal{F}$ are sub–$\sigma$–algebras such that $\mathcal{G}$ is independent of $X$ and $\mathcal{M}$. Prove that $$\mathbb{E}(X\mid\sigma\,(\mathcal{G},\mathcal{M}))=\mathbb{E}(X\mid\mathcal{M}).$$

Following hints from my textbook, I have proved that for all $G\in\mathcal{G}$ and $M\in\mathcal{M}$ $$\int_{G\cap M}\mathbb{E}(X\mid\mathcal{M})\,\text{d}\mathbb{P}=\int_{G\cap M}X\,\text{d}\mathbb{P}.$$
However, there's number of issues I do not understand and I hope you could clarify them to me.
I know that $\mathbb{E}(X\mid\sigma\,(\mathcal{G},\mathcal{M}))$ is the only r.v. $\eta$ such that
(i) $\eta$ is $\sigma\,(\mathcal{G},\mathcal{M})$–measurable,
(ii) $\forall_{A\in\sigma\,(\mathcal{G},\mathcal{M})} \int_A\eta=\int_AX.$
By showing that RHS of the equality in the problem satisfies (i) and (ii), I'm done. However, my questions are:

$1)$ Why is $\mathbb{E}(X\mid\mathcal{M})$ a $\sigma\,(\mathcal{G},\mathcal{M})$–measurable r.v.?
  $2)$ So far, I proved (ii) for $A$'s of the form $A_1\cap A_2$ where $A_1\in\mathcal{G}$, $A_2\in\mathcal{M}$. Does the claim follows from that? If so, why?

Thanks for help!

Edit: Ad question 2): I've just found that it is sufficient to verify (ii) for every set $A$ in some $\pi$–system that contains $\Omega$ and generates $\sigma\,(\mathcal{G},\mathcal{M})$. Is it true that $\{G\cap M\mid G\in\mathcal{G}, M\in\mathcal{M}\}$ is a generator of $\sigma\,(\mathcal{G},\mathcal{M})$? I will strongly appreciate any stories that may possibly improve my understanding of $\sigma$–algebras.

A: *

*Because $E[X\mid \cal M]$ is by definition $\cal M$-measurable and $\cal M\subset \sigma(\cal G,\cal M)$.

*The idea which consists to use $\pi$-system is good. Let $\mathcal{P}:=\{G\cap M,G\in\mathcal{G},M\in\cal M\}$. Then $\cal P\supset \cal M,\cal G$ as $\Omega\in\cal M\cap\cal G$. If $G\in \cal G$ and $M\in\cal M$, then $G\in\sigma(\cal G,\cal M)$ and $M\in\sigma(\cal G,\cal M)$, and their intersection still  will be in $\sigma(\cal G,\cal M)$, proving that $\sigma(\cal P)=\sigma(\cal G,\cal M)$.

Now we conclude showing that the collection of subsets $S$ of $\Omega$ satisfying
$$\int_SE[X\mid \mathcal M]\mathrm{d}\Bbb P=\int_SX\mathrm{d}\Bbb P$$
is a $\lambda$-system.


text:
Q: "There was an error running the selected code: 'Unable to resolve service for type" I'm getting this error while creating a controller in .NET 5
Please help me resolve this ?
enter image description here

A: This link can solve your problem as I think. It seems like you forgot to add something in your collection of service. Check the solution, if it doesn't work let me know your feedback.


text:
Q: .htaccess in multiple query string i try use .htaccess to make clean URL. But i have problem in mutiple query string parameters.
I have three kinds of URL format like this :
 1. http://localhost/websekolah/main.php?page=register
 2. http://localhost/websekolah/main.php?page=detail_news&uid=10
 3. http://localhost/websekolah/main.php?page=gallery&hal=3

And i want my URL like this :
.    1. http://localhost/websekolah/register
     2. http://localhost/websekolah/detail_news/10
     3. http://localhost/websekolah/gallery/hal/3

I create this .htaccess but just only work for 1 query string
RewriteEngine On
RewriteRule ^[css|images|js|config|lib|pages] - [L,NC]
RewriteRule ^(.*)$ main.php?page=$1 [L,QSA]

I check my url redirection using this in main.php :
<?php
    session_start();

    if(isset($_GET['page'])) {
        $page = $_GET['page'];

        $_SESSION['curr_page'] = $page;

        if(isset($_GET['process'])) {

            $process = $_GET['process'];

            if(file_exists("pages/process_$process.php")) {
                include "pages/process_$process.php";
            } else {
                include "pages/404.php";
            }

        } else {
            if(file_exists("pages/body_$page.php")) {
                include "pages/body_$page.php";
            } else {
                include "pages/404.php";
            }
        }

    } else {
        include "pages/body_home.php";
    }
?>

Please help, thank you :)

A: Try changing

RewriteRule ^(.*)$ main.php?page=$1 [L,QSA]

To

RewriteRule ^(.*)$ main.php [L,QSA]

The query parameters will still be in $_GET

A: Use this:
RewriteRule ^([^/]+)/?$ main.php?page=$1 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/?$ main.php?page=$1&uid=$2 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ main.php?page=$1&$2=$3 [L,QSA]
RewriteRule ^$ main.php [L,QSA]


text:
Q: Avoid possible statement with regex How to replace a part of string with avoid a year numbers (f.e. 2019 or 2019-2020) before the first slash occurance with Regex
//something is wrong here
preg_replace('/^[a-z0-9\-]+(-20[0-9]{2}(-20[0-9]{2})?)?/', '$1', $input_lines);

Needed:
abc-def/something/else/ [incl. slash if there is not character before it]
abc-def-2019/something/else/
abc-def-2019-2020/something/else/
abc-def-125-2019/something/else/

A: My initial closure was insufficient to handle all requirements.  Yes, you have a greedy quantifier problem, but there is more to handle.
Code: (Demo) (Regex101 Demo)
$tests = [
    'abc-def/something/else/',
    'abc-def-2019/something/else/',
    'abc-def-2019-2020/something/else/',
    'abc-def-125-2019/something/else/'
];

var_export(
    preg_replace('~^(?:[a-z\d]+-?)*?(?:/|(?=20\d{2}-?){1,2})~', '', $tests)
);

Output:
array (
  0 => 'something/else/',
  1 => '2019/something/else/',
  2 => '2019-2020/something/else/',
  3 => '2019/something/else/',
)

My pattern matches alpha-numeric sequences, optionally followed by a hyphen -- a subpattern than may be repeated zero or more times ("giving back", aka non-greedy, when possible).
Then the first non-capturing group must be followed by a slash (which is matched) or a your year substrings which also may have a trailing hyphen (this is not matched, but found via a lookahead).
If this doesn't suit your real projects data, you will need to provide more and more accurate samples to test against which reveal the fringe cases.

A: If the forward slash has to be present and it should stop after the first occurrence of 2019 or 2020, you might use:
^(?=[a-z\d-]*/)[a-zA-Z013-9-]+(?>2(?!0(?:19|20)(?!\d))|[a-zA-Z013-9-]+)*/?

In separate parts that would look like

*

*^ Start of string

*(?=[a-z\d-]*/) Assert that a / is present

*[a-zA-Z013-9-]+ Match 1+ times any of the listed (Note that the 2 is not listed)

*(?> Atomic group

*

*2(?!0(?:19|20)(?!\d)) Match 2 and assert what is on the right is not 019 or 020

*| Or

*[a-zA-Z013-9-]+ Match 1+ times any of the listed

*)* Close group and repeat 0+ times

*/? Match optional /
Regex demo | Php demo
Your code might look like
preg_replace('~^(?=[a-z\d-]*/)[a-zA-Z013-9-]+(?>2(?!0(?:19|20)(?!\d))|[a-zA-Z013-9-]+)*/?~', '', $input_lines);


text:
Q: adding a highchart into wordpress I'm trying to add a highchart to a custom page template.
So far I've added the below code in-between header in the header file and the added the div into the page template. The issue is that the chart is not showing in my page template.
What could be the reason why it is not showing?
In header file between  tags

in the page template I've added the following

A: It looks like you are trying to load something similar to the jsfiddle example from highcharts.com: http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/line-basic/
Your first error, Uncaught reference: $ is not defined on your Javascript console when loading the page means you are not loading jQuery library, which is a requirement for highcharts.
You have to load jquery before highcharts. The example uses jquery 1.9.1, so you should load that version (or higher) before including the highcharts library. E.g.
...

...

(Be aware that althought this method should work, WordPress has its own and more appropriate way to include jQuery or any javascript library on a page template to avoid conflicts. See http://codex.wordpress.org/Function_Reference/wp_enqueue_script and http://codex.wordpress.org/Function_Reference/wp_register_script )
Your second error is that you have to wait for the container to exist (dom ready) before trying to manipulate its content.
You can do that by using jQuery's document ready function. Something like:

(More info on http://learn.jquery.com/using-jquery-core/document-ready/ )
These related answers might help you too:
How could I embed a HighCharts interactive graph into a wordpress 3.5.1 page?
highcharts and wordpress
Lastly, you might be interested on a couple of FOS wordpress plugins that already do the heavy work of creating a highchart for you:
https://wordpress.org/plugins/rj-quickcharts/
https://wordpress.org/plugins/table2chart/


text:
Q: Creating sections for each different item in a table in html/knockout js I am working on an application in which I have different products with some other data associated with it in an html table with data binded using knockout js. The below code doesnot display products in sections but each product gets displayed as a different product though they are same.
HTML

            Product
            Term
            Location
            Pipeline
            Bid C/P
            Bid Volume
            Index

            Bid
            Offer
            Offer Volume
            Offer C/P

        <input type="text" id="txbReadBid"  data-bind="value: Bid" />

        <input type="text" id="txbReadOffer" data-bind="value: Offer" />

            Product
            Term
            Location
            Pipeline
            Bid C/P
            Bid Volume
            Index

            Bid
            Offer
            Offer Volume
            Offer C/P

From the below screen shot you can see that I have similar products with different other fields but they are not sectioned. Now I would like t have a section for each product like Product C5 has four entries in the table so, I want all of them in a single section and whenever I click on '+' image on the right it adds a row with same product associated with that '+' image and I am trying to add it to the same product section.

A: I have figured out a solution as follows
Index.cshtml

            Term
            Location
            Pipeline
            Bid C/P
            Bid Volume
            Index

            Bid
            Offer
            Offer Volume
            Offer C/P

            Term
            Location
            Pipeline
            Bid C/P
            Bid Volume
            Index

            Bid
            Offer
            Offer Volume
            Offer C/P

Knockout JS
ko.observableArray.fn.extendsdistinct = function (attrib) {var me = this;me.index = {};me.index[attrib] = ko.observable({});ko.computed(function () {var attribIndex = {};ko.utils.arrayForEach(me(), function (item) {var key = ko.utils.unwrapObservable(item[attrib]);if (key) {attribIndex[key] = attribIndex[key] || [];attribIndex[key].push(item);}});me.index[attrib](attribIndex);});return me;};
var CanadianCrudeViewModel = function (CanadianContext) {
    var self = this;
    self.canadiancrudes = ko.observableArray();
    self.products = ko.observableArray();
    self.datainput = ko.observableArray();
    self.loading = ko.observable(true);

self.subsetcanadiancrudes = ko.observableArray(self.datainput()).extendsdistinct('Product');
        self.products = ko.computed(function () {
        var products = ko.utils.arrayMap(self.subsetcanadiancrudes(), function (item) {
            return item.Product;
            })
        return ko.utils.arrayGetDistinctValues(products).sort();
        });
 viewModel.canadiancrudes.push(obsCanadianCrude);
        viewModel.subsetcanadiancrudes.push(obsCanadianCrude);
        viewModel.canadiancrudes.sort(function (left, right) { return left.Product() === right.Product() ? 0 : (left.Product() < right.Product() ? -1 : 1) });


text:
Q: Objective-C - Element-wise addition (and division) of two matrices with Accelerate.framwork I have two matricies (of type float *), so I guess they can be viewed as arrays.
I need to do an element-wise addition of the two matrices, and I would like to increase performance as much as possible. This will be for an iOS app, so I would like to see if the Accelerate.framework has such a function to do this.
The documentation for Accelerate.framework is a bit difficult to understand though. There are a bunch of functions with the word add in them, but I have no idea which or how they work.
Has anyone had to do this before? Can you point me in the correct direction?
NOTE: I will also need to do the same this for division (i.e., element-wise division); and I'd like to also use Accelerate.framework if possible.

A: If your matrices can be viewed as arrays (are contiguous in memory), the functions you're looking for are vDSP_vadd and vDSP_vdiv.


text:
Q: How to locate what produces sound in a website? I want to mute the sound coming from https://open.spotify.com/ website on specific times (using a script I made) in chrome.
I'm searching for the element which is actually producing the sound so I can deactivate/remove it or manipulate it somehow to do so and be able to turn it back on later. However, I couldn't locate what is producing the sound in the webpage.
I tried searching for and found no <audio / <video / <iframe / .swf / .start( in the page's source code. Is there any other way to produce sound with html in chrome?
Otherwise, I guess it's coming from a javascript loaded with the webpage. In the latter case, how can I find which script is the one producing sound? In addition, how can I locate where this specific one is called from in the webpage source code / manipulate it the way I want to?
Thanks


text:
Q: I need help in creating an HTML5 Video Player with an Playlist that automatically plays all videos in the Playlist First of all, I'm not a programmer, I have some basic knowledge in HTML and CSS but when it comes to javascript I'm pretty much lost.
I found this jsfiddle: http://jsfiddle.net/Jzs6B/655/ with an HTML5 Player with a Playlist, is there any possibility to upgrade this player, so that it begins to automatically play the first video in the playlist once the player is loaded, then the second when the first one ended and so on until all Videos in the Playlist have been played from the top to the bottom?
Here is the relevant javascript code:
$(function() {
    $("#playlist li").on("click", function() {
        $("#videoarea").attr({
            "src": $(this).attr("movieurl"),
            "poster": "",
            "autoplay": "autoplay"
        })
    })
    $("#videoarea").attr({
        "src": $("#playlist li").eq(0).attr("movieurl"),
        "poster": $("#playlist li").eq(0).attr("moviesposter")
    })
})

A: Try This
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>mouseover demo</title>
    <script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
    <style>
        #videoarea {
    float:left;
    width:640px;
    height:480px;
    margin:10px;
    border:1px solid silver;
}
    </style>
    <script type="text/javascript">

        var i = 0;
        var totalVideos = 2; //have added 3 videos to source 0 - 2
        var myArray1 = new Array(
"http://html5videoformatconverter.com/data/images/happyfit2.mp4",
"http://grochtdreis.de/fuer-jsfiddle/video/sintel_trailer-480.mp4",
"http://html5example.net/static/video/html5_Video_VP8.webm");
        var now = 0;
        $(function () {
            $("#videoarea").attr({
                "src": myArray1[0]
            })

        });

        function next(e) {
            i += 1;

            $("#videoarea").attr({
                "src": myArray1[i]
            });
            if (i == totalVideos ) {
                i = 0;
            }
        }
    </script>
</head>
<body>
    <div id="AnchorHolder" style="width:50%; height:50%;">
        <video id="videoarea" onended="next(this)" controls="controls" poster="" src="" autoplay></video>
    </div>
    <button onclick='submitForm()'>
        Save</button>
</body>
</html>

Explanation:
1)Store the videos source as an array.
2)Set a counter i = 0 and number of files
3)On onend of a video change src to next object in the array , and set the counter so that it gives 0 after the last video is played.
Hope this helps. Let me know if you need more help. And also accept if the answer solves your issue.


text:
Q: Drawing a grid using dynamic 2D array in C I am trying to draw a grid using dynamically allocated 2D array.
Here is my code,
#include <stdio.h>
#include <stdlib.h>

int main(void){

    int i,j;
    int width;
    int height;

    printf("");
    scanf("%d %d",&height, &width);

    char** arr=malloc(sizeof(char*)*height);
    for ( i = 0; i<height;i++){

            arr[i] = malloc(sizeof(char)*width);

        }

    for ( i = 0; i<height; i++){
        for ( j = 0; j<width; j++){

                arr[i][j] =  '+' ;
                printf("%c\n", arr[i][j]);

            }
        }

    for (int i=0;i<height;i++){
        free(arr[i]);
    }
    free(arr);

    return 0;

}

And if I type 2 2 for height and width,it returns
+

+

+

+

But I am expecting to get
+
+

+
+

Any help would be appreciated.

A: You're printing a newline after each datum, not after each row of data.
Change this:
    for ( j = 0; j<width; j++)
    {
        arr[i][j] =  '+' ;
        printf("%c\n", arr[i][j]); // WRONG: newline after each cell
    }

to this:
    for ( j = 0; j<width; j++)
    {
        arr[i][j] =  '+' ;
        printf("%c ", arr[i][j]);
    }
    fputc('\n', stdout);  // RIGHT: newline after each row.

and for what its worth, the array is utterly useless if all you want to do is draw a grid. Just draw the grid.


text:
Q: calculating max payout. Casino Probability. pls help On a slot mashine there are 4 rolls. each roll has 4 colors. Yellow, Blue, Green, Purple. on each role there are 15 fields where the 4 colors can appear.
Chance for 4 Yellow: 6/15 * 6/15 * 6/15 * 6/15 = 0.0256
Chance for 4 Blue:   4/15 * 4/15 * 4/15 * 4/15 = 0.00505679
Chance for 4 Green: 3/15 * 3/15 * 3/15 * 3/15 = 0.0016
Chance for 4 Purple: 2/15 * 2/15 * 2/15 * 2/15 = 0.00031604938
The cost for 3 spins is 1$.
What should the maximum payout be for each of the colors in order not to generate loss?
Help with how to solve this would be greatly appriciated!!!


text:
Q: Parsing
* tag using beautiful soup Consider this code:
divTag = soup.find_all("div", {"class":"classname"})
print divTag
for tag in divTag:
    ulTag = soup.find_all("ul", {"class":"classname"})
    print ulTag
    for tag in ulTag:
        liTag = soup.find_all("li", {"class":"classname"})
        print liTag
        for tag in liTag:
            diTag = soup.find_all("div", {"class":"classname"})
            print diTag
            for tag in diTag:
                aTags = tag.find_next("a")
                value = aTags.string
                print value

It prints only "divTag" & "ulTag". I'm sure all the class names are right. There are about 7 'li' tags within the 'ul' tag but it does not print any of the 'li' tags. Please help. Thanks in advance.
UPDATE:

"value"  string string1 7 hours ago

I basically want to extract the "string" value within the 'a' tag.

A: Here every time you are searching in soup. So you are failing. You should search for a tag in it's parent tag.
Try something like this:
divTag = soup.find_all("div", {"class":"classname"})
for ulTag in divTag:
    for liTag in ulTag.find_all("li", {"class":"classname"}):
        for tag in liTag.find_all("div", {"class":"classname"}):
            for aTag in tag.find_all('a'):
                print aTag.string

For the html you provided, The output is:
"value"
string1
7 hours ago

A: The full solution with a next_sibling
ulTag = soup.find("ul", {"class": "classname"})
aTags = ulTag.find_all("a")
for aTag in aTags:
    sibling = aTag.next_sibling
    siblingString = str(sibling).strip()
    if len(siblingString) > 0:
        print siblingString


text:
Q: Getting an image imbedded in an NSAttributedString (via NSTextAttachment) to be treated as a single character, so that it doesn't break lines? I'm embedding an image in an NSAttributedString, and I want iOS to treat it as a character that is a part of the word before it, so that it doesn't get broken onto its own line.  I read somewhere that is supposed to be the default behavior, but for the life of me I can't get it to work.  Here's my code (I'm the inserting this attributed string as the title of a button):
    var title = "This is an example string. Test testtt"
    let titleTextString = NSMutableAttributedString(string: title)

    let imageAttachment =  NSTextAttachment()
    imageAttachment.image = UIImage(named:"myIcon")
    imageAttachment.bounds = CGRect(x: 0, y: 1.0, width: 14, height: 6)
    let imageAttachmentString = NSMutableAttributedString(attachment: imageAttachment)

    titleTextString.append(imageAttachmentString)
    button.setAttributedTitle(titleTextString, for: .normal)

Here's an image of what it looks like:

As you can see, there is no whitespace at the end of the string.  I am trying to get the label to consider the text attachment a normal non-whitespace character, and thus part of the word "testtt", which would then cause the "testtt" to be word-wrapped (words are otherwise correctly word-wrapped, and I've set word wrapping on both the label and in the paragraph style of the NSAttributedString).
Complicating this matter is that I found the existence of a non-breaking which solve the problem, but forces other parts of the string to be unnecessarily broken.  If I append a non-breaking space to the end of the string:
var title = "This is an example string. Test testtt" + "\u{A0}"
I then get the correct breaking behavior, but for some reason the previous word is also unnecessarily broken:

Does anyone have any idea how to get this to behavior correctly (i.e., count the image as any other letter, rather than whitespace?)

A: You can accomplish that by adding a zero-width non-breaking space: \u{FEFF} to the end of your original string.
var title = "This is an example string. Test testtt\u{FEFF}"
let titleTextString = NSMutableAttributedString(string: title)

let imageAttachment =  NSTextAttachment()
imageAttachment.image = UIImage(named:"myIcon")
imageAttachment.bounds = CGRect(x: 0, y: 1.0, width: 14, height: 6)
let imageAttachmentString = NSMutableAttributedString(attachment: imageAttachment)

titleTextString.append(imageAttachmentString)
button.setAttributedTitle(titleTextString, for: .normal)

Credit to this SO question+answer In a UILabel, is it possible to force a line NOT to break in a certain place
EDIT:
To answer your question about wrong word wrapped. You can find the answer here. It's a new behavior for word wrapping introduced by Apple.

A:
Set button title label text lineBreakMode as .byWordWrapping and textAlignment as .center to get the output as you aspect, See the following code.
let title = "This is an example string. Test testtt"
let titleTextString = NSMutableAttributedString(string: title)

let imageAttachment =  NSTextAttachment()
imageAttachment.image = UIImage(named:"myIcon")
imageAttachment.bounds = CGRect(x: 0, y: 1.0, width: 14, height: 7)
let imageAttachmentString = NSMutableAttributedString(attachment: imageAttachment)

titleTextString.append(imageAttachmentString)
button.titleLabel?.lineBreakMode = .byWordWrapping
button.titleLabel?.textAlignment = .center
button.setAttributedTitle(titleTextString, for: .normal)


text:
Q: Excel sumproduct combine multi row I want to check A1:A10 whether they are repeated themselves in A1:A10.
I know i can use this formula in B1 to B10.
Is it possible to simplify it by one formula?
=sumproduct(($a$1:$a$10=A1)*1>1)

=sumproduct(($a$1:$a$10=A1:A10)*1>1) ???

A: Yes you could try:

Formula in B1:
=SUMPRODUCT((COUNTIF(A1:A10,A1:A10)>1)*(1/COUNTIF(A1:A10,A1:A10)))

In this case there are two values that are repeated/have duplicates; Test3 and Test4.
In case your goal was only to count ALL rows that have duplicates (repeated values), you can use =SUMPRODUCT((COUNTIF(A1:A10,A1:A10)>1)*1) which in this case would give you 6.
EDIT
For multiple columns, replace COUNTIF with COUNTIFS and extend with the columns you want to compare:

Formula in C1:
=SUMPRODUCT((COUNTIFS(A1:A10,A1:A10,B1:B10,B1:B10)>1)*(1/COUNTIFS(A1:A10,A1:A10,B1:B10,B1:B10)))

A: If you have Office 365 with the new Dynamic Array functions (currently available in the insider build), you can use the Unique() function and compare a count of the range with a count of the unique values of the range.
=COUNTA(UNIQUE(A1:A10))<>COUNTA(A1:A10)

Read more about the new Dynamic Arrays here.


text:
Q: Sony Xperia Z with android lollipop not registering ACTION_USB_DEVICE_ATTACHED I have an external usb device that attaches to the micro usb port on android devices, and everything was working fine on all devices until android lollipop came out. Now it no longer works on Sony Xperia Z phones.
So it works on all devices with 4.0 or greater (and that have usb hosting) except the Sony Xperia Z with lollipop (works fine on the Sony before lollipop).
So the question is, why would it stop working on lollipop and only specifically on the Xperia Z? Something changed on that phone, but I don't know what.
Here is my setup for registering usb devices.
The Manifest File
    <activity
        android:name="com.edgetechlabs.drinkmate_play.MainActivity"
        android:windowSoftInputMode="adjustPan"
        android:screenOrientation="portrait"
        android:launchMode="singleTask"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
            <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"/>
        </intent-filter>
        <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
            android:resource="@xml/device_filter" />
        <meta-data android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"
            android:resource="@xml/device_filter" />
    </activity>

The Device Filter
<resources>
    <usb-device vendor-id="8352" product-id="16881"/>
</resources>

The MainActivity
@Override
public void onResume() {
    super.onResume();
    //get the intent of the activity
    Intent intent = getIntent();
    String action = intent.getAction();
    Log.i(TAG, "MainActivity Resumed with intent " + action);

    //if the device has been plugged in
    if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(intent.getAction())) {
        Log.i(TAG, "Device Attached to start app");
        UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
        setDeviceConnection(device);
    }
}

@Override
public void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Log.i(TAG, "New Intent Recieved " + intent.getAction() + " with dmPluggedIn = " + dmPluggedIn);

    // whenever a new intent is received from an app re-launch due to the device being plugged in
    // or an intent being manually set, set the intent of the app to it only if it was from
    // a device being attached. That way, when the app goes to the background with the device still attached
    // the ATTACHED intent remains (because the MAIN intent is blocked)
    if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(intent.getAction())) {
        System.out.println("changing intent to usb");
        setIntent(intent);
    }
}

To specify why it isn't working, it never registers the USB_DEVICE_ATTACHED intent (either when I plug in the device to start the app, or plug it in when the app has started). All the phone does is ask what kind of keyboard it is you just inserted. I don't know a ton about the device itself (someone else built it), but I can try to get as much information as requested. But it hasn't changed, this code hasn't changed at all since before lollipop came out. The only thing that has changed, is it no longer works on Sony Xperia Z with Lollipop.
UPDATE 1
reading through the logs I discovered
    W/ContextImpl(  858): Calling a method in the system process without a
qualified user: android.app.ContextImpl.sendBroadcast:1355
com.android.server.usb.UsbSettingsManager.blacklistedDeviceDetached:777
com.android.server.usb.UsbHostManager.usbDeviceRemoved:397
com.android.server.usb.UsbHostManager.monitorUsbHostBus:-2
com.android.server.usb.UsbHostManager.access$000:54

    W/BroadcastQueue(  858): Permission Denial: receiving Intent
{act=android.hardware.usb.action.USB_DEVICE_DETACHED flg=0x10 (has extras) }
    to ProcessRecord{3f67a3f 9138:com.edgetechlabs.drinkmate_play/u0a276}
    (pid=9138, uid=10276)
    requires com.sonyericsson.permission.BLACKLISTED_USB_DEVICE due to sender  android (uid 1000)

so I added
<permission
    android:name="com.sonyericsson.permission.BLACKLISTED_USB_DEVICE"
    android:protectionLevel="signature" />

to my manifest but I get
W/PackageManager(  858): Package com.edgetechlabs.drinkmate_play
attempting to redeclare system permission
com.sonyericsson.permission.BLACKLISTED_USB_DEVICE; ignoring new declaration

So something changed with permission with usb devices but I am not sure how to fix the problem. How can i get the device to accept this usb?

A: I was having similar problem before some days. But as Xperia-Z is not a BLACKLISTED_USB_DEVICE, the system permission
<permission
    android:name="com.sonyericsson.permission.BLACKLISTED_USB_DEVICE"
    android:protectionLevel="signature" />

would not hep you.
You need to request for permissions manually to detect device. Please refer: http://developer.android.com/guide/topics/connectivity/usb/host.html#permission-d for more details.
But launching an app on USB attachment is still need to be reached. As per my finding there might be two reasons of failure:

*

*Either the native code is having some issue which is leading to treat device as physical keyboard by-default.
(Ref: Uinput virtual device is detected as physical keyboard on android)

*Or there is issue in Xperia devices. As Sony company itself says, they do not guarantee that all usb devices would be supported on Sony devices. (Ref: http://support.sonymobile.com/global-en/xperiaz4tablet/userguide/Connecting-your-device-to-USB-peripherals/ https://support.sonymobile.com/gb/xperiaz3compact/userguide/Connecting-your-device-to-USB-peripherals/ )


text:
Q: React Children only expected to receive a single react child when using with TouchableWithoutFeedback In my application I have a text input, I want to hide the keyboard and lose focus whenever the user clicks anywhere on the screen or closes the keyboard.
I created this function for this:
interface DismissKeyBoardProps {
  children?: ReactNode
}

const DismissKeyboard: React.FC<DismissKeyBoardProps> = ({ children }) => (
  <TouchableWithoutFeedback
  onPress={() => Keyboard.dismiss()}> {children}
  </TouchableWithoutFeedback>
);

I use the above method like that:
const App: React.FC = () => {

  return (
    <>
      <StatusBar barStyle="dark-content" />
      <SafeAreaView>
        <Text> Test </Text>
        <DismissKeyboard>
          <TextInput placeHolder= {"place holder"}/>
        </DismissKeyboard>
      </SafeAreaView>
    </>
  );
};

However, when I try to run it I get an error:
React.children.only expected to receive a single React element child.
I don't understand why am I getting this error, when DismissKeyBooard has indeed only one child - TextInput.
Edit:
I tried the suggested solution like that, but I keep getting the same error.
  return (
    <View>
      <SafeAreaView>
        <>
          <DismissKeyboard>
            <TextInput style={{height: 40, borderColor: 'gray', borderWidth: 1}} placeHolder={"hint"}/>
          </DismissKeyboard>
        </>
      </SafeAreaView>
    </View>
  );

A: Try to wrap your children with <View>, I guess it will help you.
const DismissKeyboard: React.FC<DismissKeyBoardProps> = ({ children }) => (
  <TouchableWithoutFeedback
  onPress={() => Keyboard.dismiss()}>
   <View>
    {children}
   </View>
  </TouchableWithoutFeedback>
);


text:
Q: Can't open phpmyadmin on browser with Docker I have created a docker-compose.yml file with the following parameters:
version: '3'
services:
 php:
  build: ./docker/images/php
  ports:
   - 80:80
  volumes:
   - ./htdocs:/var/www/html
  container_name: php
  networks:
   - default

 mysql:
  image: mysql:latest
  container_name: mysql
  environment:
   MYSQL_ROOT_PASSWORD: dani
   MYSQL_DATABASE: mysql_database
   MYSQL_USER: dani
   MYSQL_PASSWORD: dani
  ports:
   - "3306:3306"
  volumes:
   - ./dbdata:/var/lib/mysql
  networks:
   - default

 phpmyadmin:
  image: phpmyadmin/phpmyadmin
  container_name: phpmyadmin
  ports:
   - 8080:8080
  environment:
   - PMA_HOST=mysql
  networks:
   - default

networks:
 default:

This is the console output:

But, when I try to go to localhost:8080 :
I can't see phpmyadmin dashboard. What can I do?
Thanks!

A: you can change for image and port by this code:
 phpmyadmin:
  image: phpmyadmin:latest
  container_name: phpmyadmin
  restart: always
  ports:
   - 8080:80
  environment:
   - PMA_HOST=mysql
  networks:
   - default

May be just it for your problem, good luck

A: you have specified the wrong port in the phpmyadmin service, you've to map from 8080 to 80 where the application && try this environement also
Change the port & Env with this one:
ports:
  - 8080:80
environment:
  - PMA_ARBITRARY=1

A: you can Try in your image
phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
      - '8080:80'
    restart: always
    environment:
      PMA_HOST: mysql
    depends_on:
      - mysql
    networks:
      - mysql_network


text:
Q: Xamarin: How to deal with an ACTION_ANSWER Activity I tried to deal with incoming calls to cancel or answer it but I can't.
I tried the following code:
[BroadcastReceiver(Label = "Blocking Calls")]
[IntentFilter(new string[] { "android.intent.action.PHONE_STATE" })]
public class MyReceiver : Android.Content.BroadcastReceiver
{
    private const string IntentAction_BlockingCalls = "android.intent.action.PHONE_STATE";

    public override void OnReceive(Context context, Intent intent)
    {
        if (intent.Action == IntentAction_BlockingCalls)
        {
            // ensure there is information
            if (intent.Extras != null)
            {
                // get the incoming call state
                string state = intent.GetStringExtra(TelephonyManager.ExtraState);

                // check the current state
                if (state == TelephonyManager.ExtraStateRinging)
                {
                    // read the incoming call telephone number
                    string telephoneNumber = intent.GetStringExtra(TelephonyManager.ExtraIncomingNumber);

                    Intent buttonDown = new Intent(Intent.ActionMediaButton);
                    buttonDown.PutExtra(Intent.ActionView, new KeyEvent(KeyEventActions.Down, Keycode.Headsethook));
                    context.SendBroadcast(buttonDown);

                    Toast.MakeText(context, telephoneNumber, ToastLength.Short).Show();  // Flag 4
                    // check the read telephone
                    if (string.IsNullOrEmpty(telephoneNumber))
                        telephoneNumber = string.Empty;
                }
                else if (state == TelephonyManager.ExtraStateOffhook)
                {
                    // Toast.MakeText(context, "The call is answered", ToastLength.Short).Show();  // Flag 5
                    // incoming call answer
                }
                else if (state == TelephonyManager.ExtraStateIdle)
                {
                    // Toast.MakeText(context, "The call have ended", ToastLength.Short).Show();  // Flag 6
                    // incoming call end
                }
            }
        }
    }
}

I fetch the incoming phone number successfully but I can't answer or cancel it.So, I tried to use the action (ActionAnswer) below
Intent A = new Intent(Intent.ActionAnswer);

And as it's appearing in this screen shot from android developer site
image
the output and the input are nothing!!!.
How can I deal with that action? or there are any other methods I can use to cancel the incoming calls?
Thanks for advise.
Here is the link of android developer.
https://developer.android.com/reference/android/content/Intent.html#ACTION_ANSWER

A: Finally, I found the solution and it works fine with me.
That is the part we need.
// check the current state
                if (state == TelephonyManager.ExtraStateRinging)
                {
                    // read the incoming call telephone number
                    string telephoneNumber = intent.GetStringExtra(TelephonyManager.ExtraIncomingNumber);

                    // You can use Endswith, Equals, or any other available methods
                    //if (telephoneNumber.EndsWith("604"))
                    if (telephoneNumber.Equals("01282790604"))
                    {
                         var manager = (TelephonyManager)context.GetSystemService(Context.TelephonyService);

                        IntPtr TelephonyManager_getITelephony = JNIEnv.GetMethodID(
                                manager.Class.Handle,
                                "getITelephony",
                                "()Lcom/android/internal/telephony/ITelephony;");

                        IntPtr telephony = JNIEnv.CallObjectMethod(manager.Handle, TelephonyManager_getITelephony);
                        IntPtr ITelephony_class = JNIEnv.GetObjectClass(telephony);
                        IntPtr ITelephony_endCall = JNIEnv.GetMethodID(
                                ITelephony_class,
                                "endCall",
                                "()Z");
                        JNIEnv.CallBooleanMethod(telephony, ITelephony_endCall);
                        JNIEnv.DeleteLocalRef(telephony);
                        JNIEnv.DeleteLocalRef(ITelephony_class);

                        Toast.MakeText(context, telephoneNumber + "Is Blocked", ToastLength.Long).Show();
                    }


text:
Q: Kubectl: get a shell to a running container under Windows I'm trying to log into running container using Kubectl, according to instructions in https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/, but I'm failing miserably:
kubectl exec -it mycontainer -- /bin/bash

Unable to use a TTY - input is not a terminal or the right kind of
  file rpc error: code = 2 desc = oci runtime error: exec failed:
  container_linux.go:247: starting container process caused "exec:
  \"D:/Applications/Git/usr/bin/bash\": stat
  D:/Applications/Git/usr/bin/bash: no such file or directory"
command terminated with exit code 126

It looks like kubectl tries to exec bash on my machine, which is totally not what I want to achieve.
I can exec commands without spaces:
$ kubectl exec mycontainer 'ls'
lib
start.sh

But with not:
$ kubectl exec mycontainer 'ls .'
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"ls .\": executable file not found in $PATH"

command terminated with exit code 126

What I'm doing wrong?
I've tried both in mingw git shell , as with plain windows console.

A: Seems it might be related to this github issue.
One of the workarounds might be to use winpty as specified here.
winpty kubectl.exe exec -it pod-name -- sh
You can also try /bin/sh instead of /bin/bash it worked for me, but I do not have a Windows machine to check it in the same environment as you.

A: Below command worked for me to launch windows command prompt
kubectl exec -it mycontainer -- cmd.exe


text:
Q: Converting a UIAlertView text into a UILabel Kind of a weird question, I know but i'm wondering how it would be possible to transfer information from a UIAlertView to a UILabel. I've been trying myself for the past few hours with no luck. I'm playing around with some pre-existing code so it is kind of hard for me to follow my steps back as to how they came to populate the UIAlertView, however I'm thinking it'll be easier to display the body text on the Label rather than type over the code. It is also using a REST API which is how the data is being generated (generates 4 different instances depending on political alignment).
Here is a snippet of the UIAlertViewCode
NSData *data = [NSJSONSerialization dataWithJSONObject:result options:0 error:0];

[[[UIAlertView alloc] initWithTitle:@"Response" message:[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show];

will i require any other pieces of code??
thanks in advance :)

A: Store the message in a variable then reuse it:
//message
NSData *data = [NSJSONSerialization dataWithJSONObject:result options:0 error:0];
NSString *message = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

//UIAlert
[[[UIAlertView alloc] initWithTitle:@"Response" message:message
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show];

//UILabel
yourLabel.text = message;


text:
Q: a good program for designing 2d textures to use in XNA? I'm developing a game with Microsoft XNA. I haven't used any modelling program(even 2d modelling) before and I want to learn one. Which program is best ? Is there any free tutorial for it?

A: A few other really good free alternatives:

*

*Paint.NET: Good for bitmap editing

*InkScape: Great for vector art

A: GIMP is pretty common for those with limited (or no) budget.  Beware though, it has a steep learning curve.  Otherwise if you have the money Adobe Illustrator and Photoshop.
If you want to do 3d stuff, Blender (free, open-source), 3ds Max(pricey), Maya(pricey).
There will be tutorials galore for just about any of these tools.
What you often won't find in many of the tutorials though is if you want to use them in a game, you'll probably want to use dxtex and DXT compression after the fact.
This may not be a programming question but for programmers getting into a bit of the technical artist role this is definitely important stuff to know.

A: http://tilestudio.sourceforge.net/ I'm a beginner, and this free program really does the trick. It's really easy to animate, supports copy paste from files, per-pixel editing and all the stuff you need to have for a simple 2d game.


text:
Q: VueJS 2 Directives insert event I'm new VueJS Student, and i was trying to do a directive, and i stopped because i dont know why i can't get the element. What's am i doing wrong? I just want to get the el element.
Here is a JSFiddle or the code below.
HTML

        {{item.name}}

JS
Vue.directive('test', {
  inserted: function (el) {
        document.querySelector('#directiveLog').innerHTML = el;
  }
})

new Vue({
    el: '#vue-app',

  data: {
    itens:[
     {name: "hello"},
     {name: "fun"},
     {name: "world"}
   ]
  }

});

A: Parameter 'el' in function inserted(el) {...} - it is your element where v-test is inserted.

 Vue.directive('test', {
        inserted: function (el) {
            document.querySelector('#directiveLog').innerHTML = el.innerHTML;
  }
})

new Vue({
    el: '#vue-app',

  data: {
    itens:[
     {name: "hello"},
     {name: "fun"},
     {name: "world"}
   ]
  }

});

                    {{item.name}}


text:
Q: What's the difference between "sh command" and run as executable? I used a script suggested by @Artem S. Tashkinov :"I've written this for myself but it runs on console."
See related post here
$sh raw_io.sh:
20: shopt: not found
raw_io.sh:
48: declare: not found
raw_io.sh:
61: Syntax error: redirection unexpected

I found out I just had to make it executable and double-click on it, then "Run in terminal":
Since it is refreshing, I can't copy/paste the output. So I made a screenshot instead:

Since it works from a double-click, but I need to click on "Run in terminal", I was also wondering how to launch it direcly from the terminal.
~/Desktop$ raw_io
raw_iso: command not found

So what's the difference between these ways of launching this?

A: How do you execute a script called myscript?
sh myscript        # Or sh /path/to/myscript
bash myscript      # Or bash /path/to/myscript
perl myscript      # Or perl /path/to/myscript
python myscript    # Or python /path/to/myscript

etc.
This is easy but you do need to know which interpreter to use to run the script, and as you have noticed trying to use the wrong one will generate errors (for example using sh instead of bash).
Better, is to let the script declare the correct interpreter itself. This is defined using the #! on the first line. For example this line would declare bash (specifically /bin/bash) as the interpreter:
#!/bin/bash

To use this feature you need to make the script executable,
chmod a+x myscript

and then provided it is in one of the list of colon-separated directories specified in $PATH you can run it exactly like any other program - with just its name
myscript

However, notice that the current directory (notated as .) is not in $PATH so if you're working on a script in the current directory, you will need to provide a path to the script so that it can be found. Here the . represents current directory and it's a path relative to your current working directory (i.e. the same place):
./myscript    # Or /full/path/to/myscript

There are good reasons why . is not usually in the $PATH, but if you must add it then put it at the end of the $PATH rather than the beginning. (See History of UNIX not including current directory in $PATH and Why is . not in the path by default?.)
Notice that the script name or extension does not matter (unless you end up using a command name such as test that's already present in the system directories listed in $PATH). I've used myscript as the example here. You could use myscript.sh if you wanted, or even confusion.png, but you don't use ls.exe so I don't see a need to have myscript.sh. Be aware, though, that some GUIs may use file extensions to guess what's in the file and using extensions in a nonstandard way (such as png for a script) may confuse them. The proper way for a GUI to identify file contents would be to use an equivalent to the file command, but not all of them do that:
file myscript

Finally, when I've finished working on a script I'm going to reuse I tend to put it into a directory that is included in my $PATH. It then becomes a tool as easy to access as ls or cp. In my case I use $HOME/bin but you can choose any directory you like as long as it's listed in $PATH.


text:
Q: How and why to conjugate verb with and/or subject Which of the following statements is correctly conjugated? Is there a rule or explanation for conjugating verbs with and/or subjects?

The X and/or Y is true.

or

The X and/or Y are true.

Does the plurality of X and Y matter?

A: Actually, it doesn't matter one darn bit if the subjects joined by "and" are singular or plural.

- Rule 1: Subjects joined by "and" will always be plural.
is = singular verb ||||  are = plural verb
Tom and I are awesome. (plural)
Those girls and I are awesome. (plural)
Those girls and boys are awesome. (plural)

- Rule 2: For subjects joined by "or" or "nor", you look at the subject closest to the verb.
is = singular verb |||| are = plural verb
Either those girls or Tom is awesome.  ('Tom' is closest to the verb, so we use a singular verb.)
Either Tom or those girls are awesome. ('Girls' is closest to the verb, so we use a plural verb.)

Edit: To accommodate JanusBahsJacquet's interpretation of this question, I will also answer his question.
When using and/or or or/and, you use the latest conjunction in time.
In the case of "and/or", we would use "or":
Angie and/or Tom is going to pay for this. (We use the singular "is" and not the plural "are" because we are applying the "or" rule.)


text:
Q: adding values before mysql extraction or after? Say this is our sql statement
SELECT points, value
FROM table WHERE x = y

This returns something like this
points  |  color
  5         red
  11        red
  2         blue
  9         blue

I would now like to add the points of the color "red" and add the points of color "blue". And then update the table with the new points.
What is the best approach for this? or is this better solved in a mysql statement before extraction?

A: Maybe you want this?
SELECT SUM(points) AS points, value
FROM yourtable
WHERE x = y
GROUP BY value

If you need  to update the table you can store this result in a tempoary table and then either rename the tables or delete all rows from the original table and then copy them from the temporary table.


text:
Q: How do I code-sign the executable launcher that is created when bundling a JavaFX application? So after much pain I'm coming to the completion of my project and now I need to know how to code sign the executable. No, not the .jar, I know how to do that. What I need is to be able to code-sign the .exe file that launches the .jar for our users, so that they don't see the "Do you want to allow the following program from an unknown publisher" warning message.
I know how to customize the process with an INNO script and I can use that to code-sign the installer, and I know how to include different icon files that will be used for the executables and shortcuts, and I know how to code-sign the jar through the ANT script, but this, this eludes me entirely.
So, does anyone know how I can go about code-signing the .exe that launches the jar when bundling a self-contained JavaFX application?

A: Add the following as first line of package/windows/MyProject.iss file:
#expr Exec("C:\Program Files (x86)\Windows Kits\8.0\bin\x64\signtool.exe", "sign /n CompanyName /tr tsa.starfieldtech.com " + AddBackslash(SourcePath) + "MyProject\MyProject.exe")

To ensure that exe file is writable add package/windows/MyProject-post-image.wsf:
<?xml version = "1.0" ?>
<package>
    <job id="CodeSign">
    <script language = "VBScript">
        <![CDATA[
            'Set File as Normal. . .

            Dim objFSO, objFile
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            Set objFile = objFSO.GetFile("MyProject\MyProject.exe")
            objFile.Attributes = 0

        ]]>
    </script>
    </job>
</package>

A: Okay so I found it. This is pretty painful because there are (if I'm using this term in the correct context) "race conditions" here in that if the code signing doesn't finish before you start running the process again, it fails because it can't do anything with the .exe because it's being used by another process.
Turns out as long as your IDE is running in Admin (for Windows anyway) there's no need to elevate your script either.
Anyay, my problem was that the file was being set as Read-Only. VERY annoying but fortunately VBScript allows for you to change a files attributes so it was just a matter of doing that before trying to code-sign it :
<?xml version = "1.0" ?>
<package>
    <job id="CodeSign">
    <script language = "VBScript">
        <![CDATA[
            'Set File as Normal. . .

            Dim objFSO, objFile
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            Set objFile = objFSO.GetFile("<Relative Path>\<File.exe>")
            objFile.Attributes = 0

            Dim Shell
            Set Shell = WScript.CreateObject("WScript.Shell")
            Shell.Run "<Code Sign> ""<Relative Path>\<File.exe>""", 1, True
            Set Shell = Nothing
            Set objFSO = Nothing
            Set objFile = Nothing
        ]]>
    </script>
    </job>
</package>

So now, finally, at LONG LAST we have a complete and viable answer to this, evidently very esoteric question that no one but myself has dealt with (or is a very closely guarded secret, I'm not sure which) : How do you code-sign the executable created by a JavaFX bundle before it gets stored?

*

*Create a WSF file with either JavaScript or VBScript (your
preference)

*Add the directory in which the file is being stored to the Class Path (for NetBeans you go to Tools -> Options -> Java Tab, select Add Directory next to Class Path, browse to the directory, and add it).

*In your WSF file, in the Script section, get the file object and set its attributes to normal (0).

*Then Shell.Run your preferred method of code signing applications. 1 is for showing the Code Sign window, True is to make the VBScript wait until it's finished to hopefully avoid a race condition.

The .exe will ALWAYS be stored one directory up from the WSF script file so the relative path is always going to be <FILENAME>\<FILENAME.exe>.
I really, REALLY hope this saves someone a LOT of grief some day...

A: Seems that as of Inno Setup 5.5.9 (2016-04-06) there is Flag 'sign' for the Files section that can be used to sign the application exe. You still need to add the .wsf file to package/windows folder as indicated in other answers.
http://www.jrsoftware.org/files/is5-whatsnew.htm


text:
Q: How to convert javascript to LLVM IR? Is there any LLVM backend for javascript? If not, other tools that convert dynamic language(similar to javascript) to LLVM IR will also be okay.
Because I am writing a dynamic language compiler and such tools can help me find out how some features are implemented.

A: FTL JIT (JavaScriptCore) uses LLVM as a backend.
Other VMs for dynamic languages using LLVM MCJIT:

*

*Pyston

*HHVM

*LLILC

*Julia

*The list goes on


text:
Q: Phone validate regex Hi I am trying to make a regular expression on validating phone numbers to start with 02 and be 10 digits(including the 02). This is what I have but it doesn't seem to be working:
/^02[0-9]{8}$/

Thanks for the help

A: If I use the phone number 0234567891, a possible regex could be:
/^(02){1}[0-9]{8}$/

Ensure you match the '02' exactly once and then and 8 digits after.


text:
Q: unexpected T_STRING on first line of code I have been getting an error saying unexpected T_STRING on line 2 of this script:
<? php
session_start();
$incidentKey = $_SESSION['incidentKey'];
$incidentDetailsQuery = mysql_query("SELECT * FROM incidents WHERE incidentKey='".$incidentKey."'");
while ($incidentDetails = mysql_fetch_assoc($incidentDetailsQuery);
?>

And despite looking through the forum heaps, I have had no luck. This was even coming up as an error saying  unexpected T_STRING on line 2 when I the code started like this:
<? php
$incidentKey = $_SESSION['incidentKey'];
etc.....

I've gone through all other includes and couldn't find any missing terminators leading up to this script. Can anyone think why else I would be getting this error?

A: Remove the space in
  <? php

to make it
  <?php


text:
Q: React: update hook variable immediately (to be used by another function for adding/removing event listeners) There is a React component I'd like to refactor to a functional component using hooks. The function looks like this:
const T = () => {
    const [idx, setIdx] = React.useState<number>(0);

    ...

    const func1 = (e: React.MouseEvent<HTMLDivElement>, c: number) => {
        setIdx(c);
        window.addEventListener("mousemove", func2);
    }

    const func2 = (e: MouseEvent) => {
        console.log(idx);
    }
}

func1 is something called on mouse down.
func2 is something that gets called by an event listener while the mouse is dragged. The whole function is quite complex so I'm hoping for minimal restructuring.
How can I get func2 to get the new version of idx?
*Edit:
For some reasons, this has been marked as a duplicate of The useState set method is not reflecting a change immediately The accepted solution from the link (useEffect) does not work in my example for removing event listeners. In my post, the first solution of the accepted answer works (the second part doesn't).

A: If you want idx to be updated immediately don't you should look for a solution combining useEffect and useRef hooks, due to the fact that useState works asynchronously it waits until it gathers all state updates then perform them all for performance.
const refIdx = useRef<number>(0);
   const func1 = (e: React.MouseEvent<HTMLDivElement>, c: number) => {
        refIdx.current = c;
        window.addEventListener("mousemove", func2);
    }
useEffect(() => {
 // perform the action you want to trigger on idxChange here
}, [refIdx.current]}

A: The issue is that func2 is defined when the component is loaded/updated, and since state updates are asynchronous, then when you're adding the event listener, it sets the currently defined func2 with the original idx as the callback.
What you can do is to wrap func2 in a function that takes idx as a parameter and returns a function that can then act as the callback.
Then you add the listener in setState's callback to use the new state value right away.

const { useState } = React

const T = () => {
    const [idx, setIdx] = useState(0);

    const func1 = (e, c) => {
        setIdx(prev => {
          let newIdx = 1; // 1 instead of c for the example
          window.addEventListener("mousemove", func2(newIdx)); // call outer func2 with new state
          return newIdx // set new state
        });
    }

    const func2 = idx => (e) => {
        console.log(idx);
    }

    return
Click Here

}

ReactDOM.render(
<T />,
window.root
)
#drag-me{
width: 100px;
height: 100px;
background-color: beige;
}

You can also use useEffect to add the event listener, but it'll run each time idx is set, including when the component first mounts. You can use states to control this. For example, I used a state that represents func1 being called.

const { useState, useEffect } = React

const T = () => {
    const [idx, setIdx] = useState(0);
    const [funcCalled, setFuncCalled] = useState(false);

    useEffect(()=> {
      if(!funcCalled) return
      const func2 = e => console.log(idx);
      window.addEventListener('mousemove', func2);
      return () =>{
        if (!funcCalled) return
        window.removeEventListener('mousemove', func2)
      } // Cleanup after component unmounts
    },[funcCalled])

    const func1 = (e, c) => {
        setIdx(1) // 1 instead of c for the example
        setFuncCalled(true) // React respects state update order
    }

    return
Click Here

}

ReactDOM.render(
<T />,
window.root
)
#drag-me{
width: 100px;
height: 100px;
background-color: beige;
}

Don't worry about the order of state updates, react will update idx first becfore updating funcCalled. Source


text:
Q: TypeError: g is not a function While re-writing one of my applications from scratch (to go from legacy to AMD) I'm encountering an error which I can't figure out. It is driving me crazy. I'm probably just misspelling something or have another minor mistake, but I just can't figure out what. Any help would be highly appreciated!
I'm still in development mode, so my code isn't that pretty at this time. You can see it live in action at here: http://tpgrf.nl/testserver/alpha/topotrainer/flevoland
The javascript code:
//Define area and url's
var currentPath = window.location.pathname.split('/');
var AREA = currentPath[currentPath.length - 2];
if (AREA == 'europa' || AREA == 'wereld' || AREA == 'nederland') {
    var AREAURL = AREA;
    var AREAisProvince = false;
} else {
    AREAURL = 'nederland';
    var AREAisProvince = true;
}; //Ondervang provincies

var basemapURL = window.location.protocol + "//tiles.arcgis.com/tiles/nSZVuSZjHpEZZbRo/arcgis/rest/services/Topografie_in_de_klas_" + AREAURL + "_ondergrond/MapServer";
var contentFeatureURL = window.location.protocol + "//services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_" + AREAURL + "/FeatureServer/0";

var CONTENT = 'cito100'; //Default to 'cito100', user can adjust manually
var TYPES = ''; //empty for now, will be defined later by the user
var TYPES = 'plaats'; //for testingunction's//
//
function generateUUID() {
    var d = new Date().getTime();
    var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = (d + Math.random() * 16) % 16 | 0;
        d = Math.floor(d / 16);
        return (c == 'x' ? r : (r & 0x7 | 0x8)).toString(16);
    });
    return uuid;
};

//
//Figure something out here to detect if the user as a new or returning visitor
//

//////////////////////////////////////
//Create a basemap and load features//
//////////////////////////////////////
var dojoConfig = { parseOnLoad: true };

var map;
require(["esri/geometry/Extent", "esri/SpatialReference", "esri/map", "esri/graphic", "esri/layers/ArcGISTiledMapServiceLayer", "esri/tasks/query", "esri/tasks/QueryTask", "esri/tasks/FeatureSet", "esri/layers/GraphicsLayer", "esri/Color", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/symbols/PictureMarkerSymbol", "esri/renderers/UniqueValueRenderer", "esri/renderers/ClassBreaksRenderer",
    "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/TitlePane",
    "dojo/domReady!", "dojo/dom", "dojo/on"],
    function (Extent, SpatialReference, Map, Graphic, Tiled, Query, QueryTask, FeatureSet, GraphicsLayer, Color, SimpleMarkerSymbol, SimpleLineSymbol, PictureMarkerSymbol, UniqueValueRenderer, ClassBreaksRenderer, dom, on) {
        //@TODO: Can we actually define this on the basemap mapserver?
        if (AREA == 'nederland' || AREAisProvince == true) {
            var initExtent = new Extent(-165715, 6453119, 1435181, 7205260, new SpatialReference({ wkid: 102100 }));
        }
        if (AREA == 'europa') {
            var initExtent = new Extent(-2827847, 2851709, 6838658, 11375669, new SpatialReference({ wkid: 102100 }));
        }
        if (AREA == 'wereld') {
            var initExtent = new Extent(-19705424, -14849545, 21700207, 21624981, new SpatialReference({ wkid: 102100 }));
        }

        map = new Map("map", {
            extent: initExtent
        });

        //let's add a basemap
        var tiled = new Tiled(basemapURL);
        map.addLayer(tiled);

        where = 'Cito100_onderdeel=1';
        if (AREAisProvince == true) {
            where += ' AND Provincie=\'' + AREA + '\'';
        }
        map.on("load", getFeaturesToMapAndStorage(where));

        function getFeaturesToMapAndStorage(whereClause) {
            console.log(whereClause);
            //query the featureService
            var query = new Query();
            query.returnGeometry = true;
            query.outFields = ["*"];
            query.outSpatialReference = new SpatialReference({ wkid: 102100 });
            query.where = whereClause;

            var queryTask = new QueryTask(contentFeatureURL);

            queryTask.on("complete", function (event) {
                //map.graphics.clear();
                var featureGraphicsLayer = new GraphicsLayer();

                //@TODO: Can't we find a way to use the symbols from the featurservice directly, instead of the url's?
                defaultSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 10,
            new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
            new Color([255, 0, 0]), 1),
            new Color([0, 255, 0, 0.25]));

                var renderer = new UniqueValueRenderer(defaultSymbol, "Type");
                renderer.addValue("Plaats", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/FeatureServer/0/images/89e5f81878a69f9cc0525c841f98af54", 11, 11));
                renderer.addValue("Gebied", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/FeatureServer/0/images/165c76bd4465728a34f6d18df4a1ec03", 28, 28));
                renderer.addValue("Water", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/FeatureServer/0/images/f9c146a401f48c4f38202e83c2e4582a", 22, 22));
                renderer.addValue("Provincie", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/FeatureServer/0/images/7a5373d8f1dcd1ecc03cefbab687b97c", 38, 32));
                renderer.addValue("Land", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_europa/FeatureServer/0/images/7a5373d8f1dcd1ecc03cefbab687b97c", 38, 32));
                renderer.addValue("Werelddeel", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_wereld/FeatureServer/0/images/48f2256a49253388488d813d721c054b", 32, 38));

                var features = event.featureSet.features;
                var featureCount = features.length;
                for (var i = 0; i < featureCount; i++) {
                    var graphic = features[i];
                    featureGraphicsLayer.add(graphic);
                }
                featureGraphicsLayer.renderer = renderer;
                map.addLayer(featureGraphicsLayer);

                //@TODO: Update localstorage

            }); //end on queryTask complete

            queryTask.execute(query, queryComplete);

            function queryComplete() {
                console.log("fire function queryComplete");
                //@TODO: reset progressbar
            }; //End function queryComplete

        } //end function getFeaturesToMapAndStorage

        //The two closing tags below are essential and close the complete DOJO part.
    } //end function after require (AMD style)
    ); //end require

A: Your issue is with: map.on("load", getFeaturesToMapAndStorage(where));
You're calling getFeaturesToMapAndStorage which returns undefined, and passing that in as the "load" handler. I'm guessing that the minified version of whatever it is that you're using uses g as a reference to your handler.
Since g is undefined, you're basically saying undefined(loadEvent).

EDIT: I'm guessing you meant to do something like this:
map.on("load", function(){
    getFeaturesToMapAndStorage(where);
});

EDIT 2: For clarity, I'll explain what was wrong in more detail.
The difference between what you had and what I suggested above, is that you were calling getFeaturesToMapAndStorage on the line containing map.on("load", getFeaturesToMapAndStorage(where)); (as opposed to calling it after map's load event). In order to call your function getFeaturesToMapAndStorage with a predetermined parameter, you need to call it from a function (like the anonymous function above - function(){...}) that would then be passed in as the event handler.
Alternatively, due to how you have things scoped, you could reference your where inside of getFeaturesToMapAndStorage in place of having a whereClause parameter.


text:
Q: My prisoners wont move from the holding to cell to the actual cell I have a cell block with 25 cells but none of my prisoners will move there from the holding cell. I have working power and water beds and toilets they are separate from each other it has all the requirements why wont it work? Any ideas?

A: This behavior is caused by cell quality : some prisoners do not diserve any cell based on cell quality and their behavior.
When you go to "Policy" tab you can choose to enable or disable the cell quality ratings.

This is the description on hoover :

Use Cell Quality
If enabled, Prisoners will only be assigned to a cell of a quality they deserve, based on their behavior. Poorly behaved prisoners will never be assigned to a high quality cell, even if there are no other cells available.
  If disabled, prisoners will be assigned to any cell regardless of quality, but but prisoners in cells of lower quality than average will be more resentful. Prisoners will still be upgraded to higher quality cells if they behave well.

You have a few solutions :

*

*Disable the Cells Quality Ratings

*Build new low quality cells

*Downgrade you cells quality (remove windows, TV, bookshelves, chairs...)

*Wait until you prisoners behave better and deserve a better room (bad idea, they will fight a lot if they are unhappy in an holding cell).

A: If you actually have defined cells, guards will eventually move prisoners into them from the holding cell. If this isn't happening, you may not have enough guards.
If you have free guards and they're still not moving, you can select each prisoner and manually order him into a cell.

A: Cancelling the holding cell room designation will force the prisoners out of the holding cell and allocate them a free cell each.
Once you have more prisoners arriving than you have cells for you can mark the room as a holding cell again.

A: In newer versions, if the prisoner isn't entitled to a room level close to your available rooms, they won't be transferred.
Basically, if you have all high-level (luxurious) cells, your new transfers won't be allowed into them.
Make sure you have some lower-level cells for your transfers until they've had enough good behavior (days without incident) to be allowed into your nicer cells.


text:
Q: What am I allowed to assume in questions like this?
Suppose $T \in \mathcal{L}(V, W)$, and $(w_1, \ldots, w_m)$ is a basis of $\operatorname{range}(T)$. Prove that there exists $(\varphi_1, \ldots, \varphi_m) \in \mathcal{L}(V, \mathbf{F})$ such that $$ T(v) = \varphi_1(v)w_1 + \cdots + \varphi_m(v)w_m $$ for every $v \in V$.

$V$ and $W$ are both vector spaces over a field $\mathbf{F}$.
I always find questions like this hard to understand, and I never know what exactly I am 'allowed' to do. I see two ways of interpreting it:

*

*We define $(\varphi_1, \ldots, \varphi_m) \in \mathcal{L}(V, \mathbf{F})$. These linear maps cannot change, and must be valid for every $v \in V$ such that $T(v) = \varphi_1(v)w_1 + \cdots + \varphi_m(v)w_m$.

*For every $v \in V$, we must be able to define some $(\varphi_1, \ldots, \varphi_m) \in \mathcal{L}(V, \mathbf{F})$ such that $ T(v) = \varphi_1(v)w_1 + \cdots + \varphi_m(v)w_m $ holds. Note that key difference here being we can redefine $(\varphi_1, \ldots, \varphi_m)$ for each $v \in V$.
Clearly there is only one correct interpretation. Which one is it? And if the other interpration was intended, how would the question have been worded differently?

A: The first interpretation is the correct one.
One way you can tell this is the order of the quantifiers. The statement is:

There exist $\phi_1,\ldots,\phi_m \in \mathcal L(V,\mathbf F)$ such that for all $v \in V$ the equation $T(v) = \phi_1(v) w_1 + ... + \phi_m(v) w_m$ holds.

In particular, the quantifier on $v$ coming after the quantifiers on the $\phi$'s tells you that the $\phi$'s cannot depend on $v$.
And then, like any existence proof, what you actually have to do, as you say, is to define $\phi_1,\ldots,\phi_m \in \mathcal L(V,\mathbf F)$ and then use their definitions to verify that the required equation holds (for all $v \in V$).

A: Your first interpretation is the correct one. I agree that the question statement is somewhat unclear, and would be more clear if it were written as follows:

Prove that there exists $(\phi_1, \dots$, such that for all $v\in V$, $T(v) = \dots$.

If the other interpretation had been intended, the question would be worded as

Prove that for any $v\in V$, there exists $(\phi_1, \dots$

or perhaps as

Fix $v\in V$. Prove that there exists $(\phi_1,\dots$


text:
Q: Shrinkage of free disk space (Windows XP) Before you tell me I should change the system, I tell you that my laptop has CPU Pentium Dual Core 2GHz and 2GB RAM, so I don't think newer version of Windows than XP will work on that (maybe 7, if I get one and use minimal settings), and installing Xubuntu or any other Linux distribution means all the games I have and like are going bye bye, probably forever. Not to mention ability of using scanners and printers...
Where free disk space in Windows XP dissapears? I use CCleaner on weekly basis and I recently compressed C:/WINDOWS/Installer (biggest disk space eater, according to WinDirStat) and I got finally 14% of free disk space - for a couple of days. Now again I have only 11% of free disk space and I have no idea why...
Of course I could gain most of disk space by deleting C:/WINDOWS (biggest catalog on C disk), but I can't do that, for obvious reasons. My files take less than 10% of total used disk space.
Total disk C space - 39,06 GB, used - 34,53GB, free - 4,5GB. My Documents and Settings catalog takes 5,40 GB. CCleaner frees 500MB of disk space, at best. C:/WINDOWS - 12,3 GB.
the D partition has 193,8GB total, used 172,5 and free about 20GB. It doesn't contains system files, so it's easier to delete files there. All games are installed on D partition. Music I download (from jamendo and ektoplazm.com) and rip from bought CDs also goes there.
Well, I can always save my files on D partiton (I already moved my photos there), but it hardly changes anything.
Buy another disk? We're talking about laptop here.
"vssadmin 1.0 - administracyjne narzędzie wiersza polecenia Usługi kopiowania woluminów w tle
(C) Copyright 2001 Microsoft Corp.
W systemie brak kopii w tle." - no backgound copies. I hardly see this information useful at this moment.

A: Normally win xp only needs less than 15GB as Microsoft says. practically i installed and used win xp with 6GB drive without any problems. I think you should first do a full scan with a good anti virus program. try disk analyzer program to find what files are taking space in how much capacity. The one i use is a tool that comes with tune-up utilities. it is not free software though. there should be plenty of free alternatives available.Google for it.
then post results here.
or if none of these works, then you can try re installing windows xp as a final resort

A: There are, generally speaking, three reasons for why you may see your free space shrinking:

*

*Temporary files - these are files that are created by almost every piece of software running on your computer and are used to hold data for a short amount of time. Some programs clean up their temporary files (it may depend on the way they are configured) but most don't and these files can end up taking up a lot of space. The most effective solution to this problem would be to install cleanup software like CCleaner, you generally only need to configure it once and run it regularly to keep the temporary files from accumulating. You can also set it up to automatically run the clear on a schedule.

*System restore which is a functionality of the operating system that allows you to restore critical system files to an earlier version in an event that some of them become corrupted. On Windows XP especially System Restore is known to store a lot of restore points, way more than are necessary (from personal experience I can say that having restore points farther than a week ago is pretty useless since restoring from that point means a lot of changes that you've done get undone and at that point you might as well save yourself the hassle and simply reinstall the OS). Long story short you can delete some of the oldest restore points to get some space back (remember to keep a few of the most recent ones though - I once used a restore point to fix a Windows XP OS that refused to boot up because of corrupted registry files).

*In a rare situation that your system needs more memory than your RAM and pagefile can provide the OS may make the pagefile larger. The pagefile is a file that your OS treats as space to store data that was originally stored in RAM but wasn't used for a while and needed to be freed because of new data that needed to be moved into RAM. The solution here is to go into advanced system settings and remove the pagefile, restart the OS and recreate the pagefile with a smaller size (It is recommended for the pagefile to be at least as large as the amount of RAM in your computer).
I won't preach to you about how you should get a new computer since you probably heard it often enough. I would advise you to buy an external hard drive for your data. Not only will it allow you to free some space on your internal hard drive but you can also use it as a backup if your hard drive fails.


text:
Q: Mongo takes too much memory when insert data I'm using mongo as a database log. I store on it all the logs of an application, so I have a high rate of inserts, for example 100 inserts per second. To accomplish that I developed a part of the application dedicated to store in mongo the data. this app only uses a mongo connector.
But the memory consuption is incredible high, I mean after start to use mongo the heap memory has increased in about 300MB and the CPU takes over 90%. Anyone knows how I can decrease this memory consuption or why it is happening?. I've tried to use Mysql and the heap memory keeps normal (only is increased in 20MB) and Cpu doesn't increment as mongo situation.
The data to store is very simple.
in fact I used the following json for separate test with the same results.
{testData:'something i'}
Is there any way to create a datasource with mongo?

A: see this link.   https://groups.google.com/forum/#!topic/mongodb-user/w7G1xRy3TZQ
the bottom line is Mongo caches indexes and data in available RAM

A: What WriteConcern do you use?
If you use WriteConcern.UNACKNOWLEDGED (default) or ERRORS_IGNORED, your writes will not be blocked, and the server will buffer all data to try to keep up. If you send data faster that it can write to disk, it will need to buffer all in memory. Use WriteConcern.JOURNALED to avoid this.
If you have a replica-set, you need to use WriteConcern.MAJORITY for these kinds of usage. I had a similar issue where the primary node acknowledged everything, but the replica's could not follow, resulting in the operations log filling up until it ran out of disk space.
Greets.

A: Its all about how you design your database try to use normalization or embedded documents here is reference doc here is the link
go through it you can understand  the data modeling concepts.


text:
Q: Проблемы с Retrofit'ом в API 28 и выше Написал приложение погоды и все это время тестировал на виртуальном устройстве. Там оно работает и выполняет все функции. Но вот после установки на мой телефон Xiaomi у меня просто крутится ProgressBar (который я установил во время загрузки и получения данных). Протестировал на другой телефоне Samsung Galaxy A3 и все заработало так же, как и на виртуальном устройстве. Потом взял другой телефон Xiaomi - та же беда с ProgressBar. Как я понял дело именно в прошивке MiUI. Кто-нибудь сталкивался с этим? И как это исправить?

A: Проблема была в протоколе http, а точнее в его использовании. Как мне посоветовал ЮрийСПб я изменил тип протокола на https и программа заработала корректно на всех версиях Android


text:
Q: How to run Selenium in parallel using TestNG? I'm trying to run two methods that belong to same class in parallel. My code launches two separate browsers, but when the first method completes, instead of killing that particular browser, it kills the other browser.
Method A - Browser A - Say it takes 20 seconds
Method B - Browser B - Say it takes 40 seconds
When Method A is done, it kills Browser B instead of Browser A.
Here is my code:
public class AccountTest {

    private WebDriver driver;

    @BeforeMethod(alwaysRun=true)
    public void initializeDriver() throws MalformedURLException {
        driver = new FirefoxDriver();
        driver.manage().deleteAllCookies();
        driver.manage().window().maximize();
    }

    @Test(groups="Login")
    public void loginTest() {
        HomePage homePage = new HomePage(driver);
        SignInPage signInPage = homePage.signIn();
        signInPage.signIn("test_user0401@fakemail.com", "abcd1234");
    }

    @Test(groups="Register")
    public void registerTest() {
        HomePage homePage = new HomePage(driver);
        SignInPage signInPage = homePage.signIn();
        RegisterPage registerPage = signInPage.register();
        registerPage.register();
    }

    @AfterMethod(alwaysRun=true)
    public void tearDown() {
        driver.quit();
    }
}

Here is my testng.xml:
<suite name="Automation Suite" parallel="methods" verbose="10">

    <test name="AccountTest">
        <classes>
            <class name="com.selenium.test.AccountTest"/>
        </classes>
    </test>

</suite>

I'm not using Grid at the moment. Trying to make this work on my local, but I will start using Saucelabs to run parallel tests moving forward.
Do you have any idea what's wrong?
Thanks in advance

A: TestNG will only instantiate your class once.  Thus, every time your @BeforeMethod method runs, the driver field gets overwritten.
To change this, you can either run your classes in parallel, or you can set up a @DataProvider to pass in the driver.


text:
Q: Python : Zip function t1 = ("a", "b", "c", "d")
t2 = (1, 2, 3, 4)
z = zip(t1, t2)
print(list(z))
print(dict(z))

It seems like we can cast the zip object only once. After z = zip(t1, t2) only the first casting either list(z) or dict(z) works and the other one does not work. Why is it so ?

A: Another option is to use the itertools.tee() function to create a second version of your generator:
from itertools import tee
t1 = ("a", "b", "c", "d")
t2 = (1, 2, 3, 4)
z,z_backup = tee(zip(t1, t2))
print(list(z))
print(dict(z_backup))


text:
Q: How to create s custom window in Python to display an iframe? For displaying video player I would like to create a custom window that shows the output of the iframe html code I give.How do I create it ? I use Python idle and Windows

A: Please give more details. What are you using to parse html code?
what are you using for an ui?
If you are really new... try some googles :)
Pywebview
This might help. But for referent please try and google before asking.


text:
Q: Remove symbols while appending in excel I'm having some parsing issues here. I have a column of Twitter handles, with '@' in front of them, and I'm trying to auto-append them in a URL on the next column.
Example:
| @Bob | https://twitter.com/@Bob |
The code in the second cell is ="https://twitter.com/"&A17.
How do I either filter out the '@' symbols or append beginning from the second character in the string (which I would do with str[1:] in Python).

A: You can use a combination of RIGHT and LEN.
="https://twitter.com/"&RIGHT(A17,LEN(A17)-1)

Alternatively, you can use SUBSTITUTE to the same effect.
="https://twitter.com/"&SUBSTITUTE(A1,"@","")

SUBSTITUTE may be a better option if the formatting of the Twitter handles in column A is inconsistent at all.