text:
Q: What is the first value at which a IEEE 64-bit float cannot distinguish two integers? I am counting on a Double (IEEE-conformant 64-bit float) to keep track of some very large numbers. The problem is that I need to maintain unit resolution of integers (the ones place).
The problem is that I know that, as IEEE floats increase in value, they decrease in precision. I am sure that at some point, we get something like this:
...
xxxxxxxxxxxxxxxxx04
xxxxxxxxxxxxxxxxx05
xxxxxxxxxxxxxxxxx06
xxxxxxxxxxxxxxxxx08
xxxxxxxxxxxxxxxxx10
...

where some integers cannot be represented at all. I want to know where that point is, so that I might be able to guard against it, warn users, or set company policy.

Note that the I am using floating-point numbers for a good reason; the fraction part is also important to the application, but it is far less important than the integer part.

A: The IEEE-754 basic 64-bit binary floating-point format uses 53-bit significands. Every finite number it encodes has the form s • F • 2e, where s (for sign) is +1 or −1, F (for fraction) is the number of a 53-bit binary numeral b.bbb…bbb (note the "." after the first bit), and e is an exponent from −1022 to +1023. (Often, floating-point numbers are normalized by shifting the bits to move the first 1 bit to the leading b position and adjusting the exponent to compensate. For discussion of representable values, we can ignore this; all numbers representable with a leading 0 are also representable with a leading 1, as long as the exponent is within bounds, which it is for this question.)
This tells us everything needed to answer the question. Every integer from 0 to 253−1 is representable in the form +1 • b.bbb…bbb • 252 for some combination of values of the bits b.bbb…bbb. And 253 is representable as +1 • 1.000…000 • 253. But 253+1 is not representable because it would need an F in the form 1.000…0001, where 54 bits are required (the first for 253 and the last for 20).
After that, 253+2 is representable, because spanning its highest and lowest 1 bit requires only 53 bits (from 253 to 21). So, at this magnitude, the even integers are representable, and the odd integers are not.
So, the transition from consecutive representable integers to non-representable integers looks like:

*

*9,007,199,254,740,919 = 253−3 is representable.

*9,007,199,254,740,920 = 253−2 is representable.

*9,007,199,254,740,921 = 253−1 is representable.

*9,007,199,254,740,922 = 253 is representable.

*9,007,199,254,740,923 = 253+1 is not representable.

*9,007,199,254,740,924 = 253+2 is representable.

*9,007,199,254,740,925 = 253+3 is not representable.

*9,007,199,254,740,926 = 253+4 is representable.

A: According to Wikipedia:

Any integer with absolute value less than 224 can be exactly represented in the single precision format, and any integer with absolute value less than 253 can be exactly represented in the double precision format. Furthermore, a wide range of powers of 2 times such a number can be represented. These properties are sometimes used for purely integer data, to get 53-bit integers on platforms that have double precision floats but only 32-bit integers.

Emphasis mine
That is to say, the highest-value integer-precision number for a IEEE 64-bit is 9,007,199,254,740,992, with the next-highest number being 9,007,199,254,740,994. In your question's format:
9007199254740990
9007199254740991
9007199254740992
9007199254740992
9007199254740994
9007199254740996
9007199254740996

Note that some float-to-string algorithms will print this like:
9007199254740990.0
9007199254740991.0
9007199254740992.0
9007199254740992.0
9.007199254740994e+15
9.007199254740996e+15
9.007199254740996e+15


text:
Q: Jquery Jcrop plugin loads image multiple times I ran into an issue with jquery Jcrop plugin
I'm using it to allow the user to crop an image, but when he/she is not satisfied with that, I set to reset the original image.
I use PHP to store the original image and cropped the image as well.
When the user hits the reset button the original image loads from the server and jcrop is reapplied.
But dear friends my issue is when the user clicks the "reset image" button the cropped image and original image both are displaying. there is a new  tag with no id or class is created by Jcrop and it doesn't remove when I destroy jcrop.
below is my code for the reset button
    $("#reset_crop").click(function(){
    refreshImg($("#profpic"), "files/"+fileName);

/*
refreshImg function adds date at Date() at the end of the image url to ignore cache. and change the src attr to the original file name.
*/
    $(this).attr("disabled","disabled");
    jcrop.destroy();
    $("#profpic").on('load',function(){ jcrop = createJcrop();  });

    });

My Jcrop settings are
function createJcrop(){

return  $.Jcrop("#profpic",{
            boxWidth:345,
            trueSize:[width, height],
            width:345,
            onSelect: showCoords,
            onChange: showCoords
        });
}

the function of the crop button is
    $("#crop").click(function(){
    jcrop.release();
    var newfile;
        jcrop.destroy();
        $.ajax({
        url:'crop.php',
        async:false,
        data:{fileName:fileName,width:coordinates[0],height:coordinates[1],x:coordinates[2],y:coordinates[3]},
        success:function(data){
                //console.log(data);
                    newfile = data;
            },
        error:function(){

                alert("something went wrong");
            }
    });

    refreshImg($("#profpic"), "files/"+newfile);
    $("#reset_crop").removeAttr('disabled');

$(this).attr("disabled","disabled");

});

redpajama_set_name: RedPajamaStackExchange


text:
Q: Loading successive select boxes on startup with javascript I am trying to populate select boxes from javascript at start up, with each one depending on the previous one.
In HTML code I have

xxxxxxx
xxxxxxx

Javascript code is
function start_up()
{
 load_select('','Type1')
 load_select(document.getElementById('select_first').value,'Type2')
}

function load_select(argument,code)
{
   xmlhttp=GetXmlHttpObject();
   if (xmlhttp==null)
       {
          alert ("Browser does not support HTTP Request");
          return;
       }
   var url="getdropdown.php";
   url=url+"?q="+code+argument;
   url=url+"&sid="+Math.random();  // this is needed to make sure its not loading a cached version
 last_http_type=code;
   xmlhttp.onreadystatechange=stateChanged;
   xmlhttp.open("GET",url,true);
   xmlhttp.send(null);
}

function stateChanged()
{
   if (xmlhttp.readyState==4)
    {
             if (last_http_type=="Type1")
                document.getElementById("FirstList").innerHTML=xmlhttp.responseText;
             else if (last_http_type=="Type2")
               document.getElementById("SecondList").innerHTML=xmlhttp.responseText;
             else if (last_http_type=="Type3")
               document.getElementById("OutputTable").innerHTML=xmlhttp.responseText;
             else if (last_http_type=="Type4")
               document.getElementById("OutputTable").innerHTML=xmlhttp.responseText;
             last_http_type="cleared";
        }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  return new XMLHttpRequest();   // code for IE7+, Firefox, Chrome, Opera, Safari
if (window.ActiveXObject)
  return new ActiveXObject("Microsoft.XMLHTTP");   // code for IE6, IE5
return null;
}

The select boxes are named select_first and select_second when their code is generated in php.
This works fine for the first one, but the second load_select fails due to it not knowing about select_first. I was assuming that its done sequentially and thus, by the time it reaches the statement, should know about the first drop down. (Note that the code above is simplified a little bit to illustrate the problem, the second argument of load_select determines the exact SQL call, also stateChanged is slightly more complicated since it needs to know which load_select was called. However, they all work fine by themselves, its the multiple load at startup which fails.)

A: So basically you are making two consecutive AJAX calls and try to tie the execution of second one to the result of the first one? This doesn't work that way, because first A letter in AJAX means Asynchronous, meaning "okay, guys, I'll go fetch that url but you can go on without me". So javascript fires first request and then goes further without waiting for it to return something.
If you want to run second request only after successful execution of the first one, then you'll need to use callbacks and onSuccess() event.
To make it shorter, put the second call in the stateChanged() function.

A: You should write your javascript separate from your html.
So your page startup event should be
window.onload = function() {
    ....
    }
 or with jquery:
 $(function() {
  ....
 });

So there you can put your other functions and code. And here would be a excellent to use JQuery. Look for example load method. It would propably solve your problems much faster than writing ajax from scratch.


text:
Q: BeautifulSoup - Scrape Table Without A Class I am stuck with a project which requires me to scrape a table from a website. The problem I am running into is there are multiple tables on the webpage and none of them seem to have classes when I inspect the elements. The table rows and columns do however have classes assigned to them.
The table I am needing to scrape is the table detailing zip code, location, city, population, and avg income.
I am new to web-scraping/BeautifulSoup and would appreciate any help I can get.
http://zipatlas.com/us/pa/philadelphia/zip-code-comparison/median-household-income.htm
from bs4 import BeautifulSoup
import requests

income_url = "http://zipatlas.com/us/pa/philadelphia/zip-code-comparison/median-household-income.htm"
headers = {"User-Agent": "Mozilla/5.0"}

response = requests.get(income_url,headers = headers)
response.status_code

soup = BeautifulSoup(response.content,"html.parser")

A: The table already have attribute!

So we can use this with pandas read_html
attrs={'rules': 'all'}

With the following short and simple code:
import pandas as pd

df = pd.read_html(
    "http://zipatlas.com/us/pa/philadelphia/zip-code-comparison/median-household-income.htm",
    attrs={'rules': 'all'},
    header=0,
    index_col="#")[0]

print(df)

A: If you're after <table> tags, Pandas' read_html() is what you'll want to use (it uses BeautifulSoup under the hood, but does the work for you). It'll return a list of dataframes. The table you are after is the table in index position 11. Then it's just a matter of manipulating the dataframe to get what you want.
import pandas as pd

income_url  = 'http://zipatlas.com/us/pa/philadelphia/zip-code-comparison/median-household-income.htm'
dfs = pd.read_html(income_url )

df = dfs[11]
df.columns = df.iloc[0,:]
df = df.iloc[1:,:].reset_index(drop=True)

If you are after that particular table by tags/attributes, you are correct it doesn't have a class attribute. But you aren't limited to find only class. In this site, the table does have the attribute rules="all" or frame="box", so you can use one of those:
from bs4 import BeautifulSoup
import requests

income_url = "http://zipatlas.com/us/pa/philadelphia/zip-code-comparison/median-household-income.htm"
headers = {"User-Agent": "Mozilla/5.0"}

response = requests.get(income_url,headers = headers)
response.status_code

soup = BeautifulSoup(response.content,"html.parser")
table = soup.find('table',{'rules':'all'})

df = pd.read_html(str(table))[0]
df.columns = df.iloc[0,:]
df = df.iloc[1:,:].reset_index(drop=True)

Output:
print (df.to_string())
0     # Zip Code               Location                        City Population Avg. Income/H/hold National Rank
0    1.    19113  39.870679, -75.247782  Philadelphia, Pennsylvania        136         $70,833.00        #1,450
1    2.    19106  39.950472, -75.147231  Philadelphia, Pennsylvania       8359         $61,720.00        #2,617
2    3.    19118  40.072443, -75.212415  Philadelphia, Pennsylvania       9608         $60,179.00        #2,986
3    4.    19154  40.095521, -74.981818  Philadelphia, Pennsylvania      35606         $51,949.00        #5,075
4    5.    19119  40.052013, -75.192553  Philadelphia, Pennsylvania      28873         $46,520.00        #7,487
5    6.    19116  40.115569, -75.013276  Philadelphia, Pennsylvania      32560         $44,776.00        #8,502
6    7.    19128  40.049525, -75.230253  Philadelphia, Pennsylvania      36420         $43,629.00        #9,136
7    8.    19127  40.027929, -75.224083  Philadelphia, Pennsylvania       5465         $43,490.00        #9,226
8    9.    19150  40.072482, -75.171735  Philadelphia, Pennsylvania      25274         $42,342.00       #10,007
9   10.    19114  40.069361, -75.000264  Philadelphia, Pennsylvania      31083         $41,592.00       #10,652
10  11.    19115  40.092757, -75.042597  Philadelphia, Pennsylvania      31853         $39,075.00       #12,928
11  12.    19130  39.967905, -75.174735  Philadelphia, Pennsylvania      22874         $38,668.00       #13,307
12  13.    19111  40.063318, -75.077631  Philadelphia, Pennsylvania      58874         $37,996.00       #13,922
13  14.    19103  39.952795, -75.173949  Philadelphia, Pennsylvania      19714         $37,959.00       #13,970
14  15.    19152  40.061595, -75.046385  Philadelphia, Pennsylvania      31379         $37,760.00       #14,143
15  16.    19149  40.037448, -75.065561  Philadelphia, Pennsylvania      48483         $37,210.00       #14,713
16  17.    19153  39.894414, -75.232375  Philadelphia, Pennsylvania      12324         $36,872.00       #15,129
17  18.    19129  40.015462, -75.182928  Philadelphia, Pennsylvania      10748         $36,465.00       #15,573
18  19.    19136  40.040272, -75.020603  Philadelphia, Pennsylvania      40080         $35,650.00       #16,647
19  20.    19102  39.953423, -75.165384  Philadelphia, Pennsylvania       4396         $35,625.00       #16,711
20  21.    19126  40.056119, -75.136564  Philadelphia, Pennsylvania      16484         $34,607.00       #17,924
21  22.    19135  40.022732, -75.049612  Philadelphia, Pennsylvania      30881         $34,584.00       #17,946
22  23.    19147  39.936633, -75.153153  Philadelphia, Pennsylvania      32680         $34,431.00       #18,129
23  24.    19151  39.979740, -75.256726  Philadelphia, Pennsylvania      31255         $33,840.00       #18,751
24  25.    19138  40.056028, -75.159179  Philadelphia, Pennsylvania      34477         $32,248.00       #20,628
25  26.    19137  39.995604, -75.074623  Philadelphia, Pennsylvania       8069         $31,761.00       #21,311
26  27.    19120  40.034147, -75.119198  Philadelphia, Pennsylvania      68831         $31,588.00       #21,529
27  28.    19131  39.986772, -75.219521  Philadelphia, Pennsylvania      47044         $30,099.00       #23,512
28  29.    19141  40.037904, -75.145392  Philadelphia, Pennsylvania      34984         $28,861.00       #24,807
29  30.    19125  39.977245, -75.125222  Philadelphia, Pennsylvania      23646         $28,679.00       #24,999
30  31.    19124  40.017119, -75.092814  Philadelphia, Pennsylvania      63131         $28,574.00       #25,098
31  32.    19144  40.031929, -75.176099  Philadelphia, Pennsylvania      46794         $27,436.00       #26,201
32  33.    19148  39.913130, -75.155421  Philadelphia, Pennsylvania      48573         $27,097.00       #26,529
33  34.    19145  39.913431, -75.191556  Philadelphia, Pennsylvania      45647         $26,655.00       #26,971
34  35.    19142  39.921746, -75.233277  Philadelphia, Pennsylvania      29063         $25,973.00       #27,536
35  36.    19143  39.942892, -75.225460  Philadelphia, Pennsylvania      71169         $25,826.00       #27,668
36  37.    19146  39.939069, -75.182585  Philadelphia, Pennsylvania      35783         $24,803.00       #28,329
37  38.    19107  39.951623, -75.158637  Philadelphia, Pennsylvania      12340         $24,448.00       #28,539
38  39.    19139  39.961529, -75.230259  Philadelphia, Pennsylvania      43866         $21,329.00       #30,102
39  40.    19123  39.964212, -75.147103  Philadelphia, Pennsylvania       9818         $21,096.00       #30,195
40  41.    19134  39.992219, -75.107863  Philadelphia, Pennsylvania      57922         $20,903.00       #30,253
41  42.    19140  40.011789, -75.145282  Philadelphia, Pennsylvania      57125         $20,077.00       #30,509
42  43.    19132  39.996457, -75.170586  Philadelphia, Pennsylvania      41709         $18,777.00       #30,808
43  44.    19122  39.977688, -75.145885  Philadelphia, Pennsylvania      19589         $18,395.00       #30,887
44  45.    19104  39.960323, -75.197883  Philadelphia, Pennsylvania      50125         $16,151.00       #31,267
45  46.    19121  39.981980, -75.179120  Philadelphia, Pennsylvania      34935         $15,888.00       #31,300
46  47.    19133  39.993092, -75.141671  Philadelphia, Pennsylvania      27971         $13,828.00       #31,507
47  48.    19112  39.893156, -75.168944  Philadelphia, Pennsylvania         29              $0.00       #31,963
48  49.    19108  39.959626, -75.160879  Philadelphia, Pennsylvania          0              $0.00       #31,977

A: I would go for Pandas way.
import pandas as pd

URL = 'http://zipatlas.com/us/pa/philadelphia/zip-code-comparison/median-household-income.htm'

df = pd.read_html(URL)[11]
df.columns = df.iloc[0]
df = df[1:]
df.drop(columns='#', inplace=True)
print(df.head())

# to csv

df.to_csv('data.csv', index=False)

You can change data types of Pandas with df['column_name'] = df['column_name'].astype(float)


text:
Q: CruiseControl.Net, MSBuild and NUnit The CruiseControl.Net documentation advises against using the NUnit task, suggesting instead that NUnit is called within the build script.
I'm trying to work out what is the best way to achieve this.
I've added a 'RunTests' project to my solution which uses the NUnit MSBuild Community Task to execute the tests.
I wanted to add a 'Test' target to this project so that I could run MSBuild against the whole solution with the targets "Build;Test".  However, MSBuild didn't like this, reporting thet the solution didn't include a Test target.
What should I be doing?  I'm not entirely clear why CruiseControl.Net suggests we don't use the NUnit task.  If I do wrap up the calls to NUnit within a MSBuild project, I'm not entirely sure if I should be calling MSBuild twice from CC.Net (once to build everything and once to call the test).  If I should be combining the Build and Test within one call to MSBuild, how do I achieve this?
Any tips gratefully received.
Sandy

A: There is no reason why you can't have several calls to MSBuild from your ccnet project. In our projects, we have the first call to MSBuild compile the code. The second call uses an MSBuild script that runs our unit tests and code analysis.


text:
Q: Find links to nonexistent pages in MediaWiki I have been searching for a few days and it is hard to find specifics for wikimedia.
Does anyone know of an extension, or report that will show internal links to nonexistent pages?
We host a wiki where we have users that have crated some excellent content, but to have to go through each page to find the links to pages that have not been created yet is next to impossible due to the amount of content.
Any help or ideas would be greatly appreciated...

A: Go to your Special:SpecialPages list and you will find

*

*Wanted categories

*Wanted files

*Wanted pages

*Wanted templates
which are (more or less) dynamic lists of all redlinks in your wiki.

A: If you want to only see a list of dead links for a specific page or a group of pages, you can use DynamicPageList to run a linksfrom query with openreferences = yes. Go here for more info: http://semeb.com/dpldemo/index.php?title=DPL:Manual_-_DPL_parameters:_Criteria_for_page_selection#linksfrom


text:
Q: How to express residue I have struggled a lot to solve that exercise: How to express the following
$\operatorname{Res}(\sin(e^z/z), 0))$ as a series. I tried to expand in Taylor Series, but I came across a multinomial series that is hard to work with.

A: A possible approach:
$$
 \sin\bigl(\frac{e^z}{z} \bigr) = \sum_{k=0}^\infty \frac{(-1)^k}{(2k+1)!} \bigl(\frac{e^z}{z} \bigr)^{2k+1}
= \sum_{k=0}^\infty \frac{(-1)^k}{(2k+1)!} \frac{e^{(2k+1)z}}{z^{2k+1}} \\
= \sum_{k=0}^\infty \frac{(-1)^k}{(2k+1)!} \frac{1}{z^{2k+1}}
\sum_{l=0}^\infty \frac{((2k+1)z)^l}{l!}
$$
The residue is the coefficient of $z^{-1}$ in the
Laurent series, and entries in the double sum contribute to that
coefficient exactly if $l = 2k$. The residue at $z=0$ therefore is
$$
 \sum_{k=0}^\infty \frac{(-1)^k(2k+1)^{2k}}{(2k+1)!(2k)!}
$$
I don't know if that can be simplified further.


text:
Q: Sparse Autoencoder with Tanh activation from UFLDL I have been working of of the UFLDL tutorials (In matlab/octave) :
http://deeplearning.stanford.edu/wiki/index.php/UFLDL_Tutorial
and have been trying out the sparse autoencoder on different datasets. I tried running it on time-series data and encountered problems. Since the input data has negative values, the sigmoid activation function (1/1 + exp(-x)) is inappropriate. When substituting in tanh, the optimazion program minfunc (L-BFGS) fails (Step Size below TolX). I decreased the TolX constant dramatically with no change.
I changed the output layer to linear, kept the input layer sigmoid, but this isn't a preferable solution. The output of the autoencoder is scaled up by a constant (0.5), which boogers the cost function. So.... in short:
Why doesn't the Tanh activation function work with L-BFGS? (or is something else wrong)?
..What am I missing? Everywhere one reads it says that activation functions are pretty interchangable.  I know there are workarounds (rescale data, use FFT coefficents etc.) but I don't see why this doesn't work.
Anyway, thanks in advance to anyone who answers! First post on here, I've been reading these  types of forums more and more and am finding them increasingly helpful..

A: I think I might have figured it out. Thanks to both of you for answering! The sparsity penalty uses Kullback Leibler Divergence. See this link, a bit more than half the way down the page. (Can you type in Latex in here?) It might be kinda long anyway..
http://deeplearning.stanford.edu/wiki/index.php/Autoencoders_and_Sparsity
In english: The sparsity penalty tries to minimize the activations of the hidden units, but it assumes a sigmoid with output range between 0 and 1, since KL div is real only between 0 and 1.
If the average activation of tanh is 0 (which is what we would want for a sparse autoencoder) then the KL div given on that page is unhappy.
Ive looked around without luck;
is there a form of KL div which has an appropriate range for the tanh activation? Any references someone could point me to? On that site linked above, the author says many choices of sparsity penalty are ok, but doesn't elaborate further on what those other choices could be. Is it prudent to just make something up..? Or look for something thats accepted. Thanks again!

A: I'm kinda loosely following UFLDL, and i've ran into the same problem.
I'm trying (beta/2*m)*mean(mean(abs(a2))) to regularize the cost for sparsity, thinking that as an increase in the activation of one neuron in will be linearly matched by a decreases in the activation of the other neurons. I hope that will lead to better sparsity than KL; the low derivative of KL near p implies that as a2_j gets closer to p, further decreases in a2_j lead to smaller decreases of the cost, making it less and less likely that a2_j reaches p; a linear cost doesn't have that problem.
However i have some trouble figuring out how to modify d2 to get the correct gradients during backpropagation. You've probably found some other solution by now, but if not, this might be worth figuring out. If you (or anyone else!) figure it out, i'd love getting the answer =)
edit: d2 =   d2   + ( (network.beta / (2 * network.examples)) * exp(-a2); ) .* z2_grad; seems to give ok-ish results.
edit2: No it doesn't. Sorry 'bout that

A: I have tried the sparse autoencoder algorithm following the UFLDL. I am using fortran90.
In my code I have used the tanh activation function. The p_hat term has been modified to range  [0,1] using,
p_hat = (p_hat+1.0)/2.0

As a consequence the sparse penalty doesn't become infeasible. My cost function converges smoothly, but the activation nodes in the hidden layer donot turn inactive (-1). I am unable to understand the phenomenon. This doesn't help my purpose of reducing dimension of the input vector.


text:
Q: GAE Task queue is keeping negative tasks running in the "Tasks Running" section in the admin console I am currently working on a Python project with GAE, and as strange as it may seem, my default queue is keeping a negative count of tasks running even though i manually deleted all tasks. Why is it doing this odd thing? and how to stop it? attached you can find a picture of what i mean...

And due to this issue, my scheduled cron jobs are not running when using the default queue, i have not tested it with a custom queue. But a negative count of tasks running? seriously??

A: This was an AppEngine issue, it was fixed later that day.


text:
Q: Simple Abstract Algebra Problem, which of the following are fields... I am wondering if anyone could point me to a good method to go about determining if the following sets of integers constitute a field or not: $\mathbb Z_3$, $\mathbb Z_4$, $\mathbb Z_5$, and $\mathbb Z_6$. I have come to the conclusion that the ternary integers do not because there is not multiplicative inverse for the even integers. But, as for the others, I feel that there must exist a method for deciding without going through and checking commutativity, Identity, additive and multiplicative inverses, associativity. Thanks in advance for any assistance.

A: If $s=mn$ is composite, $m,n$ are not zero in $\Bbb Z_s$, but $mn$ is. This means $\Bbb Z_s$ is not even an integral domain if $s$ is composite, let alone a field. If $p$ is prime, $p\mid ab\implies p\mid a$ or $p\mid b$. This means $\Bbb Z_p$ is an integral domain. Moreover, since if $1\leq q<p$ then $p\not\mid q\implies (p,q)=1$, this means all nonzero elements have inverses (use Bezout's theorem), so it is a field.
As it has been brought up, every finite integral domain is a field. The proof is not hard: if $a$ is nonzero consider the map from $D$ to itself given by $x\mapsto ax$. If $ax=ay$ then $a(x-y)=0$. Since $a\neq 0$, $x=y$, so this map is injective, whence it is bijective, since $D$ is finite. Thus there must exist $a'$ that gets mapped to $1$. This means $aa'=1$. Since $a$ was arbitrary, we're done.

A: Think about this: An element $x$ in ${\bf Z}_n$ is invertible if and only if $x$ is relatively prime to $n$.
He explained to you that if $n$ is not prime, then ${\bf Z}_n$ is not a integral domain. It turns out that every finite integral domain is a field.


text:
Q: Analyticity of $\frac{z}{\bar z +2}$ I can't seem to find a way to express $$f(z)=\frac{z}{\bar z +2}$$
as $u(x,y)+iv(x,y)$ so that I can check the Cauchy-Riemann equations. There must be some really simple idea to prove that $f(z)$ is not analytic anywhere but I'm stuck. Any help?

A: Note that $(\bar{z}+2)(z+2)=|z+2|^2$.
Hence, for $z=x+iy\not=-2$,
$$\frac{z}{\bar z +2}=\frac{z(z+2)}{|z+2|^2}=\frac{(x+iy)(x+2+iy)}{(x+2)^2+y^2}.$$
Now it is easy to find the real part $u(x,y)$ and the imaginery part $v(x,y)$.
P.S. However, in order to check if $f$ is analytic there is a shorter way: see mercio's answer.

A: If $f$ was analytic, $g(z) = \frac z {f(z)}-2 = \overline z$ would also be analytic when $z \neq 0,-2$.


text:
Q: Javascript Regular Expression to match string unless preceeded by backslash How do I match U1234, but not \U1234 in Javascript?
I can't figure out how to not match the single backslash.
The closest I can get is:
\[\\]{0}U[0-9]{4}\b

But that doesn't work.
Any suggestions?

A: JavaScript definitely does not support lookbehind assertions. The next best way to get what you want, in my opinion, would be
(?:^|[^\\])(U[0-9]{4})

Explanation:
(?:          # non-capturing group - if it matches, we don't want to keep it
   ^         # either match the beginning of the string
   |         # or
   [^\\]     # match any character except for a backslash
)            # end of non-capturing group
(U\d{4})     # capturing group number 1: Match U+4 digits

A: [^\\]U[0-9]{4} or something along these lines. It will not match the sequence on the very beginning of subject string…

A: Unfortunately JS doesn't seem to support proper syntax for this, i.e. back assertion /(?<!\\)U[0-9]{4}/.
So you need to use:
/[^\\]U[0-9]{4}/

This is syntax for regexp literal. If you put regexp in a string, you have to escape backslashes again:
"[^\\\\]U[0-9]{4}"

A: I would suggest using lookbehind, but JavaScript doesn't seem to support it. Maybe you can match on U[0-9]{4}, find where the match is, and check the character to its left to see if it's a \ or not?

A: JavaScript's RegExp does not support negative look-behind assertions.  Ideas that propose you match only /[^\]U/ will match strings like "_U", so that's not the answer.  Your best bet is to use two regular expressions, the first to find all occurrences, then the second to filter the look-behind.
"\\U0000 U0000".match(/\\?U[0-9]{4}/g)
.filter(function (match) {
    return !/^\\/.test(match)
})

A: Ummm ... Is \^U[0-9]{4}\b works for you?


text:
Q: MongoDB: how to query with a specific rule for a specific element in $in? Honestly I doubt that it is possible but just giving a shot here.
Here's an example of DB records
{
    type: 'fruit',
    name: 'apple',
    quantity: 3
}
{
    type: 'fruit',
    name: 'orange',
    quantity: 10
}
{
    type: 'vegetable',
    name: 'tomato',
    quantity: 4
}
{
    type: 'meat',
    name: 'beef',
    quantity: 2
}

then here's the query
{type: { $in: ['fruit', 'vegetable', 'meat']}}

So this will return all of the records in collection 'apple', 'orange', 'tomato', 'beef'.
I would like to query 'fruit', 'vegetable', 'meat' and also the records that have quantities more than 5 for 'fruit' only but not others.
So the result will be
orange, tomato, beef

Not sure my explanation makes sense but is this a possible query? or I should go query twice?
Thanks for reading.

A: Please try:
{
    $or: [
        { type: { $in: ['vegetable', 'meat'] } },
        { type: { $in: ['fruit'] }, quantity: { $gt: 5 } }
    ]
}

I hope that helps.


text:
Q: prevent execution of default constructor in design time in ViewModel I put some data access logic in my default construct of ViewModel class.
However, whenever try to open xaml designer window, visualstudio try to execute default constructor of ViewModel, then popup error window from this.
How can I prevent execution of default constructor in ViewModel class.
I know GetIsInDesignModel() method can do this in codebehind class, but it is impossible to use in ViewModel class because parameter of this method require DependencyObject type.
any solution for this?

A: You can access the IsInDesignMode property statically in your ViewModel code with
(bool)DependencyPropertyDescriptor.FromProperty(
                                 DesignerProperties.IsInDesignModeProperty,
                                 typeof(DependencyObject)
                                 ).Metadata.DefaultValue;


text:
Q: Refresh another forms DataGridView from button click I have a form (customersForm) displaying a datagridview with customer information. And a second form (viewForm) which allows the user to view, edit,delete and update selected datagridview row. When I click update, or delete i'd like the datagridview on the customerForm to refresh displaying the updated data. How can I do this from a button click?
This is the viewForms complete code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;

namespace Lewis_Warby_Airbrushing
{
    public partial class viewForm : Form
    {
        DataRowView Data = null;
        public viewForm(DataRowView dr)
        {
            InitializeComponent();
            Data = dr;
            }

        private void closeBTN_Click(object sender, EventArgs e)
        {

            this.Close();
        }

        private void viewForm_Load(object sender, EventArgs e)
        {
            refTxt.Text = Data["Reference"].ToString().Trim();
            firstTxt.Text = Data["First Name"].ToString().Trim();
            surenameTxt.Text = Data["Surename"].ToString().Trim();
            address1Txt.Text = Data["Address Line 1"].ToString().Trim();
            address2Txt.Text = Data["Address Line 2"].ToString().Trim();
            countyTxt.Text = Data["County"].ToString().Trim();
            postTxt.Text = Data["Post Code"].ToString().Trim();
            contactTxt.Text = Data["Contact Number"].ToString().Trim();
            emailTxt.Text = Data["Email Address"].ToString().Trim();

        }

        private void deleteBTN_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Customer information will be perminantly deteled. Do you with to continue? ", "Confirm Delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string constring = @"Data Source=|DataDirectory|\LWADataBase.sdf";
                string Query = "delete from customersTBL where Reference ='" + this.refTxt.Text + "';";
                SqlCeConnection conDataBase = new SqlCeConnection(constring);
                SqlCeCommand cmdDataBase = new SqlCeCommand(Query, conDataBase);
                SqlCeDataReader myReader;
                try
                {
                    conDataBase.Open();
                    myReader = cmdDataBase.ExecuteReader();
                    MessageBox.Show("Customer information has been deleted", "Deleted Sucessfully");
                    while (myReader.Read())
                    {

                    }
                    MessageBox.Show("Please exit the Customers window and re-open to update the table");
                    this.Close();
                    //displays a system error message if a problem is found
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);

               }

            }

        }

        private void editBTN_Click(object sender, EventArgs e)

            {
                bool notEditable = true;
                if (editBTN.Text == "Update")
                {
                    int UserID = Convert.ToInt32(refTxt.Text);
                    UpdateDataBase( UserID );

                    editBTN.Text = "Edit";
                    deleteBTN.Visible = true;
                    notEditable = true;
                }
                else
                {
                    deleteBTN.Visible = false;
                    editBTN.Text = "Update";
                    deleteBTN.Visible = false;
                    notEditable = false;
                }
                firstTxt.ReadOnly = notEditable;
                surenameTxt.ReadOnly = notEditable;
                address1Txt.ReadOnly = notEditable;
                address2Txt.ReadOnly = notEditable;
                countyTxt.ReadOnly = notEditable;
                contactTxt.ReadOnly = notEditable;
                emailTxt.ReadOnly = notEditable;
                postTxt.ReadOnly = notEditable;

        }

private void UpdateDataBase(int customerID)
         {
             if (MessageBox.Show("Customer information will be updated. This change cannot be undone. Are you sure you want to continue? ", "Confirm Edit", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 string constring = @"Data Source=|DataDirectory|\LWADataBase.sdf";
                 string Query = @"update customersTBL set [First Name] = @fname,
                  surename = @sur, [Address Line 1] = @addr1,
                  [Address Line 2] = @addr2, County = @county,
                  [Post Code] = @pcode, [Email Address] = @mail, [Contact Number] = @ctNo
                  WHERE Reference = @id";
                 using (SqlCeConnection conDataBase = new SqlCeConnection(constring))
                 using (SqlCeCommand cmdDataBase = new SqlCeCommand(Query, conDataBase))
                 {
                     try
                     {
                         conDataBase.Open();
                         cmdDataBase.Parameters.AddWithValue("@fname", this.firstTxt.Text);
                         cmdDataBase.Parameters.AddWithValue("@sur", this.surenameTxt.Text);
                         cmdDataBase.Parameters.AddWithValue("@addr1", this.address1Txt.Text);
                         cmdDataBase.Parameters.AddWithValue("@addr2", this.address2Txt.Text);
                         cmdDataBase.Parameters.AddWithValue("@county", this.countyTxt.Text);
                         cmdDataBase.Parameters.AddWithValue("@pcode", this.postTxt.Text);
                         cmdDataBase.Parameters.AddWithValue("@mail", this.emailTxt.Text);
                         cmdDataBase.Parameters.AddWithValue("@ctNo", this.contactTxt.Text);
                         cmdDataBase.Parameters.AddWithValue("@id", customerID);
                         int rowsUpdated = cmdDataBase.ExecuteNonQuery();
                         if (rowsUpdated == 0)
                             MessageBox.Show("No customer found to update");
                         MessageBox.Show("Customer information sucessfully updated", "Update Sucessfull");
                     }
                     catch (Exception ex)
                     {
                         MessageBox.Show(ex.Message);
                     }
                 }
             }
}

The complete code for customerForm:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;

namespace Lewis_Warby_Airbrushing
{
    public partial class customerForm : Form
    {
        public customerForm()
        {
            InitializeComponent();
        }

        public void customerForm_Load(object sender, EventArgs e)
        {

            // TODO: This line of code loads data into the 'lWADataBaseDataSet.customersTBL' table. You can move, or remove it, as needed.
            timer1.Start();
            this.lWADataBaseDataSet.EnforceConstraints = false;
            this.customersTBLTableAdapter.Fill(this.lWADataBaseDataSet.customersTBL);

        }

        private void viewBTN_Click(object sender, EventArgs e)
        {
            int selectedRowIndex = customersTBLDataGridView.SelectedCells[0].RowIndex;
            DataGridViewRow selectedRow = customersTBLDataGridView.Rows[selectedRowIndex];

            viewForm frm2 = new viewForm((DataRowView)selectedRow.DataBoundItem);
            frm2.ShowDialog();

        }
        addForm addForm = new addForm();
        private void addBTN_Click(object sender, EventArgs e)
        {
  if (addForm == null || addForm.IsDisposed == true)
                addForm = new addForm();
  addForm.ShowDialog();
  this.customersTBLTableAdapter.Fill(this.lWADataBaseDataSet.customersTBL);

        }

        int count = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            count = customersTBLBindingSource.Count;
            statusLBL.Text = "You currently have "+count.ToString()+" customer(s) stored in this database";
        }
        searchForm searchForm = new searchForm();
        private void searchBTN_Click(object sender, EventArgs e)
        {
            if (searchForm == null || searchForm.IsDisposed == true);
            searchForm = new searchForm();
            searchForm.ShowDialog();
        }

        }

        }

A: There is a lot you don't specify in your question, but let's assume this scenario:
When customerView is shown, you call the database to fill a DataGridView with customer details. At some point you either dbl-click on a DGV row, or you select a row and click a button, and then show viewForm, passing in the data in the currently selected row. Again, you don't specify how this is done, but let's assume you pass in a Data Transfer Object of some kind.
Once done editing, you click a button, save the changes to the database, then close viewForm.
According to your comments this is the general workflow you have in your application now.
In this case, you can simply re-fetch the data, as you did when first showing customerView when the viewForm.ShowDialog() method returns.
Unless there is something else I don't get, this can be easily done like this:
//customerForm
private void button1_Click(object sender, EventArgs e)
{
        ViewFormClass viewForm = new ViewFormClass();
            viewForm.SetCustomerData(dataObject);
        viewForm.ShowDialog(); // will stop here waiting for viewForm to close
        this.FetchCustomerData();
}

where FetchCustomerData() is the same method you called when opening customerView. In there you would typically fetch the data and bind it to controls.
Cheers
EDIT:
As per your own code, with a simple modification:
        private void viewBTN_Click(object sender, EventArgs e)
        {
            int selectedRowIndex = customersTBLDataGridView.SelectedCells[0].RowIndex;
            DataGridViewRow selectedRow = customersTBLDataGridView.Rows[selectedRowIndex];

            viewForm frm2 = new viewForm((DataRowView)selectedRow.DataBoundItem);
            frm2.ShowDialog();
            this.customersTBLTableAdapter.Fill(this.lWADataBaseDataSet.customersTBL);

        }


text:
Q: I want to redirect on particular page after click on submit button I have two submit buttons in contact form 7. I want to set two different redirection link on both buttons after sent mail. How can I set links on different buttons
add_action( 'wp_footer', 'mycustom_wp_footer' );

function mycustom_wp_footer() {

?>
<script type="text/javascript">
$('#down_pc').click(function() {
    window.location.href = 'http://www.test.com/';
    return false;
});
$('#down_mac').click(function() {
    window.location.href = 'http://www.test2.com/';
    return false;
});
</script>
<?php
}

I have put onclick event but it is redirect without sent mail and without check validation.

A: Try below code, it will help you
function action_wpcf7_submit( $instance, $result ) { ?>
    <script type="text/javascript">
         $( '#down_pc' ).click( function() {
             window.location.href = 'http://www.test.com/';
             return false;
         } );

         $( '#down_mac' ).click( function() {
             window.location.href = 'http://www.test2.com/';
             return false;
         } );
    </script>
<?php };

add_action( 'wpcf7_submit', 'action_wpcf7_submit', 10, 2 );


text:
Q: getting extra [] at the end of json array I am getting an extra [] at the end of the json and it is causing me problems. I tried to search why or where these [] are added but couldn't find anything.
so what I need is [{content},{content},{content}] but I am getting [{content},{content},{content}][]
The result should be:

[{"botserialnumber":1,"name":"","phone":null,"bloodpressure":20,"isbreathing":null,"isawake":null,"heartrate":101,"readPhone":null,"readBot":1},{"botserialnumber":4,"name":"ar","phone":"7084","bloodpressure":90,"isbreathing":0,"isawake":0,"heartrate":90,"readPhone":1,"readBot":1},{"botserialnumber":6,"name":"","phone":null,"bloodpressure":1,"isbreathing":null,"isawake":null,"heartrate":5,"readPhone":null,"readBot":1}]

but instead is:

[{"botserialnumber":1,"name":"","phone":null,"bloodpressure":20,"isbreathing":null,"isawake":null,"heartrate":101,"readPhone":null,"readBot":1},{"botserialnumber":4,"name":"ar","phone":"7084","bloodpressure":90,"isbreathing":0,"isawake":0,"heartrate":90,"readPhone":1,"readBot":1},{"botserialnumber":6,"name":"","phone":null,"bloodpressure":1,"isbreathing":null,"isawake":null,"heartrate":5,"readPhone":null,"readBot":1}][]

The code used:
case 'getdata':

 $heroes = array();

 $stmt = $conn->prepare("SELECT botserialnumber, name, phone, bloodpressure, isbreathing, isawake, heartrate, readPhone, readBot FROM healers");

 $stmt->execute();

 $stmt->bind_result($botserialnumber, $namen, $phone, $bloodpressure, $isbreathing, $isawake, $heartrate, $readPhone,$readBot);

while($stmt->fetch()){

 //pushing fetched data in an array
 $temp = [
  'botserialnumber'=>$botserialnumber,
   'name'=>$namen,
   'phone'=>$phone,
   'bloodpressure'=>$bloodpressure,
    'isbreathing'=>$isbreathing,
   'isawake'=>$isawake,
    'heartrate'=>$heartrate,
     'readPhone'=>$readPhone,
     'readBot'=>$readBot
 ];

 //pushing the array inside the hero array
 array_push($heroes, $temp);
}

//displaying the data in json format
echo json_encode($heroes);

 break;


text:
Q: login loop ubuntu? I stuck in the login loop ubuntu 18.10
and after I enter ctrl+alt+f3
I can not log in to my user account 'jake'
but I can log in to 'root'
then I can not see any xauthority in the file system.
what should I do with root to fix the login loop


text:
Q: Cantor construction is continuous I define a function $f:\mathbb{R}\to\mathbb{R}$ as follows:
$f(x)=0$ for $x\le 0$. $f(x)=1$ for $x\ge1$.
$f(x)=\dfrac12$ for $x\in\left[\dfrac13,\dfrac23\right]$.
$f(x)=\dfrac14$ for $x\in\left[\dfrac19,\dfrac29\right]$, $f(x)=\dfrac34$ for $x\in\left[\dfrac79,\dfrac89\right]$.
and so on.
So this function has been defined on $\mathbb{R}$, except for the Cantor set. How can we fill in the function on the Cantor set, so that we get a continuous function?

A: Denote the funcion you constructed on $\mathbb{R}\setminus C$ by $f$. The question is how to define Cantor's function on $[0,1]$. You can use the formula
$$
F(x)=\sup_{t\in[0,x]\setminus C} f(t),\qquad x\in[0,1]
$$
The function $F$ is continuous thanks to the following lemma.

Lemma. Let $F:[a,b]\to\mathbb{R}$ is non decreasing and $F([a,b])$ is dense in $[F(a),F(b)]$, then $F$ is continuous.

Proof. Since $F$ is non decreasing there exist finite one sided limits at any $x\in[a,b]$, denote them $F(x+)$ and $F(x-)$. Assume $F$ is discontinuous at $c\in[a,b]$, then $f(c-)<f(c+)$. In this case $F([a,b])\cap[F(c-),F(c+)]=\{F(c)\}$, so $F([a,b])$ is not dense in $[F(a),F(b)]$. Contradiction.

A: Define the cantor function as defined in wikipedia http://en.wikipedia.org/wiki/Cantor_function , see section "iterative construction". Then prove that
$$|f_{n+1}(x)-f_{n}(x)|\leq \frac {1}{2^n}$$
and use this to prove that $\sup_{x\in[0,1] }|f_m(x)-f_n(x)|\to 0$ as $m,n\to \infty$. Therefore $f_n$ converges uniformly, and the limit has to be continuous, since the functions $f_n$ are.


text:
Q: Server automatically redirecting despite lack of any noticeable redirects We've just recently set up a new apache box to test with (for simplicity we'll call it internalIp). We have two produciton apache servers that we duplicated the setup from, and made the appropriate changes.
Everything was working fine execpt when we hit the root of the box (http://internalIp) it redirects to http://internalIp/ourCompany/sub/index.jsp which we're sure came from the regular apache boxes.
So we found the index.html at /usr/local/apache2/html that had a redirect in it and removed it. However it's still redirecting to that url, even though there doesn't look to be anywhere it could be happening. We searched every file in etc, usr, and var for "ourCompany/sub/index.jsp" but couldn't find it anywhere.
I've checked all the html files at usr/local/apache2/html, and the sites-enabled config file. I can't find anywhere else that might be causing the redirect to happen.
Any ideas on how we can diagnose or fix this problem would be greatly appreciated. I can provide further information if needed.

A: Browsers can keep a redirect cache, try to browse your website with chrome incognito or ie private browsing. Got this error a lot of time when using redirect 301 and remove them later.


text:
Q: Calling java servlet from sap Fiori project I have created a SAPUI5 project and deployed on SAP FIORI. On the project I try to call a java servlet class through ajax called "ExampleSap" but I get an error message '404 (NOT FOUND)', this is strange because on my local webserver (tomcat 8.0) it works.
Here is my code:
Example.controller.js
onPressButton: function (evt) {
    $.ajax({
        url : 'ExampleSap',
        type: 'GET',
        success : function(data) {
            alert("OK");
        },
        error : function(data){
            alert("error");
        }
    });

ExampleSap.java
public class ExampleSap extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

  //do something
     }
  }


text:
Q: type object 'datetime.datetime' has no attribute 'datetime' I have gotten the following error:

type object 'datetime.datetime' has no attribute 'datetime'

On the following line:
date = datetime.datetime(int(year), int(month), 1)

Does anybody know the reason for the error?
I imported datetime with from datetime import datetime if that helps
Thanks

A: If you have used:
from datetime import datetime

Then simply write the code as:
date = datetime(int(year), int(month), 1)

But if you have used:
import datetime

then only you can write:
date = datetime.datetime(int(2005), int(5), 1)

A: I run into the same error maybe you have already imported the module by using only import datetime so change  from datetime import datetime to only import datetime. It worked for me after I changed it back.

A: Datetime is a module that allows for handling of dates, times and datetimes (all of which are datatypes). This means that datetime is both a top-level module as well as being a type within that module. This is confusing.
Your error is probably based on the confusing naming of the module, and what either you or a module you're using has already imported.
>>> import datetime
>>> datetime
<module 'datetime' from '/usr/lib/python2.6/lib-dynload/datetime.so'>
>>> datetime.datetime(2001,5,1)
datetime.datetime(2001, 5, 1, 0, 0)

But, if you import datetime.datetime:
>>> from datetime import datetime
>>> datetime
<type 'datetime.datetime'>
>>> datetime.datetime(2001,5,1) # You shouldn't expect this to work
                                # as you imported the type, not the module
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
>>> datetime(2001,5,1)
datetime.datetime(2001, 5, 1, 0, 0)

I suspect you or one of the modules you're using has imported like this:
 from datetime import datetime.

A: import time
import datetime
from datetime import date,timedelta

You must have imported datetime from datetime.

A: You should really import the module into its own alias.
import datetime as dt
my_datetime = dt.datetime(year, month, day)

The above has the following benefits over the other solutions:

*

*Calling the variable my_datetime instead of date reduces confusion since there is already a date in the datetime module (datetime.date).

*The module and the class (both called datetime) do not shadow each other.

A: You should use
date = datetime(int(year), int(month), 1)

Or change
from datetime import datetime

to
import datetime

A: For python 3.3
from datetime import datetime, timedelta
futuredate = datetime.now() + timedelta(days=10)

A: I found this to be a lot easier
from dateutil import relativedelta
relativedelta.relativedelta(end_time,start_time).seconds

A: Avoid to write:
from datetime import datetime
datetime.datetime.function()

Solution No. 1:
import datetime
datetime.datetime.function()

Solution No. 2:
from datetime import datetime
datetime.function()

A: from datetime import datetime
import time
from calendar import timegm
d = datetime.utcnow()
d = d.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
utc_time = time.strptime(d,"%Y-%m-%dT%H:%M:%S.%fZ")
epoch_time = timegm(utc_time)

A: delete one datetime from:
date = datetime.datetime(int(year), int(month), 1)

and you get this:
date = datetime(int(year), int(month), 1)

you already imported the first one with this:
from datetime import datetime
so its redundant.

A: The Problem Is That You Are Using The Tag
from datetime

I had The Same Problem You Need To use It Like This Instead
import datetime


text:
Q: Add dynamic page as funnel step in Google Analytics I want to add as the first step of my funnel a dynamic page like this /profile/personal?new=1&ref_product_id=21666, where the id number is dynamic
It would be great to have some help with the best Regex for this type of situation.
Thanks.

A: This regex should cover it:
^/profile/personal\?new=1&ref_product_id=[0-9]+


text:
Q: JVM memory stats don't make sense to me I'm trying to understand the output of various JVM memory diagnostics. First thing I do,
$ jcmd 27263 GC.heap_info
27263:
 garbage-first heap   total 29319168K, used 16150310K [0x00000000c3000000, 0x00000000c3806fd8, 0x00000007c0800000)
  region size 8192K, 1132 young (9273344K), 8 survivors (65536K)
 Metaspace       used 457222K, capacity 526687K, committed 526848K, reserved 1507328K
  class space    used 50629K, capacity 68310K, committed 68352K, reserved 1048576K

So the used heap size is 16150310k/(1024^2) = 15.4GB. And now I do:
$ jstat -gc 27263
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT
 0.0   65536.0  0.0   65536.0 2547712.0 1736704.0 26705920.0 6794156.1  527104.0 457297.5 68352.0 50635.9   1876  212.356   0      0.000  212.356

And I add up S1U (S1 survivor space utilization), EU (Eden space utilization), OU (Old gen utilization): 65536.0 + 1736704.0 + 6794156.1 = 8,596,396.1K = 8.2GB.
What am I missing here? Why does Eden + survivor + Old gen ≠ heap?


text:
Q: Adding a variable to tidy data whose value is based on a column-row calculation My current project contains data that's got a structure like:
my_df <- tibble(
  zn = c("hm","hm", "hm", "h60","h60","h60", "h85","h85","h85"),
  nm = c("c", "cA", "cB", "c","cA", "cB", "c","cA", "cB"),
  val = c(60, 40, 20, 250, 150, 100, 400, 250, 150),
  znt = c(100, 100, 100, 300, 300, 300, 500, 500, 500),
)

my_df
# A tibble: 9 x 4
zn    nm      val   znt
  <chr> <chr> <dbl> <dbl>
1 hm    c        60   100
2 hm    cA       40   100
3 hm    cB       20   100
4 h60   c       250   300
5 h60   cA      150   300
6 h60   cB      100   300
7 h85   c       400   500
8 h85   cA      250   500
9 h85   cB      150   500

And I would like to add a new variable, c0, whose value is defined c0 = znt - c for each zn.  The final result would look like:
# A tibble: 12 x 4
   zn    nm      val   znt
   <chr> <chr> <dbl> <dbl>
 1 hm    c0       40   100
 2 hm    c        60   100
 3 hm    cA       40   100
 4 hm    cB       20   100
 5 h60   c0       50   300
 6 h60   c       250   300
 7 h60   cA      150   300
 8 h60   cB      100   300
 9 h85   c0      100   500
10 h85   c       400   500
11 h85   cA      250   500
12 h85   cB      150   500

I have an idea about how to do it but it seems very convoluted and I'm hoping there's a better way. If this could be accomplished using something from the tidyverse that'd be awesome, too.

A: Another option:
library(tidyverse)

my_df %>%
  group_split(zn) %>%
  map_dfr(~ add_row(.data = .,
                    zn = .$zn[1],
                    nm = 'c0',
                    val = .$znt[1] - .$val[.$nm == 'c'],
                    znt = .$znt[1],
                    .before = 1))

Output:
# A tibble: 12 x 4
   zn    nm      val   znt
 * <chr> <chr> <dbl> <dbl>
 1 h60   c0       50   300
 2 h60   c       250   300
 3 h60   cA      150   300
 4 h60   cB      100   300
 5 h85   c0      100   500
 6 h85   c       400   500
 7 h85   cA      250   500
 8 h85   cB      150   500
 9 hm    c0       40   100
10 hm    c        60   100
11 hm    cA       40   100
12 hm    cB       20   100

A: my_df %>%
   bind_rows(my_df %>% filter(nm == "c") %>%
   mutate(nm = "c0" ,  val = znt - val)) %>%
   arrange(zn, nm)

gives
zn    nm      val   znt
   <chr> <chr> <dbl> <dbl>
 1 h60   c       250   300
 2 h60   c0       50   300
 3 h60   cA      150   300
 4 h60   cB      100   300
 5 h85   c       400   500
 6 h85   c0      100   500
 7 h85   cA      250   500
 8 h85   cB      150   500
 9 hm    c        60   100
10 hm    c0       40   100
11 hm    cA       40   100
12 hm    cB       20   100

A: Another option is to go wide, calculate, then go long.
my_df %>%
  pivot_wider(names_from = "nm", values_from = "val") %>%
  mutate(c0 = znt - c) %>%
  pivot_longer(cols = -c(zn, znt), names_to = "nm", values_to = "val")
#> # A tibble: 12 x 4
#>    zn      znt nm      val
#>    <chr> <dbl> <chr> <dbl>
#>  1 hm      100 c        60
#>  2 hm      100 cA       40
#>  3 hm      100 cB       20
#>  4 hm      100 c0       40
#>  5 h60     300 c       250
#>  6 h60     300 cA      150
#>  7 h60     300 cB      100
#>  8 h60     300 c0       50
#>  9 h85     500 c       400
#> 10 h85     500 cA      250
#> 11 h85     500 cB      150
#> 12 h85     500 c0      100


text:
Q: Copy file from Computer to Android Phone I try to copy file from my PC to Phone but it gets IOException error.
I have written the following code for this task:
Runtime rt = Runtime.getRuntime();
rt.exec("adb pull mnt/sdcard/Samsung/Music/test.mp3 E:/");

A: There can be two reasons:

*

*You may not have the permission to access that file.

*You working directory doesn't have access to adb. Try running the command as:
"cmd /c /pathtoadb/adb.exe pull /pathtofile e:/tryadifferentdirectory/"

A: You can also push a file into device using DDMS tool in eclipse. Select mnt/sdcard from file explorer and then click on push file button.


text:
Q: Group by one column and count the other conditionally - Mysql I have a scheme like the following:
     (id int primary key, itemid int, title char(3) )
which is a database of online purchases in MySQL.
Title column can be either 'Mr' or 'Mrs'. I want to see how many men have purchased each item.
for example the following table:
(id, itemid, title)
(1 , 1     , 'Mr' )
(2 , 1     , 'Mr' )
(3 , 2     , 'Mrs')
(4 , 2     , 'Mrs')
(5 , 2     , 'Mrs')

should result into following table:
(itemid, number_of_men_who_purchased)
(1, 2)
(2, 0)

Most importantly, Note that if No men have purchased an item, still an itemid is to be listed, and a zero should be put in front of it. I cannot form a table where this condition holds. But I think it is possible. As you may have noticed, table is not normalized and performance wont be much of an issue here.
Thank you in advance :)

A: Group on itemid and conditionally sum up. title='Mr' returns 1 if true, else 0, so if no men purchased item with ID 2 the result is 0.
SELECT itemid,SUM(title='Mr') AS number_of_men_who_purchased FROM <table> GROUP BY itemid


text:
Q: Bind ItemSource to listbox This question is probably asked many times before but I have seen so many answers I really dont know what to do.
I have a ListBox:
<listbox ItemSource="{Binding listitems}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <grid>
                <Textblock text="{Binding value1}">
                <Textblock text="{Binding value2}">
            </grid>
        </DataTemplate>
    </ListBox.ItemTemplate>
</listbox>

and I have a list of the following class:
List<Items> listitems = new List<Items>();
public class Items
{
    public string value1 { get; set; }
    public string value2 { get; set; }
}

Sometimes, the list gets updated (more elements added), and I want to let the listbox know the list is updated and update the UI accordingly.
At this moment I bind the list to the listbox in my c# manually, and when it changes, I clear the listbox and add the list again, which is not desired.
I wonder how the listbox can update automatically?

A: Instead of generic List<T>, use ObservableCollection which internally implements INotifyCollectionChanged interface responsible for updating elements on UI.
ObservableCollection<Items> listitems = new ObservableCollection<Items>();

EDIT
ListItems have to be property. You can't bind it with field -
ObservableCollection<Items> listitems = new ObservableCollection<Items>();
public ObservableCollection<Items> Listitems
{
   get
   {
      return listitems;
   }
   set
   {
      listItems = value;
   }
}

XAML -
<Listbox ItemSource="{Binding Listitems}">

A: You have to change the List to ObservableCollection and implement everything according to the MVVM pattern.
public ObservableCollection<Items> Listitems
{
    get { return _listitems ; }
    set
    {
        _listitems  = value;
        RaisePropertyChanged(() => Listitems );
    }
}

The same thing you have to do for each of the properties in Items. Also use Prism for binding. You can find many nice tutorials online like this

A: If you are using List then you have to notify using INotifypropertyChanged otherwise you can use ObservableCollection.
also have to use NotifyOnSourceUpdated=True.


text:
Q: Excel 2013 – put "N/A" in all cells in a row based on the input in a cell I created an Excel database. At a certain column, I can only input Yes/No. What I want to happen is if I put "No", all cells after that cell for that row will show N/A. However, if the answer is Yes, I want those cells to accept be able to accept input.
Given that this has to be true for the whole table and for every new row added and that there is a possibility I would go back and change my answer to "No", I cannot rely on a formula. How can I consistently make sure that the cell values adjust depending on whether the important cell contains a Yes or No?
Example:
Cols    A     B     C      D     E
Row1   Yes   12    Some   1     3
Row2   No    N/A   N/A    N/A   N/A

Note: In case it might affect anything, Columns D and E have Data Validation and can only accept answers from a pre-set list. I have included "N/A" on this list just in case.

A: You could write an event procedure in VBA (of type Worksheet_SelectionChange), check if column A in your table is the target area, and conditionally fill the cells with 'N/A' text. But this would discard all values previously entered.
As an easy alternative, I suggest using Conditional Formats. The condition is
=(TOLOWER($A4)<>"yes")

for cells in row 4, and the format if True would be an identical text color and pattern color. This way, all content is hidden from view while the values are not touched. After all, this is for guiding a person on data input, visually.

A: To add onto your conditional formatting question: Your range can be an equation, instead of a fixed range. This will make the OFFSET function particularly useful, as you can have the conditional formatting automatically expand to include your selection. For example:
=Offset(A1,0,0,CountA(A1:A1000),1)

Will automatically expand to include everything in column A, up to row 1000. If you want it to expand horizontally
=Offset(A1,0,0,1,CountA(A1:DZ1))

Etc.
This will break if you have column breaks in the middle. Not sure how well it handles with merged cells as well (Haven't tested it yet) For issues like that, try something like this: (Example given with 5 blank rows for spacing reasons)
=Offset(A1,0,0,CountA(A1:A1000)+5,1)

Etc. Hopefully that'll help with your "but I need to keep expanding it" issue.


text:
Q: awk: runaway regular expression I can run command on ubuntu:
free | grep Mem | awk '{print $3/$2 * 100.0}'

And get result:
20.1092

But when I try to put it in alias:
alias memTotal="free | grep Mem | awk '{print $3/$2 * 100.0}'"

It don't work:
$ memTotal
awk: line 1: runaway regular expression / * 100.0} ...

A: Try
alias memTotal='free | grep Mem | awk '\''{print $3/$2 * 100.0}'\'

Breaking down the quoting, that's
'free | grep Mem | awk '

followed by an escaped single quote \', then the quoted awk expression '{print $3/$2 * 100.0}' and finally the escaped literal closing quote \'


text:
Q: Android Studio Emulator PANIC Any of my emulators won't work. Usually I use a physical device however right now I want to use advanced profiling feature and in order for it to work I need a device with API 27+ so I have set up an emulator for Google Pixel API 27. When I try to run the app the emulator crashes with following errors.
   The default Haxm API 25 emulator doesn't return any  errors, Android Studio simply doesn't react when I try to choose it from the list. Nothing happens.
14:03   Emulator: PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT

14:03   Emulator: Process finished with exit code 1

A: Thanks to this post
I have learned that solutions proposed in a link provided by @Rick M. do work but you have to RESTART YOUR COMPUTER


text:
Q: using regex - or any other solution - to change number (1-)(2-) to
*
* tags I have a problem using regex in C#, or at least what I think it will be the solution of my problem, I have this string for example:

"Go to Original Budget screen, \n1- Check if Original Budget is Original Budget CV\n- Check if Remaining Budget is Remaining Budget CV\n- Check new field Exchange rate \n- Check new field Original Budget FC \n- Check new field Remaining Budget FC \n2- Check renamed  field under Weekly Details:\n- Check if In Flow is In Flow CV \n- Check if Out Flow is Out Flow CV \n- Check new field In Flow FC\n- Check new field Out Flow FC"

I need it to be :

Go to Original Budget screen
*
*Check if Original Budget is
  Original Budget CV
*
*Check if Remaining Budget is Remaining
  Budget CV
*Check new field Exchange rate
*Check new
  field Original Budget FC
*Check new field Remaining Budget
  FC
*Check renamed field under Weekly Details:

*
*Check if In Flow is In Flow CV
*Check if Out Flow is
  Out Flow CV
*Check new field In Flow FC
*Check new
  field Out Flow FC

so if the simple example didn't get the message, I want to put
 and
 tag in that string so I can use it on a web application
this is a simple of my code:
  private string regexmethod(string field)
    {
        string strRegex = @"^(.+?)\\n[\d|\w]-\W+";
        Regex CatchBetweenTheFirstDot = new Regex(@"\\n[\d|\w]-\W+(.+?)\\n[\d|\w]-\W+");
        Regex CatchTheNumbers = new Regex(@"\\n[\d|\w]-\W+");
        Regex CatchFirstLineBeforDot = new Regex(strRegex);
        Regex CatchInsideFirstRegex = new Regex(@"\\n-\W+");
        var matchFirst = CatchFirstLineBeforDot.Matches(field);
        var matchBetween = CatchBetweenTheFirstDot.Matches(field);
        StringBuilder str = new StringBuilder();
        if (matchFirst.Count > 0)
            str.Append(matchFirst[0].Value);
        foreach (Match matchItem in matchBetween)
        {
            str.Append("

");
            string newvalue = matchItem.Value;
            var matchTheInside = CatchInsideFirstRegex.Matches(newvalue);
            for (int i = 0; i < matchTheInside.Count; i++)
            {
                if (i == 0)
                {
                    newvalue.Replace(matchTheInside[i].Value, @"

");
                }
                else
                {
                    newvalue.Replace(matchTheInside[i].Value, @"<\li>
");
                }
            }
            if (newvalue.Length > 0)
            {
                newvalue += "

";
                str.Append(newvalue);
            }

        }

this is what i got so far, but it didn't work with me.
any help will be thankful.

A: Here is class for parsing lines from your text:
public class ListItem
{
    public static bool TryParse(string s, out ListItem item)
    {
        item = null;
        if (!IsListItem(s) && !IsOrderedListItem(s))
            return false;

        item = new ListItem { IsOrdered = IsOrderedListItem(s),
                              Text = GetItemText(s) };
        return true;
    }

    private static bool IsListItem(string s) {
        return Regex.IsMatch(s, @"^- .*");
    }

    private static bool IsOrderedListItem(string s) {
        return Regex.IsMatch(s, @"^\d+- .*");
    }

    private static string GetItemText(string s) {
        return s.Substring(s.IndexOf('-') + 1).Trim();
    }

    public bool IsOrdered { get; private set; }
    public int Index { get; private set; }
    public string Text { get; private set; }
    public string Html {
        get { return String.Format("
{0}
", Text); }
    }
}

Originally I thought you will need to display ordered list items in ordered list
 but I removed that part. This is code which builds html lists:
public static IEnumerable<string> CreateHtmlLists(IEnumerable<string> lines)
{
    ListItem currentItem = null;
    int listDepth = 0;

    foreach (var line in lines)
    {
        ListItem item;
        if (!ListItem.TryParse(line, out item)) {
            yield return line; // not list item, return as is
            continue;
        }

        if (currentItem == null || (currentItem.IsOrdered && !item.IsOrdered))
        {
            yield return "
"; // start new nested list
            listDepth++;
        }
        else if (!currentItem.IsOrdered && item.IsOrdered)
        {
            yield return "
"; // close nested list
            listDepth--;
        }

        yield return item.Html;
        currentItem = item;
    }

    while (listDepth > 0) { // close all parent lists
        listDepth--;
        yield return "
";
    }
}

And usage:
var lines = text.Split('\n');
text = String.Join("\n", CreateHtmlLists(lines));

Output for your sample text:
Go to Original Budget screen,

Check if Original Budget is Original Budget CV

Check if Remaining Budget is Remaining Budget CV

Check new field Exchange rate

Check new field Original Budget FC

Check new field Remaining Budget FC

Check renamed field under Weekly Details:

Check if In Flow is In Flow CV

Check if Out Flow is Out Flow CV

Check new field In Flow FC

Check new field Out Flow FC


text:
Q: How to publish a message with Spring Cloud Stream on application Startup? I am trying to send a message to rabbitmq with spring cloud stream on application startup. Using the sample code below.
public interface Barista {
    @Input
    SubscribableChannel orders();
}

SpringBoot app which enables bindings
@SpringBootApplication
@EnableBinding(Barista.class)
public class DemoSpringCloudStreamApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoSpringCloudStreamApplication.class, args);
    }
}

Application Runner that should just send a message on startup
@Component
public class Startup implements ApplicationRunner {

    @Autowired
    private Barista barista;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        Message<String> message = MessageBuilder.withPayload("test")
                                             .build();

        barista.orders().send(message);
    }

    //    @StreamListener("orders")
    //    public void handle(String message) {
    //        System.out.println(message);
    //    }
}

The code above produces the exception below unless I uncomment the commented out code above.
java.lang.IllegalStateException: Failed to execute ApplicationRunner
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:791) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:778) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
    at com.example.demospringcloudstream.DemoSpringCloudStreamApplication.main(DemoSpringCloudStreamApplication.java:12) [classes/:na]
Caused by: org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'application.orders'.; nested exception is org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers, failedMessage=GenericMessage [payload=test, headers={id=4170f931-b303-dc96-152b-19d5c3421fb3, contentType=application/json, timestamp=1528930565229}]
    at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) ~[spring-integration-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:445) ~[spring-integration-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:394) ~[spring-integration-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at com.example.demospringcloudstream.Startup.run(Startup.java:25) ~[classes/:na]
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:788) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
    ... 5 common frames omitted
Caused by: org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers
    at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:138) ~[spring-integration-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:105) ~[spring-integration-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:73) ~[spring-integration-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    ... 9 common frames omitted

I am using Spring Boot 2.0.2 and Sprig Cloud Stream 2.0.0 as shown in the pom below
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo-spring-cloud-stream</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo-spring-cloud-stream</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.RC2</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream-test-support</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>

According to this accepted answer https://stackoverflow.com/a/42600330/438319 the 'ApplicationRunner' should work. However, I get
org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers The app firing the events does not need to listen to the event.
So how do I fire an event with Spring Cloud Stream on application startup without having to listen to the event?

A: It actually tells you in the error message exactly what it means.
Caused by: org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'application.orders'.; nested exception is org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers, failedMessage=GenericMessage [payload=test, headers={id=4170f931-b303-dc96-152b-19d5c3421fb3, contentType=application/json, timestamp=1528930565229}]

You are sending a message to application.orders channel but there are no subscribers to that channel.

A: You are sending the message to an input channel. That's why you are getting the error when you have no subscribers to the channel.
In order to send message from your application, try to define your channel as an output channel like:
public interface Barista {
  @Output
  MessageChannel orders();
}

If you actually want your channel as an input channel for any reason, you must add a subscriber.


text:
Q: how to access to wordpress dashboard?

hey there i hosted my site on AWS and it was all okay when i used ssl insecure content but unfortunately  i deactivated that plugin by mistake and it made me logout of my admin panel.
So, now when i try to access my dashboard by typing correct username it is not allowing me to sign in into it. please help me in  this. The first image shows how my login page looks (different from each time) and a popup box that appears when i try to login in my account and after clicking on it it reverts me back to same login page. please do help me i am depressed now.

A: First thing, better to attach the valid SSL certificate as it's not only about your dashboard but the end-user will also face the same issue when they try to  access your website.
Or if you think that you were able to access your website with that plugin, then do the following

*

*Ssh to your instance

*install the plugin from the command line that you have removed and it will start working back.

wp plugin install <plugin-name>

how-to-install-wordpress-plugins-wp-cli

A: This is because your wordpress site is attempting to load your assets over HTTP rather than HTTPS.
Your SSL comes back as valid when running SSL labs so there is no need to worry about your SSL being invalid.
This will come down to your site actually loading on HTTP behind the load balancer so it is not aware it should be loaded over HTTPS.
There is a small change you can make that fools your blog into believing that it should return HTTPS urls. At the top of your index.php file add the following
$_SERVER['HTTPS'] = 'on';
$_SERVER['SERVER_PORT'] = 443;

By doing this only HTTPS urls will be rendered on your site allowing it to be fully accessible as intended.

A: This is happening because of SSL Issue. Do the Following

*

*Install Really Simple SSL Plugin https://wordpress.org/plugins/really-simple-ssl/

*Change Site Url and Home URL Prefix from http:// to https://

Note:- Disable SSL and Install Plugin First in order to be Succesfully run it


text:
Q: Drupal wrongly allowing access for anonymous users to a single edit page My Drupal / ubercart install has a bizarre issue. Anonymous users can access an edit page /node/44/edit for s SINGLE node only - an ubercart product. I have created a new version of the node, which does not have the issue. The tabs (view / edit) are also available on the product page to anonymous users. The issue became clear when the page was edited by a spam bot.
Is there any way I can output the decision making process which Drupal makes to the screen? For example can I output the variables to the screen which Drupal uses to make the decision about whether the user has access to a given URL or not?
Thanks in advance.

A: There may be a better way, but to start, you could create a custom module that implements hook_menu_alter, then dump the contents of the $items array, to see the access callback associated with /node/44/edit or /node/%/edit.

A: One thing to try would be to "rebuild node permissions" You do this from the admin/content/node-settings page. It might be as simple as the permissions being jacked up, which is rare but does happen sometimes.


text:
Q: How to add Margin in Jetpack Compose? How exactly can you add Margin in Jetpack Compose?
I can see that there is a Modifier for padding with Modifier.padding(...) but I can't seem to find one for margins or am I blind?
Someone guide me please.
Thank you very much.

A: Thinking in terms of padding and margin you refer to the so-called box model that we are used to. There's no a box model in Compose but a sequence of modifiers which is applied to a given composable. The trick is that you can apply the same modifier like padding or border multiple times and the order of these matters, for example:
@Composable
fun PaddingExample() {
    Text(
        text = "Hello World!",
        color = Color.White,
        modifier = Modifier
            .padding(8.dp) // margin
            .border(2.dp, Color.White) // outer border
            .padding(8.dp) // space between the borders
            .border(2.dp, Color.Green) // inner border
            .padding(8.dp) // padding
    )
}

As the result you'll get this composable:

This design is well explained in the Modifiers documentation:

Note: The explicit order helps you to reason about how different modifiers will interact. Compare this to the view-based system where you had to learn the box model, that margins applied "outside" the element but padding "inside" it, and a background element would be sized accordingly. The modifier design makes this kind of behavior explicit and predictable, and gives you more control to achieve the exact behavior you want.

A: So from what I can understand after reading the documentation there is no margin modifier as such as the API designer felt it is redundant to give something different name which essentially does the same thing.
So let's say you want to apply a margin of 8dp before colouring your container with yellow background and you want the container with a padding of 4dp for the content.
Column(modifier = Modifier.padding(all = 8.dp)
                          .background(color = Color.Yellow)
                          .padding(all=4.dp)) {
        Text(text = "Android")
        ...
    }

Here in the above example you can see that I have applied the padding first and after that I have added background colour to the container and finally the last padding. And here's how it looks. Just like we intended.

A: I was also looking for something which should give me a direct option to set margin on a View like TextView. But unfortunately we don't have margin support in Jetpack compose. But the good news is we can still achieve it by using layout container like Box, which allows us to add views like TextView, ImageView etc.
So you can add margin to any of the child(TextView) by using padding modifier to the parent(Box).
Here is the code:
Box(Modifier.padding(10.dp)) {
    Surface(color = Color.LightGray) {
        Text(text = "Hello $text!", color = Color.Blue,
            modifier = Modifier.padding(16.dp))
    }
}

And the result is:

Here I have given 10.dp padding to the box.
Hope it is useful.

A: You can also use Spacer:
Spacer(modifier = Modifier.width(10.dp))

It represents an empty space layout, whose size can be defined using Modifier.width, Modifier.height and Modifier.size modifiers.
Suppose you want to add margin between 2 composables, then you can achieve it as
Text(
    text = stringResource(id = R.string.share_your_posters),
    fontSize = 16.sp,
    color = Color.Black
)

Spacer(modifier = Modifier.width(10.dp))

Image(painter = painterResource(id = R.drawable.ic_starts), contentDescription = null)

A: You can achieve the same effect as margin with putting your content, that has padding, inside a different composable like Box and make outer composable clickable. With this approach, inner padded areas will be included in clickable content.

A: The margin is different than padding, margin is the space outside the widget, where padding is the distance inside the widget, in old XML you could have decided explicitly which one to use, however the new compose way is different.
How compose treat paddings and margins?
There is an object which can be set as Parameter to the composable called Modifier, you can use this to do both margins and paddings.
Example of Padding:
    Text(
    text = "Test",
    modifier = Modifier
        .padding(16.dp)
        .clickable { }
)

Example of Margin
    Text(
    text = "Test",
    modifier = Modifier
        .clickable { }
        .padding(16.dp)
)

As you can see the order makes a difference here in compose, all the modifiers are implemented by order.

A: You can consider padding and margin as the same thing (imagine it as "spacing"). A padding can be applied twice (or more) in the same composable and achieve the similar behavior you would get with margin+padding. For example:
val shape = CircleShape
Text(
    text = "Text 1",
    style = TextStyle(
        color = Color.White,
        fontWeight = FontWeight.Bold,
        textAlign = TextAlign.Center),
    modifier = Modifier.fillMaxWidth()
        .padding(16.dp)
        .border(2.dp, MaterialTheme.colors.secondary, shape)
        .background(MaterialTheme.colors.primary, shape)
        .padding(16.dp)
)

Will result on this:

As you can see, the first padding is adding a space between the component and its border. Then the background and border are defined. Finally, a new padding is set to add space between the border and the text.

A: You can achieve a margin effect by using nested Surface elements with padding
e.g.
@Composable
fun MainScreen() {
    Surface(color=Color.Yellow, modifier=Modifier.padding(10.dp)){
        Surface(color=Color.Magenta, modifier=Modifier.padding(30.dp)) {
            Surface(
               color = Color.Green,
               modifier = Modifier.padding(10.dp).wrapContentSize()) {
               Text(text = "My Dummy Text", color = Color.Black)
            }
        }
    }
}


text:
Q: Why can't I use _mm_sin_pd? Specifics says:
__m128d _mm_sin_pd (__m128d a)
#include <immintrin.h>
CPUID Flags: SSE
Description
Compute the sine of packed double-precision (64-bit) floating-point elements in a expressed in radians, and store the results in dst.

But it seems it is not defined?

A: This symbol has a blue header, that means it's part of SVML. Link against it to get the symbol, as the documentation requires it.
SVML will then dispatch the call to the most adequate implementation for your architecture.


text:
Q: Using msvcrt with Mingw-w64 I'm trying to use the Mingw-w64 toolchain provided by LH_Mouse, version 10.2.1.
When compiling this small program:
#include <windows.h>
#include <stdio.h>

int wmain()
{
    wprintf(L"Hello world!\n");
    ExitProcess(0);
}

with the following command:
gcc.exe test.c -o test64.exe -municode -s -Os -Wall -nostdlib -lmsvcrt -lkernel32 -e wmain

I get an error: undefined reference to `__mingw_vfwprintf'
Z:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.1/../../../../x86_64-w64-mingw32/bin/ld.exe: R:\Temp\ccDSsj2M.o:test.c:(.text+0x3d): undefined reference to `__mingw_vfwprintf'
collect2.exe: error: ld returned 1 exit status
I previously used Mingw-w64 7.3.0 provided on SourceForge and everything worked fine.
Of course I can use the stdlib (and in this case there is no error) but this increases the size of the executable.
I have read that some changes have been done recently to support UCRT. Is it related?
Is there a way to use msvcrt like before?
Edit: using -lmingwex does not really help. If located after -lmsvcrt, it produces a huge amount of varied "undefined reference" errors. If located before, we got several "undefined reference" to ___chkstk_ms, and one to _pei386_runtime_relocator.
The first ones can be removed by adding -lgcc after -lmingwex. For the last "undefined reference", I have found nothing. Adding -lmingw32 does not help, no matter its location.
So for now, the only possibilities I see are to either modify stdio.h, or create my own declarations.
Well, I use mingw since many years and its not the biggest issue I encountered. But I am a bit disappointed that it affects such basic functions.

A: You are trying to compile your application with -nostdlib option which means that standard C functions (like printf, scanf, wprintf, ...) are not available for your application. Therefore you should not include standard C header files (like stdio.h, stdlib.h, ...) and also you should not use wprintf in your application.
If you really want to standard C function with -nostdlib option then you have to write your own C header files and also your own implementation of standard C functions (like wprintf).
What you did was to include MinGW's stdio.h header file which calls lot of standard C functions and also internal MinGW functions and then told gcc (via -nostdlib to not link these standard functions and neither internal MinGW functions. Which obviously resulted in lot of linker errors.
Then you have tried to manually link msvcrt.dll library but it failed too as this Windows library does not contain internal MinGW functions used in MinGW's stdio.h header file.
If you really want not use standard C functions from gcc/MinGW (via -nostdlib option) but rather directly via Windows msvcrt.dll library then you have to use also Windows stdio.h header file and not MinGW one. But beware that Windows header file stdio.h is not supported for gcc compiler and it also does not have to work.
So you should first answer questions, why you are trying to use standard C functions (like wprintf) without standard C library with gcc compiler? This sounds really strange and such thing is common only in freestanding environment or for bare-metal applications (like firmware, bootloader, kernel, ...). Are you workarounding some other bug which you have not mentioned?
And to answer your question, why in previous version it (probably) worked fine. Older version of gcc compiled C code according to C89 standard (with GCC extensions). New version of gcc started to compile C code according to C11 standard. Windows library msvcrt.dll provides only subset of standard C functions and only for C89 standard. For this reason MinGW provides its own implementation (or fixes) for some standard C functions to be compliant with C99 and C11 standards. As older gcc compiled your application as C89 code and manually linked msvcrt.dll library provided somehow compatible implementation for printf and wprintf, it resulted in final exe file without errors. Now with new gcc you are compiling your application as C11 code and you are trying to call C11 wprintf function but this function in msvcrt.dll is not compatible with C11 and therefore you get lot of errors.
Windows provides C11 standard functions in UCRT libraries. msvcrt.dll provides only subset of C89.
So you really should not compile your application with -nostdlib if your intention is to produce executable application and use standard C functions.
You can instruct new gcc to compile your C application as C89 with option -std=c89. This should instruct new gcc to behave like old gcc.


text:
Q: Unable to connect the android device to Windows 7 I have the following configuration

*

*Windows 7 Ultimate running on MacBookPro

*Samsung Galaxy SIII (GT-I9300) with cyanogenmod 10.2(stable)

*Android SDK with eclipse

I tried so much but my eclipse is not detecting the phone for usb debugging of an android application. I already tried the following.

*

*I enabled the USB debugging on phone

*After I connect my phone through USB cable I can only charge the phone. But can't do any file transfer.

*I installed the samsung kies lite and samsung kies 3 also. But no luck. Still cant detect.

*In the device manager, under other devices, it lists my phone as usb device with name GT-I9300 with an yellow mark. I tried to update the driver and chose the google driver which comes with sdk. But it shows Windows could not find device driver software for your device.

*I tried the commands "adb devices"  and "fastboot devices". But the list is blank.

Now I am out of options. Can anybody give me some idea where is the problem or how can i troubleshoot it step by step?

A: You need to download Google usb driver in your SDK (http://developer.android.com/sdk/win-usb.html)
Then update the driver with local file from SDK_PATH/extras/google/usb_driver/
[EDIT]
If you still have the problem do update driver like this:

*

*Choose Let me pick from the list of device drivers on my computer

*Click Have disk

*Browse for SDK_PATH/extras/google/usb_driver/android_winusb.inf

*Select Android ADB Interface and install.

A: I had the same problem and this is how I fixed it. Hope it works for you as well.

*

*Open the "Device Manager".

*Expand the "Other Devices" and right click on the device below

*Select the "Update drivers" option.

*Then "Browse my computer for driver software" and choose "let me pick from list of device drivers from my computer".

*Click the "have disk" button.

*Pick the "android_winsub.inf" file from SDK driver.

*Select "Android ADB Interface"

Then simply click ok and install it. Remember the "Other  Devices" option may get disappear after the completion of the process so check in the task bar there should be a USB icon showing the connectivity. That means it's working fine and you're good to go.


text:
Q: generate variable based on first occurrence of a value I have 5 repeat measures called pub1:pub5 each taking a value of 1 to 4. Each was measured at a different age age1:age5. That is, pub1 was measured at age1....pub5 at age5 etc.
I would like to create a new variable age_pb2 that shows the age at which a value of 2 first occurred in pub. For example, for individual x, age_pb2 will equal age3 if the first time a value of 2 is scored is in pub3
I have tried modifying previous code but not had much luck.
library(tidyverse)
#Example data
N <- 2000
data <- data.frame(id = 1:2000,age1 = rnorm(N,6:8),age2 = rnorm(N,7:9),age3 = rnorm(N,8:10),
               age4 = rnorm(N,9:11),age5 = rnorm(N,10:12),pub1 = rnorm(N,1:2),pub2 = rnorm(N,1:2),
               pub3 = rnorm(N,1:2),pub4 = rnorm(N,1:2),pub5 = rnorm(N,1:2))

 data <- data %>% mutate_at(vars(starts_with("pub")), funs(round(replace(., .< 0, NA), 0)))

#New variable showing first age at getting a score of 2 (doesn't work)

i1 <- grepl('^pub', names(data)) # index for pub columns
i2 <- grepl('^age', names(data)) # index for age columns

data[paste0("age_pb2")] <- lapply(2, function(i) {
j1 <- max.col(data[i1] == i, 'first')
j2 <- rowSums(data[i1] == i) == 0
data[i2][cbind(seq_len(nrow(data)), j1 *(NA^j2))]
})

A: set.seed(1)
N <- 2000
data <- data.frame(id = 1:2000,age1 = rnorm(N,6:8),age2 = rnorm(N,7:9),age3 = rnorm(N,8:10),
                   age4 = rnorm(N,9:11),age5 = rnorm(N,10:12),pub1 = rnorm(N,1:2),pub2 = rnorm(N,1:2),
                   pub3 = rnorm(N,1:2),pub4 = rnorm(N,1:2),pub5 = rnorm(N,1:2)) %>%
  mutate_at(vars(starts_with("pub")), funs(round(replace(., .< 0, NA), 0))) %>%
  mutate(age_pb2 = eval(parse(text = paste0("age", which.min(apply(select(., starts_with("pub")), 2, function(x) which(x == 2)[1]))))))

The way it works, you apply over the pubs columns and take with which(x == 2)[1] the first matched row per column, then take the which.min to get the column index number (of pub respectively age) which you then paste with "age" to assign (using eval(parse(text = variable name))) the respective column.
E.g. here after apply you get
[pub1 = 2,  pub2 = 1, pub3 = 2, pub4 = 4, pub5 = 2]

which is the first occurrence of 2 per column. The earliest (which.min) occurrence is for the second pub column, thus index is 2. This pasted with "age" and eval parsed to mutate.
EDIT
It is probably more convenient to do it in a for loop for all age_pbi, or there is an easy solution in dplyr that I am not aware of.
for (i in 1:5) {
  index <- which.min(apply(select(data, starts_with("pub")), 2, function(x) which(x == i)[1]))
  data[ ,paste0("age_pb", i)] <- data[ ,paste0("age", index)]
}

Note however, that which.min takes the first minimum. E.g. pub1 and pub2 both have a 1 in the first row, so the above approach assigns age1 to age_pb1 whereas it could be age2 as well. I don't know what you want to do with this, so can't say what is a better option.