text:
Q: Installing RS2008 against SQL Server 2000 Is there any chance of installing Reporting Services 2008 against an instance of SQL Server 2000? The docs clearly state that only SQL Server 2005 or 2008 are supported, but I thought I should ask anyway, for ways to bypass this limitation.
I should mention that I am not talking about the data source for my reports (which is a remote data source that can be any type of sql server). I am interested in the databases where the report server stores its things.

A: No, the reportserver and reportservertempdb REQUIRE 2005 or 2008. You could source data for your reports from a 2000 instance, but your reporting services databases need to be 2005 or 2008.
see: http://msdn.microsoft.com/en-us/library/ms157285.aspx and read the section on Database Server Version Requirements

A: I have no idea if this would work, however reporting services also depends on the SQL Server Agent service (for subscriptions) as well as the relational databases, so both would need to be compatible. If you have Reporting Services 2008 then you (or your organisation) must own a SQL Server 2008 license of some sort, therefore I cannot see why you would ever want to do this since you can install the SQL 2008 database engine to support your report server (on the same server, otherwise you would need an additional license).
Bear in mind that as of April 2008 SQL Server 2000 is no longer in mainstream support from Microsoft, so you should avoid implementing new infrastructure or functionality using this version wherever possible. The configuration you describe above, even if you got it to work, would be unsupported by Microsoft and probably all ISVs and partners.


text:
Q: Check Box is not showing hidden NavBar in CSS I'm trying to use a responsive navbar with CSS, but the check box is not showing the hidden navbar at media queries settings at max-width of 760px, I'm providing the full navigation bar code for you to see where is the prblem, please check my codes at the screen settings I used, I know he is something wrong, but where? I don't know.
I'll be gratfull.

#navigationBar {
  width: 100%;
  margin: 80px 0;
  display: flex;
  text-align: center;
  justify-content: space-between;
  align-items: center;
}
#navBarLogo,
#navigationBar ul {
  width: 50%;
  display: flex;
}
#navBarLogo img {
  width: 25%;
}

#navigationBar ul li {
  margin-right: 10%;
  list-style: none;
}
li a {
  text-decoration: none;
  color: aliceblue;
}
li a:hover {
  color: #ea6731;
  transition: 0.5s;
}
@media(max-width:760px){
  #navigationBar {
    width: 100%;
    margin: 50px 0;
    display: block;
  }
  #navBarLogo {
  width: 100%;
  display: block;
  padding: 0;
}
#navigationBar ul {
  display: none;
}

#navBarLogo img {
  width: 15%;
}

.nav-toggle:checked ~ #navigationBar ul{
  width: 100%;
  display: block;
  padding: 0;
}

#navigationBar ul li {
  margin: 0;
  list-style: none;
}
}

            <input type="checkbox" class="nav-toggle"/>

Home

Portfolio

About

Contact

A: Problems:

*

*Line 50: .nav-toggle:checked ~ #navigationBar ul { should be   .nav-toggle:checked ~ ul { removing the #navigationBar.

Why? You cannot select a parent selector from a child element, and the .nav-toggle is a child itself to the #navigationBar.

*Line 41: #navigationBar ul { should be just ul { removing the #navigationBar. Same applies on Line 10 #navigationBar ul { to be only ul {
Why? As we fix Line 50 and uses .nav-toggle:checked ~ ul we need to use ul instead of #navigationBar ul as Line 41 will overwrite our styles at line 41 due to its higher priority in CSS Specificity.
PROTIP: I suggest giving that ul a class like menu-items instead of relying on ul selector to avoid any conflicts with other ul in your website
Fully working code:

#navigationBar {
  width: 100%;
  margin: 80px 0;
  display: flex;
  text-align: center;
  justify-content: space-between;
  align-items: center;
}
#navBarLogo,
ul {
  width: 50%;
  display: flex;
}
#navBarLogo img {
  width: 25%;
}

#navigationBar ul li {
  margin-right: 10%;
  list-style: none;
}
li a {
  text-decoration: none;
  color: aliceblue;
}
li a:hover {
  color: #ea6731;
  transition: 0.5s;
}
@media (max-width: 760px) {
  #navigationBar {
    width: 100%;
    margin: 50px 0;
    display: block;
  }
  #navBarLogo {
    width: 100%;
    display: block;
    padding: 0;
  }
  ul {
    display: none;
  }

  #navBarLogo img {
    width: 15%;
  }

  .nav-toggle:checked ~ ul {
    width: 100%;
    display: block;
    padding: 0;
  }

  #navigationBar ul li {
    margin: 0;
    list-style: none;
  }
}

  <input type="checkbox" class="nav-toggle" />

Home

Portfolio

About

Contact

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to use timestamp as 'x' value for data visualization? Please see the screenshot of the dataframe I am using:

I am trying to use the index value ('TIMESTAMP') as 'x' to do data visualization, however it gives me value error.
Here's the error I am seeing:

Here's the code I used:
sns.scatterplot(data=crimes_2018, x='TIMESTAMP', y='TYPE')

If I want to use the index 'TIMESTAMP' as 'x' value. Do I need to enter additional information than its index name?
Any advice is appreciated!

A: We can map the TYPE column which is categorical to numerical, and then call sns.scatterlot

*

*Step 1 - Reproducing the Data

>>> import seaborn as sns
>>> import pandas as pd
>>> import random

>>> dates = pd.date_range('2018-01-01','2018-01-10')

>>> reas = ['Mischief', 'Theft of Bicycle', 'Theft from Vehicle', 'Break and Enter']
>>> reasons = [random.choice(reas) for i in range(10)]

>>> df = pd.DataFrame({'TIMESTAMP':dates,'TYPE':reasons})
>>> df
   TIMESTAMP              TYPE
0 2018-01-01   Break and Enter
1 2018-01-02   Break and Enter
2 2018-01-03          Mischief
3 2018-01-04   Break and Enter
4 2018-01-05  Theft of Bicycle
5 2018-01-06          Mischief
6 2018-01-07   Break and Enter
7 2018-01-08   Break and Enter
8 2018-01-09          Mischief
9 2018-01-10  Theft of Bicycle

*

*Step 2 - Creating mapped column

>>> dct = {item:i for i, item in enumerate(reas)}
>>> df['TYPE_MAPPED'] = df['TYPE'].map(dct)
   TIMESTAMP              TYPE  TYPE_MAPPED
0 2018-01-01   Break and Enter            3
1 2018-01-02   Break and Enter            3
2 2018-01-03          Mischief            0
3 2018-01-04   Break and Enter            3
4 2018-01-05  Theft of Bicycle            1
5 2018-01-06          Mischief            0
6 2018-01-07   Break and Enter            3
7 2018-01-08   Break and Enter            3
8 2018-01-09          Mischief            0
9 2018-01-10  Theft of Bicycle            1

>>> df[['TIMESTAMP','TYPE_MAPPED']].set_index('TIMESTAMP').plot()


text:
Q: Android: Javascript function not continuing after eval() I am trying to execute an arbitrary Javascript function on an Android WebView and get its result.  To invoke the function, I use loadUrl() and I have also added a Javascript interface that is supposed to be called with the result.  This is what the JS looks like that I am trying to execute from loadUrl():
(function () {
  var res = eval(foo());
  MyInterface.setResult(res);
})()

foo stands in for the name of the function I am trying to invoke and MyInterface is the interface that I added earlier.  When I do this, foo() does get invoked but the next call does not.  I tried changing MyInterface.setResult(res); to simpler JS statements like console.log("finished") but nothing is executed after eval().  If I remove eval the next statement is executed.  Any idea on what's going on here?

A: eval takes a string. It's trying to invoke a string foo is returning.
Try eval("foo()");
edit: you could just call the function without eval as well.


text:
Q: Python: how to drop duplicates with duplicates? I have a dataframe like the following
df
     Name  Y
0     A    1
1     A    0
2     B    0
3     B    0
5     C    1

I want to drop the duplicates of Name and keep the ones that have Y=1 such as:
df
     Name  Y
0     A    1
1     B    0
2     C    1

A: Use drop_duplicates method,
df.sort_values('Y', ascending= False).drop_duplicates(subset=['Name'])

A: groupby + max
Assuming your Y series consists only of 0 and 1 values:
res = df.groupby('Name', as_index=False)['Y'].max()

print(res)

  Name  Y
0    A  1
1    B  0
2    C  1

A: Does  'Y' column contain only  0-1? In that case, you can try the following :
df = df.sort_values(['Y'], ascending= False)
df = df.drop_duplicates(['Name'])


text:
Q: How to get time from user with respect to timezone Good day,
I am working on a project reporting.
and its my first time i have to deal with datetime.
I have database mongodb, as we know mongodb stores date time in UTC.
now i would like to show data from users provided date and time zone.
for example if i am login in my system i can set my timezone from dropdown. say i choose GMT+05:00 now if i choose date start and end as 2018-07-05 and 2018-07-06
how can i get the proper time with user specified time zone.
I guess if user has selected the time zone GMT+05:00 then date must be start from 2018-07-04 19:00:00 and 2018-07-05 19:00:00 minus 5 hours from given time.
how can i achieve this is java.

A:     String userTimeZone = "Asia/Samarkand";
    String userDate = "2018-07-05";

    ZoneId zone = ZoneId.of(userTimeZone);
    Instant dbInstant = LocalDate.parse(userDate)
            .atStartOfDay(zone)
            .toInstant();

    System.out.println(dbInstant);

This prints what you had expected:

2018-07-04T19:00:00Z

I don't know MongoDB's JDBC driver, but I assume it would be happy to accept an Instant and store it in UTC in the database.
GMT+05:00 is not really a time zone, it's a GMT offset. If your user is in a time zone that uses the same UTC offset always, it would work. But politicians tend to change their minds, so even if that time zone doesn't use summer time (DST), it may do in a couple of years. And very many time zones already do. Therefore your user should pick a proper time zone like Asia/Tashkent, for example.
Edit: I understand from your comment that MongoDB expects a java.util.Date object. Funny and old-fashioned, but in that case the conversion is straightforward when you know how:
    Date dbDate = Date.from(dbInstant);
    System.out.println(dbDate);

On my computer in Europe/Copenhagen time zone this printed:

Wed Jul 04 21:00:00 CEST 2018

Don't be fooled: this is the correct time. Date.toString (implicitly called through System.out.println) grabs my JVM's time zone setting and uses it for generating the string. The Date itself doesn't have a time zone in it and holds the same point in time as the Instant.
Link: Oracle tutorial: Date Time

A: If you already have the user selected time zone what you need to do is parse the date from DB to GMT:
Date dateFromDb = getDateFromDb(); // date from db
LocalDateTime localDateTime = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.of("GMT")); // parsing date to GMT but using LocalDateTime
Date correctDate = Date.from(localDateTime); // transforming into java.util.Date


text:
Q: Get a single page's URL metric based on its base URL, ignoring the query string The hit URL of a single page can be different like /post/15777, /post/15777?fbclid=xxx or /post/15777?rel=notification.
I want to get the URL /post/15777 metric (pageviews) but could not by using the API method getPageUrl in matomo api module because it would think of them as different URL.
GET /?
module=API&format=JSON&method=Actions.getPageUrl&pageUrl=/post/15777&idSite=1&period=range&date=2018-12-12,2019-12-12&token_auth=xxxxxxxxxxxxxxxxxx

A: Solved
Instead of method Actions.getPageUrl with pageUrl parameter, use the Actions.get method with segment parameter of pageUrl contains a specific url segment=pageUrl=@/post/15777
GET /?module=API&format=JSON&method=Actions.get&segment=pageUrl=@/post/15777&idSite=1&period=range&date=2018-12-12,2019-12-12&token_auth=xxxxx


text:
Q: Implicit differentiation , leibniz notation- problem differential operator notation in multivariable calc here are three examples of what im finding troublesome in understanding, i can workout the basics by myself but when it comes to iterating the differential operator i find the notation and the process convoluted. My biggest problem is i dont know in which logical step im making the mistake and so i dont know what to search so i can clear my confusion.
example one change the equation $y'' +\frac{2}{x}y'+y=0 $ by taking "$x$ as a function and $t=xy$ for a free variable"
my work- i take $\frac{\mathrm dy}{\mathrm dx}=\frac{\frac{\mathrm dy}{\mathrm dt}}{\frac{\mathrm dx}{\mathrm dt}}=\frac{1}{x\frac{\mathrm dx}{\mathrm dt}}$ but my book solution says $\frac{1}{x\frac{\mathrm dx}{\mathrm dt}}-\frac{1}{x^2}$ and i have no idea why since even if they used the chain rule $\frac{\mathrm d (\frac{t}{x})}{\mathrm dt}$ it would not give the book answer.even if we swapped in $y=\frac{t}{x}$ and then using the chain rule i dont get and extra $t$ as in  $\frac{1}{x\frac{\mathrm dx}{\mathrm dt}}-\frac{t}{x^2}$
example two find $\mathrm d z , \mathrm d^2 z$ given implicit function (1) $\frac{x}{z}=\ln(\frac{z}{y})+1$ so i use the total differential on (1) to get $$\frac{z\mathrm dx-x \mathrm dz}{z^2}=\frac{y}{z}\frac{y \mathrm dz - z \mathrm dy}{y^2}$$   from which by rearranging we can get $\mathrm d z$ $$\mathrm d z=\frac{z(y\mathrm dx+z\mathrm dy)}{y(x+z)}$$ $(x\neq-z)$  by simple algebra manipulation, now we use total derivative on  (2)$$ zy\mathrm dx-xy \mathrm dz -yz \mathrm dz-z^2 \mathrm dy=0$$ to get (book answer gives this)$$y(x+z)\mathrm d^2 z=z\mathrm dx \mathrm dy+(z \mathrm dy - x \mathrm dy)\mathrm dz -y^2 \mathrm dz^2$$ and i dont understand this process at all as by going by partial derivatives i dont get the second derivative to look like that(i dont know how i would use chain rule on for example $yz \mathrm dx=z\mathrm dx\mathrm dz+y\mathrm dx\mathrm dz$ ?) and im confused as to what $\mathrm dz^2$ is supposed to mean rigorously at this point. after rearranging and using $\mathrm dz$ the book answer gives $$\mathrm d^2 z=-\frac{z^2(y\mathrm dx-x\mathrm dy)^2}{y^2(x+z)^3}$$
example three  transform $y'''=\frac{6y}{x^3}$ if new variable is $t=\ln(|x|)$ so i begin to calculate $y'$ as follows $$\frac{\mathrm dy}{\mathrm dx}=\frac{\mathrm dy}{\mathrm dt}\frac{\mathrm dt}{\mathrm dx}=\frac{1}{x}\frac{\mathrm dy}{\mathrm dt}$$ now to calculate the second derivative by t i do as follows $$\frac{\mathrm d^2y}{\mathrm dx^2}=\frac{1}{x}\frac{\mathrm d}{\mathrm dx}\left(\frac{\mathrm dy}{\mathrm dt}\right)=\frac{1}{x}\frac{\mathrm dt}{\mathrm dx}\frac{\mathrm d}{\mathrm dt}\left(\frac{\mathrm dy}{\mathrm dt}\right)=\frac{1}{x^2}\frac{\mathrm d}{\mathrm dt}\left(\frac{\mathrm dy}{\mathrm dt}\right)$$ and i thought that was it but the book solution gives this for the $\frac{\mathrm d}{\mathrm dt}(\frac{\mathrm dy}{\mathrm dt})=\frac{\mathrm d^2 y}{\mathrm dt^2}-\frac{\mathrm dy}{\mathrm dt}$ and i dont get how we got to this by using the  chain rule given the first derivative like so $\frac{(\mathrm dy)'\mathrm dt-\mathrm dy (dt)'}{(\mathrm dt)^2}$
im not sure what im getting wrong and i think i need a bit of "hand holding" so i would beg   please explain where im making the mistake or link me to a book/theory for this. i have no formal knowledge in differential forms or wedge products as im a second year math student.

A: Example one. Since $x$ is a function of $t$ and $y$ is a function of $x$, we have
$$
t=x(t)y(x(t))
$$
or
$$
y(x(t))=\frac{t}{x(t)}.
$$
Applying the chain rule, we get
$$
\frac{dy}{dx}\cdot\frac{dx}{dt}=\frac{1\cdot x-t\cdot \frac{dx}{dt}}{x^2}
=\frac1{x}-\frac{t\cdot \frac{dx}{dt}}{x^2}
$$
and
$$
\frac{dy}{dx}=\frac1{x\cdot \frac{dx}{dt}}-\frac{t}{x^2}.
$$
Example two. Technically, the procedure looks like this: the differential from the left and right sides of the equality is taken. The differentials of $dx$ and $dy$ are equal to zero, $d(dz)=d^2z$. We have
$$
zy\, dx-xy \, dz -yz \, dz+z^2 \, dy=0.
$$
The first term, $zy\, dx$, gives us $y \,dx\, dz+z\,dx\, dy$; the second, $xy \, dz$, gives $y\,dx\,dz+x\,dy\,dz+xy\,d^2z$, etc.:
$$
y \,dx\, dz+z\,dx\, dy-(y\,dx\,dz+x\,dy\,dz+xy\,d^2z)
$$
$$
-(z\,dy\,dz+y\, dz^2-yz\,d^2z)+2z\,dy\,dz=0
$$
Example three. Here $x$ is a variable, so you shouldn't treat it like a constant:
$$
\frac{d^2y}{dx^2}=\frac{d}{dx} \left( \frac{1}{x}\cdot\frac{dy}{dt}\right)=
-\frac{1}{x^2}\cdot\frac{dy}{dt}+\frac{1}{x}\cdot\frac{d}{dx} \left( \frac{dy}{dt} \right)
$$


text:
Q: Solutions X Y Z One ounce of solution X contains only ingredients a and b in a ratio of 2 : 3. One ounce of solution Y contains only ingredients a and b in a ratio of 1 : 2. If solution Z is created by mixing solutions X and Y in a ratio of 3 : 11, then 630 ounces of solution Z contains how many ounces of a?
(A) 68, (B) 73, (C) 89, (D) 219, (E) 236
Please help me solve this, I'm stuck at first step.

A: Your question is very basic, nonetheless, here's the answer:
For solution $Z$, the ratio of $X$ and $Y$ is $3:11$
$X$ : $Y$ = $3:11$
Which means, in 14 parts of solution $Z$, $X$ will be 3 parts and $Y$ will be 11 parts.
So, in 630 ounces of solution $Z$, $X$ will be = $\frac {630\times 3}{14} = 135$ Ounce.
And $Y$ will be = $\frac {630\times 11}{14} = 495$ Ounce.
Volume of $a$ in $Z$ = {volume of $a$ in $X$ $+$ volume of $a$ in $Y$}
Volume of $a$ in $X$ = $135 \times \frac {2}{5} = 54$
Volume of $a$ in $Y$ = $495 \times \frac {1}{3} = 165$
Total volume of $a$ in $Z$ = $54 + 165 = 219$.
The answer is $219$.

A: OK.  So you used $\frac{3}{3+11}$ and $\frac{11}{3+11}$ to deduce that you're dealing with 135 of Solution X and 495 of Solution Y.
Then you look at them individually.  $\frac{2}{5}$ of Solution X is type $a$ and $\frac{3}{5}$ of Solution X is type $b$.  Or $\frac{2}{5}\times135$ is $a$ and $\frac{3}{5}\times135$ is $b$
Similarly:  $\frac{1}{3}$ of Solution Y is type $a$ and $\frac{2}{3}$ of Solution Y is type $b$.  Or $\frac{1}{3}\times495$ is $a$ and $\frac{2}{3}\times495$ is $b$.
Add up those two values of $a$ and hopefully you get 219.


text:
Q: Is it advisable to have "pure" model objects additionally to managed objects? I have seen in some (REST) iOS apps that they use "pure" model object, e.g. "Product", core data object, e.g. "ProductCore", and an object to represent the remote objects e.g. "ProductJSON".
I myself usually also use this architecture, I think it leads to clear separation of concerns. It has also some practical benefits, for example there are situations in which I want to create a model object but not add it to core data yet. Or others where I want to send the models directly to the server and not store them in core data.
On the other side, it consumes more memory and I have to maintain more classes. It's also not necessary for a memory cache as core data has one. Temporary objects (e.g. form data which hasn't been validated yet) can also be deleted without performance issues, as managed objects are only in memory until saved. There are also not portability benefits, as anything that understands Swift/ObjC also understands core data... extensibility can be achieved at least with extensions. Maybe subclassing.
So I was wondering, is there an overall preferred way to setup model clases in applications? In which context does an additional layer with pure model objects make sense, where is it an overkill?
Edit: I don't consider this an "opinion based" question. The optimal architecture can be different depending on the requirements, but which is one better under which circumstances should be able to be determined based on facts.

A: I am not sure what is meant by a pure object. Here is what I am doing:

*

*Service model represents the data sent to and received from web services, and corresponds to their JSON payloads. I write adapters to map JSON to service models and vice versa.

*Entity models represent persistent data. These are the Core Data classes corresponding to my data model, and inherit from NSManagedObject.

*View models represent data displayed in a view. Each view has its own view model. This approach maps the view model precisely to the view. An adapter class builds the view model from entity models and/or service models (if the data to be displayed is not persistent). The adapter shapes the data to the view, and does things like formatting dates to simplify the job of the view controller.
A table view cell, for example, might display elements from several entity models. The view model would contain a class representing the data to be displayed in each cell, and the adapter would build one for each cell. Populating the table view cell in the view controller becomes a very simple task of mapping one-to-one between view model and cell fields.
This approach might seem overkill, but I have found it to be extremely effective and worth the effort. It greatly simplifies the code in the view controllers, and makes testing easier.


text:
Q: What is the inverse image when $f$ is a constant function? If I have a function $f: A\rightarrow B$ , The inverse image of a set $H\subseteq B$ is defined by $f^{-1}(H) = \{x\in A\mid f(x)\in H\}$
I think I have a reasonable understanding on finding inverse images when given something like $f(x) = x^2-1$, but I am having trouble comprehending what happens when $f(x) = c\quad$ for some  $c\in\mathbb{R}$. If $H$ is some set $(a,b), [a,b), [a,b], etc\in\mathbb{R}$. What is $f^{-1}(H)$?
Does the size of the set make a difference say $(-\infty,\infty)$ versus $[-3,2]$?
Does inclusion make a difference say $[-3,2]$ versus $(-3,2]$?
I know the elementary fact that the inverse of a constant function would just be a vertical line of the form $x=n,$ $n\in\mathbb{R}$ Which is not a function thus every constant function has no inverse. But I know the inverse-image which is a set has nothing to do with the inverse which is a function. Any guidance or knowledge would be appreciated. Also I am fairly new to working with functions in this manner so I would appreciate a delicate explanation.

A: If $f\colon A\to B$ is a constant function, i.e. $f(A) = b \in B$ then
$$f^{-1}(\{b\}) = A.$$


text:
Q: HTML Formatting in the Automated Mail Content StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);

String rowFormat = "%8s %8s %8s %8s%n";
pw.printf(rowFormat, "Col A", "Col B", "Col C", "Col XY");
pw.printf(rowFormat, "A", "19", "Car", "55");
pw.printf(rowFormat, "X", "21", "Train C", "-4");
pw.printf(rowFormat, "B", "-9", "Bike", "0");
String message = sw.toString();
System.out.println(message);

The above program prints the following table and the alignment is perfect.
Col A    Col B    Col C   Col XY
    A       19      Car       55
    X       21  Train C       -4
    B       -9     Bike        0

Instead of printing the string message, I am passing the string to another function which sends email with the content of the mail as the string message.
mail.setContent(message.toString(),"text/plain");

This is how I am setting the content as message in my mail.
But the alignment of the table is not appropriate as I do receive while printing the string. What must be done such that I receive the content of my mail as similar as the printing format of the string.
I can realize that setting the mime type as text/html and using the
 tag for forming the table will help me to achieve the task required.
Kindly let me know, how and where should be the

 tags must be inserted inorder to find the tabular format in the content of the mail.

A: Personally, I would use velocity for something like this, however, I think this is what you want:
String headerFormat = "
%8s	%8s	%8s	%8s%n
";
String rowFormat = "
%8s	%8s	%8s	%8s%n
";

pw.printf(headerFormat, "Col A", "Col B", "Col C", "Col XY");
pw.printf(rowFormat, "A", "19", "Car", "55");
pw.printf(rowFormat, "X", "21", "Train C", "-4");
pw.printf(rowFormat, "B", "-9", "Bike", "0");

String message = "
" + sw.toString() + "
";
System.out.println(message);

You can get more info on html tables here.


text:
Q: How do I use regular expressions in PostgreSQL to remove the end of a field matching pattern? How can I simplify this PostgreSQL? Basically I want to check if the fields end with
(1) or just (1) and replace and repeat from numbers from 1-30. I assume it can be done with regular expressions somehow, but I haven't got it working.
UPDATE discogs.artist_meta
SET name = substr(name,0, strpos(name,' (1)'))
WHERE name LIKE '% (1)';

UPDATE discogs.artist_meta
SET name = substr(name,0, strpos(name,'(1)'))
WHERE name LIKE '%(1)';

UPDATE discogs.artist_meta
SET name = substr(name,0, strpos(name,' (2)'))
WHERE name LIKE '% (2)';

UPDATE discogs.artist_meta
SET name = substr(name,0, strpos(name,'(2)'))
WHERE name LIKE '%(2)';

A: *

*use the regexp_replace(target, regexp, replacewith) function

*your pattern would be something like ' ?\(([1-9]|[12][0-9]|30)\)$'

*i'm not exactly sure what you are trying to replace with...just removing the number? if so, replace with ''.

Regexp explanation:
" ?"                 = optional space
\(                   = opening parenthesis (escaped)
([1-9]|[12][0-9]|30) = numbers 1-30
\)                   = closing parenthesis (escaped)
$                    = end of content

Regarding your comment:
update discogs.artist_meta
set name = regexp_replace(name, ' ?\(([1-9]|[12][0-9]|30)\)$', '')
where name ~ ' ?\(([1-9]|[12][0-9]|30)\)$'


text: Q: How do I calculate the Fourier Series of a given sound wave? Let's say I have recorded a piece of music and have it saved as an audio .wav file. How do I take this audio sample and manually, mathematically, calculate the Fourier Series and Fourier coefficients of it?


text:
Q: Next-generation tag wikis that leverage simple conventions to empower your creativity A lot of tag wikis contain vague buzzwords and read like advertisements.
Take, for example, the excerpt of the tag wiki of the aurelia tag on Stack Overflow:

A next generation JavaScript client framework that leverages simple conventions to empower your creativity.

This tells me precisely nothing. It seems like it is the tagline copied from the website of the technology in question.
Are such tag wikis considered good? Should they be removed or edited?

A:
Are such tag wikis considered good?

The specific one you listed as an example is not really good, no.

Should they be removed or edited?

If you mean remove the tag, then you need to raise a burninate-request question on the relevant site, suggesting which tag is not useful, too generic, dupe or could be a synonym etc.
If you mean remove the description then they should be edited if they are no good or could be improved.  If that means re-writing the entire thing as the current text is completely gobbledegook, then sure wipe it clean and start again.
Essentially, the target is "improvement", and that leaving all, some, or none of the current text depends on the specific tag and current text.

A lot of tag wikis contain vague buzzwords and read like
  advertisements.

I agree, however this is what community moderating is there for, so we can as a community improve things and suggest edits to tag wikis and such like.
Then if the general consensus is an edit suggestion improves the tag wiki/excerpt, then it will be approved.
I'm not sure (exactly) what problem you are reporting, other than there are some poor tag wikis/excerpts which could be improved.
Yes there are some terrible tag wikis and excerpts, so just edit them :)

There are also thousands of good tag wiki and excerpts, so I don't think there is a large enough issue here to be concerned or to have to do anything specific or new.
Just edit them as and when you see poor ones, or when any improvement can be made.


text:
Q: How do I know when window is created? How can I check if window is already created? I tried this
BOOL isWindowReady = FALSE;
while(!isWindowReady)
{
    hwnd = FindWindow(windowClass, NULL);
    if (hwnd == NULL) {
        hwnd = FindWindow(windowClass, NULL);
    }
    else {
        isWindowReady = TRUE;
    }
}

but id doesn't work.

A: Your code is technically fine (though your second call to FindWindow() is redundant) - provided you are supplying the correct value for windowClass, that is.
That being said, your loop can be simplified:
while (!FindWindow(windowClass, NULL)) { Sleep(100); }

Or, if you need the HWND to access the window later:
HWND hWindow;
do
{
    hWindow = FindWindow(windowClass, NULL);
    if (hWindow) break;
    Sleep(100);
}
while (true);


text:
Q: GLib-GObject-CRITICAL warnings I'm confused by these two warnings. Can anyone explain how I might have come about triggering them, and how they would be able to be debugged in gdb?

(gtkworkbook:24668): GLib-GObject-CRITICAL **: g_cclosure_new: assertion `callback_func != NULL' failed
(gtkworkbook:24668): GLib-GObject-CRITICAL **: g_signal_connect_closure_by_id: assertion `closure != NULL' failed

A: One thing you can try is pass in --g-fatal-warnings to Gtk::Main, this will cause warnings to assert.  You can attach with gdb and maybe figure out some more detail about where this is failing.

A: I found the problem.
This code was ported from an original implementation in C, and I had a requirement before to use an array of function pointers to call the functions inside of a shared library. Although this [seemed] to work at the time once I actually started using them it was not the case. I am a little stumped on why its not working, but I was able to centralized the problem to the following piece of code.

gtk_signal_connect (GTK_OBJECT (plugin()->workbook()->gtk_workbook), "switch-page",
 (GtkSignalFunc)this->signals[NOTEBOOK_SWITCHPAGE], plugin->workbook());

Was changed to the following:

gtk_signal_connect (GTK_OBJECT (plugin()->workbook()->gtk_workbook), "switch-page",
 (GtkSignalFunc)signal_gtknotebook_switchpage, plugin->workbook());

Now, the code compiles and I am not getting any nasty errors. I think this is the answer!


text:
Q: Hasura: How to filter and THEN sort, with one-many relationship I'm new to databases, but I feel what I am trying to do should be pretty commonplace...
What I am trying to achieve is to allow a user to apply both a price range filter and a price sort to the results that my site fetches for them. So I want to find all prices within the specified price range, and then sort them by price.
I have a Hasura DB running on Heroku. The DB has two tables, seeds and prices. One row in seeds table, i.e. one seed, can be related to multiple rows in the prices tables, i.e. many prices. They are joined by a foreign key constraint and a one-many relationship, or Object to Array.
I am attempting to query seeds using the following GraphQL query:
{
  seeds(
    where: {prices: {price: {_gte: "10", _lte: "200"}}},
    order_by: {prices_aggregate: {min: {price: asc_nulls_last}}}
  ) {
    product_name
    prices {
      price
    }
  }
}

What I want this query to do is to filter out all prices.price that are not within the valid range (10, 200), and then sort them in order of prices.price ascending. However what happens is that the results are sorted by prices.price ascending INCLUDING values that are not within the range, then the results are filtered.
I will give an example to clarify. Consider the following results from the above query:
{
  "data": {
    "seeds": [
      {
        "product_name": "Northern Lights Auto Feminised Seeds",
        "prices": [
          {
            "price": 3.48
          },
          {
            "price": 6.79
          },
          {
            "price": 9.58
          },
          {
            "price": 104.5
          }
        ]
      },
      {
        "product_name": "The White OG Feminised Seeds",
        "prices": [
          {
            "price": 3.48
          },
          {
            "price": 6.79
          },
          {
            "price": 15.68
          }
        ]
      },
      {
        "product_name": "Special Kush #1 Feminised Seeds from Royal Queen Seeds",
        "prices": [
          {
            "price": 3.49
          },
          {
            "price": 13.53
          },
          {
            "price": 8.29
          }
        ]
      }
    ]
  }
}

The above results are correct, because there are valid values for prices.price within the range specified (104.5, 15.68, 13.53) respectively,  however the results are not in the right order. They are instead ordered by the lowest price.prices, regardless of the filter which was specified (10, 200).
The correct order for the results would be:
{
  "data": {
    "seeds": [
      {
        "product_name": "Special Kush #1 Feminised Seeds from Royal Queen Seeds",
        "prices": [
          {
            "price": 3.49
          },
          {
            "price": 13.53
          },
          {
            "price": 8.29
          }
        ]
      },
      {
        "product_name": "The White OG Feminised Seeds",
        "prices": [
          {
            "price": 3.48
          },
          {
            "price": 6.79
          },
          {
            "price": 15.68
          }
        ]
      },
      {
        "product_name": "Northern Lights Auto Feminised Seeds",
        "prices": [
          {
            "price": 3.48
          },
          {
            "price": 6.79
          },
          {
            "price": 9.58
          },
          {
            "price": 104.5
          }
        ]
      }
    ]
  }
}

Can anyone help me, and explain how I can achieve these correct results? It is worth mentioning that it is not possible to sort the results after the query as there are thousands and the sort will definitely affect which results are returned from the DB.
Thanks, in advance!

A: The where clause you are applying to seeds will fetch all seeds that have atleast one price within the range you have specified. This will NOT filter the price data that you are fetching in the nested query.
For filtering the price you need to apply the where clause inside prices array relationship.
{
  seeds(
    where: {prices: {price: {_gte: "10", _lte: "200"}}}, -> this filters seeds
    order_by: {prices_aggregate: {min: {price: asc_nulls_last}}}
  ) {
    product_name
    prices(where:{price:{_gte: "10", _lte: "200"}}) { -> this filters price
      price
    }
  }
}


text:
Q: Apply CSS rule to multiple elements within a sub-class I have the following markup:

Content

For simplicity, lets assume that class-XXX can only have the values class-1, class-2, class-3 and class-4.
I want to apply the rule color: #fff; to every child of class-5 that is not a child of class-1. Here that part of my stylesheet:
.class-2 .class-5,
.class-3 .class-5,
.class-4 .class-5 {
  color: #fff;
}

This is not working and I'm not really sure why. I don't believe that the rule is being overridden either.
UPDATE
As AndrewBone pointed out, the rule appears to work in a minimal example. I now understand what is wrong, but I don't know how to fix it:
There is a rule being applied to h1 in another CSS file (can't be removed) and that rule is being given higher priority than the rule I was writing. How can I fix this?
Here is an example JSFiddle.
SOLUTION
Vucko pointed out that the h1 type selector has higher priority and so the rule will not be applied. So, in order to avoid listing all possible combinations one should use the * selector!
End result:
.class-2 .class-5 *,
.class-3 .class-5 *,
.class-4 .class-5 *{
  color: #fff;
}

My thanks to Paulie_D and David Wilkinson for teaching me about the :not pseudo-selector.

A: This would do it..
  [class^="class-"]:not(.class-1) .class-5 {
          */ your styles here */
        }

...but this only works for a specific methodolody in classnames as above.

[class^="class-"]:not(.class-1) .class-5 {

  color: red;

}

Content

Content

Content

Content

Content

A: If you have some container for those divs, you can then use the :not selector (as Harry mentioned in the comment):

.main :not(.class-1) .class-5 {
  color: red;
}

1

2

3

4

5

.main :not(.class-1) .class-5 {
  color: red;
}

JSFiddle

A: This does the trick: https://jsfiddle.net/023rox1k/
CSS:
.wrapper :not(.class-1) .class-5 {
  color: blue;
}

HTML:

Content

Content

Content

Content

The :not selector is quite powerful and obviously targets elements not of a certain class in this case.


text:
Q: Patron de diseño Decorator Estoy entregando un trabajo en el que tengo que simular un juego de guerra entre diferentes personajes. Estas unidades son clases que heredan de una clase mas general llamada Unidad aca les dejo el codigo:
package unidades;

public abstract class Unidad {

    private Integer salud;
    private Double posx;
    private Double posy;
    private Double rangomax;
    private Double rangomin;

    Unidad(Double posx, Double posy, Integer salud, Double rangomax, Double rangomin){
        this.posx = posx;
        this.posy = posy;
        this.salud = salud;
        this.rangomax = rangomax;
        this.rangomin = rangomin;
    }

    public Integer getSalud() {
        return salud;
    }

    public void setSalud(Integer salud) {
        this.salud = salud;
    }

    public Double getPosx() {
        return posx;
    }

    public void setPosx(Double posx) {
        this.posx = posx;
    }

    public Double getPosy() {
        return posy;
    }

    public void setPosy(Double posy) {
        this.posy = posy;
    }

    public Double getRangomax() {
        return rangomax;
    }

    public void setRangomax(Double rangomax) {
        this.rangomax = rangomax;
    }

    public Double getRangomin() {
        return rangomin;
    }

    public void setRangomin(Double rangomin) {
        this.rangomin = rangomin;
    }

    @Override
    public abstract String toString();

    public Double calcularDistancia(Unidad victima) {
        Double resultado;
        resultado = Math.sqrt(Math.pow(victima.getPosx()-posx, 2) + Math.pow(victima.getPosy()-posy, 2));
        return resultado;
    }

    public boolean validarVida() {
        boolean validacion;
        if(getSalud()>=1) validacion = true;
        else validacion = false;
        return validacion;
    }

    public boolean validarRango(Unidad victima) {
        boolean validacion;
        if(calcularDistancia(victima)>=rangomin && calcularDistancia(victima)<=rangomax) validacion = true;
        else validacion = false;
        return validacion;
    }

    public abstract void infligirDaño(Unidad victima);

    public void atacarUnidad(Unidad victima) {/*template method**/
        if(validarVida()==true) {
            if(validarRango(victima)==true) {
                infligirDaño(victima);
            }else System.out.println("La unidad esta fuera de rango de ataque");
        } else System.out.println("No se puede atacar cuando la unidad esta muerta");
    }

}

les muestro el ejemplo de una subclase como por ejemplo Arquero:
package unidades;
import java.util.Random;

public class Arquero extends Unidad{

    private Integer daño = 5;
    private Integer flechas = 20;

    public Arquero(Double posx, Double posy){
        super(posx,posy,50,5.0,2.0);
    }

    public Integer getDaño() {
        return daño;
    }

    public void setDaño(Integer daño) {
        this.daño = daño;
    }

    public Integer getFlechas() {
        return flechas;
    }

    public void setFlechas(Integer flechas) {
        this.flechas = flechas;
    }

    @Override
    public String toString() {
        String cadena;
        cadena = "Arquero:  Salud: " + getSalud() + "  Flechas: " + flechas + "\n";
        return cadena;
    }

    public void recargaFlechas() {
        int random;

        Random j = new Random(System.currentTimeMillis());
        random = j.nextInt(10)+1;

        if(random > 9) {
            flechas = flechas +6;
            System.out.println("Carcaj recargado. flechas : " + flechas);
        }
    }

    @Override
    public void infligirDaño(Unidad victima) {

            if(getFlechas()>=1) {
            victima.setSalud(victima.getSalud() - getDaño());
            setFlechas(getFlechas() - 1);
            }
            else System.out.println("No hay suficientes flechas");
            recargaFlechas();
    }

    }

y otra subclase como lancero:
package unidades;

public class Lancero extends Unidad{
private Integer daño = 25;

public Lancero(Double posx, Double posy){
    super(posx,posy,150,3.0,1.0);
}

public Integer getDaño() {
    return daño;
}

public void setDaño(Integer daño) {
    this.daño = daño;
}

@Override
public String toString() {
    String cadena;
    cadena = "Lancero:  Salud: " + getSalud() + "\n";
    return cadena;
}

@Override
public void infligirDaño(Unidad victima) {
    victima.setSalud(victima.getSalud() - getDaño());
}

}

y despues en un metodo main ejecuto algunas pruebas , algo sencillo como para comprobar las clases:
package principal;

import unidades.Arquero;
import unidades.Lancero;

import unidades.*;

public class Pruebas {

    public static void main(String[] args) {

        Arquero a = new Arquero(1.00,1.00);
        Lancero l = new Lancero(3.00,3.00);
        Caballero c = new Caballero(3.00,4.00);
        Soldado s = new Soldado(3.00,3.00);

        l.atacarUnidad(a);
        a.atacarUnidad(l);

        System.out.println(l.toString() + a.toString());

        c.atacarUnidad(s);
        s.atacarUnidad(c);

        System.out.println(s.toString() + c.toString());

    }

}

el tema es cuando el trabajo me pide que implemente el patron decorator. Tengo que agregar 3 items que puedan ser equipados por una unidad , se puede equipar uno solo, dos, o todos.NO SON EXCLUYENTES. Uno da daño de ataque otro da defensa y otro aumenta la energia (esa es para una clase Soldado pero que no puse aca). La pregunta es , puedo usar el patron decorator para implementar esos items usando el codigo que acabo de pasar? gracias por leer!

A: Voy a simplificar tu problema. El ejercicio te indica que debes crear una Interfaz llamada "Unidad" y otra llamada "Item" las interfaces por lo que veo solo necesitan lo siguiente:
Unidad
public interface Unidad {
  public long getDaño();
}

Item
public interface Item {
  public long getDañoBase();
}

ahora las Unidades pueden utilizar Items que den un bonus de daños. Para que los items no sean excluyentes puedes utilizar varios patrones, el de composición o bien el decorador. Tu problema te solicita el decorador, así que creamos una clase, llamada: "UnidadConItem" dicha clase tiene la responsabilidad de relacionar los bonus de los Items con las Unidades.
public class UnidadConItem implements Unidad {
  private final Unidad unidad;
  private final Item item;

  public UnidadConItem(Unidad unidad, Item item)
  {
    this.unidad = unidad;
    this.item = item;
  }

  @Override
  public long getDaño()
  {
    return (unidad.getDaño() + item.getDañoBase());
  }
}

Ahora creas las clases de Unidades
Arquero
public class Arquero implements Unidad {
  @Override
  public long getDaño()
  {
    return 5;
  }
}

Lancero
public class Lancero implements Unidad {
  @Override
  public long getDaño()
  {
    return 25;
  }
}

Ahora creas las clases de Items y sus Bonus
FlechasFuego
public class FlechasFuego implements Item
{
  @Override
  public long getDañoBase()
  {
    return 100;
  }
}

Excalibur
public class Excalibur implements Item
{
  @Override
  public long getDañoBase()
  {
    return 50;
  }
}

PocionConcentracion
public class PocionConcentracion implements Item
{
  @Override
  public long getDañoBase()
  {
    return 10;
  }
}

TalismanNegativo
public class TalismanNegativo implements Item
{
  @Override
  public long getDañoBase()
  {
    return -30;
  }
}

Luego puedes manipular la vida de una Unidad y sus items;
Unidad pj = new Arquero(); // daño = 5
pj = new UnidadConItem(pj, new FlechasFuego()); // daño = 105
pj = new UnidadConItem(pj, new PocionConcentracion()); // daño = 115
pj = new UnidadConItem(pj, new TalismanNegativo()); // daño = 85
System.out.println(pj.getDaño()); // imprime "85"

Te dejo el código completo en el siguiente enlace:
https://mega.nz/#!Lwg01S4D!N6vdApPO8azHxZnzpoIZwB2tGqoeUaEoC9O4sRTTcwo


text:
Q: How to send and receive data from python to arduino at the same time I currently have an arduino code, which is connected to three sensors: temperature, pressure and humidity. I would like to make a code in python that of an order (by int or strg), this sends the type of sensor that I want to read, example: if I enter by keyboard 1, it constantly sends me temperature data; if income 2, send me pressure data; and thus be able to enter any digit at any time.
Pd: Sorry my bad english,I don't know if i could explain my problem
I have a similar code in arduino with switch case, and it works perfectly. but I can not make it work in python since when I put raw_input (), the program stops waiting for input and stops reading the sensor data.
Python
import serial
import time

ser=serial.Serial('/dev/ttyUSB0',baudrate=115200)
while 1:
 ser.setDRT(False)
 #c=raw_input()
 #ser.write(c)
 med=a.readline()
 print med

this just works fine to read data from one sensor type assigned by default

A: If you have tasks, that needs to run in parallel, you can use threads. One thread gets the sensor data and the other waits for input.
Python has a very easy to use builtin module for threading.

*

*Official python docs: https://docs.python.org/3.7/library/threading.html

*Tutoialspoint: https://www.tutorialspoint.com/python/python_multithreading.htm
A very simple implementation example might look like this:
import threading

def wait_input():
    while True:
        user_input = input()
        # do something with user_input

def get_sonsordata()
    while True:
        med=a.readline()
        print(med)

input_thread = threading.Thread(target=wait_input)
input_thread.start()
sensor_thread = threading.Thread(target=get_sonsordata)
sensor_thread.start()


text:
Q: Installed Ubuntu 14.04 - cannot connect to internet with wired or wireless connection I just installed Linux and Ubuntu 14.04 alongside my Windows 8 on my HP Pavilion. First, I had problems with the graphics card and it said it could only operate in low graphics mode.But it just stall when I tried this.
I have Googled some potential fixes for this, but they all require an Internet connection which I am unable to obtain. I can boot in recovery mode, but I can't connect to either a wired or wireless connection. It can see both but can't connect, just keeps trying to connect.
Any help on either issue would be greatly appreciated.
$ sudo lshw -c network
  *-network
       -description: Wireless interface
       -product: RT3290 Wireless 802.11n 1T/1R PCIe
       -vendor: Ralink corp.
       -physical id: 0
       -bus info: pci@0000:08:00.0
       -logical name: wlan0
       -version: 00
       -serial: 54:35:30:80:eb:01
       -width: 32 bits
       -clock: 33MHz
       -capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
       -configuration: broadcast=yes driver=rt2800pci driverversion=3.13.0-29-generic firmware=0.37 latency=0 link=no multicast=yes wireless=IEEE 802.11bgn
       resources: irq:18 memory:c2610000-c261ffff
  *-network
       description: Ethernet interface
       product: RTL8101E/RTL8102E PCI Express Fast Ethernet controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:09:00.0
       logical name: eth0
       version: 08
       serial: a0:1d:48:e4:ff:c4
       size: 100Mbit/s
       capacity: 100Mbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full firmware=rtl8106e-2_0.0.1 04/23/13 latency=0 link=yes multicast=yes port=MII speed=100Mbit/s
       resources: irq:59 ioport:4000(size=256) memory:c2504000-c2504fff memory:c2500000-c2503fff

$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr a0:1d:48:e4:ff:c4
          inet6 addr: fe80::a21d:48ff:fee4:ffc4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:36631 errors:0 dropped:0 overruns:0 frame:0
          TX packets:189 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2200377 (2.2 MB)  TX bytes:38826 (38.8 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:191 errors:0 dropped:0 overruns:0 frame:0
          TX packets:191 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:13717 (13.7 KB)  TX bytes:13717 (13.7 KB)

wlan0     Link encap:Ethernet  HWaddr 54:35:30:80:eb:01
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

I figured it out. Thanks everyone for your help.
It was a combination of two problems:
https://superuser.com/questions/756145/ubuntu-14-04-wired-connection-detected-but-no-internet-access
That worked after I did some other stuff to allow the changes to be saved, and then I went to the settings and used the proprietary drivers as suggested below, although it didn't work the first time. I had to reinstall in order to achieve success.

A: I had a similar problem with my HP Pavilion, but only with the wireless.
Here's how I fixed it:
After booting up run sudo service network-manager restart.
Then my wireless started working.
Go to System Settings->Software&Updates-> Additional Drivers
If there is a proprietary networking driver available, enable it.
Restart the computer, and it should connect.

A: Here is how I solved it.
I edited /etc/resolv.conf with administer rights.
There was one line
# Generated by NetworkManager

I added the line
nameserver 192.168.1.1

which is most router ip addresses. If you have a different router ip address use that.
Extra information.
Before I did this I was able to access the router by typing in the ip address. I was able to ping ip addresses but not urls. That's when I realised I had a DNS problem. I tried editing the DNS ip address using network manager but it didn't work. Actually my name server has a different ip address but the one I provided wi

A: Going on assumption that you're plugged into a router that gives out IPs automatically (DHCP), try sudo dhclient -r then sudo dhclient eth0 if successful try ping 8.8.8.8 post results if it didn't work

A: I had the same issue. For me editing the /etc/network/interfaces file resolved the issue.
What I did was edited the line:
iface lo inet telnet

to:
iface lo inet dhcp

Hope this helps.

A: I can simply solve the problem by doing the following:
gksu gedit /etc/NetworkManager/NetworkManager.conf

Then I just change "false" in the file to "true" and then save and restart (only network manager restart can also work)


text:
Q: asynchronous console output to a textblock i would like to execute an executable file with some parameters.
I would like my WPF application to output the console lines and show it in a textblock asynchronously.
This is what i've done so far:
System.Threading.Thread.Sleep(5000);
System.Diagnostics.Process runantc = new System.Diagnostics.Process();
runantc.StartInfo.FileName = "CMD.EXE";
runantc.StartInfo.Arguments = "/C " + Antcbatchpath;
runantc.StartInfo.UseShellExecute = false;

runantc.StartInfo.RedirectStandardOutput = true;
runantc.StartInfo.RedirectStandardError = true;

runantc.OutputDataReceived +=new DataReceivedEventHandler(runantc_OutputDataReceived);

runantc.Start();

runantc.BeginOutputReadLine();

runantc.Close();

private static void runantc_OutputDataReceived (object sendingProcess,
DataReceivedEventArgs outLine)
{
 //i am not sure what should be here
}

The above code is altered according to msdn's webpage
I have a lot of trouble following their code namely because they need to add in strings or some sort. I am a beginner at events handling and such processes. Please kindly help me, all i need is just to output these lines to a textblock asynchronously.
For example, the console would output:
running test...

i should see that in textblock:
running test...

then after a few seconds another line appears:
running test...
this is a new line 1

and the above should also appear in the textblock after a few seconds:
running test...
this is a new line 1

A: The following code should do what you want:
private static void runantc_OutputDataReceived (object sendingProcess, DataReceivedEventArgs outLine)
{
    YourControl.Dispatcher.BeginInvoke(new Action(() => { YourControl.Text += outLine.Data; }), null);
}

EDIT: Ok it seems I have to explain the code a little bit:
The Dispatcher.BeginInvoke function needs a delegate as callback and an array of parameters.

*

*Dispatcher.BeginInvoke http://msdn.microsoft.com/en-us/library/cc190824.aspx

*Delegate (the first parameter of BeginInvoke) http://msdn.microsoft.com/en-us/library/system.delegate.aspx

*Action (a delegate) http://msdn.microsoft.com/en-us/library/system.action.aspx

*Lambda Expression ( f.e. () => {...} executes the code in { ... }) http://msdn.microsoft.com/en-us/library/bb397687.aspx

*params keyword http://msdn.microsoft.com/en-us/library/w5zay9db%28v=VS.100%29.aspx

A: I am not sure it will appear as you are expecting, but you can get the details from the output text using DataReceivedEventArgs.Data property.


text: Q: what could be the reasons that a neural network stuck on a high loss while training I'm training a neural network to predict one continuous value. so my problem is a regression Problem, it should be simple I have 3 or 4 features and the target I want to predict is a value of an angle so between 0 and 360. I'm using pytorch/skorch for that and I think it is a pretty cool API, I standardize/normalize the features before feeding it to the network, I tried different architectures, different hyperparams etc.. but I noticed that the Network start learining good so the loss start decreasing in a good way but when it reach 6000 or 7000 it somehow stuck there and the Network have a hard time to learn further. Now I don't know why this is happening and I'm seeking for advice or guide. I'm sure I have no errors in my code because I tried fitting only 10 data points from my dataset and that worked ( the NN achieved to overfit on those 10 samples) but when I take the whole dataset which containing 10000 data points, the network stucks at that high loss value and it is having a hard time to train further, I'm not sure what can cause this, I mean at least a Neural network should overfits on training data but my Network doesn't even achieve to overfit. Anyone please know what can be the reasons that lead to such behavior or what can I try other than batch normalization, more complex architectures, different hyperparams?


text:
Q: Need MYSQL query for this scenario Consider the following 2 tabls....
M.no   budget    created date
1      250M       2010
2      210M       2011
3      200M       1999
4      150M       1994

S.no   Name
1      Avator
2      Transformers
3      Titanic
4      Dark knight

Now i want a query to find the movie names which has budget greater than titanic.

A: select m.name
from movies m inner join budgets b on (b.no = m.no)
where b.budget > (select budget
                  from from movies mm inner join budgets bb on (bb.no = mn.no)
                  where mm.name = ?)

A: All movie names with their budget:
SELECT S.name, M.budget
FROM   S
JOIN   M ON M.no = S.no

Budget of Titanic:
SELECT M.budget
FROM   S
WHERE  S.Name = 'Titanic'
JOIN   M ON M.no = S.no

All movie names which has budget greater than titanic:
SELECT S.name
FROM   S
WHERE  M.budget > (
    SELECT M.budget
    FROM   S
    WHERE  S.Name = 'Titanic'
    JOIN   M ON M.no = S.no
)
JOIN   M ON M.no = S.no


text:
Q: Object oriented use of properties/methods in real webapplications? I just moved from my "everything-in-functions" coding style to OOP in PHP. I know, there are a lot of sources in order to code properly, but my main problem is, after reading so many tutorials about coding a blog/cms/any web app in OOP it's quite not that understandable to me to code it the right way.
I was told the concept of OOP is basically close to the real world.
So properties are just properties of any object and methods are like what the object should do. But I can't really understand how to use these properties and methods in a web app. In the real world, it's easier than in a web application for me, for instance:
Let's say we want to create a human named "Paul" and he should drive a car.
class human
{

    public $gender;
    public $name;

    function __construct($inGender=null, $inName=null) {

        $this->gender = $inGender;
        $this->name = $inName;

    }

    public function driveCar() {

    //Let the car be driven.
    //...

    }

}

$paul = new human('male','Paul');
$paul->driveCar();

Alright, but when it comes to an object in a web application, let's say I want to code a blog system specifically let's focus the posts. Properties could be id, name, content, author of a post, BUT what does a post actually do? It can't really perform an action so I would code it like this:
class post
{

    public $id;
    public $title;
    public $content;
    public $tags;

        //Overloading the Variables
        function __construct($inId=null, $inTitle=null, $inContent=null, $inTags=null) {

            if(!empty($inId) || $inId == 0) {
                $this->id = $inId;
            }
            if(!empty($inTitle)) {
                $this->title = $inTitle;
            }
            if(!empty($inContent)) {
                $this->content = $inContent;
            }
            if(!empty($inTags)) {
                $this->tags = explode(' ', $inTags);
            }

        }

}

//In order to pass multiple posts to an constructor I would use a foreach loop

$posts[] = new post(0,'Hello World', 'This is a test content','test blog oop');
$posts[] = new post(1,'Hella World!', 'This is made my myself','test test test');

//Usage in a template

<?php foreach($posts as $post): ?>

<?= $post->title;?>

<?= $post->content;?>

<?php endforeach; ?>

The problem here is the method does not do anything, what is not supposed to do I guess. And another problem would be, when I would store data into an array, I can't use a single array with data of posts as several parameters for the constructor. Even if this was a single post, how to accomplish the passing of data as an array properly in order to use the array as the parameters? Maybe I just coded it not the best way, but what would be a better way? I heard of setter and getter and magic methods. What would here best practise?
Alright, but another question. How would I program the create/delete posts functionality, new classes or new methods? I can't really imagine anything of this in the real world concept.
This all is not that clear for me since it's nowhere explained on any tutorial.
Help would be amazing.
regards

A: answering all your questions needs a book as understanding the oop concept completely needs much reading and practicing.
But to answer your post class I give you an easy to use example where you can create a class which will help you create, read, delete and update posts.
This class can be used in all your projects as it's a class and classes are simply there to make our life easier.
So here we go:
first we create the class:
class posts
{
    //we just need a post title and a post content for the new post.
    //So we create two properties for post_title and post_content
    private $post_title; //the variables are private so we we restrict access the them from outside the class.
    private $post_content;
    private $connection;
    //you really don't need here the _constructor function, but it's your choice.
    //For example you can do all your database connection stuff in the constructor method to make it easy for users.
    //So if someone creates a posts object it is obvious that he's going to make some interactions with the database so you open connections in your constructor.
    //next we create the methods for our posts class

    public function __constructor()
    {
        //here you created the connection to your database. You can retrieve
        //the parameters to the mysqli_connect from a eg. config.php file to make your class more dynamic.
        $this->connection = mysqli_connect('hostname', 'username', 'password', 'databasename');
    }

    public function create_post($title, $content)
    {
        $this->post_title=$title;
        $this->post_content=$content;
        $query="INSERT INTO posttable(id,title,content) VALUES('$this->post_title','$this->post_content')";
        $result=$mysqli_query($this->connection,$query);
    }

    public function update_post($post_id, $post_title, $post_content)
    {

    }

    public function delete_post($post_id)
    {

    }

    public function view_posts($query, $fields)
    {
        $result=mysqli_query($this->connection, $query);
        $finalData=array();
        while ($row=mysqli_fetch_assoc($data)) {
            foreach ($fields as $field) {
                array_push($finalData, $row[$field]);
            }
        }
        return $finalData;
    }
}

//now we're going to use the class.
$post=new posts(); //a new posts object is created and the __construct method opened connection to db.
$post->create_post('some title', 'some content');//inserted new post into database.
$post->update_post($id, $content, $title);//you've just updated a post
$post->delete_post($id);//you've just deleted a post.

//getting posts
$query="SELECT * FROM posts";
$fields=array('id','title','content');

$all_posts=$post->view_posts($query, $fields);
//now you have $all_posts which is filled with an array of all posts from the posts table.
//now you can loop through it and show it on your page.
for ($i=0; $i<=count($all_posts); $i++) {
    echo '
'.$mydata[$i].'
';
    $i++;
    echo '
'.$mydata[$i].'
';
    $i++;
    echo '
'.$mydata[$i].'
';
}

I didn't implement the update and delete method code but I think it's easy for you to write it by yourself.All my goal was to show you how you can use oop in your web applications. I personally have nearly 50 classes written by myself and do all the major jobs for nearly all possible web application tasks. It's up to you how you create your classes. Just for your knowledge, oop programming needs training and experience. You can do a task in multiple forms and with different solutions. You can find dozens of books which teach you oop design who's concept and goal is to teach you how to design a class to the best way.
I hope I was helpful


text:
Q: How to make a UIImageView centered in a Scrollview when zoom out? Just trying to figure out a way to make a ordinary photo viewer for iPhone and I just couldn't make the zooming work.
    myimageview = UIImageView()
    myimageview.translatesAutoresizingMaskIntoConstraints = false
    myimageview.image = UIImage(named: "1")
    scrollview = UIScrollView()
    scrollview.delegate = self
    scrollview.backgroundColor = UIColor.brownColor()
    scrollview.minimumZoomScale = self.view.frame.width/myimageview.image!.size.width
    scrollview.maximumZoomScale = 1.0
    scrollview.translatesAutoresizingMaskIntoConstraints = false

    self.view.addSubview(scrollview)
    scrollview.addSubview(myimageview)
    let views = ["scrollview":scrollview,"myimageview":myimageview]
    //add scrollview constraints
    self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[scrollview]|", options: [], metrics: nil, views: views))
    self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[scrollview]|", options: [], metrics: nil, views: views))
    scrollview.contentSize = myimageview.image!.size
    //add contentview:myimageview constraints
    let imagesize = myimageview.image!.size
    //let dd = (self.view.frame.height-imagesize.height*self.view.frame.width/imagesize.width)/2
    scrollview.addConstraint(NSLayoutConstraint(item: myimageview, attribute: .CenterY, relatedBy: .Equal, toItem: scrollview, attribute: .CenterY, multiplier: 1.0, constant: 0))
    scrollview.addConstraint(NSLayoutConstraint(item: myimageview, attribute: .Left, relatedBy: .Equal, toItem: scrollview, attribute: .Left, multiplier: 1.0, constant: 0))

    scrollview.addConstraint(NSLayoutConstraint(item: myimageview, attribute: .Width, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: myimageview.image!.size.width))
    scrollview.addConstraint(NSLayoutConstraint(item: myimageview, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: myimageview.image!.size.height))

So basically, I got a scrollview and I got an imageview and I added it to the subviews of uiscrollview. And I manually set the contentsize of the scrollview and I set the zooming. I also added the viewForZoomingInScrollView delegate function. Zooming works fine.
Problem:
when zoom out, I want the image to show in the middle of the screen(uiscrollview) but now it's on the top. As you can see below, the picture is on the top, I want it to be in the middle of the screen. It seems the CenterY doesn't work. No error has been found. The code I pasted is in the ViewDidLoad function.

A: Ok, I found that still, after 2 yrs, autolayout can't solve this problem, you had to write it manually. Very sad.
var myimageview:UIImageView!
var scrollview:UIScrollView!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    myimageview = UIImageView()
    //myimageview.translatesAutoresizingMaskIntoConstraints = false
    myimageview.image = UIImage(named: "1")
    myimageview.frame = CGRectMake(0, 0, myimageview.image!.size.width, myimageview.image!.size.height)
    scrollview = UIScrollView()
    scrollview.delegate = self
    scrollview.backgroundColor = UIColor.brownColor()
    scrollview.minimumZoomScale = self.view.frame.width/myimageview.image!.size.width
    scrollview.maximumZoomScale = 1.0
    scrollview.translatesAutoresizingMaskIntoConstraints = false

    self.view.addSubview(scrollview)
    scrollview.addSubview(myimageview)
    let views = ["scrollview":scrollview,"myimageview":myimageview]
    //add scrollview constraints
    self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[scrollview]|", options: [], metrics: nil, views: views))
    self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[scrollview]|", options: [], metrics: nil, views: views))
    scrollview.contentSize = myimageview.image!.size

}

func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {
    // center the image as it becomes smaller than the size of the screen
    return myimageview
}

func scrollViewDidZoom(scrollView: UIScrollView) {
    let boundsSize = self.scrollview.bounds.size
    var contentsFrame = self.myimageview.frame

    if (contentsFrame.size.width < boundsSize.width) {
        contentsFrame.origin.x = (boundsSize.width - contentsFrame.size.width) / 2.0
    } else {
        contentsFrame.origin.x = 0.0
    }

    if (contentsFrame.size.height < boundsSize.height) {
        contentsFrame.origin.y = (boundsSize.height - contentsFrame.size.height) / 2.0
    } else {
        contentsFrame.origin.y = 0.0
    }

    myimageview.frame = contentsFrame;
}


text:
Q: Django: using a premade mysql db with no relationships defined I have a mysql db with data in it and no relationships defined. What I want is to use this database in a Django project and I want it to have the relationships defined. There are fields that are supposed to be ForeignKeys but are defined as IntegerFields. So basically I want to change them to foreignKeys.
What I have:
company_id = models.IntegerField(blank=True, null=True)

What I Want:
company_id = models.ForeignKey('Company', on_delete=models.CASCADE)

class Inquiry(models.Model):
    id = models.AutoField()
    company_id = models.IntegerField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'inquiry'

What I am trying:
class Inquiry(models.Model):
    id = models.AutoField()
    company_id=models.ForeignKey('Company',on_delete=models.CASCADE,null=True)
    class Meta:
        managed = True
        db_table = 'inquiry'

A: Please see the following link: Django - Legacy Databases
After you've created your models.py, you will need to do execute a migrate. After the first migrate, go into models.py and make the edits you need!
EDIT/ADDITION
Essentially:
python manage.py inspectdb > models.py

Remove managed = False from class Meta: of each model
python manage.py migrate

Treat it as if it was created by django from the beginning :)
EDIT 2
Again, my solution should work. The way you are trying to define the relationship isn't the way django's relationships like to be defined. To link an inquiry to a company, this should work:
class Company(models.Model):
    company_name = models.CharField(max_length=50) #django automatically creates a PK/ID field
class Inquiry(models.Model):
    company = models.ForeignKey(Company, on_delete=models.CASCADE, null=True, blank=True) #null and blank params not required

Django will take care of establishing the MySQL relationships in the DB, that is the whole purpose of using the django ORM.
Once you have defined the fields in django, run a migration:
python manage.py makemigrations
python manage.py migrate

Django should alter the tables in your MySQL accordingly (I'm not 100% sure)

A: From the django docs on related_name:

The name to use for the relation from the related object back to this one. It's also the default value for related_query_name (the name to use for the reverse filter name from the target model).

In the scenario you have, add the Company model, then, in the Inquiry model ForeignKey, specify a related_name field name with the Company attribute you want to link.
class Company(models.Model):
    id = models.AutoField()
    ...

class Inquiry(models.Model):
    id = models.AutoField()
    company_id=models.ForeignKey(to=Company, related_name="id", null=True, blank=True)
    class Meta:
        managed = True
        db_table = 'inquiry'


text:
Q: How to stop fake reviews and fake signups on Magento 1 and Magento 2? We have 2 websites one is on Magento 1 and the second is on Magento 2 , In both websites we get fake reviews and fake signups everyday. Someone told me to add captcha which will not let bots or automated softwares to make fake reviews and fake signups. Any other solutions? or captcha is the best solution ?
If there are some extensions or any other solutions please give detail answer.

A: Google Recaptcha can help. Its not perfect, but when I implemented it on a contact form, it had a noticeable impact on the amount of spam coming in.
If you don't already have your site on a service like Cloudflare, you should do that. The free tier will give your some performance improvements and will filter a lot of bad traffic. With the paid plans you can start to create custom rules that can help you filter out some of the junk that comes in.
Its not fool-proof, I still get spam on my site, but its a start.
You can also make sure that you require e-mail confirmation for new accounts, and don't allow guest reviews. You'll still get spam, but at least they won't have as large of an impact on your site.

A: Follow the below steps.

*

*Enable captcha for customers signup which is the default functionality of Magento2.
Login to adminend -> Stores -> Configuration -> Customers ->Customer Configuration -> CAPTCHA

*Allow reviews only by registered customers which are an admin end-setting for Magento2

Login to adminend -> Stores -> Configuration -> Catalog ->Catalog -> Product Reviews -> Allow Guests to Write Reviews


text:
Q: Is it possible to extract the Facebook Graph url from the image URL? Basically, I am looking to do the inverse of this question: Getting the "real" Facebook profile picture URL from graph API
So, if this is my image URL:
https://scontent.xx.fbcdn.net/hprofile-xat1/v/t1.0-1/p200x200/1538635_10152313443182867_788243216_n.jpg?oh=72d672bc10ab01386ad5e490c097e059&oe=56A4392D
the design of Facebook's CDN will cause that URL to expire and 404 in the near future. So I am wondering, is it possible to get a URL that will not expire? For the above example, the permanent URL is this:
http://graph.facebook.com/517267866/picture?type=large
which will always 302 to an image URL. I am not sure if this is possible, but any insight would be appreciated.
I also tried looking for a solution in Facebook's Graph API documentation but I couldn't find any reference to this issue. Although I am unfamiliar with the Facebook Graph API, I think posting this question can help others in a similar position.

Update
Here is a slightly different example: How do I find a reliable image URL for the following photo:
https://www.facebook.com/DuwamishTreeCanopy/photos/pb.350520565135304.-2207520000.1444201132./401682256685801/?type=3&theater
?

A: You cannot "extract" something out of the CDN link... Why don't you just stick with the
https://graph.facebook.com/{user_id}/picture?type=large

link? It should also work without an access token and with app-scoped user ids AFAIK.


text:
Q: Manipulation of Infinite Series Example I'm struggling to understand the manipulation of an infinite series shown in the text below.

We begin with the series $\sum_{n=0}^{\infty} u^n$ which we know converges since $|u|<1$. We then express each term as an infinite series using the series for $u$ and the product rule for power series to obtain series for terms with higher exponents.
But then I don't understand on the penultimate line the justification for "unpacking" each of these series and then collecting like terms. I know absolutely convergent series can be rearranged and I know that $\sum_{n=0}^{\infty} u^n$ is absolutely convergent, but this, to my understanding, would only allow you to rearrange the terms in the original series $1+u+u^2+...$ So I could understand repositioning the infinite sums giving each $u^n$. But I can't understand breaking up those infinite sums and then freely repositioning the individual terms.
To put it in a different way, I wouldn't think you could just remove the brackets around for example $(z^2/3!-z^4/5!+...)$ on the third to last line and freely move the terms. I would think those brackets would have to remain and you could just freely move the infinite sum contained in the brackets.
What rule/property of infinite series allows the manipulation shown in the penultimate line of the above text?

A: What they are trying to do is use $\frac{1}{1-x}=\sum_{r=0}^{\infty}x^{r}$.
You see that inside the radius of convergence the series $\displaystyle u=\sum_{r=1}^{\infty}\frac{(-1)^{r-1}z^{2r}}{(2r-1)!}$ behaves like a single variable. And you CAN view
$\frac{1}{1-u}=\sum_{r=0}^{\infty}u^{r}$.
Then they are just viewing $u^r$ as a multinomial expansion and then just figuring out the first few terms of the series. This is fairly common in Taylor Series/Laurent Series manipulation. All of these has to be done inside the Radius of convergence.
Now for your "brackets" point. We CAN again do this.
for example. If we want to write the Maclaurin Expansion of $e^{\sin(z)}$.
We can do the following.
$\displaystyle e^{\sin(z)}=\sum_{r=0}^{\infty}\frac{\sin(z)^{r}}{r!}=1+\frac{\left(z-\frac{z^{3}}{3!}+...\right)}{1!}+\frac{\left(z-\frac{z^{3}}{3!}+...\right)^{2}}{2!}$  and figure out the first few terms. You will see that this becomes fairly important in something like finding the Residue where only the coeff of $\frac{1}{z}$ will be required.
Now if this method seems too out of place for you.
Then you can just Expand $\csc(z)$ around the origin using it's Maclaurin expansion and then divide by $\frac{1}{z^{2}}$. Computing the first few derivatives is not hard. Also the taylor series for $\csc$ is well known and many references can be found by just a simple google search.
Otherwise what you can also try is dividing $1$ by the polynomial $z-\frac{z^{3}}{3!}+...$ . That is also a form of series manipulation. I would refer you to Brown and Churchill's complex variables and applications
from page 222 under the title Multiplication and Division of Power Series as reference.
I hope this helps.


text:
Q: identifier error onclick of image Here is my code: Onclick of delte icon, I am passing values
for (var i = 0; i < data.length; i++) {
        data[i]["actions"] = '
' + '' +'
';
    }

I am passing id and the region code on delete. This is how my onclick looks

But it gives me an error saying :
SyntaxError: identifier starts immediately after numeric literal

getServerId(server-0a95755c-369b-4518-8b86-68864d94be21);
--------------------------

Can someone please help me out? Thanks


text:
Q: Canvas rendering once, after all actions A little confused with one moment, appreciate any help.
I'm making an app, that uses canvas for rendering game board.
And I faced a problem that its not optimal, rendering canvas for each little change.
Here's what the structure is at the moment:
function renderCanvas() {
  // calling for each row
}

function renderRow() {
  // calling for each cell
}

function renderCell() {
  // Here i use FillRect and StrokeRect both
}

Functions cooperate with passing context to each other.
Now it renders each cell. And using beginPath appears to deal only with stroke.
I wonder if i can startPath (like beginPath) somehow in renderCanvas function and after all operations with context are done - i could render that all once?

A: You can only do one styling per beginPath...
So if your cells require different colors, fonts, opacities then you must do a beginPath for each different style (but you can group same-styles together into one beginPath).


text:
Q: Can you recommend a .cvsignore file for a Visual C#.NET solution? I've developed a Visual C#.NET 2008 Express Edition solution containing three projects. I am cleaning it up to commit it into a CVS repository.
There are several files that are created during the build process that are not necessary to be placed in the repository since they will be regenerated automatically.
The question: Can anyone suggest a list of patterns to be placed into a .cvsignore file so that these generated files and folders are ignored?

A: Typically these are the only things that you have to commit:

*

*.sln files

*.cs files

*.csproj files

*.config files

*External DLLs and corresponding XML/config files that you are referencing

*other non-generated files that your application uses

All the rest are to be ignored, including:

*

*.suo files

*.csproj.user files

*/bin folder and contents

*/obj folder and contents

*practically everything else

A: Thanks!  This is what I have created:
bin
obj
*.cache
*.suo
*.csproj.user


text:
Q: Background tasks and activity Has anyone any idea on how to solve the generic problems related to starting a task in background from an activity and when the task is finished posting the result to the activity that created ? (the activity might get destroyed in the meantime due to a orientation change ,or receiving a call , or might be in the process of destroying and recreation)

A: Depending of what you are doing you might consider using a Service as well.


text:
Q: How to implement a deterministic finite automaton class in C++ I'm trying to implement a deterministic finite automaton in C++. Here's what I have:
typedef unsigned int state;

class Dfa {
    private:
        std::set<state> states;                                   // \(Q = q_0 q_1 q_2 \ldots q_{N - 1} \)
        std::set<char> alphabet;                                  // \(\Sigma\)
        state initial;                                            // \(q_0\)
        std::set<state> accept;                                   // \(F\)
        std::function<std::optional<state>(state, char)> delta;   // \(\delta(q, i)\)

    public:
        d_recognize();
};

According to the "Speech and Language Processing", by Daniel Jurafsky and James H. Martin, delta can be either a transition function or matrix. The closest parallel in C++ imo is a map<pair<unsigned int, char>, unsigned int>. So I want delta to be either a function<optional<unsigned int>(unsigned int, char)> or a map<pair<unsigned int, char>, unsigned int>. I think that this might be a good time to use concepts in C++, but I'm not actually sure how to write a concept that accepts both a function<optional<unsigned int>(unsigned int, char)> or a map<pair<unsigned int, char>, unsigned int>. How should I approach this problem?

A: First of all you do not necessarily need a std::function. Any function or callable that returns an optional<unsigned int> for given (unsigned int, char) will do. I don't know DFA, but options are:

*

*precalculate the values to have them readily available in a map, or

*calculate them when needed with a function, or

*combine both and use a function that internally uses a map for memoization.

Your choice. Do you need the result only for a small subset of input? Then a map will waste memory. Is the function expensive to calculate? Then perhaps a go for a function with memoization.


text:
Q: If $f(x)=g(t)$ and $x=t^2$ what are $f'$ and $f''$? If I have $f(x)=g(t)$ and $x=t^2$, can we conclude from this what $f'(x)$ and $f''(x)$ are in terms of g(t) and its derivatives?

A: I think it's just a composition of functions. $f(x)=g(t)$, $x=t^2$, then we have
$$
y=f(x),\ x=u(t)=t^2,
$$
so
$$
z=(f\circ u)(t)=g(t).
$$
Then
$$
\frac{dz}{dt}=\frac{dz}{dx}\frac{dx}{dt}.
$$
Since
$$
\frac{dz}{dx}=\frac{df}{dx}\ \text{and}\ \frac{dz}{dt}=\frac{dg}{dt},
$$
so
$$
\frac{dg}{dt}=\frac{df}{dx}\frac{dx}{dt}=2t\frac{df}{dx}
$$
i.e.,
$$
f^\prime=\frac{1}{2t}g^\prime.
$$
I think it should be like this. Any way the chain rule applies here.

A: if $x=t^2\Rightarrow t=\sqrt{x}$ thus:
$f'(x)=\frac{\partial}{\partial x}g(t(x))=\frac{\partial t(x)}{\partial x}g'(t)=\frac{1}{2\sqrt{x}}g'(t)$, now we apply the chain rule again:
$f''(x)=\frac{\partial}{\partial x}(\frac{1}{2\sqrt{x}}g'(t))=\frac{\partial}{\partial x}(\frac{1}{2}x^{-\frac{1}{2}})g'(t)+\frac{1}{4x}g''(t)=-\frac{1}{4}x^{-\frac{3}{2}}g'(t)+\frac{1}{4x}g''(t)$


text:
Q: App Store Sign-in Problem I just got a MacBook Air, and because it's my first Mac, I set up an Apple ID and account while setting up my MacBook. However, I can't sign-in to the App Store. Here's what happens:

*

*Box that says "Sign in to download from the App Store." And I sign-in.

*Another box says "This Apple ID has not yet been used with the App Store. Please review your account information."

*I click on "review", a new box says "Sign in required for account creation."

*So, I enter my password, and the box that says "This Apple ID has not yet been used with the App Store. Please review your account information" comes up again.

*From here I encounter an endless loop.
From what I found online, setting up payment information should fix this situation, but I have entered payment information and this problem still persists.

A: I figured it out finally. After much searching and trial and error, here's literally the only way it would work because none of the other answers on here worked for me: click on your name in settings where it shows you your AppleID and what kind of Apple product you're on, then click on Media & Purchases, then click on View Account and sign in with AppleID when it prompts you, then follow the steps to review it and choose your payments, and voilà you are able to download apps now.


text:
Q: What is the fastest way to calculate most dominant eigenvalue/singular value? I only know of the following power iteration. But it needs to create a huge matrix A'*A when both of rows and columns are pretty large. And A is a dense matrix as well. Is there any alternative to power iteration method below? I have heard of krylov subspace method, but I am not familiar with it. In anycase I am looking for any faster method than the one mentioned below:
B = A'*A; % or B = A*A' if it is smaller
x = B(:,1); % example of starting point, x will have the largest eigenvector
x = x/norm(x);
for i = 1:200
  y = B*x;
  y = y/norm(y);
  % norm(x - y); % <- residual, you can try to use it to stop iteration
  x = y;
end;
n3 = sqrt(mean(B*x./x)) % translate eigenvalue of B to singular value of A

A: I checked 'svd' command of matlab with a 100*100 randomly generated matrix. It is almost 5 times faster than your code.
s = svd(A);
n3 = s(1);


text:
Q: UITableView inside of UIScrollView or using TableView Header I guess this question is more of a best practice question than a problem solving question.
I would like to have a page on my app that has a UITableView at the bottom of it and some buttons/text above the UITableView but instead of just the UITableView scrolling, I would like the whole page to scroll.
I have been searching around and some people say to put the UITableView inside of a UIScrollView and disable scrolling on it and recalculate the height so the table view is as tall as all of it's rows.
Then I have read some other people say just to put the buttons/text in a Table Row Header and just have that scroll with the whole table view.
Which is the better practice and are either of them frowned upon?
Thanks!

A: Open the main storyboard and on the bottom right hand side you should see a list of view controllers, buttons, gestures etc.. In that list there should be a controller called "page control" that opts for the page-scroll you are looking for as well as the continuous one which you are trying to get rid of, you can just insertt this in to your basic view controller (via drag and drop). As for the button responsible for the segue (turning the page) you can find that in the list too. I can't explain how to program the button to turn the page step by step as I am typing this on my phone at work right now. If you want I can edit this later in more detail


text:
Q: Do Objective-C properties (self.foo) have much more overhead than using ivars (_foo)? I prefer to write "self.foo" instead of "_foo", mostly for style reasons. In theory self.foo means a function call, while _foo doesn't. I think this ok because it's unlikely to matter much for most code.
My question is: does the compiler optimize this to the same thing anyways? Maybe it can't, due to method swizzling? Does anyone have any insight?

A: No, the compiler doesn't optimize it to just an instance variable access. It cannot optimize it, because the class could have a subclass that overrides the getter method. (Note that subclasses can be created at runtime!)
However, you shouldn't worry about the message-sending overhead unless you've profiled your code and determined that it's a bottleneck.


text:
Q: STASM how face feature detection works i'm trying to work on STASM but the manual doesn't really explain how it works, i want to understand how does ASM detect the face feature in STASM. can you please help me. thank you

A: Please read the documentation cited in Section 7 of the Stasm 4 manual, which says:
Stasm is based on the Active Shape Model (ASM) developed by Cootes and Taylor [4,
14].
[4]  T. F. Cootes and C. J. Taylor. Technical Report: Statistical Models of Appearance
for Computer Vision. The University of Manchester School of Medicine, 2004.
http://www.isbe.man.ac.uk/~bim/Models/app_models.pdf.
[14] S. Milborrow and F. Nicolls. Active Shape Models with SIFT Descriptors and MARS. VISAPP, 2014.
http://www.milbo.org/stasm-files/active-shape-models-with-sift-and-mars.pdf.


text:
Q: Using a python api that stores a dict in a list of dicts...with no key values The python API (gmusicapi) stores playlists as a list of dicts with the track info as a dict inside that dict.
-edit- this is wrong. it does have some sort of key when printed, but I cant find out how to access the keys within the dict.
list = [
    { ##this dict isn't a problem, I can loop through the list and access this.
    'playlistId': '0xH6NMfw94',
    'name': 'my playlist!',
    {'trackId': '02985fhao','album': 'pooooop'}, #this dict is a problem because it has no key name. I need it for track info
    'owner': 'Bob'
    },

    { ##this dict isn't a problem, I can loop through the list and access this.
    'playlistId': '2xHfwucnw77',
    'name': 'Workout',
    'track':{'trackId': '0uiwaf','album': 'ROOOCKKK'}, #this dict would probably work
    'owner': 'Bob'
    }
]

I have tried using for loops and accessing it through somethings like:
def playLists(self):
    print 'attempting to retrieve playlist song info.'
    playListTemp = api.get_all_user_playlist_contents()
    for x in range(len(playListTemp)):
        tempdictionary = dict(playListTemp[x])

The problem here is tempdictionary has a dict in it called tracks but I can't seem to access the keys/value pairs inside it no matter what I do.
when printed it returns something like:
[u'kind', u'name', u'deleted', u'creationTimestamp', u'lastModifiedTimestamp', u'recentTimestamp', u'shareToken', 'tracks', u'ownerProfilePhotoUrl', u'ownerName', u'accessControlled', u'type', u'id', u'description']

where 'tracks' is a dict containing artist, title, tracknumber etc
I also tried something like:
tempdictionary['tracks'][x]['title']
with no luck. Other times I have tried creating a new dict with tracks dict as a velue but then I get an error saying it needs a value of 2 and it found something like 11 etc.
im new to python so if anyone here could help with this I would be very thankful

A:
it does have some sort of key when printed, but I cant find out how to access the keys within the dict.

Iterate over the dict:
for key in dct:
    print(key)
    # or do any number of other things with key

If you'll also be looking at the values of the dict, use .items() to save yourself a dict lookup:
for key, value in dct.items():
    print(key)
    print(value)

A: You might consider using classes to encapsulate common traits.  Currently, each of your track and playlist dictionaries have a lot of duplicate code (ie. "track_id=", "owner="Bob").  Using classes reduces duplicate and makes your meaning more obvious and explicit.
class AudioTrack(object):
    def __init__(self, ID, album=None):
        self.id = ID
        self.album = album
        self.owner = 'Bob'

Create a single AudioTrack objects like this:
your_first_track = AudioTrack('02985fhao', 'pooooop')

Or create a list of AudioTrack objects like this:
your_tracks = [
    AudioTrack("0x1", album="Rubber Soul"),
    AudioTrack("0x2", album="Kind of Blue"),
    ...
    ]

In this way, you could inspect each AudioTrack object:
your_first_track.id     #Returns '02985fhao'

Or do something for all AudioTrack objects in your_tracks:
#Prints the album of every track in the list of AudioTrack intances
for track in your_tracks:
    print track.album

You might make playlists using dictionaries where:
my_playlist = {
    id: "0x1",
    name: "my playlist",
    tracks:  [AudioTrack("0x1", album="Rubber Soul"),
              AudioTrack("0x2", album="Kind of Blue")]
    }


text:
Q: Ruby Cucumber: Selenium Webdirver - IE 11 link flashes, cannot click on I am experiencing IE browser links flashing issue when I run test automation written in Ruby Cucumber using Selenium WebDriver.
   Scenario: Navigating to Reporting home page.
      Given I see menu Reporting available.
      When I navigate to "Annual Reporting".
      Then I see the correct header on Annual Reporting page.

home_page.rb (Approach 1: using page_object)
     link(:annual_reporting_link, :id => 'annualReportingLinkId')

     def go_to_reporting
       mouse_over_home
       wait_until(5) do
           annual_reporting_link
       end
    end

Result: Could not click on the link because of the link flashing.
Then I tried the following (Approach 2: Using send_keys)
    @browser.find_element(:id, 'annualReportingLinkId').send_keys :return

    and

    @browser.find_element(:id, 'annualReportingLinkId').send_keys(KEYS.ENTER)

but it did not work either.  I am getting this error when run the test:
 Selenium::WebDriver::Error::ElementNotVisibleError: Cannot click on element

The HTML:

Report 1

Report 2

Annual Reporting

Manage Users

Test automation is able to expend the home menu, which contains sub-menus - hyperlinks. But after mouse_over_home (the home menu), the sub-menu started flashing. I need to click on "annual_reporting_link" to go to this reporting page, but because of flashing, the test automation cannot click on it at all.
Anyone has a solution that worked for you? Please share your solution.
Environment:
   Ruby: 1.9.3
   Cucumber: 2.1.0
   Selenium Webdriver: 2.53.4
   page-object: 1.2.0
   IE: 11

A: I've had this issue before using Selenium Webdriver and IE. I found that it was a bug between my version of IE and Selenium Webdriver.
When I experienced this problem, I put a break-point before the link was clicked and debugged the test, I then manually tried to click the link in IE and I was still unable to do so 9 times out of 10 because of this bug, the link was simply ''flashing'' and unresponsive.
I'd recommend upgrading your version of Selenium Webdriver to version 3.0.0, that should fix the problem.
If you don't want to make the jump to Selenium Webdriver 3.0.0, You need find out the exact version of IE 11 you're using. Try to upgrade or downgrade your version of IE 11, this should also fix the problem, but you may find you're stuck on a version of IE 11 until you upgrade to Selenium Webdriver 3.0.0.
Antoher solution is to set the persistent hovers to false within your IE profile, something like this:
profile = Selenium::WebDriver::IE::Profile.new
profile['enablePersistentHover'] = false

driver = Selenium::WebDriver.for :IE, :profile => profile


text:
Q: Unable to locate package libffi and libffi5-dev on Ubuntu 12.04.4 through apt-get $ sudo apt-get install libffi libffi5-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libffi
E: Unable to locate package libffi5-dev

another try:
$ sudo apt-get install libffi5 libffi-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libffi5

and
$ cat /etc/issue
Ubuntu 12.04.4 LTS \n \l

What am I supposed to do now?

A: The packages are be called libffi6 and libffi-dev.
Package names can be searched on http://packages.ubuntu.com/

For searching packages use apt-cache search.
Example in your case following can help you:
$ apt-cache search libffi
libffi-dev - Foreign Function Interface library (development files)
libffi6 - Foreign Function Interface library runtime
libffi6-dbg - Foreign Function Interface library runtime (debug symbols)
ffindex-dbg - simple index/database for huge amounts of small files (debug)
libbfio-dbg - Library to provide basic input/output abstraction (debug)
libffindex0 - library for simple index/database for huge amounts of small files
libffindex0-dev - library for simple index/database for huge amounts of small files (development)
libjffi-java - Java Foreign Function Interface
libjffi-jni - Java Foreign Function Interface (JNI library)

A: You can also try installing the upstream Debian libffi5 package, if another package specifically requires libffi5.
See: https://packages.debian.org/wheezy/libffi5 or the appropriate upstream Debian version for your Ubuntu release.
Download the appropriate Debian package (.deb) for your architecture, and install using dpkg; e.g. dpkg -i libffi5_3.0.10-3+deb7u2_amd64.deb. Then either fix the original install (apt-get -f install), or reinstall the desired package (apt-get install ...).

A: Your Ubuntu package repository may be too old to update.
Keep in mind select the suitable architecture and change your package repository url by adding a line to your /etc/apt/sources.list like this:
deb https://launchpad.net/ubuntu/+mirror/mirror.enzu.com-archive focal main

There are alternative other mirror links  like  https://launchpad.net/ubuntu/+mirror/mirror.enzu.com-archive.
Select the suitable mirror based on your region and internet speed.
or you can download the package directly and install it.


text: Q: Generate a poster image from Spring I want to create a Spring view that will take an object from the request, and generate a .png poster based on that object. Is there an existing View technology for that?


text:
Q: Version issue with change from .net 4.5.2 to 4.0 in Entity Framework I have an .edmx file which includes a lot of tables. The file is inside a project created with .NET 4.5.2. But my other projects are using .NET version 4.0 and i can not refer this project. I have to change my used .NET version to 4.0. But it gives me an error below while rebuild process. I can not solve this.

The primary reference "EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089,
  processorArchitecture=MSIL" could not be resolved because it was built
  against the ".NETFramework,Version=v4.5" framework. This is a higher
  version than the currently targeted framework
  ".NETFramework,Version=v4.0".

A: You need to reinstall EF6 using nuget as explained here: https://learn.microsoft.com/en-us/nuget/consume-packages/reinstalling-and-updating-packages
Go to Tools > NuGet Package Manager > Package Manager Console
Then type Update-Package -Id EntityFramework -Version 6.0.0 –reinstall
You might need to edit your packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
    <package id="EntityFramework" version="6.0.0" />

    <!-- ... -->
</packages>

A: EF has both a net40 folder and a net45 folder. You are most likely referencing the dll in net45. If you uninstalled the package and reinstalled as CodeCaster suggested, then you may have a stuck reference in your csproj file. You can try this:

*

*Right click your web project and choose "Unload Project". Now you can right click and edit it.

*Look for the reference path and if it says \net45 change it to \net40

*Right click and reload project.

<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>


text:
Q: Does the following tag question sound natural? "Seems like it's no longer possible, is it?" I'm not sure if it is actually a tag question though. Because if it were a tag question then most probably, there should be doesn't it at the end of it.
But that's not what I want to ask the person I'm asking the question; rather, I want to ask them whether or not it is still possible.
If that construction is not possible, then how would you word it?