text:
Q: Do the units for acceleration break down when we're talking about bodies undergoing centripetal acceleration at a constant speed? I've always taken values like $2 m/s^2$ to indicate that the speed of the body increases by $2m/s$ every second, but I fail to see how this can apply for situations where we're talking about bodies undergoing centripetal acceleration (at a constant speed). Yes, I agree that the velocity is changing, but its magnitude isn't and it feels, at least to me, as if the units break down here: if $m/s^2$ suggests that a particular $m/s$ value is being added to the initial velocity each second, how does that apply for bodies undergoing centripetal acceleration at a constant speed, where the speed isn't changing?

A: Acceleration and velocity are vectors, which have magnitude and diretcion. Speed is the magnitude of velocity - it may remain constant while the direction of velocity is changing. What you are given here is the magnitude of the acceleration - if it is perpendicular to the velocity, the latter will change only its direction, but not magntitude.

A: Say the body has a speed of 30m/s, and initially moves in X direction, meaning its velocity along X is 30m/s, and along Y it's 0m/s.
An acceleration of 2m/s² means that the velocity changes by 2m/s every second. A centripetal acceleration is directed along a right angle to the velocity, so in our situation it's a Y acceleration, meaning that after a second we get a Y velocity component of 2m/s, while X velocity stays unchanged at 30m/s.
(Of course, this was a bit simplified, not giving exact results, as a true centripetal acceleration should change its direction a bit during this one second, as the velocity direction changes. But in our case, the resulting error is far below 1%.)
And that's what happens when a car moves along a 900m-diameter circle at 108km/h: its velocity changes by 2m/s towards the circle center every second.

A: Even if you have $a=2m/s^2$  for time t=0 it does not say that the velocity changes by 2m/s in 1s- this supposes that a is constant, if a=2m/s^2+2m/s^3*t  the velocity change is only in the very first moment $2m/s^2*\Delta t$
Same with centripetal acceleration, it changes not  magnitude but direction all the time, so it alters the direction of v continuously.


text:
Q: How to start a new static website project with SASS installed in MACOS I was trying to install sass in one of my latest static website project, But got up with a few errors like FAILED TO BUILD GEM NATIVE EXTENSIONS. Its been 5 years I used sass last time, that time it was quite easy by simply adding gem install sass, But I found its difficult.
I have read a few articles and there its saying to install brew, RVM etc etc. I use MACOS. How can I solve my problem from scratch? What should I install and where to install (root / inside project folder).

A: ruby-sass has been deprecated, and it's recommended that you use another installation method.
https://sass-lang.com/install
I recommend installing via brew (which is a package manager for OS X) since you're on OS X.
https://brew.sh/
To install Brew, open your terminal and paste this:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Once the install completes, enter the following command:
brew install sass/sass/sass

redpajama_set_name: RedPajamaStackExchange


text:
Q: SQL - Find records in continuous time series as groups in PostgreSQL I have a timeseries data in which I'm trying to find continous streaks of records in order within a certain time interval, grouping by each series of continual records. For example, if the time interval is 5 minutes between records for each set (group) any record next record that was within 5 minutes would be in the set and any record over 5 minutes would end the set (group). A new set (group) would emerge from the next two records within 5 minutes.
**Minute seperation is not in the table, it is calculated in the query
|    |                     |                                   |          |                                                            |
|----|---------------------|-----------------------------------|----------|------------------------------------------------------------|
| id | timestamp           | minute separation (Calculated **) | group    | notes                                                      |
| 1  | 2018-02-13T01:18:00 | 0                                 | Group 1  |                                                            |
| 2  | 2018-02-13T01:22:00 | 4                                 | Group 1  |                                                            |
| 3  | 2018-02-13T01:25:00 | 3                                 | Group 1  |                                                            |
| 4  | 2018-02-13T01:31:00 | 6                                 | No Group | breaks group 1                                             |
| 5  | 2018-02-13T01:38:00 | 7                                 | No Group | not within interval on either side                         |
| 6  | 2018-02-13T01:44:00 | 6                                 | Group 2  | Start of group 2                                           |
| 7  | 2018-02-13T01:47:00 | 3                                 | Group 2  |                                                            |
| 8  | 2018-02-13T01:48:00 | 1                                 | Group 2  |                                                            |
| 9  | 2018-02-13T01:49:00 | 1                                 | Group 2  |                                                            |
| 10 | 2018-02-13T01:51:00 | 2                                 | Group 2  |                                                            |
| 11 | 2018-02-13T01:57:00 | 6                                 | Group 3  | Breaks Group 2, included in next group as start of group 3 |
| 12 | 2018-02-13T01:59:00 | 2                                 | Group 3  |                                                            |
| 13 | 2018-02-13T02:01:00 | 2                                 | Group 3  |                                                            |
| 14 | 2018-02-13T02:02:00 | 1                                 | Group 3  |                                                            |
| 15 | 2018-02-13T02:08:00 | 6                                 | No Group | Breaks group 3                                             |
| 16 | 2018-02-13T02:15:00 | 7                                 | No Group |                                                            |
| 17 | 2018-02-13T02:22:00 | 7                                 | No Group |                                                            |

I can find the difference between 2 rows in order and extract them, but I'm not sure how I would extract a series of n+1 rows.
My Working sample is here:  http://sqlfiddle.com/#!17/e9fa1/7
Sample Data SQL Insert:
CREATE TABLE time_series (
  id SERIAL UNIQUE,
  name TEXT,
  timestamp TIMESTAMPTZ
);

INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T01:18:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T01:22:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T01:25:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T01:31:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T01:38:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T01:44:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T01:47:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T01:48:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T01:49:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T01:51:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T01:57:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T01:59:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T02:01:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T02:02:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T02:08:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T02:15:00');
INSERT into time_series (name,timestamp) VALUES ('Test','2018-02-13T02:22:00');

Working Query:
WITH my_series AS
(
  SELECT *, ROW_NUMBER() OVER (ORDER BY timestamp) AS rn
    FROM time_series
)
SELECT o1.id AS id1, o1.timestamp AS date1, o2.id AS id2, o2.timestamp  AS date2, ABS(EXTRACT(EPOCH FROM (o1.timestamp - o2.timestamp))) AS diff

  FROM my_series as o1 JOIN my_series  as o2
    ON o1.rn + 1 = o2.rn
  WHERE ABS(EXTRACT(EPOCH FROM (o1.timestamp - o2.timestamp))) < 300;

I need to either return each group as one set (that will work as I should be able to repeat the query noting the timestamp that the query ended to start the next one, although that does not seem very efficent), or return all the groups labeled as group, like this:
Desired result:
|    |                     |                                   |          |                                                            |
|----|---------------------|-----------------------------------|----------|------------------------------------------------------------|
| id | timestamp           | minute separation (Calculated **) | group    | notes                                                      |
| 1  | 2018-02-13T01:18:00 | 0                                 | 1        |                                                            |
| 2  | 2018-02-13T01:22:00 | 4                                 | 1        |                                                            |
| 3  | 2018-02-13T01:25:00 | 3                                 | 1        |                                                            |
| 6  | 2018-02-13T01:44:00 | 6                                 | 2        |                                                            |
| 7  | 2018-02-13T01:47:00 | 3                                 | 2        |                                                            |
| 8  | 2018-02-13T01:48:00 | 1                                 | 2        |                                                            |
| 9  | 2018-02-13T01:49:00 | 1                                 | 2        |                                                            |
| 10 | 2018-02-13T01:51:00 | 2                                 | 2        |                                                            |
| 11 | 2018-02-13T01:57:00 | 6                                 | 3        |                                                            |
| 12 | 2018-02-13T01:59:00 | 2                                 | 3        |                                                            |
| 13 | 2018-02-13T02:01:00 | 2                                 | 3        |                                                            |
| 14 | 2018-02-13T02:02:00 | 1                                 | 3        |                                                            |

A: You want to use lag() and lead().  I would enumerate all the groups, even the ones with only one row:
select s.*,
       sum( (timestamp >= prev_timestamp + interval '5 minute' or prev_timestamp is null)::int ) over (order by timestamp) as grp
from (select s.*,
             lag(timestamp) over (order by timestamp) as prev_timestamp,
             lead(timestamp) over (order by timestamp) as next_timestamp
      from my_series s
     ) s;

The logic is a bit more complicated for your actual question.  I think this does the trick:
select s.*,
       (case when timestamp > prev_timestamp + interval '5 minute' and
                  timestamp < next_timestamp - interval '5 minute' and
             then NULL
             else sum( (timestamp >= prev_timestamp + interval '5 minute' and next_timestamp < timestamp + interval '5 minute')::int ) over (order by timestamp)
        end) as grp
from (select s.*,
             lag(timestamp) over (order by timestamp) as prev_timestamp,
             lead(timestamp) over (order by timestamp) as next_timestamp
      from my_series s
     ) s;

A: There is something similar which I had implemented with monthly grouped data. Please let me know if a similar solution can be applied for this case:
https://stackoverflow.com/a/59961217/7357308
and I have a blog regarding same as well: https://medium.com/@adib0073/quick-fix-to-importing-time-series-data-from-sql-server-93ad77f9b3d0
Please let me know if this helps.


text:
Q: Do not understand the source code of Arrays.copyOf I have trouble understanding the source code of Arrays.copyOf.
public static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType) {
    T[] copy = ((Object)newType == (Object)Object[].class)
        ? (T[]) new Object[newLength]
        : (T[]) Array.newInstance(newType.getComponentType(), newLength);
    System.arraycopy(original, 0, copy, 0,
                     Math.min(original.length, newLength));
    return copy;
}

*

*what is this line checking?
(Object)newType == (Object)Object[].class

*What are the differences between (T[]) new Object[newLength] and (T[]) Array.newInstance(newType.getComponentType(), newLength). why Array.newInstance not good enough for both cases?

*This following line compiles, but crashes at run time (as expected). When should I use this method?
Integer[] nums = Arrays.copyOf(new String[]{"a", "b"}, 2, Integer[].class)

A: First of all, the cast in that line
((Object)newType == (Object)Object[].class)

are absobuletly needed. Removing them will result in a compilation error :
incomparable types: Class<CAP#1> and Class<Object[]>
 where CAP#1 is a fresh type-variable:
  CAP#1 extends T[] from capture of ? extends T[]

Now to answer your question What is this line checking ?
It simply verify if the given array is of object type, which is part of the answer for your other question Why Array.newInstance not good enough for both cases?
In the first case, we already know that the array is of Object type so there is no point in calling the newInstance method to retrieve the correct type, this would only result in performance loss.
As for your final example,
Integer[] nums = Arrays.copyOf(new String[]{"a", "b"}, 2, Integer[].class)

That it does compile, it is true. Because the given arguments to the method are all valids. It will certainly fail at runtime; what would be the expected output of converting "a" to Integer type ?
Now, when to use copyOf ? When you already know the both types, and already know that they are valid together.
It main usage is to return a copy but truncated or padded with [null/default values] to the original array.

A: *

*It is checking if newType is array of Objects or not:
Object[] a1 = new Object[100]; -- array of Objects

String[] a2 = new String[100]; -- array of Strings

Why to do that? Because new Object[n] is faster than Array.newInstance

*Array.newInstance(Class<?> componentType, int... dimensions) creates an array of types defined by the first argument, eg String.class -> String[]. Note that String[].class.getComponentType() returns String.class

*You cannot use it like that, but it can be like this
Integer[] nums = Arrays.copyOf(new Object[]{1, 2}, 2, Integer[].class);

in this case it depends only on actual type of elements, eg
  Arrays.copyOf(new Object[]{1L, 2}, 2, Integer[].class);

will fail, you cannot write in Integer[] anything but Integer

A:
What is this line checking? (Object)newType == (Object)Object[].class

It's checking simple equality (likely for the purpose of a micro-optimization, but more on that later).
The unusual casting is necessary because Class<Object[]> (the type of Object[].class) and Class<? extends T[]> are incomparable types. Basically, for an equality comparison with == to compile, one of the sides has to be a subtype or supertype of the other.
I.e. we can't do:
// doesn't compile
// this expression can never evaluate to true
(new Integer(0) == new Float(0f))

The rules for generic types are a bit more complicated and there are a few cases where a comparison doesn't compile, but it may still evaluate to true.
The reason Class<Object[]> is not a supertype of Class<? extends T[]>, despite Object[] being a supertype of all object array types, is that Java generics are invariant without the presence of a wildcard.
Another way to do the comparison would be:
(newType == (Class<? extends Object[]>)Object[].class)

What are the differences between (T[]) new Object[newLength] and (T[]) Array.newInstance(newType.getComponentType(), newLength)?

*

*new Object[...] creates an array the normal way, of a type that is statically known. Remember, the code has just checked that T[] is Object[].

*Array.newInstance(...) uses reflection to dynamically create an array of the Class type passed in.

Why Array.newInstance not good enough for both cases?

An operation using reflection is generally slower than its non-reflective counterpart.
The reflection tutorial says:

Because reflection involves types that are dynamically resolved, certain Java virtual machine optimizations can not be performed. Consequently, reflective operations have slower performance than their non-reflective counterparts, and should be avoided in sections of code which are called frequently in performance-sensitive applications.

Java SE is filled with micro-optimization like this. The writers of SE try to squeeze everything they can out of it.
But I wouldn't be worried about a performance hit in this case: newInstance and copyOf are HotSpot intrinsics. This means that ideally calls to these methods get replaced with machine-specific assembly. Anecdotally, I ran some tests and found the difference between new Object[...] and Array.newInstance(...) to be negligible. The code in the question is probably a relic, although it may still be useful on less well-equipped JVMs.
Reflection can also be disabled in certain contexts with strict security (such as an applet), but not typically for a normal desktop application.

When should I use this method?

In general, you will probably never use this overload. This overload is only useful if you want to change the type of the array.

*

*Widening:
Object[] a = Arrays.copyOf(
    new String[] { "hello", "world" }, 3, Object[].class);
a[2] = Character.valueOf('!');
System.out.println(Arrays.toString(a));

*Narrowing:
String[] a = Arrays.copyOf(
    new Object[] { "hello", "world" }, 2, String[].class);
System.out.println(String.join(" ", a));

It's more typical to use Arrays.copyOf(T[], int).

A:

*

*what is this line checking?

(Object)newType == (Object)Object[].class

It is checking whether variable newType holds a reference to an instance of java.lang.Class representing type Object[].  The casts are unneeded.

*What are the differences between (T[]) new Object[newLength] and (T[]) Array.newInstance(newType.getComponentType(), newLength). why Array.newInstance not good enough for both cases?

As far as I can tell, Array.newInstance() could be used in both cases, but non-reflective ordinary array construction is likely a bit faster.  Thus, I suppose that Object[] is called out as a special case for performance reasons, but I have no idea whether that case is exercised frequently enough for the optimization to be important.

*This following line compiles, but crashes at run time (as expected). When should I use this method?

Integer[] nums = Arrays.copyOf(new String[]{"a", "b"}, 2, Integer[].class)

You should use it when you need to copy an array to an array with a possibly different (but compatible) element type, especially when the element types are not statically known.  If you know you want the copy to have the same element type as the original, then it's easier to use the original array's clone() method.

A: Let me attempt to answer this:
To answer your first question, it's checking if the newType type is the same as the types in the array. Both are also upcasting the types to an Object type. That is, it tries to see if the array's parent type is of object. See this SO question on Upcasting and Downcasting. My guess is that it casts not because to check for type-safety. Even though all objects in Java derive from objects as a superclass.
It would be helpful to notice that
 T[] copy = ((Object)newType == (Object)Object[].class)
    ? (T[]) new Object[newLength]
    : (T[]) Array.newInstance(newType.getComponentType(), newLength);

is actually one line. i.e it is actually an if-else conditional.
result = (condition) ? (doThisIfTrue) : (elseDoThisIfFalse)
Simple example here
So essentially that line would be the same as:
T[] copy;
Boolean condition = ((Object)newType == (Object)Object[].class)
if(condition)
     copy = (T[]) new Object[newLength];
else
     copy = (T[]) Array.newInstance(newType.getComponentType(), newLength);

The reason why creating a new instance in Array.newInstance is likely a performance choice, where if the program always has to create new instances it'll be more expensive than just directly initializing a generic Object array and copy things over.
Arrays.copyOf will create a new array (with references to the old one) but with a newer length and pads the unused positions with empty objects. This is what it does on an array of ints in which it pads the unused indexes with zeros.
Arrays.CopyOf serves to provide a shallow-copy of the objects, that is it refers to the old items, but in a new array. This SO question has more info on it.


text:
Q: Having $x^3=(3+4i)\overline{x},$ with $x$ a complex number, what is the sum of the moduli of its roots? I've started by applying modulus on both sides knowing that $$|x| = \left\lvert\overline{x}\right\rvert=\sqrt{a^2+b^2},$$ which is a constant $k.$ That leads me to the equation $k^3=5k,$ which leads to either $k=-\sqrt{5}$ or $k=\sqrt{5}.$ The sum of the moduli of the roots will be just $2\sqrt{5}$?

A: No, it is not $2\sqrt5$, and your justification is not correct. The number $k$ cannot be $-\sqrt5$, since $k\geqslant0$.
There is an obvious root, which is $0$. If $x$ is a root and $x\neq0$, then\begin{align}x^3=(3+4i)\overline x&\implies\lvert x\rvert^3=5\left\lvert\overline x\right\rvert=5\lvert x\rvert\\&\implies\lvert x\rvert^2=5.\end{align}Therefore, $x=\sqrt5\bigl(\cos(\theta)+i\sin(\theta)\bigr)$ for some $\theta\in\mathbb R$. And\begin{align}x^3=(3+4i)\overline x&\iff5\sqrt5\bigl(\cos(3\theta)+i\sin(3\theta)\bigr)=\sqrt5(3+4i)\bigl(\cos(-\theta)+i\sin(-\theta)\bigr)\\&\iff\cos(3\theta)+i\sin(3\theta)=\left(\frac35+\frac45i\right)\bigl(\cos(-\theta)+i\sin(-\theta)\bigr).\end{align}Now, if $\alpha\in\mathbb R$ is such that $\cos\alpha=\frac35$ and that $\sin(\alpha)=\frac45$, the last equality is equivalent to$$\cos(3\theta)+i\sin(3\theta)=\cos(\alpha-\theta)+i\sin(\alpha-\theta).$$ This leads to $4$ solutions: $\theta=\frac\alpha4$, $\theta=\frac\alpha4+\frac\pi2$, $\theta=\frac\alpha4+\pi$, and $\theta=\frac\alpha4+\frac{3\pi}2$ (after this, you will be getting  the same roots). So, besides $0$, there are $4$ roots, all of which have absolute value $\sqrt5$. Therefore, the answer is $4\sqrt5$.

A: You're correct that if $k=|x|,$ then $x^3=(3+4i)\overline{x}$ yields $k^3=5k$ by taking the modulus of both sides. However, from there, you've gone off track.
From $k^3=5k,$ we can conclude that $k\in\left\{0,-\sqrt{5},\sqrt{5}\right\}.$ However, $k$ is a modulus, so cannot be negative! Thus, $k\in\left\{0,\sqrt{5}\right\}.$
If the equation were a polynomial in $x,$ we could conclude that it has exactly three roots, and at that point, you'd be able to conclude that the sum of the roots' moduli is $2\sqrt{5},$ so long as you could show that $0$ was a root of multiplicity $1.$ However, it is not a polynomial in $x.$
By the prior work, we know that $|x|=0$ or $x=\sqrt{5},$ so, recalling that $x\overline x=|x|^2,$ we find that $$x^3=(3+4i)\overline{x}$$ holds if and only if either $x=0$ or $$x^4=(3+4i)x\overline{x}=(3+4i)|x|^2=15+20i.$$ Thus, since $x^4=15+20i$ is a polynomial in $x$ whose roots necessarily have modulus $\sqrt{5},$ the sum of the moduli is $0+4\sqrt{5}=4\sqrt{5}.$

A: Let $x=re^{it}, \bar x=re^{-it}$ where $r\ge0, t$ are real
$r^3e^{3it}=(3+4i)re^{-it}$
If $r\ne0,$ $$r^2e^{i4t}=3+4i$$
Taking modulus both sides $r^2=5\implies r=\sqrt5$
$\implies e^{i4t}=\dfrac{3+4i}5=e^{iy}$  where $y=\arccos\dfrac35$
$\implies 4t=2m\pi+\arccos\dfrac35$ where $m$ is any integer
$\implies t=\dfrac{m\pi}2+\dfrac{\arccos\dfrac35}4$ where $m=0,1,2,3$
So, we have $4$ unequal non-zero roots each having modulus $=\sqrt5$


text:
Q: Change the UILabel text color on button click I have button in application i want that when user click on that button then it should show the unselected question labels text to red color
Only one lable text is changing of the Q1 only not the others.

-(IBAction)nextButtonClicked
{
    if ([professionLabel.text isEqualToString:@"Profession"])
    {
        errorLabel.text=@"Please Select the Highlighted Answers";
        Q1.textColor=[UIColor redColor];
    }
    else if ([workLabel.text isEqualToString:@"Work"])
    {
        errorLabel.text=@"Please Select the Highlighted Answers";
        Q2.textColor=[UIColor redColor];
    }
    else if([yearLabel.text isEqualToString:@"Year"])
    {
        errorLabel.text=@"Please Select the Highlighted Answers";
        Q3.textColor=[UIColor redColor];
    }
    else
    {
        [self submitSurveyAnswers];
        [self submitSurveyAnswersOne];
        [self submitSurveyAnswersTwo];
        OnlineViewController*targetController=[[OnlineViewController alloc]init];
        targetController.mynumber=mynumber;
        [self.navigationController pushViewController:targetController animated:YES];
    }
}

A: Try and remove the else from the else if, then it will go in all the conditions one by one .... Else if will imply that if one statement is satisfied then the others will be skipped by default.
if ([professionLabel.text isEqualToString:@"Profession"]) {
errorLabel.text=@"Please Select the Highliteg Answers";
Q1.textColor=[UIColor redColor];
}

if ([workLabel.text isEqualToString:@"Work"]) {
errorLabel.text=@"Please Select the Highliteg Answers";
Q2.textColor=[UIColor redColor];
}
if([yearLabel.text isEqualToString:@"Year"]){

errorLabel.text=@"Please Select the Highliteg Answers";
Q3.textColor=[UIColor redColor];
}


text:
Q: static const GLchar *c becomes undefined the shaderLoader Function retrieves a String, i then convert it to const char with c_str(). But for some reason c is undefined. Any Hint?
static const GLchar *  c[1000];

*c =  shaderLoader("C:\\Users\\Dozent-01\\Desktop\\User\\CG\\bin\\vertShader.txt").c_str();

glShaderSource(vertex_shader, 1, c, NULL);

A: In you code include this file
  #include <GL/glew.h>

Refer this post

A: I assume c_str() behaves the same as std::string::c_str() does. That doesn't covnert anything. It gives you a pointer to the data stored in the string, which is only valid as long as the string itself remains alive and unchanged.
I will also assume shaderLoader() returns a temporary object. You take a pointer to its data and store that pointer in c[0]. At the end of this expression, the temporary is destroyed and thus the pointer no longer points to valid data. It's dangling.
You'll have to copy the data, not just store a pointer to it. Something like this:
auto str = shaderLoader("whatever");
c[0] = new GLchar[str.size() + 1];
strcpy(c[0], str.c_str());
// don't forget to delete[] the memory when no longer needed

Of course, there is also the question of why you have an array of 1000 pointers to cosnt GLchar. I suspect you actually meant c to be a buffer of characters where to store the string. If so, you'd change the code like this:
static const GLchar c[1000];

strncpy(c, shaderLoader("whatever").c_str(), sizeof(c));


text:
Q: fputs with #include "test.txt" - compilation error text.txt file contains 1 line
ooo

This is the code:-
fputs (
#include "test.txt"
,stdout
);

Compile Error :
1:1: error: 'ooo' undeclared (first use in this function)

A: the #include will include the content of your file in place of the statement. So your code would be interpreted as :
fputs (
ooo
,stdout
);

The error makes sense, because apparently, ooo is not something you have defined earlier.
If you meant to print the actual string ooo, you should surround it by quotes in your txt file, so it becomes "ooo".

A: From 6.10.2p3

A preprocessing directive of the form
# include "q-char-sequence" new-line

causes the replacement of that directive by the entire contents of the
  source file identified by the specified sequence between the "
  delimiters.

Here the content was ooo and the compiler didn't understand what this ooo meant. It never saw its declaration.


text:
Q: Can I add the same marker in different ArrayLists? I would like to know how can I add for example the same marker into different array lists. I have let's say 5 array lists and 7 markers. I am adding the markers to the map, adding each marker to it's corresponding list and filter to display or hide the markers according to the list selected by the user. Everything works fine when the lists contain different markers, but when I have common markers in two lists the common marker will be kept only in the last list added.
List<Marker> firstList = new ArrayList<>();
List<Marker> secondList= new ArrayList<>();
List<Marker> thirdList= new ArrayList<>();
List<Marker> fourthList= new ArrayList<>();
List<Marker> fifthList= new ArrayList<>();

 Marker marker1 = mMap.addMarker(new MarkerOptions().position(latLong1).title("MARKER1").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker1"));
 Marker marker2 = mMap.addMarker(new MarkerOptions().position(latLong2).title("MARKER2").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker2"));
 Marker marker3 = mMap.addMarker(new MarkerOptions().position(latLong3).title("MARKER3").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker3"));
 Marker marker4 = mMap.addMarker(new MarkerOptions().position(latLong4).title("MARKER4").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker4"));
 Marker marker5 = mMap.addMarker(new MarkerOptions().position(latLong5).title("MARKER5").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker5"));
 Marker marker6 = mMap.addMarker(new MarkerOptions().position(latLong6).title("MARKER6").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker6"));
 Marker marker7 = mMap.addMarker(new MarkerOptions().position(latLong7).title("MARKER7").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker7"));

firstList.add(marker1);
secondList.add(marker2);
secondList.add(marker3);
thirdList.add(marker1);
thirdList.add(marker4);
fourthList.add(marker5);
fifthList.add(marker6);
fifthList.add(marker7);
fifthList.add(marker1);
fifthList.add(marker2);

So when I filter the markers by lists for example if I filter for firstList no marker will be displayed, if I filter for thirdList only marker4 will be displayed and if I filter for fifthList than al the markers will be displayed including marker1. So the list keeps only the last added common items. So how can I make it so that the lists will keep all their objects even though they are common to other lists?
Thanks in advance!
UPDATE:
I don't know if this is exactly what you suggested, but I did this and now the filter is working properly. By doing this I have another problem.
List<Marker> firstList = new ArrayList<>();
List<Marker> secondList= new ArrayList<>();
List<Marker> thirdList= new ArrayList<>();
List<Marker> fourthList= new ArrayList<>();
List<Marker> fifthList= new ArrayList<>();

firstList.add(mMap.addMarker(new MarkerOptions().position(latLong1).title("MARKER1").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker1")));
secondList.add(mMap.addMarker(new MarkerOptions().position(latLong2).title("MARKER2").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker2")));
secondList.add(mMap.addMarker(new MarkerOptions().position(latLong3).title("MARKER3").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker3")));
thirdList.add(mMap.addMarker(new MarkerOptions().position(latLong1).title("MARKER1").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker1")));
thirdList.add(mMap.addMarker(new MarkerOptions().position(latLong4).title("MARKER4").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker4")));
fourthList.add(mMap.addMarker(new MarkerOptions().position(latLong5).title("MARKER5").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker5")));
fifthList.add(mMap.addMarker(new MarkerOptions().position(latLong6).title("MARKER6").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker6")));
fifthList.add(mMap.addMarker(new MarkerOptions().position(latLong7).title("MARKER7").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker7")));
fifthList.add(mMap.addMarker(new MarkerOptions().position(latLong1).title("MARKER1").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker1")));
fifthList.add(mMap.addMarker(new MarkerOptions().position(latLong2).title("MARKER2").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon)).snippet("Snippet marker2")));

Now I want to add OnInfoWindowClickListener to my markers info window. Each marker must open a new activity. Before doing this modification I was adding all the markers to the a private Map allMarkersMap = new HashMap(); and I was adding every marker to the HashMap with allMarkersMap.put(marker1, Marker1.class);
 GoogleMap.OnInfoWindowClickListener MyOnInfoWindowClickListener = new GoogleMap.OnInfoWindowClickListener() {
    @Override
    public void onInfoWindowClick(Marker marker) {
        Class cls = allMarkersMap.get(marker);
        Intent intent = new Intent(MainActivity.this, cls );
        startActivity(intent);
    }
};

How can I do this now?

A: Your markers have the same references, that's what leads you to this behaviour.
Instead of creating and passing markers, you should create MarkerOptions and when you add a marker to your array list then create a new Marker. MarkerOptions is the object which keep the informations you want for your markers, that's the only object which should be instantiated once.


text:
Q: Join two tables but stop after first match and keep all rows from Left table Thanks in advance for taking the time to consider my problem. I have the following two tables:
pcidTable:

PCID

pcidtest1

pcidtest1

examplepcid2

foopcid3

barexample4

matchTable:

Channel
Match String

TestCh1
pcidtest

TestCh2
pcid

TestCh3
bar

I want to combine the tables on the case that a PCID contains the Match String as a substring. This is fairly easy to do when the PCID only matches one row, as it would be a simple join. However, when a PCID contains Match Strings from multiple rows, I only want it to join from the first "match". So, the result of these two tables would ideally look like the following:
IDEAL RESULT TABLE:

PCID
Channel

pcidtest1
TestCh1

pcidtest1
TestCh1

examplepcid2
TestCh2

foopcid3
TestCh2

barexample4
TestCh3

If I do a query like this, I get multiple rows for each the PCID rows with value "pcidtest1", because "pcidtest1" contains both "pcidtest" and "pcid":
-- Assume REGEXP_CONTAINS is a built in method that will return a
-- boolean signifying whether or not the second parameter is
-- a substring of the first.
SELECT pcidTable.pcid, matchTable.channel
FROM pcidTable
LEFT JOIN matchTable
  ON REGEXP_CONTAINS(pcidTable.pcid, matchTable.match_string)

The above script would result in this table, which is not what I want because it contains multiple rows for each PCID that has multiple matches:

PCID
Channel

pcidtest1
TestCh1

pcidtest1
TestCh2

pcidtest1
TestCh1

pcidtest1
TestCh2

examplepcid2
TestCh2

foopcid3
TestCh2

barexample4
TestCh3

I instead want a table (see "IDEAL RESULT TABLE" above) that only contains one row for each row in the pcidTable, with the first match it sees in matchTable. Two things to note:

*

*We can assume that the matchTable is sorted by the length of the match string in descending order.

*This example would result in duplicate rows (pcidtest1 <--> TestCh1), but we would want to keep them as well.

Does anyone have any insight to how to approach this?
I tried writing a function that I pass a PCID string into to query against the matchTable, but the constraints of the problem do not allow me to use a subquery in a function, and it must be done in a join clause.

A: This is very inefficient but it will work -
WITH pcidNumbered AS (
  SELECT pcid, ROW_NUMBER() OVER() row_num
  FROM pcidTable
)
SELECT pcid, channel
FROM (
  SELECT *, COUNT(*) OVER(PARTITION BY row_num ORDER BY LENGTH(match_string) DESC) c
  FROM pcidNumbered p
  LEFT JOIN matchTable m
    ON p.pcid LIKE CONCAT('%', m.match_string, '%')
) t
WHERE c = 1;


text:
Q: showing toastr after checking if the password and user name is correct from database as a practice i made a log in form and linked it with a MySQL database and am trying to show a toastr according to to the result that is if the username and password are correct or not so when the input fields are empty it's showing the error toaster but when i add any thing in the fields it always shows the success toastr i don't know how to fix that
here is my html code
 <form class="sing_in_form " method="POST" action="#">
                <input id="email" type="text" name="username" placeholder="Email">
                <input id="password" type="text" name="password" placeholder="password">

                <button type="submit" id="btn" name="submit " value="LOGIN" class="btn-login">Sign In</button>

Don't have account? Sign up

            </form>

php
if(isset($_POST['username'])){ //username from the form
$uname=$_POST['username'];//username from the form
$pass_word=$_POST['password'];
$sql="SELECT * FROM `loginform2` WHERE user='".$uname."' And Pass='".$pass_word."' limit 1";

$result= $con->query($sql);

}
and my js code
 $(document).ready(function(){
$("#btn").click(function(){
var name = $("#email").val();
var password = $("#password").val();
// Returns successful data submission message when the entered information is stored in database.
var dataString = 'username='+ name + '&password='+ password;
if(name==''||password=='')
{
toastr.error("fill the feilds");
}
else
{
// AJAX Code To Submit Form.
$.ajax({
type: "POST",
url: "login(2).php",
data: dataString,
cache: false,
success: function(){
toastr.success("logged in");
}
});
}
return false;
});
});

A: Do something like this.
Put if(mysqli_num_rows($result) ===1 {echo 1};   after $result= $con->query($sql);
And then edit your ajax request as
success: function(data){
if(data ==1){
toastr.success("logged in");
}else{
//error message goes here
}
}


text:
Q: LIN transceiver instability problem I'm using the MCP2021A for my project. In this component, there is a voltage regulator but I have no use for it. They usually power microcontroller like the PIC18F2455 but I'm using a Raspberry Pi which consumes too much current.
If I don't use this regulator, I have no output on my LIN BUS.
Can someone explain to me how it works so I can find a solution ?
Schematic:

I just connected pin 3 of IC (MCP2021A) to an unused Arduino so I can have VREG_OK which I don't have if it's floating.

A:
I think it's VREG_OK that goes to 0

The problem is about the Vreg pin, but not about drawing a current from that pin. VREG_OK does not indicate if the Vreg pin is floating. Vreg is the output voltage of an on-chip regulator and the chip uses this voltage for the internals (look at the block diagram at p.2). It's not a must that you should draw current from that voltage.
However, this pin requires a bypass capacitor for stability (First sentence at p.9):

Img Src: Datasheet, p.19.
So, if you connect a low-ESR capacitor with a capacitance of at least 10uF then everything will be fine.

but if i disconnect Vreg from the Arduino that I power (just so it works, i don't need an arduino), it stops working. ... The arduino is just here so Vreg is not floating

Arduino's input line bypass capacitors are fixing the instability here :)


text:
Q: How to change the shut down and boot up logo in Kubuntu 21.10? I'm presently trying to move over to linux as my OS, rather than windows. My wife has been using Kubuntu for quite a while now. Anyways...
The one thing I really like about Kubuntu is customizing to 'make it mine' type thing.
My question is, how do you change the boot up and shut down logo's ?
I've looked online but the info seems older or a bit sketchy, so I figured I'd see if I figured I'd ask here to get the most update information on how to do this.
Thanks ahead of time for any all responses/help...

A: Go to settings --->system settings --->startup and shutdown --->splash screen. There you can change it. See picture . You can download lots of them ( button right below get new splash screens). If you download qt-curve you can even change more settings than 'standard'-kde changes ( e.g. slidebar color/width). Almost endless possibilities. See picture . Enjoy YOUR desktop in Kubuntu. If you like the answer please accept it.


text:
Q: How to upgrade PostgreSQL from version 9.1 to version 9.5 without losing data? I'm using the PostgreSQL database for my OPEN ERP application (on Ubuntu 12.04
LTS).
Are there any detailed instructions on how to upgrade PostgreSQL database?


text:
Q: ios-how to save state of button after application close? I struggle for few days and searched before.
I have button in UITableViewCell for favorite cell.
How to save state of button (selected button load image "fav.png" and normal button load "unfav.png") after application close?

//  BirdsTableViewController.m
//  iranbirdtest2
//
//  Created by Mehdi on 9/27/15.
//  Copyright (c) 2015 Mehdi.n13. All rights reserved.
//  after 15 azar-21 mehr

#import "BirdsTableViewController.h"
#import "Bird.h"
#import "GeneralViewController.h"
#import "FavoriteTableViewController.h"
#import "MyManager.h"

//NSMutableArray *favoritesArray;
@interface BirdsTableViewController (){

}
@property (strong, nonatomic) UITabBarController *myTabbarController;
@property (strong, nonatomic) GeneralViewController *myFirstViewController;

@end

@implementation BirdsTableViewController
{

}

- (IBAction)buttonTouchDown:(UIButton *)sender {

sender.selected = !sender.selected; //to switch from selected to unselected

//OR in IBaction we can use:

    /*
    if ([sender isSelected]) {
        [sender setImage:[UIImage imageNamed:@"unfav.png"] forState:UIControlStateNormal];
        [sender setSelected:NO];
    } else {
        [sender setImage:[UIImage imageNamed:@"fav.png"] forState:UIControlStateSelected];
        [sender setSelected:YES];
         [[NSUserDefaults standardUserDefaults] setBool:YES forKey: @"someKey"];
    }

     */

}

- (void) viewDidLoad {

    [super viewDidLoad];

    for (NSIndexPath *indexPath in [[NSUserDefaults standardUserDefaults] mutableArrayValueForKey:@"mySavedMutableArray"]) {
        [self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    }

    self.title=@"پرندگان ایران";

    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    //create array
    birds=[[NSMutableArray alloc]init];

    // UIButton* myButton;

    Bird *bird=[[Bird alloc]init];
    bird.name=@"زنبور خوار";
    bird.filename=@"bird1";
    bird.detail=@"این قسمت مربوط به توضیح می باشد";
    [birds addObject:bird];

    bird=[[Bird alloc]init];   //dont forget reuse
    bird.name=@"زاغ";
    bird.filename=@"bird2";
    bird.detail=@"توضیحات مربوط به شماره ۲";
    [birds addObject:bird];

    bird=[[Bird alloc]init];
    bird.name=@"طوطی";
    bird.filename=@"bird3";
    bird.detail=@"توضیحات مربوط به شماره سومی";
    [birds addObject:bird];

     //add more later

    MyManager *sharedManager = [MyManager sharedManager];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;

    //this is for page view controller:

    self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"common_bg"]];
    self.tableView.backgroundColor = [UIColor clearColor];

    UIEdgeInsets inset = UIEdgeInsetsMake(5, 0, 0, 0);
    self.tableView.contentInset = inset;
    [self.tableView setSeparatorStyle:UITableViewCellSelectionStyleNone];   //delete sepreate line odf tables

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void) viewWillDisappear:(BOOL)animated{
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    // Return the number of rows in the section.
    return birds.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];

    if (cell == nil) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];

    }

    // Configure the cell...
    tableView.allowsSelection=YES;

    Bird *current=[birds objectAtIndex:indexPath.row];
    UIImageView *birdImageView = (UIImageView *)[cell.contentView viewWithTag:100];
    birdImageView.image = [UIImage imageNamed:current.filename];

    UILabel *name = (UILabel *)[cell.contentView viewWithTag:101];
    name.text=[current name];

    //button code in table view

    UIButton *button=(UIButton *) [cell.contentView viewWithTag:103];//fav
    [button setImage:[UIImage imageNamed:@"unfav.png"] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:@"fav.png"] forState:UIControlStateSelected];
    button.frame = CGRectMake(0,0, 50, 50);
    button.tag = indexPath.row;
    [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [cell.contentView addSubview:button]; // add the button to the cell
    [cell.contentView bringSubviewToFront:button];

    // Assign our own background image for the cell
    UIImage *background = [self cellBackgroundForRowAtIndexPath:indexPath];
    UIImageView *cellBackgroundView = [[UIImageView alloc] initWithImage:background];
    cellBackgroundView.image = background;
    cell.backgroundView = cellBackgroundView;

    UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sepratortable.png"]];
    [imgView sizeToFit];
    [cell.contentView addSubview:imgView];

    return cell;
}

-(void)buttonPressed:(UIButton *)sender
{

    NSLog(@"Button Pressed");
    MyManager *sharedManager = [MyManager sharedManager];
    NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell*)sender.superview.superview];
    if([sharedManager.favoritesArray containsObject:[birds objectAtIndex:indexPath.row]])

    {
        [sharedManager.favoritesArray removeObject:[birds objectAtIndex:indexPath.row]];
        [self.tableView reloadData];
    }
    else
    {
        [sharedManager.favoritesArray addObject:[birds objectAtIndex:indexPath.row]];

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Do you want to say hello?" message:@"More info..." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Say  Hello",nil];
        [alert show];

        ;  //we can remove later

    }
    //save favorite array in plist.
    [NSKeyedArchiver archiveRootObject:sharedManager.favoritesArray toFile:@"/Users/Mehdi/Desktop/Project/Backup/21 mehr/fav.plist"];

    NSLog(@"Favoritearray : %d",sharedManager.favoritesArray.count);

    /*
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setValue:birds forKey:@"key"];

    [[NSUserDefaults standardUserDefaults] synchronize];
    */

}

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{

}

- (UIImage *)cellBackgroundForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger rowCount = [self tableView:[self tableView] numberOfRowsInSection:0];
    NSInteger rowIndex = indexPath.row;
    UIImage *background = nil;

    if (rowIndex == 0) {
        background = [UIImage imageNamed:@"cell_top.png"];
    } else if (rowIndex == rowCount - 1) {
        background = [UIImage imageNamed:@"cell_bottom.png"];
    } else {
        background = [UIImage imageNamed:@"cell_middle.png"];
    }

    return background;
}

/*
 // Override to support conditional editing of the table view.
 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
 // Return NO if you do not want the specified item to be editable.
 return YES;
 }
 */

/*
 // Override to support editing the table view.
 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
 if (editingStyle == UITableViewCellEditingStyleDelete) {
 // Delete the row from the data source
 [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
 } else if (editingStyle == UITableViewCellEditingStyleInsert) {
 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
 }
 }
 */

/*
 // Override to support rearranging the table view.
 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
 }
 */

/*
 // Override to support conditional rearranging of the table view.
 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
 // Return NO if you do not want the item to be re-orderable.
 return YES;
 }
 */

#pragma mark - Navigation
/*

 In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 UITabBarController *pvc=[segue destinationViewController];
 // Pass the selected object to the new view controller.
 //what row selected?
 NSIndexPath *path=[self.tableView indexPathForSelectedRow];
 Bird *c  =birds[path.row];

 }
 */

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    /* if ([segue.identifier isEqualToString:@"ShowGeneralView"]) {
     NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
     GeneralViewController *destViewController = segue.destinationViewController;
     destViewController.currentbird = [birds objectAtIndex:indexPath.row];
     }
     */
    self.myTabbarController = (UITabBarController*) [segue destinationViewController];
    self.myFirstViewController = [self.myTabbarController.viewControllers objectAtIndex:0];
    NSIndexPath *path=[self.tableView indexPathForSelectedRow];
    Bird *c  =birds[path.row];
    _myFirstViewController.currentbird=c;

}

@end

I have no problem for save favorite row after application close.
Problem is with button state that can't save and retrieve.
I know I must use NSUserDefaults, but how?

A: It seems as though your favorites button is in a cell, and when the button is pressed, you add or remove the favorites from the birds array.  You even seem to be storing the plist for a file for persistent storage between app launches.  Unless I'm missing something, you need to set the state of the button in the cellForRowAtIndexPath when you build the row.  Simply check the favorites array for the cell you are building and if it is in there, set the image to the correct state.
One thing to watch out for is that you need to set it regardless of what you think the default state for the image is.  This is because cells are reused (for memory efficency).  So let's say you build your cell with a default image state of a gray cell.  The user clicks the favorite icon and you set it to the red heart.  Then when the user scrolls the cell off the screen, iOS will reuse the cell and the image will still be set to the red image. If you don't explicitly set it to gray if the row is not in your favorites, it will stay red.
Also, as you allude to in your question, you could use NSUserDefaults to store your favorites array, rather than a file (and it would probably be simpler).  It would also allow you to use iCloud to sync the user favorites across devices (with a bit more work to handle merge conflicts).  There are plenty of resources for how to store data in NSUserDefaults.
In your cellForRowAtIndexPath, you would want to do something like the following:
   if([sharedManager.favoritesArray containsObject:[birds objectAtIndex:indexPath.row]])
{
    [button setSelected:NO];
} else {
    [button setSelected:YES];
}

Also, in your buttonPressed method, you should be toggling the selected state of your button using
sender.selected = !sender.selected;

I would get rid of the (IBAction)buttonTouchDown: method and put all the button handling logic in the buttonPressed method.  Having that logic in two places will cause confusion.


text:
Q: list of garbage characters like ' I am using librets to retrieve data form my RETS Server. Somehow librets Encoding method is not working and I am receiving some weird characters in my output. I noticed characters like ''' is replaced with '. I am unable to find a fix for librets so i decided to replace such garbage characeters with actual values after downloading data. What I need is a list of such garbage string and their equivalent characters. I googled for this but not found any resource. Can anyone point me to the list of such garbage letters and their actual values or a piece of code which can generate such letter.
thanx

A: Search for the term "UTF-8", because that's what you're seeing.
UTF-8 is a way of representing Unicode characters as a sequence of bytes.  ("Unicode characters" are the full range of letters and symbols used all in human languages.)  Typically, one Unicode character becomes 1, 2, or 3 bytes in UTF-8.  When those bytes (numbers from 0 to 255) are displayed using the character set normally used by Windows, they appear as "garbage" -- in this case, 3 "garbage letters" which are really the 3 bytes of a UTF-8 encoding.
In your example, you started with the smart quote character '.  Its representation in Unicode is the number 8217, or U+2019 (2019 is the hexadecimal for 8217).  (Search for "Unicode" for a complete list of Unicode characters and their numbers.)  The UTF-8 representation of the number 8217 is the three byte sequence 226, 128, 153.  And when you display those three bytes as characters, using the Windows "CP-1252" character encoding (the ordinary way of displaying text on Windows in the USA), they appear as '.  (Search for "CP-1252" to see a table of bytes and characters.)
I don't have any list for you.  But you could make one if you wrote a program in a language that has built-in support for Unicode and UTF-8.  All I can do is explain what you are seeing.
If there is a way to tell librets to use UTF-8 when downloading, that might automatically solve your problem.  I don't know anything about librets, but now that you know the term "UTF-8" you might be able to make progress.

A: Question reminder:

"...I noticed characters like ''' is replaced with '... i decided to
  replace such garbage characeters with actual values after downloading
  data. What I need is a list of such garbage string and their
  equivalent characters."

Strictly dealing with this part:

"What I need is a list of such garbage string and their equivalent
  characters."

Using php, you can generate these characters and their equivalence. Working with all 1,111,998 Unicode points or 109,449 Utf8 symbols is impractical. You may use the ASCII range in the following loop between &#128 and &#258 or another range that is more relevant to your context.
<?php
  for ($i=128; $i<258; $i++)
    $tmp1 .= "
".htmlentities("&#$i;")."	".html_entity_decode("&#".$i.";",ENT_NOQUOTES,"utf-8")."	&#".$i.";
";

  echo "

&#	"Garbage"	symbol
";
    echo $tmp1;
  echo "
";
?>

From experience, in an ASCII context, most "garbage" symbols originate in the range &#128 to &#257 + (seldom) &#8129 to &#8246.
In order for the "garbage" symbols to display, the html page charset must be set to iso-1 or whichever other charset that caused the problem in the first place. They will not show if the charset is set to utf-8.
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

.

"i decided to replace such garbage characeters with actual values
  after downloading data"

You CANNOT undo the "garbage" with php utf8_decode(), which would actually create more "garbage" on already "garbage". But, you may use the simple and fast search and replace php str_replace() function.
First, generate 2 arrays for each set of "garbage" symbols you wish to replace. The first array is the Search term:
<?php
  //ISO 8859-1 (Latin-1) special chars are found in the range 128 to 257
  $tmp1 = "\$SearchArr = array(";
  for ($i=128; $i<258; $i++)
    $tmp1 .= "\"".html_entity_decode("&#".$i.";",ENT_NOQUOTES,"utf-8")."\", ";
  $tmp1 = substr($tmp1,0,strlen($tmp1)-2);//erases last comma
  $tmp1 .= ");";
  $tmp1 = htmlentities($tmp1,ENT_NOQUOTES,"utf-8");
?>

The second array is the replace term:
<?php
  //Adapt for your relevant range.
  $tmp2 = "\$ReplaceArr = array(\n";
  for ($i=128; $i<258; $i++)
    $tmp2 .= "\"&#".$i.";\", ";
  $tmp2 = substr($tmp2,0,strlen($tmp2)-2);//erases last comma
  $tmp2 .= ");";

  echo $tmp1."\n

\n";
  echo $tmp2."\n";
?>

Now, you've got 2 arrays that you can copy and paste to use and reuse to clean any of your infected strings like this:
$InfectedString = str_replace($SearchArr,$ReplaceArr,$InfectedString);

Note: utf8_decode() is of no help for cleaning up "garbage" symbols. But, it can be used to prevent further contamination. Alternatively a mb_ function can be useful.


text:
Q: Update Data Grid View in a form by filling another form I have two forms.. form1 and form2 in form1 I have a Data Grid View with 2 columns and a button say Btn1 and in form2 I have two Textboxes and a button say Btn2 ..
Now I will open form1 and press Btn1 (I am not filling the form 1 Data Grid View here). With Btn1 Form 2 will be showed. I will enter data into the 2 textboxes and press Btn2 now I need the Data Grid View in form 1 to be filled with this data.
If possible Please tell me how to do it using a Data Table.
I am using VB.net 2012 Please help me with this. I am new to VB.net..TIA

A: I assume form1's datagridview is bound to a datatable. You can define a property in form2 through which you will pass the datatable from form1 to form2. When form2 fills the datatable,  the data should appear in the datagridview in form1.


text:
Q: Spam mail even after setting SPF I have set the SPF record for my domain powered by Google Apps. I followed the steps here .
But even after setting the SPF record, spam mails are being sent from the domain. What am I missing?

A: Adding a SPF record does not stop others from using your domain name to send spam, it simply allows the receiving server to check if the server that sends the email is authorized to do so or not.
Even if the server checks the spf record and finds the sending not to be authorized, it might still allow the email based on the local configuration.
EDIT: you can also look into "DomainKeys Identified Mail (DKIM)" (https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail | https://support.google.com/a/answer/174124?hl=en)

A: Spam mails can either be sent from an authorized server (usually because some authorized user has been infected or the account is compromised otherwise) or by non-authorized servers forging the domain name. You need to obtain examples of headers of the spam sent "from your domain" to determine which is the case.
SPF will protect recipients from spam sent from non-authorized servers forging a domain name protected by SPF. In itself it doesn't really stop spammers from trying to send the spam, and people whose servers do not check SPF are not protected.


text:
Q: How to grab edge version of cordova-android from github There is a bug fix in the latest unreleased version of cordova-android https://github.com/apache/cordova-android
How do I grab this version and use it locally? I found instructions for cordova-cli and plugman but not cordova-android.


text:
Q: General formula for ${n \choose r} + {n-2 \choose r} + {n-4 \choose r} + ... + {n-2k \choose r}$ I'm trying to figure out a general formula where $n$ decrements by 2 until $n - 2k = r$.
A more eloquent way of writing it would be
$\sum\limits_{i = 0}^{k} {r + 2i \choose r}$

A: Hint
Perhaps this can help.
Consider the following
$$(1+x)^{r+2k}+(1+x)^{r+2k-2}+\dotsb +(1+x)^{r}$$
Your expression is the coefficient of $x^r$ in this polynomial. Observe that this polynomial is a geometric series, so you want to find the coefficient of $x^r$ in
$$\frac{(1+x)^{r}(1-(1+x)^{2(k+1)})}{1-(1+x)^2}$$
Although I'm not sure if this will lead to an elegant answer.


text:
Q: How to compare and validate 2 times with 2 dates in MVC C#? How to compare and validate two times?
My scenario is I need to add various schedules. Assume that person 1 has schedules on today 18/08/2017 as Sch1: 0800-1600 and sch2:2200-0600 that is sch1 starts and ends on same daywhereassch2 starts on 18/08/2017 and ends on 19/08/2017 6am.
Now when I try to edit Schedule end time, I want to add 2 validations that schedule end time must be greater than start time and also must be greater than current system time. How to validate these two ? When I add validation then end time after 24 hrs, it takes 19/08/2017's 1am,2am,3am as less than value of 18/08/2017's 2000,2100(8pm,9pm).
My coding for validation below
if ( D.ScheduleEndTime != T.EndTime && D.ScheduleEndTime < Time)
{
    return Json(new { success = "fail", message = "End Time must be greater than current time!!!" }, JsonRequestBehavior.AllowGet);
}
else if (D.ScheduleEndTime != T.EndTime && D.ScheduleEndTime < T.StartTime)
{
   return Json(new { success = "fail", message = "End Time must be greater than start time!!!" }, JsonRequestBehavior.AllowGet);
}

In the above code D&T. D means values that entered while editing and T means values from Table in database

A: You didn't give any information on the data types you are using but sounds like you are using a custom date-time object rather than the datetime data type?
So each of your custom date-time objects have something similar to the following structure:
custom_datetime:
 - string Date (ie: 18/08/2017)
 - int startTime (ie: 2200)
 - int endTime (ie: 0600)

In that case, it would be something like this maybe...
// Temp variable to manipulate, instantiated to passed in custom_datetime D.
custom_datetime temp = D;
// First check if the passed in date time is different than date time stored
if ((temp.Date != T.Date) || ((temp.Date == T.Date) && (temp.endTime != T.endTime))) {
    // Then check if the endTime is less than the startTime
    // If it is, then the end time is the next day so increment the date in temp variable. Now use temp variable to do rest of the checks.
    if (temp.endTime < temp.startTime) {
        temp.Date++; // Increment to next day, so 18/08/2017 becomes 19/08/2017
    }

    //Check if passed in date < stored date, if it is, then it will also be less than startTime so return error.
    if (temp.Date < T.Date) {
        return Json(new { success = "fail", message = "End Time must be greater than current time!!!" }, JsonRequestBehavior.AllowGet);
    }
    //Check if the passed in date is the same as the stored date. If it is, make sure the endTime is greater than the stored startTime
    else if ((temp.Date == T.Date) && (temp.endTime <= T.startTime)) {
        return Json(new { success = "fail", message = "End Time must be greater than current time!!!" }, JsonRequestBehavior.AllowGet);
    }
    //Check if the passed in date < current system date or if the passed in date == current system date but the endTime <= the current time.
    else if ((temp.Date < Time.Date) || ((temp.Date == Time.Date) && (temp.endTime <= Time.Time)) {
        return Json(new { success = "fail", message = "End Time must be greater than current time!!!" }, JsonRequestBehavior.AllowGet);
    }
}

The code doesn't actually work, but hopefully it gives you an idea of something you can do. Need more information to give an exact answer.


text:
Q: How am I able to use/edit navigation bar features when I don't have a reference? I'm currently learning iOS development and I'm confused on how I was able to edit/use my navigation bar even though I don't have an IBOutlet?
Code:
class ChatViewController: UIViewController {

    @IBOutlet weak var tableView: UITableView!
    @IBOutlet weak var messageTextfield: UITextField!

    override func viewDidLoad() {
        super.viewDidLoad()
        title = "⚡FlashChat" //edited the title of the navigation bar for this view
        navigationItem.hidesBackButton = true //hid a button

    }

    @IBAction func sendPressed(_ sender: UIButton) {
    }

    @IBAction func logoutPressed(_ sender: UIBarButtonItem) {
        do {
            try Auth.auth().signOut()
            navigationController?.popToRootViewController(animated: true)
        } catch let signOutError as NSError {
            print ("Error signing out: %@", signOutError)
        }

    }

}

A: call setupNavBarAttributes() function from func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool located in Appdelegate.swift file and observe the changes.
It will customize the UINavigationBar of every UIViewControllers in your App.
func setupNavBarAttributes() {

        UINavigationBar.appearance().barStyle = .default
        UINavigationBar.appearance().tintColor = .cyan  // change color of the buttons of navigationbar
        UINavigationBar.appearance().barTintColor = .blue  // change front color of navigationbar
        UINavigationBar.appearance().backgroundColor = .clear
        UINavigationBar.appearance().isTranslucent = true
        UINavigationBar.appearance().shadowImage = UIImage() // make disappear the bottom shadow of navigationbar
        UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default) // make background to a blank/empty image

        UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 19, weight: .bold)]  // change the font color of navigation title

    }

A: Navigation bars are not part of the UIViewController, they are actually part of the parent UINavigationController, which encapsulates your UIViewController. So, when you access the navigationItem, you're essentially accessing the navigation controller's bar.
Read more about container view controllers here.


text:
Q: Creating an index matrix depending on Reference matrix and matrix of Data matlab given matrix A of size 6 by 6 contain  blocks of numbers,each block of size 2 by 2, and outher reference matrix R of size 2 by 12 also contain blocks of numbers, each block of size 2 by 2. the perpse of the whole process is to form a new matrix, called the Index matrix, contain index's that refer to the position of the blocks within the matrix A based on the order of the blocks within the reference matrix R. and here is an exemple
matrix A:
A  =[1 1 2 2 3 3;

     1 1 2 2 3 3;

     1 1 3 3 4 4;

     1 1 3 3 4 4;

     4 4 5 5 6 6;

     4 4 5 5 6 6 ]

matrix R:
R=[1 1 2 2  3 3 4 4 5 5 6 6;

   1 1 2 2  3 3 4 4 5 5 6 6 ]

the new matrix is:
Index =[1 2 3;

        1 3 4;

        4 5 6]

any ideas ?

A: With my favourite three guys - bsxfun, permute, reshape for an efficient and generic solution -
blksz = 2;                       %// blocksize
num_rowblksA = size(A,1)/blksz;  %// number of blocks along rows in A

%// Create blksz x blksz sized blocks for A and B
A1 = reshape(permute(reshape(A,blksz,num_rowblksA,[]),[1 3 2]),blksz^2,[])
R1 = reshape(R,blksz^2,1,[])

%// Find the matches with "bsxfun(@eq" and corresponding indices
[valid,idx] = max(all(bsxfun(@eq,A1,R1),1),[],3)
%// Or with PDIST2:
%// [valid,idx] = max(pdist2(A1.',reshape(R,blksz^2,[]).')==0,[],2)
idx(~valid) = 0

%// Reshape the indices to the shapes of blocked shapes in A
Index = reshape(idx,[],num_rowblksA).'

Sample run with more random inputs -
>> A
A =
     2     1     1     2
     1     2     2     1
     1     1     1     1
     2     2     2     2
     1     2     2     1
     1     2     1     1
>> R
R =
     2     1     1     1     1     2     2     2     1     1     1     1
     2     1     2     1     1     2     2     1     2     2     2     1
>> Index
Index =
     0     0
     5     5
     3     0


text:
Q: Get complete SQL table data asynchronously from DB Repository to JQuery file I have one JQuery file where I want "Customer" table data in JSON format.
We already have a project structure like this:
JQuery file -> Controller class -> DBRepository class -> call to DB table
Now I want to provide asynchronous call when data getting pulled.
The code will generally be like this:
Controller class:
public async Task&ltActionResult&gt GetCustomerDataAsync()
{
...
await call to DBRepository.GetCustomerData();
...
}

DBRepository class:
public async Task&ltTenantBM&gt GetCustomerData()
{
TenantBM custData = new CustomerBM();
customerData = await scoutDB.Customer.Selectt => new { t.id, t.Name, t.Role});
...
}

But somehow its not allowing me to put await call there. Even I am not sure is this a correct code or not. Please let me know the correct syntax to put everything in above format.
Thanks.


text:
Q: Laravel - Session flash did not display the content of the error message I am using session flash in my Laravel-5.8 project.
Controller
<?php

namespace App\Http\Controllers\Appraisal;

use App\Http\Controllers\Controller;
use App\Models\Appraisal\AppraisalSkill;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Exception;
use Illuminate\Support\Facades\Validator;
use Session;

class AppraisalSkillsController extends Controller
{
  public function create()
  {
    abort_unless(\Gate::allows('skill_create'), 403);
    return view('appraisal.skills.create');
  }

  public function store(Request $request)
  {
    abort_unless(\Gate::allows('skill_create'), 403);

    $this->validate($request, [
        'skill_name' => 'required|unique:appraisal_skills,company_id',
    ]);

    $skill = AppraisalSkill::create([
        'skill_name'                => $request->skill_name,
        'description'               => $request->description,
        'company_id'                => Auth::user()->company_id,
        'created_by'                => Auth::user()->id,
        'created_at'                => date("Y-m-d H:i:s"),
        'is_active'                 => 1,
    ]);
    Session::flash('success', 'Appraisal Skill is created successfully');
    return redirect()->route('appraisal.skills.index');
  }
}

view/partials/_messages.blade.php
@if (count($errors) > 0)

    <button type="button" class="close" data-dismiss="alert">×</button>
        Errors:

            @foreach ($errors as $error)

{{ $error }}

            @endforeach

@endif

@if (Session::has('success'))

    <button type="button" class="close" data-dismiss="alert">×</button>
    Success: {{Session::get('success')}}

@endif

view

                         Back to List

        @include('partials._messages')

        Create Skill

       <form  action="{{route('appraisal.skills.store')}}" method="post" class="form-horizontal" enctype="multipart/form-data">
           {{csrf_field()}}

                                        Skill Name*

                                            <input  type="text" name="skill_name" placeholder="Enter skill name here" class="form-control" value="{{old('skill_name')}}">

                                        Description

                                                <textarea rows="2" name="description" class="form-control" placeholder="Enter Description here" value="{{old('description')}}"></textarea>

                   <button type="submit" class="btn btn-primary">{{ trans('global.save') }}</button>
                <button type="button" onclick="window.location.href='{{route('appraisal.skills.index')}}'" class="btn btn-default">Cancel</button>

        </form>

When I click on save submit button, I  expect that if there is any error it should display the detail of the error. But, rather it only display Error:  without the details.
The success message is working, but the error message is not working as expected

How do I get this resolved?
Thank you.

A: There is a little mistake when looping through the errors. Change line @foreach ($errors as $error) to  @foreach ($errors->all() as $error) . It should work now!


text:
Q: Make a div wider than its parent without horizontal scrollbar and without overflow: hidden? Is it possible to get a child element to surpass the width of the parent element to the full extent of the browser without a horizontal scroll?
I've tried the solutions posted here Is there are way to make a child DIV's width wider than the parent DIV using CSS?
But with this particular HTML (see below) there's only one that works and yet creates an horizontal scrollbar (the extra width seen in the code snippet and the image below is causing the scrollbar to appear)

*I could always add an overflow-x: hidden; in  but I'd prefer not to
EDIT: There are certain css properties that even though do not make sense in the example, they should be kept in the solution (if any)

          something 1

            child full5

          something 2

    body: {
      margin: 0px;
    }

    .main {
      display: flex;
      flex-direction: column;
      align-items: center;
      background: #e8e8e8;
      border: 1px solid #000;
      margin: 0px;
      box-sizing: border-box;
    }

    .container {
      display: flex;
      flex-direction: column;
      max-width: 300px;
      width: 100%;
    }

    .parent {
      display: flex;
      /* flex-direction: column; */
      width: 100%;
      background-color: #e9cccc;
      box-sizing: border-box;
      position: sticky;
      top: 0;
    }

    .fit {
      height: 50px;
    }

    .full {
      background-color: #d1ccd8a6;
      border: 1px solid #666;
      border-radius: 3px;
      height: 50px;
      padding: 0px;
      box-sizing: border-box;
    }

    .full5 {
      width: 100vw;
      position: relative;
      left: 50%;
      right: 50%;
      margin-left: -50vw;
      margin-right: -50vw;
    }

body: {
  margin: 0px;
}

.main {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #e8e8e8;
  border: 1px solid #000;
  margin: 0px;
  box-sizing: border-box;
}

.container {
  display: flex;
  flex-direction: column;
  max-width: 300px;
  width: 100%;
}

.parent {
  display: flex;
  /* flex-direction: column; */
  width: 100%;
  background-color: #e9cccc;
  box-sizing: border-box;
  position: sticky;
  top: 0;
}

.fit {
  height: 50px;
}

.full {
  background-color: #d1ccd8a6;
  border: 1px solid #666;
  border-radius: 3px;
  height: 50px;
  padding: 0px;
  box-sizing: border-box;
}

.full1 {
  position: absolute;
  width: 100%;
  left: 0px;
  top: 0px;
}

.full2 {
  width: 100vw;
  position: relative;
  left: calc(-50vw + 50%);
}

.full3 {
  position: relative;
  width: 200%;
  left: -50%;
}

.full4 {
  margin-left: calc(-50vw + 50%);
  width: 100vw;
}

.full5 {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}

.full6 {
  margin-left: calc(-50vw + 50%);
  width: 100vw;
}

.hide {
  display: none;
}

      something 1

        child full1

        child full2

        child full3

        child full4

        child full5

        child full6

      something 2

EDIT2:
If the  has a margin:0 the posted solutions work, except if there is a vertical scrollbar (when isn't there one?)

A: Is this something you want?
I just made changes your CSS of .main, .parent and .full-5

body: {
  margin: 0px;
}

.main {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #e8e8e8;
  border: 1px solid #000;
  margin: 0px;
  box-sizing: border-box;
  position: relative;
}

.container {
  display: flex;
  flex-direction: column;
  max-width: 300px;
  width: 100%;
}

.parent {
  display: flex;
  /* flex-direction: column; */
  width: 100%;
  background-color: #e9cccc;
  box-sizing: border-box;
  top: 0;
  height: 50px;
}

.fit {
  height: 50px;
}

.full {
  background-color: #d1ccd8a6;
  border: 1px solid #666;
  border-radius: 3px;
  height: 50px;
  padding: 0px;
  box-sizing: border-box;
}

.full1 {
  position: absolute;
  width: 100%;
  left: 0px;
  top: 0px;
}

.full2 {
  width: 100vw;
  position: relative;
  left: calc(-50vw + 50%);
}

.full3 {
  position: relative;
  width: 200%;
  left: -50%;
}

.full4 {
  margin-left: calc(-50vw + 50%);
  width: 100vw;
}

.full5 {
    position: absolute;
    left: 0;
    right: 0;
}

.full6 {
  margin-left: calc(-50vw + 50%);
  width: 100vw;
}

.hide {
  display: none;
}

      something 1

        child full1

        child full2

        child full3

        child full4

        child full5

        child full6

      something 2

A: Here you go(View it in full screen for visualization):

body {
  margin: 0;
}

.main {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #e8e8e8;
  border: 1px solid #000;
  margin: 0px;
  box-sizing: border-box;
}

.container {
  display: flex;
  flex-direction: column;
  max-width: 300px;
  width: 100%;
}

.parent {
  display: flex;
  /* flex-direction: column; */
  width: 100%;
  background-color: #e9cccc;
  box-sizing: border-box;
  position: sticky;
  top: 0;
}

.fit {
  height: 50px;
}

.full {
  background-color: #d1ccd8a6;
  border: 1px solid #666;
  border-radius: 3px;
  height: 50px;
  padding: 0px;
  box-sizing: border-box;
}

.full1 {
  position: absolute;
  width: 100%;
  left: 0px;
  top: 0px;
}

.full2 {
  width: 100vw;
  position: relative;
  left: calc(-50vw + 50%);
}

.full3 {
  position: relative;
  width: 200%;
  left: -50%;
}

.full4 {
  margin-left: calc(-50vw + 50%);
  width: 100vw;
}

.full5 {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}

.full6 {
  margin-left: calc(-50vw + 50%);
  width: 100vw;
}

.hide {
  display: none;
}

      something 1

        child full1

        child full2

        child full3

        child full4

        child full5

        child full6

      something 2

A: You can use z-index in css code to bring over than parent and fill color to push background


text:
Q: Map Service Works in Flex, Won't Display using JavaScript As the title states, a map service published on my server displays and can be identified just fine when added to a web map in Viewer for Flex. I am slowly learning to use the API for JavaScript. My current JavaScript code works as intended when using a third-party map service for testing purposes. When I replace it with the service I published, it does not display the service. The rest of the map displays correctly, just not my service. I cannot figure out why it works in Flex, but not JavaScript. Any one run into this or have any ideas?
Thanks!
EDIT: Map service, dynamic. Arc 10.1, JS API 3.10
The service does display in the above example, and when you view it through the REST Services directory.
The error I'm getting is "Unable to draw graphic (geometry:null, symbol:null): null" ... but I am not finding any null geometry.


text:
Q: how to add the number to existing field I have a points table and I need to update the values based on the performance . Is possible to do
table
[
  {
    "id": 1,
    "points": 34
  },
  {
    "id": 1,
    "points": 63
  }
]

query
db.collection.update({
  id: 1
},
{
  "$set": {
    "points": "points" + 10
  }
})

expected output
[
  {
    "_id": ObjectId("5a934e000102030405000000"),
    "id": 1,
    "points": 44
  },
  {
    "_id": ObjectId("5a934e000102030405000001"),
    "id": 1,
    "points": 63
  }
]

A: You can use $inc:
db.collection.update({
  id: 1
},
{
  "$inc": {
    "points": 10
  }
})

There is no $dec for decrementing, instead use $inc with a negative number.
Are you actually using mongoose? It looks like a plain mongo node driver query. If you have a Mongoose Model, you can use updateMany


text:
Q: How to display all lines in file where last field is one digit Could someone please help me out with question.
Display all of the lines in the file where the last field is one digit long.
Search for ',' before the field, then use a character class to make sure
it's one digit, and anchor it to the end of the line to make sure it's the
last field.
I have tried :
grep ",[0-9]{1}$" inventory

grep ",[.]{1)$" inventory

grep ",[/d]$" inventory

A: Try:
grep ',[0-9]$' inventory

You don't need the {1} quantifier, since that's the normal meaning of any unquantified regular expression.
grep uses basic regular expressions, and doesn't support \d to represent digits, so you have to use [0-9].

A: This will work:
grep ',[0-9]$' inventory

This will work also:
grep  ',[[:digit:]]$' inventory

A: It should be sufficient to use:
grep ',[0-9]$' inventory

You could make the first work with the -E option, but the repetition count seems like overkill:
grep -E ',[0-9]{1}$' inventory

The second is unrescuable because of the mismatch between { and ), and the [.] only matches a dot at the end of the line after the comma.
The last would work if your grep supports -P (Perl) and you fix the regex:
grep -P ',\d$' inventory

You don't need the explicit character class brackets because \d is already the 'digits' character class.  OTOH, it works OK if you use ,[\d]$.  The backslash is crucial.

A: *

*Grep uses basic regular expressions (BREs), so you need to escape the {}.

*Since you want exactly one, you don't need {1} at all.

*[.] removes the special meaning of ., only matching a literal period.

*[/d] (1) digits are \d; (2) this matches / or d, [\d] would match \ or d.

You want ,[0-9]$.


text:
Q: Function to iterate through multi level list nested with dicts does not work properly I want to compare two lists and verify if they are the same. Though the lists might have items in a different order so just comparing list1 == list2 would not work.
Those lists can be nested into multi-level with dicts, strings, integers, and lists, so just using sorted(list1) == sorted(list2) would not work either.
I'm trying to create a function that iterates through a multi-level list and sort each list inside of it in ascending order.
The results I'm having so far only sorts the first level main list. All the other "sub lists" get sorted inside the function but when I print the final result they are unsorted the same way before using the function.
Function created so far:
def sort_multilevel_obj(items):
    if isinstance(items, dict):
        for v in items.values():
            if isinstance(v, list):
                v = sorted(v)
            v = sort_multilevel_obj(v)
    if isinstance(items, list):
        items = sorted(items)
        for i in items:
            i = sort_multilevel_obj(i)

    return items

Example of multi-level list:
mylist = [
    'string1',
    [
        {
            1:'one',
            2:'two',
            3:[4,2,'ddd'],
            4:{'x':'xx'}
        },
        'substring'
    ],
    {
        'somekey':7,
        'anotherkey':[
            'ccccccc',
            100,
            4,
            'blabla'
        ]
    }
]

When I pass the list into the function the result I got is:
[{'z': ['ccccccc', 100, 4, 'afsafas'], 'f': 7}, [{1: 'one', 2: 'two', 3: [4, 2, 'ddd'], 4: {'x': 'xx'}}, 'substring'], 'string1']

The fist list (string, list, dict) is sorted properly (to dict, list, string) but the list inside the dict (['ccccccc', 100, 4, 'afsafas']) should be returned as [4, 100, 'afsafas', 'ccccccc'] but this just doesn't work.
What am I doing wrong?

A: Try using v.sort() instead of v = sorted(v). v.sort() mutates the original list while sorted(v) returns a new object. See this answer for another explanation about the difference between v.sort() and sorted(v).
The reason why v = sorted(v) doesn't change the value in the list/dict itself is because the variable v is basically only a reference to the original value in the dict/list. When you use v = <something> you're pointing that variable to another object and thus not changing the original value.


text:
Q: Schur -Weyl duality for $sl_2$ and $S_n$ $V$ is an $m$ dimensional vector space having a structure of $sl_2(\mathbb{C})$-module, where $sl_2(\mathbb{C})$ is the Lie algebra of the Lie group $SL_2(\mathbb{C})$. The symmetric group $S_n$ acts on the tensor product $V^{\otimes n}$.
What does Schur-Weyl duality say in this case?
What is the irreducible decomposition of $V^{\otimes n}$?
If we have $S_n$ irreducible decomposition can we get $sl_2(\mathbb{C})$ decomposition and vice versa?
I would be very grateful if someone could give a detailed answer.
Thanking you in advance.

A: Here is an answer to your question about the decomposition of $V^{\otimes n}$ as an $\mathfrak{sl}_2(\mathbb{C})$-module (I assume $V$ is the standard $2$-dimensional irreducible module).
The irreducible $\mathfrak{sl}_2(\mathbb{C})$-modules are indexed by non-negative integers and the one corresponding to the integer $m$ will be denoted $L(m)$ (it has dimension $m+1$ and we know exactly what it looks like, see for example Humphrey's Introduction to Lie Algebras and Representation Theory chapter 7).
So to see how to decompose $V^{\otimes n}$ we need to know what $V\otimes L(m)$ is for some integer $m$. This is easiest to see if we look at these as $\mathfrak{gl}_2(\mathbb{C})$-modules where the decomposition of tensor products is given by the Littlewood-Richardson rule. In this case, since $V = L(1)$, we simply get that $V\otimes L(m) = L(m+1)\oplus L(m-1)$.
Now we want to apply this to see how many times $L(m)$ appears as a summand in $V^{\otimes n}$. Let us denote this multiplicity by $a_{m,n}$.
We see from the above that $a_{m,n} = a_{m-1,n-1} + a_{m+1,n-1}$.
One can check that $$a_{m,n} = \binom{n}{\frac{m+n}{2}} - \binom{n}{\frac{n - m - 2}{2}}$$ satisfies the above recursive formula when $n$ and $m$ have the same parity (and when they don't, $a_{m,n} = 0$). Note that $a_{0,2k} = a_{1,2k-1}$ is the $k$'th Catalan number.


text:
Q: How to assign basic authentication header to XMLHTTPREQUEST? I've read many answers of preflight and CORS so please do not post links referencing what I should read. Many of the answers are from a server-perspective, but I am the client in this case. Do I set the origin header? My assumption is that this is a simple request, am I right?
 req.open("POST", url, true);
 req.setRequestHeader( 'Content-Type',   'application/blahblah' );
 req.setRequestHeader( 'Accept', 'application/blahblah' );
 req.setRequestHeader("Authorization", "Basic " + btoa(user + ":" + pass));
 req.send();

Yet its still not working, my error:

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 500.

A: This post is old, but answering for anybody else who comes across it.
There is nothing wrong with your authorization header. The problem you are facing is CORS related.
You don't set the Origin header yourself. The browser does that for you. If your origin is null then I suspect this is because you are running your code from file:/// instead of http://.

A: If using this for an API request, adding the Authorization header will first make XMLHttpRequest send an OPTIONS request, which may be denied by some APIs.
To get around this you can also do:
var invocation = new XMLHttpRequest();
invocation.open("GET", url, true, username, password);
invocation.withCredentials = true;

Which will add the Authorization header and also avoid the preflight request.

A: If you want to set the authorization header
req.setRequestHeader('Authorization','Basic ' + Base64StringOfUserColonPassword);

A: Solution:
var req = new XMLHttpRequest();
    req.setRequestHeader('Authorization', 'Basic [base64 encoded password here]' );


text:
Q: Powershell Scheduled Task Issue: New-ScheduledTaskAction : Invalid namespace I am trying to run the below mentioned script to schedule a powershell task on a virtual machine:
$tName = "RunMyScript1"
$tCommand = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe"
$tArgs = "powershell -WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -File C:\Users\abc\Desktop\CommandConsoleAlert.ps1"
$repeat = (New-TimeSpan -Minutes 5)
$tAction = New-ScheduledTaskAction -Execute "$tCommand" -Argument $tArgs
$uName = "$env:userdomain" + "\" + "$env:username"
$tTrigger = New-JobTrigger -Once -At (Get-Date).Date -RepeatIndefinitely -RepetitionInterval $repeat
Register-ScheduledTask -Action $tAction -Trigger $tTrigger -TaskName "$tName" -User $uName

However, I am getting below error message-
New-ScheduledTaskAction : Invalid namespace
At N:\USERS\abc\CLS_Server_Scripts\PowerShellScheduledTask.ps1:5 char:12

*

*$tAction = New-ScheduledTaskAction -Execute "$tCommand" -Argument $tA ...

*
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

*

*CategoryInfo          : MetadataError: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [New-ScheduledTaskAction], CimException

*FullyQualifiedErrorId : HRESULT 0x8004100e,New-ScheduledTaskAction

Note: I am using powershell version 5
Could someone please help me with the issue.


text:
Q: IE opens ads automatically I have a problem. I use firefox for browsing, never open IE. But while working every now and then IE window opens with various ads even when i did not open it myself. This way a lot of instances of IE are opened making my system slow.
How to solve this issue?

A: If IE started to open by it self I would be scared of malware or virus.
My suggestion is that you do scan for virus or malware of your computer, then do a windows update.
See Computer is infected by a virus or a malware, what do I do now? for more information.


text:
Q: How to create search bar with Dependent Dropdown In react
I'm looking out for a search bar with Dependent Dropdown In react.
can anyone help me out With these?
Or else do you have any suggestions on how to create with depending on the dropdown for search bar.

A: Have you tried using react-select library? Its a pretty good one with lot of customisable functionality.
https://www.npmjs.com/package/react-select


text:
Q: Parse and Core data relation and pointers i am trying to sync my project to parse. right now i am saving my data in core data. i have 2 kind of entities: Night and Session. it's look like this: Night have many session and session have one night.

when i want to add session to night i create or fetch night and add new session. this way i can get from my night all the session and the opposite way. in order to uploading it to parse i have added in the "Session" table "Night" column ( of type Pointer ) and in "Night" table i added "Sessions" column ( of type relation ) this is how it's look like:

i already succeeded to sync all the record from parse to Core data EXCEPT the relation and Pointers.
my problem is that the only solution for that ( insert this relation into core data ) is to create new night ( i mean create instance ) and create new sessions and add them like this:
-(void)addSession:(Session *)session toNight:(Night *)night {
    if (session && night) {
        NSMutableSet * sessionSet = [night.sessions mutableCopy];
        [sessionSet addObject:session];
        night.sessions = sessionSet;
    }
}

So my Question is:

*

*this is the only way? create instance and add them?

*when i add Session to Night or when i add Night to session, why it's not shown in the DB table. i can not see this connection. ( like i see in parse ,relation and pointers)

*when i get the Relation from parse it's look like this:

sessions =     {
          "__type" = Relation;
          className = Session;
      };

what i can do with that?
Thanks for reading this long Question and i hope i was clear :)
BTW: i follow this tutorial and they do not have relation and pointers.
Updatde
i am using Parse Rest Clint API.

A:
this is the only way? create instance and add them?

yes. either you create a night object and set its sessions property; or you create a session object and set its night property. (provided you have defined and inverse in your core data model).

when i add Session to Night or when i add Night to session, why it's not shown in the DB table. i can not see this connection. ( like i see in parse ,relation and pointers)

this is not clear to me. What would you like to see in the DB table? if you add a bunch of sessions to a night, or you set the night property on session object, then when you inspect those object (reap. night - session) you can access the properties and should show the right value...

when i get the Relation from parse it's look like this:

In Parse, you do not need to model both the Pointer and the Relation (as it happens in Core Data where you have a relation and its inverse).
You just need the pointer for a one to many relationship. Parse relations are used from many to many relationships.
So, what you should to store all of the sessions in Parse is fetching them through a query like:
PFObject* night ...
PFQuery *query = [PFQuery queryWithClassName:@"Sessions"];
[query whereKey:@"night" equalTo:night];

then [query findObjects...] will give you an array of sessions you can add in a go to your Night Core Data object. (so, no need to call multiple time addSession:).
Hope this helps.

A: This is just answer to my first question: i follow this article  and i found this quote:

Core Data cannot operate on data without loading the data into memory.

so i guess i solved my first question. Yes i have to load the data into my memory and then make the connection.