text:
Q: Increment operator ++
Possible Duplicate:
post increment operator java
What is x after "x = x++"?

Can somebody explain me the result of each one of the following small programs? :
public static void main(String[] args) {
    int a = 10;
    a = a++;
    System.out.println(a);
}

The result is: 10
Why not 11 since a should have been increased after the assignment? Is that the fact that it comes to different variables left and right of the opeartor = ?
The next one:
public static void main(String[] args) {
    int a = 10;
    a = ++a;
    System.out.println(a);
}

The result is: 11
Comprehensible, but the compiler presents the warning: "The assignment to variable a has no effect". The result dissents though.
Update:
I do not modify my original question but I add this comment to clarify that now I catch the meaning of the warning. That is, even without the assignment (by a plain statement ++a) the result would be the same (11).

A: The value of a++ is a. ++ has higher precedence than =. So:

*

*The value of a is taken.

*a is incremented.

*The value as at (1) is stored into a.

So the value of a doesn't change.
You can figure out yourself what happens in the second case.

A: In first case assignment happens first and then increment. So you get value which was before increment. But in second case it gets incremented first and then gets assigned.

A: Lets analyze the Byte code produced in each way -
int a = 10;
a = a++;
System.out.println(a); //Output - 10

produced ByteCode -
0 bipush
2 istore_1
3 iload_1
4 iinc
7 istore_1
8 getstatic
11 iload_1
12 invokevirtual
15 return

and
int a = 10;
a = ++a;
System.out.println(a); //Output -11

Here compiler give warning - The assignment to variable a has no effect
Produced ByteCode -
0 bipush
2 istore_1
3 iinc
6 iload_1
7 istore_1
8 getstatic
11 iload_1
12 invokevirtual
15 return

Here we can see in 1st case variable load first then increment so it does not effect anything to variable a.
Where as 2nd case it first increment then load the variable so it got effect of increment.

A: This happens because a++ is more like a Method then a realistic Number.
you can splitt them into two seperat lines.
the first one would be
a = a;
return a + 1;

the seconde one would be
a = a+1;

A: a++ means increase the value of variable a, however a++ has the original value of a!
a = ?? means set the value of a to ??
So what you are doing is incrementing the value of a by one, and then setting it to the old value.
++a means increase the value of variable a, however ++a has the new value of a!
So in the second example you are incrementing the value of a, and then setting the value of a to that value (it has just gotten), so you are doing the same twice.

A: a++  is equivalent to a = a + 1 but increments after the value is used in expression (assignment here) ++a is same but increments before its used in expression. a = ++a; has no explicit assignment affect as it is equal to a = a = a + 1

A: When you write a++ it means a will increment AFTER the '=' operator has been processed. So
b = a++;
System.out.println(a);
System.out.println(b);

Should produce on your screen: 11, 10. Because a becomes 11 after b takes the value of 'a'. If you change the a++ to ++a you force the increment to happen before the '=' is processed so you will be giving b = a + 1 and on your screen you should be having 11,11.


text:
Q: My dlookup function made my MS access database slow is there any function instead of Dlookup to fast my database?
here is my code:
Me.txtMacroDispTest1.Value = DLookup("[TestNo]", "tblmetallurgy8", _
"[FirstArticleNumber] = '" & Me.txtFirstArticlenumber & "' and [TestNoID] = 1")

I want to display the value for the textbox from the table field [TestNo], condition to satisfy is based on number [ ie: FirstArticleNumber] and other field value will 1 [ie: TestNoID]
can anyone help me to speedup the code ?

A: If this is in a continuous form, then you will be running that query (DLookup is a query at it's most basic level) for every record.
If it's a single form then a single DLookup shouldn't be that slow to run.
On the continuous form, If possible add the lookup as a joined table to your forms underlying query, and it will only need to perform the query once for the whole dataset.
Finally, check that the fields you are referencing are indexed.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Java programming requirements I am a C# programmer. I want to learn Java to implement my windows application. But I don't know what IDE and what tools can help me.
Please help me to choose best platform and IDE and other tools.
Edit:
Thank You For Your Helping. And What is Best Ebooks and UserGuids to Learn java.

A: There are really three big IDE's that people use:
Eclipse
Netbeans
Intellij IDEA (my personal favorite)
The online Java Tutorials are a great place to start learning the language.

A: Eclipse or NetBeans will be your best bet for an IDE (in my options)
Set up Git for source control
Use Maven to manage your builds (if you're getting that complex)

A: First, download the java jdk.
http://www.java.com/en/download/index.jsp
Later, install an IDE. I suggest you to use Eclipse, I like it:
http://www.eclipse.org/
Another one very used is Netbeans:
http://netbeans.org/
Have Fun!

A: There's a short tutorial along with a great comparison table here.  It's a Java tutorial aimed at C# developers.

A: Java is very close to C# you don't need more than eclipse (Actually I prefer it more than Netbeans) and search for any syntax you want in the Java documentation

A: JDK

*

*First you need to download Java
development kit(J2SE 6)  from Sun's
website

IDEs

*

*eclipse or netbeans

Books

*

*If you are planning to use Swing for
windows application - you may read
sun's tutorial
http://java.sun.com/docs/books/tutorial/uiswing/

*Or if youa re a serious Java learner
get the Thinking in Java book from
here
http://www.odioworks.com/46-Bruce_Eckel%27s_Free_Electronic_Books.html
By the way, welcome to Java's world :)

A: Welcome to Java World. You can either use Swing or SWT for windows form like development. Here is a good link to get started with SWT http://www.developer.com/java/other/article.php/3330861/SWT-Programming-with-Eclipse.htm .
On top of what the other user's have already recommended, I would suggest getting familiarized with a J2EE container. It will come in handy in the future. Here is a link on what it is. JBOSS container is free and a pretty good one to use in my opinion. You can download it here.

A: For Windows app with SWT / AWT gui you should know there are plugins for IDE that help you to create your gui. Check for exemple Matisse for NetBeans.

A: Once you have Eclipse up and running, you should look at the Visual Editor Project plugin at Eclipse for developing windows applications. Hand-coding all of the SWT stuff is a big pain and hence the plugin will help.

A: netbensIDE will help u


text:
Q: Facebook login button not refreshing to logout automatically Using 'Facebook Login for the Web with the JavaScript SDK', I have a login button which works fine, i.e. user is logged in OK.(https://developers.facebook.com/docs/facebook-login/web#loginbutton).
However, the button does not change to the Logout button until I refresh the page. After refresh the logout button is displayed and when clicked reverts to  login button as expected. Following is the full code which can be run from within IIS. I put it in my default web site and called http://localhost/aspnet_client/system_web/4_0_30319/test.html.
NOTE: Add your App Id where it says, ADD YOUR APP ID HERE.
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

FB code is from https://developers.facebook.com/docs/facebook-login/web#example
I don't want to refresh the page programatically. It is a single page application and refreshing the page will take me to the start.
Thanks.

A: Well, I couldn't figure out why it wouldn't refresh automatically - perhaps that by design. Here is my workaround - basically add the logout button and call FB.logout myself. If someone from Facebook dev team can provide a more elegant solution, I'd love to know. Thanks.
NOTE: Add your App Id where it says, ADD YOUR APP ID HERE.
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

Log Out


text:
Q: What is the difference between tap and map in RxJS? I read the difference from the article but the main points look like this.
so with tap I can change the variables such as that if I put x=3+4 then it changes the values of variable then I can say there is one side effect.
But with map I can change the value looping each value, isn't it?
Can you pinpoint what outstanding differences they have?
tap

RxJS tap performs side effects for every value emitted by source Observable and returns an Observable identical to the source Observable until there is no error.

map

map is a RxJS pipeable operator. map applies a given function to each element emitted by the source Observable and emits the resulting values as an Observable

A: you can think of tap operator as a void function that whatever it does to the input value it does not change the original value
const source = of(1, 2, 3, 4, 5);

// here we are manipulating the input value but the output value of the observable still the same
const example = source.pipe(
  tap(val => val + 100),
);

// output: 1, 2, 3, 4, 5
const subscribe = example.subscribe(val => console.log(val));

in the other hand if we made any manipulation of the input values of the observable using the map operator it will change the output values
const example = source.pipe(
  map(val => val + 100)
);

// output: 101, 102, 103, 104, 105
const subscribe = example.subscribe(val => console.log(val));

A: A mapping function takes a thing and returns another thing. e.g. I can build a function that takes 10 and returns 11, that takes 11 and returns 12, etc.
const inc = n => n + 1;

Array#map applies such mapping function to all elements of an array but "map" doesn't mean "iteration".
In RxJS, when a data is sent to the stream it goes through a series of operators:

*

*The map operator will simply apply a function to that data and return the result.

*The tap operator however takes a data, apply a function to that data but returns the original data, if the function bothered to return a result, tap just ignores it.

Here's an example:

*

*We push 10 to stream a$, tap just log the value. We know that console.log always return undefined but that's fine because tap simply returns its parameter.

*We push 10 to stream b$, it goes through map(inc) which applies inc to 10 returning 11.

const a$ = of(10).pipe(tap(n => console.log(`tap: ${n}`)));
const b$ = of(10).pipe(map(inc));

a$.subscribe(n => console.log(`n from a$: ${n}`));
b$.subscribe(n => console.log(`n from b$: ${n}`));
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.5.5/rxjs.umd.min.js"></script>

<script>
const {of} = rxjs;
const {map, tap} = rxjs.operators;

const inc = n => n + 1;
</script>

A: Tap should be Used for Notification, logging non-contextual/critical side effects.
It's like a "peek" into the "pipe". The data stays the same, You can do something with it. Some data goes in, you look, same data comes out.
Map is for transformation/mapping of the Data in the "pipe". Some data comes in, different/transformed data comes out.

A: *

*The purpose of tap is to execute an action keeping the same value
of the observable

*The purpose of map is to transform the emitted values of the
observable
const messagesCount$ = newMessages$
.pipe(tap(messages => notificationService.notify('You have ' + message.length + ' message(s)')))
.pipe(map(messages => messages.length))

A: The tap and map are both RxJS operators, RxJS operators are just function that performs some manipulation over the data.
Both of them are pipeable operators which takes input as Observable, perform some action and return an output observable.
Difference between map and tap:
The map is a pipeable operator that takes an input observable, performs some manipulation on it and returns a new manipulated observable. For example
const source$ = of(1,2,3) // observable which will emit 1,2,3
// It take an input observable and return a new observable which will emit square of input values.
// So, the output observable will emit 1,4,9
const mapSource$ = of(1,2,3)
                    .pipe(map(value => value * value))

The tap operator on another hand takes an input observable perform some action and returns the same input observable.
const source$ = of(1,2,3) // observable which will emit 1,2,3
// It take an input observable and return a same observable after console value.
// So, the output observable will emit 1,2,3
const tapSource$ = of(1,2,3)
                    .pipe(tap(value => console.log(value)))

A: I addition to what the others are saying, in Rxjs 7.4 tap now has three more subscribe handlers, so you can use it to get notified on subscribe, unsubscribe and finalize:
https://github.com/ReactiveX/rxjs/commit/eb26cbc4488c9953cdde565b598b1dbdeeeee9ea#diff-93cd3ac7329d72ed4ded62c6cbae17b6bdceb643fa7c1faa6f389729773364cc
This is great for debugging purposes, so you can use tap to find out much more about what is happening with your stream.
Example:
const subscription = subject
.pipe(
  tap({
    subscribe: () => console.log('subscribe'),
    next: (value) => console.log(`next ${value}`),
    error: (err) => console.log(`error: ${err.message}`),
    complete: () => console.log('complete'),
    unsubscribe: () => console.log('unsubscribe'),
    finalize: () => console.log('finalize'),
  })
)
.subscribe();

A: TAP, can NOT transform:
interval(1000).pipe(tap(el=> el*2)).subscribe(console.log); // 0,1,2,3

MAP, CAN transform:
interval(1000).pipe(map(el=> el*2)).subscribe(console.log); // 0,2,4,6

If you do NOT need to transform the value, just console.log it or run external function to pass the Original value = TAP is good.
If you NEED TO TRANSFORM/CHANGE the value = MAP is the way to go.


text:
Q: Endomorphisms of the Torus Question: Show that tfae:

*

*The endomorphism of the torus $T_A:\mathbb{T}^n\to\mathbb{T}^n, [x]\mapsto[Ax]$, where $[x]:=\{x+y:y\in\mathbb{Z}^n\}$ and $A\in M_n(\mathbb{Z})$, is invertible.

*$x\in\mathbb{Z}^n \iff Ax\in\mathbb{Z}^n$.

*$|\det A|=1$.
Motivation: This question is from Barreira & Valls' Dynamical Systems: an Introduction (p. 25), which I am reading as a reading course.
I think we need to establish a relation between $|\det A|=1$ and that $A^{-1}\in M_n(\mathbb{Z})$. I could not prove this, but supposing it I could do $1\implies2, 3\implies2$ and $3\implies1$.

A: Well, $\det(A\cdot B)=\det A\cdot\det B$, and also, $\det A\in\Bbb Z$ if the entries of $A$ are from $\Bbb Z$.
So, if $\exists A^{-1}\in M_n(\Bbb Z)$, then we have the following product of integers as $AA^{-1}=I$ and $\det(I)=1$:
$$\det A\cdot \det(A^{-1})=1\,.$$
For $2\implies3$: if $A$ (any real matrix) is not invertible, then $0$ is an eigenvalue, so there is a whole line mapped to $0$, and a line definitely contains points out of $\Bbb Z^n$. So, assuming $2$, $A$ must be invertible, but the condition also implies that the preimages of the standard basis vectors are all in $\Bbb Z^n$, which are just the columns of $A^{-1}$.

A: It took me a while but I think I got it now. Here is my take (which is a slight variant of Berci's answer):

First I'll expand and reformulate the problem. Fix $d\in\mathbb{Z}_{\geq1}$ as the dimension. Let $GL(d,\mathbb{R})$ denote the group of $d\times d$ invertible matrices with real coefficients and let $GL(d,\mathbb{Z})$ denote the group of $d\times d$ invertible matrices with integer coefficients whose inverse is also with integer coefficients (as in General linear group over integers). The determinant of a matrix with integer coefficients is also an integer, and by the multiplicativity of the determinant, one can also write more explicitly $GL(d,\mathbb{Z})=M_d(\mathbb{Z})\cap\{|\det|=1\}$, where $M_d(\mathbb{Z})$ is the algebra of $d\times d$ matrices with integer coefficients. For convenience we'll identify matrices with linear maps throughout.
The $d$-torus $\mathbb{T}^d=\mathbb{R}^d/\mathbb{Z}^d$ is an abelian Lie group with Lie algebra $\mathbb{R}^d$ (with zero bracket). Let us denote the points of $\mathbb{T}^d$ by $[v]=\{w\in\mathbb{R}^d\vert w-v\in\mathbb{Z}^d\}$, $v\in\mathbb{R}^d$, where $v\mapsto [v]$ is the universal covering map (= exponential map). If $f:\mathbb{T}^d\to \mathbb{T}^d$ is a Lie group endomorphism, the linear map $f'(e_{\mathbb{T}^d}):\mathbb{R}^d\to\mathbb{R}^d$ completely determines it ($e_{\mathbb{T}^d}=[0]$). Conversely, if $A:\mathbb{R}^d\to \mathbb{R}^d$ is a linear map and $\forall v\in\mathbb{R}^d: v\in\mathbb{Z}^d\implies Av\in\mathbb{Z}^d$ (which means $A\in M_d(\mathbb{Z})$), then $A$ factors through $v\mapsto [v]$. The resulting map is denoted by $T_A$ as above. Thus any Lie group endomorphism of $\mathbb{T}^d$ is of the form $T_A: [x]\mapsto [Ax]$ for some $A\in M_d(\mathbb{Z})$. Note that $[0]$ is a fixed point of any $T_A$.
The question is about which Lie group endomorphisms of $\mathbb{T}^d$ are actually Lie group automorphisms. It suffices to find those $A$s in $M_d(\mathbb{Z})$ for which $(T_A)^{-1}:\mathbb{T}^d\to\mathbb{T}^d$ exists.

Question, rephrased: Let $A\in M_d(\mathbb{Z})$. Then the following are equivalent:

*

*$T_A$ is a Lie group automorphism of $\mathbb{T}^d$.

*$\forall v\in\mathbb{R}^d: v\in\mathbb{Z}^d \iff Av\in\mathbb{Z}^d$.

*$A\in GL(d,\mathbb{Z})$.

Proof: (1.$\implies$2.) Necessity is automatic from $A\in M_d(\mathbb{Z})$. For sufficiency, let $v\in\mathbb{R}^d$ be such that $Av\in\mathbb{Z}^d$. Then $[Av]=[0]$. Since $T_A$ is invertible, $[v]=(T_A)^{-1}\circ T_A ([v])=(T_A)^{-1}([Av])=(T_A)^{-1}([0])=[0]$, so $v\in\mathbb{Z}^d$.
(2.$\implies$3.) Let $v\in \ker(A)$. Then $Av=0\in\mathbb{Z}^d$, whence by hypothesis $v\in\mathbb{Z}^d$, so that $\ker(A)\leq \mathbb{Z}^d$, and thus $\ker(A)=0$ and $A$ in invertible (i.e. $A\in GL(d,\mathbb{R})$). Now let $w\in\mathbb{R}^d$ and put $v=A^{-1}w$. Then the hypothesis reads $A^{-1}w\in\mathbb{Z}^d \iff w\in\mathbb{Z}^d$. In particular choosing the standard basis vectors $e_1=(1,0,...,0),..., e_d=(0,...,0,1)$ as $w$ gives that any column of $A^{-1}$ is a vector in $\mathbb{Z}^d$, so that $A^{-1}\in M_d(\mathbb{Z})$. Thus $A\in GL(d,\mathbb{Z})$.
(3.$\implies$1.) By hypothesis and our considerations above regarding Lie group endomorphisms of $\mathbb{T}^d$, both $A$ and $A^{-1}$ induce endomorphisms of $\mathbb{T}^d$. Then $(T_A)^{-1}\circ T_A([x])=[A^{-1}Ax]=[x]$ and similarly $T_A\circ(T_A)^{-1}=\operatorname{id}_{\mathbb{T}^d}$, so that $(T_A)^{-1}=T_{A^{-1}}$ and $T_A$ is a Lie group automorphism of $\mathbb{T}^d$.

Finally let me note that $SL(d,\mathbb{Z})\leq GL(d,\mathbb{Z})$. The smaller group consists of Lie group automorphisms of $\mathbb{T}^d$ that not only preserve volume (which is automatic) but also orientation.


text:
Q: How the B+ tree actually works when order by some fields other than primary key? If the database uses B+tree, and we want to execute a sql query something like
select * from x order by y
I think that if the y is the primary, the B+ tree will be very fast, as you can just use the leaf node.
But what happens when the y is not the primary key, the DBMS still need to sort the whole database, is that right? And this is not trivial in my opinion.
And one guess is that if the y is primary key, the sql query will be much faster if y is other field, is that true?
I just think it is a very natural question, but I just found this: https://softwareengineering.stackexchange.com/questions/405631/how-do-b-trees-used-in-databases-sort-data-based-on-different-fields.
And still quite confused..


text:
Q: Spring:message in android I am studying Java EE and Spring for web development.
Suddenly, my manager told me to create multi language functionality in android.
I know how to do it in Java EE but I don't know how to do it in Android.
Do you have any suggestions? Can i use spring on android or do I have to use other frameworks?

A: Android already supports multi language texts, so you do not need another Framework for that.
Here is the link with all the information: http://developer.android.com/training/basics/supporting-devices/languages.html
You cannot use the Spring Framework for this as it is not a Web-Framework, not an Android-Framework. There is Spring for Android but that only gives you this functionality:

*

*A Rest Client for Android

*Auth support for accessing secure APIs


text:
Q: Why does useState is returning undefined in output? I am providing isFollowing=true here
but in useStatefollowButtonState is returning undefined as output.
const [followButtonState, setFollowButtonState] = useState(isFollowing);
console.log(`profile info component: ${isFollowing}`); //output :true
console.log(followButtonState); //output :undefined

A: If you are passing isFollowing as a prop to your component then set the value of followButtonState in useEffect instead of directly assigning it:
const [followButtonState, setFollowButtonState] = useState('');

React.useEffect(() => {
  setFollowButtonState(isFollowing)
}, [isFollowing)

I hope this will solve your issue.


text:
Q: Prove that $A$ is Symmetric matrix or antisymmetric matrix let matrix $ A\in R^{n\times n},\alpha\in R^{1\times n}$
if $\forall \alpha, \exists k\in Z $,then we have $A\alpha =kA^T\alpha ,$
prove that
$A$ is Symmetric matrix or antisymmetric matrix

A: Let $A=(a_{i,j}$) and let $$e_i=\left(\begin{array}\\0\\
\vdots\\0\\1\\0\\ \vdots\\0\end{array}\right)$$
where the $1$ is placed at the $i^{th}$ position then we have
$$a_{i,j}=e_i^T A e_j=ke_i^T A^Te_j=ka_{i,j}^T=ka_{j,i}$$
hence we can see easily that
$$a_{i,j}=k a_{j,i}=k^2 a_{i,j}$$
so $k^2=1$ and then $k=\pm 1$ and we conclude that $A$ is symmetric or antisymmetric.


text:
Q: How can i change the hour in datetime (keys in a list) without changing anything else I have a dict that looks like this
{datetime.datetime(2022, 6, 1, 0, 0): 42.3425, datetime.datetime(2022, 7, 1, 0, 0): 24.251666666666665, datetime.datetime(2022, 8, 1, 0, 0): 27.058333333333334, datetime.datetime(2022, 9, 1, 0, 0): 6.960000000000001, datetime.datetime(2022, 10, 1, 0, 0): 0.0, datetime.datetime(2022, 6, 2, 0, 0): 15.950833333333334, datetime.datetime(2022, 7, 2, 0, 0): 33.69916666666667, datetime.datetime(2022, 8, 2, 0, 0): 12.700000000000001, datetime.datetime(2022, 9, 2, 0, 0): 5.406666666666666, datetime.datetime(2022, 10, 2, 0, 0): 0.035833333333333335, datetime.datetime(2022, 6, 3, 0, 0): 14.744166666666667, datetime.datetime(2022, 7, 3, 0, 0): 30.455833333333334, datetime.datetime(2022, 8, 3, 0, 0): 14.745, datetime.datetime(2022, 9, 3, 0, 0): 8.981666666666667, datetime.datetime(2022, 10, 3, 0, 0): 0.035, datetime.datetime(2022, 6, 4, 0, 0): 42.14000000000001, datetime.datetime(2022, 7, 4, 0, 0): 18.213333333333335, datetime.datetime(2022, 8, 4, 0, 0): 11.723333333333336, datetime.datetime(2022, 9, 4, 0, 0): 6.530833333333334, datetime.datetime(2022, 10, 4, 0, 0): 0.4883333333333333, datetime.datetime(2022, 6, 5, 0, 0): 55.175000000000004, datetime.datetime(2022, 7, 5, 0, 0): 43.63749999999999, datetime.datetime(2022, 8, 5, 0, 0): 22.379999999999995, datetime.datetime(2022, 9, 5, 0, 0): 2.7191666666666667, datetime.datetime(2022, 6, 6, 0, 0): 20.865, datetime.datetime(2022, 7, 6, 0, 0): 35.29416666666666 }

i.e i have datetime as keys and some values, i want to change the hour of all of the keys to 12 (instead
of 0) without changing anything else, for ex. i want to have
(year, month, day, 12, 0) for all of them, how can I do that?

A: Given your input as:
your_input = {datetime.datetime(2022, 6, 1, 0, 0): 42.3425, datetime.datetime(2022, 7, 1, 0, 0): 24.251666666666665, datetime.datetime(2022, 8, 1, 0, 0): 27.058333333333334, datetime.datetime(2022, 9, 1, 0, 0): 6.960000000000001, datetime.datetime(2022, 10, 1, 0, 0): 0.0, datetime.datetime(2022, 6, 2, 0, 0): 15.950833333333334, datetime.datetime(2022, 7, 2, 0, 0): 33.69916666666667, datetime.datetime(2022, 8, 2, 0, 0): 12.700000000000001, datetime.datetime(2022, 9, 2, 0, 0): 5.406666666666666, datetime.datetime(2022, 10, 2, 0, 0): 0.035833333333333335, datetime.datetime(2022, 6, 3, 0, 0): 14.744166666666667, datetime.datetime(2022, 7, 3, 0, 0): 30.455833333333334, datetime.datetime(2022, 8, 3, 0, 0): 14.745, datetime.datetime(2022, 9, 3, 0, 0): 8.981666666666667, datetime.datetime(2022, 10, 3, 0, 0): 0.035, datetime.datetime(2022, 6, 4, 0, 0): 42.14000000000001, datetime.datetime(2022, 7, 4, 0, 0): 18.213333333333335, datetime.datetime(2022, 8, 4, 0, 0): 11.723333333333336, datetime.datetime(2022, 9, 4, 0, 0): 6.530833333333334, datetime.datetime(2022, 10, 4, 0, 0): 0.4883333333333333, datetime.datetime(2022, 6, 5, 0, 0): 55.175000000000004, datetime.datetime(2022, 7, 5, 0, 0): 43.63749999999999, datetime.datetime(2022, 8, 5, 0, 0): 22.379999999999995, datetime.datetime(2022, 9, 5, 0, 0): 2.7191666666666667, datetime.datetime(2022, 6, 6, 0, 0): 20.865, datetime.datetime(2022, 7, 6, 0, 0): 35.29416666666666 }

You can use the .replace() method to change the hour of your datetime object and create a new dictionary like this:
output = {key.replace(hour=12):value for key,value in your_input.items()}

output:
{datetime.datetime(2022, 6, 1, 12, 0): 42.3425, datetime.datetime(2022, 7, 1, 12, 0): 24.251666666666665, datetime.datetime(2022, 8, 1, 12, 0): 27.058333333333334, datetime.datetime(2022, 9, 1, 12, 0): 6.960000000000001, datetime.datetime(2022, 10, 1, 12, 0): 0.0, datetime.datetime(2022, 6, 2, 12, 0): 15.950833333333334, datetime.datetime(2022, 7, 2, 12, 0): 33.69916666666667, datetime.datetime(2022, 8, 2, 12, 0): 12.700000000000001, datetime.datetime(2022, 9, 2, 12, 0): 5.406666666666666, datetime.datetime(2022, 10, 2, 12, 0): 0.035833333333333335, datetime.datetime(2022, 6, 3, 12, 0): 14.744166666666667, datetime.datetime(2022, 7, 3, 12, 0): 30.455833333333334, datetime.datetime(2022, 8, 3, 12, 0): 14.745, datetime.datetime(2022, 9, 3, 12, 0): 8.981666666666667, datetime.datetime(2022, 10, 3, 12, 0): 0.035, datetime.datetime(2022, 6, 4, 12, 0): 42.14000000000001, datetime.datetime(2022, 7, 4, 12, 0): 18.213333333333335, datetime.datetime(2022, 8, 4, 12, 0): 11.723333333333336, datetime.datetime(2022, 9, 4, 12, 0): 6.530833333333334, datetime.datetime(2022, 10, 4, 12, 0): 0.4883333333333333, datetime.datetime(2022, 6, 5, 12, 0): 55.175000000000004, datetime.datetime(2022, 7, 5, 12, 0): 43.63749999999999, datetime.datetime(2022, 8, 5, 12, 0): 22.379999999999995, datetime.datetime(2022, 9, 5, 12, 0): 2.7191666666666667, datetime.datetime(2022, 6, 6, 12, 0): 20.865, datetime.datetime(2022, 7, 6, 12, 0): 35.29416666666666}

https://docs.python.org/3/library/datetime.html#datetime.date.replace


text:
Q: Subsetting with variable selection range I have to make a set of selections that vary by the day on this dataset (dat), which is composed by species (sp), day (day, in POSIXct) and area (ar):
sp  day         ar
A   1-Jan-00    2
B   1-Jan-00    6
C   2-Jan-00    2
A   2-Jan-00    1
D   2-Jan-00    4
E   2-Jan-00    12
F   3-Jan-00    8
A   4-Jan-00    3
G   4-Jan-00    2
B   4-Jan-00    1

I need to subset where species "A" occurs. However, the areas to be selected will vary by day, given by this matrix (dat.ar):
day       ar.select
1-Jan-00    (1,6)
2-Jan-00    (1,12)
3-Jan-00    (4,8)
4-Jan-00    (3,12)

More specifically, for areas where species "A" occurs, on 1-jan-00, I need only areas 1 and 6. For 2-jan-00, areas 1 and 12, and so on.
As an example, the desired output on this example for this selection is given below:
sp  day        ar
A   2-Jan-00    1
A   4-Jan-00    3

I haven't had much success getting a for loop, as I am still trying to learn the semantics in R. In summary, a rough idea of what must be done, but still struggling with the language. Here is a sketch of where I think this should go:
dat1 = with(dat,sapply(day[sp=="A" & dat.ar$day.s[i] ],
function(x) ar == (ar[sp=="A" & day == x]==dat.ar$ar.select[j])
final=dat[rowSums(dat1) > 0, ]

I believe I have to fit a for loop, that would go through dat.ar, specifying the areas to be selected in dat. But despite my efforts in trying to get for the for loop, I haven't gotten anywhere near. I am not even sure if combining an sapply and a for loop is the right way to go about this.
In case someone wishes to reproduce the problem:
sp=c("A","B","C","A","D","E","F","A","G","B")
day=c("1-Jan-00", "1-Jan-00", "2-Jan-00", "2-Jan-00", "2-Jan-00",
"2-Jan-00", "3-Jan-00", "4-Jan-00", "4-Jan-00", "4-Jan-00")
day=as.POSIXct(day, format="%d-%b-%y")
ar=c(2,6,2,1,4,12,8,3,2,1)
dat= as.data.frame(cbind(sp, day, ar))

day.s=c("1-Jan-00", "2-Jan-00", "3-Jan-00", "4-jan-00")
day.s=as.POSIXct(day.s, format="%d-%b-%y")
a.s=c(1,1,4,3)
a.e=c(6,12,8,12)
ar.select=paste(a.s, a.e, sep=",")
dat.ar=cbind(day.s, ar.select)

Any help is much appreciated.

A: You could merge your table of conditions to the original dataset and filter them conditionally. Consider a1 and a2 like your sp and day values, and obs to be like your ar value.
library(data.table)
dataset <- data.table(
a1 = c("A","B","C","B","A","A","A","A"),
a2 = c("P","Q","Q","Q","R","R","P","Q"),
obs = c(3,2,3,4,2,4,8,0)
)

constraints <- data.table(
a1 = c("A","B","C","A","B","C","A","B","C"),
a2 = c("P","P","P","Q","Q","Q","R","R","R"),
lower = c(1,2,3,4,3,2,3,2,5),
upper = c(6,4,5,7,5,6,5,3,7)
)

checkingdataset <- merge(dataset,constraints, by = c("a1","a2"), all.x = TRUE)

checkingdataset[obs <= upper & obs >= lower, obs.keep := TRUE]

#   a1 a2 obs lower upper obs.keep
#1:  A  P   3     1     6    TRUE
#2:  A  P   8     1     6      NA
#3:  A  Q   0     4     7      NA
#4:  A  R   2     3     5      NA
#5:  A  R   4     3     5    TRUE
#6:  B  Q   2     3     5      NA
#7:  B  Q   4     3     5    TRUE
#8:  C  Q   3     2     6    TRUE

A: First, I would not use as.data.frame(cbind(...)) to make your data.frames. Second, I would create dat.ar in much the same structure that you have created dat. Third, I would then just use merge to get the result you are looking for.
dat <- data.frame(sp=c("A","B","C","A","D","E","F","A","G","B"),
                  day=c("1-Jan-00", "1-Jan-00", "2-Jan-00", "2-Jan-00",
                        "2-Jan-00", "2-Jan-00", "3-Jan-00", "4-Jan-00",
                        "4-Jan-00", "4-Jan-00"),
                  ar=c(2,6,2,1,4,12,8,3,2,1))
dat$day <- as.POSIXct(dat$day, format="%d-%b-%y")

day.s <- c("1-Jan-00", "2-Jan-00", "3-Jan-00", "4-jan-00")
day.s <- as.POSIXct(day.s, format="%d-%b-%y")
a.s <- c(1,1,4,3)
a.e <- c(6,12,8,12)
ar.select <- paste(a.s, a.e, sep=",")
dat.ar <- data.frame(sp = "A", day = day.s, ar = ar.select)

dat.ar <- cbind(dat.ar[-3],
                read.csv(text = as.character(dat.ar$ar), header = FALSE))
library(reshape2)
dat.ar <- melt(dat.ar, id.vars=1:2, value.name="ar")
dat.ar
#   sp        day variable ar
# 1  A 2000-01-01       V1  1
# 2  A 2000-01-02       V1  1
# 3  A 2000-01-03       V1  4
# 4  A 2000-01-04       V1  3
# 5  A 2000-01-01       V2  6
# 6  A 2000-01-02       V2 12
# 7  A 2000-01-03       V2  8
# 8  A 2000-01-04       V2 12

merge(dat, dat.ar)
#   sp        day ar variable
# 1  A 2000-01-02  1       V1
# 2  A 2000-01-04  3       V1

Of course, I would just suggest that you make your dat.ar object in a more friendly manner to begin with. Why paste values together if you are going to separate them out later anyway? ;)
dat.ar <- data.frame(sp = "A",
                     day = c("1-Jan-00", "2-Jan-00", "3-Jan-00", "4-jan-00"),
                     a.s = c(1,1,4,3), a.e = c(6,12,8,12))
dat.ar$day <- as.POSIXct(dat.ar$day, format="%d-%b-%y")

library(reshape2)
dat.ar <- melt(dat.ar, id.vars=1:2, value.name="ar")


text:
Q: Blame Error during SonarQube Scanner execution I am using sonarqube-6.0 and i tried with a sample example to run with sonar-scanner
i am getting the blame ERROR when ever I run any project in sonar-scanner
The file Conf in sonar-scanner configuration is vi sonar-scanner.properties
#

# must be unique in a given SonarQube instance
sonar.projectKey=SonarSource-sonar-examples-8051d9d
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=java-maven-simple
sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=/Users/kingslee/work/software/projects/sonar-scanner-2.8/bin/sonar-examples

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
~

When i run command ./sonar-scanner these are the error which i get frequently

ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Unable to blame file sonar-examples/plugins/java-custom-rules/src/main/java/org/sonar/samples/java/MyJavaFileCheckRegistrar.java
 at org.sonarsource.scm.git.JGitBlameCommand.blame(JGitBlameCommand.java:128)
 at org.sonarsource.scm.git.JGitBlameCommand.access$000(JGitBlameCommand.java:44)
 at org.sonarsource.scm.git.JGitBlameCommand$1.call(JGitBlameCommand.java:112)
 at org.sonarsource.scm.git.JGitBlameCommand$1.call(JGitBlameCommand.java:109)
 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
 at org.eclipse.jgit.internal.storage.file.UnpackedObjectCache$Table.index(UnpackedObjectCache.java:146)
 at org.eclipse.jgit.internal.storage.file.UnpackedObjectCache$Table.contains(UnpackedObjectCache.java:109)
 at org.eclipse.jgit.internal.storage.file.UnpackedObjectCache.isUnpacked(UnpackedObjectCache.java:64)
 at org.eclipse.jgit.internal.storage.file.ObjectDirectory.openObject(ObjectDirectory.java:376)
 at org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:142)
 at org.eclipse.jgit.lib.ObjectReader.open(ObjectReader.java:226)
 at org.eclipse.jgit.blame.BlameGenerator.push(BlameGenerator.java:317)
 at org.eclipse.jgit.api.BlameCommand.call(BlameCommand.java:216)
 at org.sonarsource.scm.git.JGitBlameCommand.blame(JGitBlameCommand.java:126)
 ... 7 more
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.


text:
Q: How to change all datetime objects in a list to standard YYYY-MM-DD HH:MM:SS When I query MySQL with Python and the query has datetime fields then I get this list as a result.
[{'_id': 1, 'name': 'index', '_cdate': datetime.datetime(2020, 10, 27, 9, 4, 34), 'title': 'DataExtract'}, {'_id': 2, 'name': 'topmenu', '_cdate': datetime.datetime(2020, 11, 4, 19, 52, 17), 'title': 'topmenu'}, {'_id': 3, 'name': 'functions_common', '_cdate': datetime.datetime(2020, 11, 4, 19, 52, 50), 'title': 'common functions'}, {'_id': 4, 'name': 'leftmenu', '_cdate': datetime.datetime(2020, 11, 4, 19, 53, 56), 'title': 'Left Menu'}, {'_id': 5, 'name': 'todo', '_cdate': datetime.datetime(2020, 11, 7, 8, 49, 38), 'title': 'Todo'}, {'_id': 6, 'name': 'cron_publish', '_cdate': datetime.datetime(2020, 12, 2, 19, 30, 11), 'title': 'Run Publish reports'}, {'_id': 7, 'name': 'test', '_cdate': datetime.datetime(2020, 12, 2, 22, 32, 54), 'title': 'test'}, {'_id': 8, 'name': 'help', '_cdate': datetime.datetime(2020, 12, 5, 7, 12, 44), 'title': 'Help'}, {'_id': 9, 'name': 'api', '_cdate': datetime.datetime(2020, 12, 5, 21, 22, 13), 'title': 'API'}, {'_id': 10, 'name': 'ben', '_cdate': datetime.datetime(2021, 10, 4, 11, 37, 3), 'title': 'List of Reports'}]

How do I either get the query to return the date fields in YYYY-MM-DD HH:MM:SS format? Or how do I convert them in the returned list.  When I try to change them by enumerating over the results python throw as error that the dictionary has changed.

A: The datetime.datetime() objects you're getting are the standard representation of these objects - if you were expecting strings instead, you could simple convert them with datetime.strftime('%Y-%m-%d %H:%M:%S', value) but keep in mind that the datetime object is a more flexible way of keeping the data around. I'd recommend only formatting the date in a specific way if you're writing it to the screen or a file format that expects a string.
Example:
data = [{'_id': 1, 'name': 'index', '_cdate': datetime.datetime(2020, 10, 27, 9, 4, 34), 'title': 'DataExtract'}, {'_id': 2, 'name': 'topmenu', '_cdate': datetime.datetime(2020, 11, 4, 19, 52, 17), 'title': 'topmenu'}, {'_id': 3, 'name': 'functions_common', '_cdate': datetime.datetime(2020, 11, 4, 19, 52, 50), 'title': 'common functions'}, {'_id': 4, 'name': 'leftmenu', '_cdate': datetime.datetime(2020, 11, 4, 19, 53, 56), 'title': 'Left Menu'}, {'_id': 5, 'name': 'todo', '_cdate': datetime.datetime(2020, 11, 7, 8, 49, 38), 'title': 'Todo'}, {'_id': 6, 'name': 'cron_publish', '_cdate': datetime.datetime(2020, 12, 2, 19, 30, 11), 'title': 'Run Publish reports'}, {'_id': 7, 'name': 'test', '_cdate': datetime.datetime(2020, 12, 2, 22, 32, 54), 'title': 'test'}, {'_id': 8, 'name': 'help', '_cdate': datetime.datetime(2020, 12, 5, 7, 12, 44), 'title': 'Help'}, {'_id': 9, 'name': 'api', '_cdate': datetime.datetime(2020, 12, 5, 21, 22, 13), 'title': 'API'}, {'_id': 10, 'name': 'ben', '_cdate': datetime.datetime(2021, 10, 4, 11, 37, 3), 'title': 'List of Reports'}]

for rec in data:
    rec['date_str'] = datetime.datetime.strftime('%Y-%m-%d %H:%M:%S', rec['_cdate'])

That would add 'date_str' field to every record with the format you require. Of course, you could also modify it to overwrite the original value.


text:
Q: Using WebMatrix.Data.Database.Open in View So after following:
http://www.w3schools.com/aspnet/webpages_database.asp
I'm trying to connect a database with my view as such:
@{
    var db = Database.Open("SmallBakery");
    var selectQueryString = "SELECT * FROM Product ORDER BY Name";
}

I have referenced WebMatrix.Data and
var db = Database.Open("SmallBakery");

works in my model/controller but not in the view. When I do:
@var db = Database.Open("SmallBakery");

It's not finding the reference to WebMatrix.Data, only to System.Data.Entity.Database which does not contain the Open method. I'm not able to reference WebMatrix in my view either as such
@using WebMatrix.Data;

What am I missing?

A: Ok found out for some reason I need to copy WebMatrix.Data to \bin folder. Now it works.

A: Asides from copying the WebMatrix.dll file to your bin folder.I tried that and it didn't work. You could also add a reference to WebMatrix at the beginning of the page where you want to use it. For example:
@using WebMatrix.Data;
then you can continue with your code, this worked for me after I installed WebMatrix.Data package via Nuget.


text:
Q: Connect (SSH) to the same server, through two different gateways, with different server users What I would like to achieve is to be able to connect to some target.server from my local machine, without having to type any passwords, with the following commands:
ssh user1@target.server
ssh user2@target.server

Each user above only accepts a connection from a specific IP address, corresponding to respectively gateway1.example and gateway2.example. I have added all necessary SSH keys to the right authorized_keys, so that I can do, without typing passwords:

*

*ssh gateuser1@gateway1.example from local machine, then ssh user1@target.server from gateway1.

*ssh gateuser2@gateway2.example from local machine, then ssh user2@target.server from gateway2.

Now I think it remains to put the right things in my local ~/.ssh/config. When I add:
Host target.server
    ProxyCommand ssh -o 'ForwardAgent yes' gateuser1@gateway1.example 'ssh-add && nc %h %p'

Then ssh user1@target.server works. But I don't know how to make both user1 and user2 work. I tried:
Host target.server
    User user1
    ProxyCommand ssh -o 'ForwardAgent yes' gateuser1@gateway1.example 'ssh-add && nc %h %p'
Host target.server
    User user2
    ProxyCommand ssh -o 'ForwardAgent yes' gateuser2@gateway2.example 'ssh-add && nc %h %p'

or
Host target.server
    User user1
        ProxyCommand ssh -o 'ForwardAgent yes' gateuser1@gateway1.example 'ssh-add && nc %h %p'
    User user2
        ProxyCommand ssh -o 'ForwardAgent yes' gateuser2@gateway2.example 'ssh-add && nc %h %p'

but it still didn't work for user2: all went through gateway1 and not gateway2.
Thank you very much in advance for your help!
Update: I've been able to make the following commands work:
ssh user1
ssh user2

(without @target.server), using the following configuration:
Host user1
    HostName target.server
    User user1
    ProxyCommand ssh -o 'ForwardAgent yes' gateuser1@gateway1.example 'ssh-add && nc %h %p'
Host user2
    HostName target.server
    User user2
    ProxyCommand ssh -o 'ForwardAgent yes' gateuser2@gateway2.example 'ssh-add && nc %h %p'

This is what I will be using, but I'm still curious to see a solution to the two commands at the beginning of this question.

A: As you figured out, aliases are a good solution. If you don't want to use them, the Match directive might be another valid option.
Host target.server
    Match User user1
        ProxyCommand ssh -o 'ForwardAgent yes' gateuser1@gateway1.example 'ssh-add && nc %h %p'
    Match User user2
        ProxyCommand ssh -o 'ForwardAgent yes' gateuser2@gateway2.example 'ssh-add && nc %h %p'

From the ssh_config man page:

Match   Restricts the following declarations (up to the next Host or Match keyword) to be used only when the conditions following the Match keyword are satisfied.


text:
Q: How can I get more expedition modules? I found some ruins with my explorer and let it dig around a bit. But when I went with this explorer to a second site, I couldn't construct an expedition there.
I checked the Civilopedia and it said that expeditions consume expedition modules, and I noticed that my explorer didn't have any expedition modules left.

How can I get more expedition modules, so I simply have to built more explorers, or can I get them in any other way?

A: Send your explorer back into one of your cities to gain another expedition module.  It's similar to the way units in Civ5 have to go back to your territory to upgrade.
Additionally, there's a Virtue called Pathfinders in Tier II of the Prosperity tree that will give your explorers 3 more expedition modules. Upon choosing this virtue, all your explorers will instantly receive 3 more modules regardless of their location.


text:
Q: Why does my disk drive access slow so much after adding a new drive? Originally my system had two SATA disk drives - I added an extra SATA disk drive to my system and when accessing this disk it sometimes take about 50 times longer to access the drive. (Windows Explorer can take about 2 mins to populate the basic directory and there is nothing special about the directory)
This doesn't happen all the time, but can't identify a pattern at the moment.
Any ideas what I've done wrong?
(Using Windows Vista Home Premium - PC is custom made - this is just on my development PC. What other useful info can I give?)

A: After double checking all the cables, you could try to test the drive with the dedicated software from the producer, like:

*

*SeaTools for Seagate

*Data Lifeguard Diagnostic for WD

A: You could check if the BIOS settings are different for the disk you added. We have had problems with slow SATA disks due to the BIOS being set to use a legacy mode.


text:
Q: Distance confusion about Shuncom SZ05-ADV ZigBee module I ordered this module looking at the datasheet that it has a range of 2000m LOS distance. But now when I test it, I can receive signal from a maximum of 50m distance! It sends 2.4GHz signals. As far I understand, LOS distance means straight line distance. Am I making any wrong assumption about the datasheet?

A: Adding to what Connor Wolf said in the comments, transmitters have a defined maximum transmit power (usually measured in dBm or mW) whilst receivers have a defined maximum sensitivity. Together, plus several other factors, they form what is known as a "link budget". For instance, if you've got a 20 dBm transmitter and a receiver with a -60 dBm sensitivity, you can theoretically afford up to 80 dB in attenuation. Attenuation comes from many sources (connectors, cables, antenna matching, etc.), and the transmission medium as well (i.e., the air). They all might add quite a bit of attenuation. The data rate and modulation add to the equation as well.
After all that, if the antenna is perfectly omnidirectional (i.e., it irradiates in all directions like a sphere), the signal power will be distributed in all directions as well, diminishing its power rapidly in proportion to distance and other factors. If your antenna is not omnidirectional, however, it may "concentrate" the irradiated power in a cone shape, for instance, where all the power that would otherwise have been transmitted in directions you don't need is directed to the direction the antenna is pointed to instead. In this way, without changing the transmitting power you can reach farther, at the expense of not reaching every direction. The most extreme case would be a very very directional antenna, where you can transmit almost all the power in one specific direction. This is a very delicate setup and you need to point the antenna very precisely, because a little deviation from the line of sight (a small wind, perhaps) might mean lossing your target entirely.
Antenna directionality is usually specified in "dBi", which is how it varies from the point of view of an ideal dipole antenna, which has a known gain shape. An 8 dBi figure tells you that a receiver aligned with the most gain direction of the transmitter would receive 8 dB more of signal than it would receive if you have used a dipole. Not much. Mind that a receiver NOT aligned with the most gain direction would receive far less signal than it would from a dipole. That's how antenna directionality works: it takes from one direction in order to give to another.
The receiver antenna works in the exact same way, but backwards: if it's directional it concentrates its sensitivity in one direction, but becomes "deaf" to the rest.
Long story short, most RF modules specify the line of sight capability of the module with the most expensive and very carefully set up antenna, in a very specific situation which not adheres to your specific scenario. Some of them might include application notes specifying how, where and when the measurements where taken (things like weather affect the transmission too!). You might be inclined to think that this is a rip-off, but consider this: they don't know anything about your usage case; they couldn't specify what would be your results. There is no "common" scenario per-se: reflections (as buildings, objects, etc.) greatly affect the results. So, the most "honest" value (although I concede, misleading) is perhaps an ideal line of sight value.
Look at this link budget calculator for an idea of what is involved in the calculation.


text:
Q: ListView items not showing tap animation When I first created my ListView, tapping an item made a nice gradient animation, but it doesn't show anymore for some reason, and I've made too many recent changes to tell what broke it. Is there something in my code that's overriding the animation or breaking it? I'm pretty stumped :/
ACTIVITY XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.nwoodthorpe.busstop.AddActivity">

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Select a Route"
        android:textColor="#ffffff"
        android:id="@+id/header"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:minHeight="60dp"
        android:gravity="center"
        android:textSize="25sp"
        android:background="@color/colorPrimary"
        android:layout_alignParentEnd="false"
        android:layout_alignParentRight="false"
        android:layout_centerHorizontal="true"
        android:typeface="normal"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="14dp"
        android:layout_marginLeft="28dp"
        android:adjustViewBounds="true"
        android:maxWidth="35dp"
        android:maxHeight="35dp"
        android:scaleType="fitCenter"
        android:src="@drawable/back"
        android:id="@+id/back"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="false"
        android:layout_alignParentStart="false"
        android:layout_alignParentLeft="true"
        android:clickable="true"
        />

    <View android:background="#000"
        android:layout_width="match_parent"
        android:layout_height="1px"
        android:layout_below="@id/header"
        android:id="@+id/div"/>
    <ListView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/list"
        android:layout_below="@+id/div"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentBottom="true"
        android:clickable="true"/>

</RelativeLayout>

ACTIVITY JAVA FILE
public class AddActivity extends AppCompatActivity {

    public void onBackClick(View v){
        finish();
    }

    public void setButtonListeners(){
        ImageView backButton = (ImageView)findViewById(R.id.back);
        backButton.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                onBackClick(v);
            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add);

        ArrayList<BusRoute> routes = UserValues.getInstance().stops;

        ArrayAdapter adapter = new AddListAdapter(this, 0, routes);

        // Link the data and our listview using the adapter.
        ListView listView = (ListView) findViewById(R.id.list);
        listView.setAdapter(adapter);

        setButtonListeners();
    }
}

ITEM XML FILE:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="60dp"
    android:gravity="center_vertical"
    android:minHeight="60dp"
    android:background="@color/background"
    android:clickable="true"
    >

    <TextView
        android:id="@+id/smallname"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_marginLeft="20dp"
        android:background="@drawable/circle"
        android:gravity="center"
        android:text="51A"
        android:textColor="@android:color/tab_indicator_text"
        android:textStyle="bold"
        android:layout_centerVertical="true"
        android:textSize="15sp"
        android:focusable="false"
        />

    <TextView android:id="@+id/longname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="85dp"
        android:layout_centerVertical="true"
        android:text="Name"
        android:textStyle="bold"
        android:textSize="14sp"
        android:focusable="false"/>

</RelativeLayout>

A: It's the material design. Since android 5.0, google show us the Material Design. The ListView is a part of it.
You can check if the device's version is android 5.0 or later. Also you can use some libraries like this one.
The animation is like this. Check the last section Z-axis motion.
You find the animation is gone because you set the background color. Try to remove the item's background.


text:
Q: Simple example on how to receive an AWS IOT topic on a Raspberry Pi I'm looking for a simple JavaScript example of how to receive messages from a topic. I'm trying to create a Build Cop using CodeBuild, Lambda, SNS, and finally, IoT. I've successfully published messages to the topic, but I can't for the life of me figure out what to do to receive the message.
The examples in the SDK are not well-documented (to me at least) and I can't figure out which import to use or why, and how to subscribe to a simple topic.
The code to send the message to the thing is the following. I'm sending it from a Lambda. The code is written in TypeScript, but I'm copying and pasting the transpiled JavaScript into the console since it does not seem to support TypeScript natively.
const params = {
  topic: 'topic/buildcop',
  payload: color,
  qos: 1
};

this.iotdata.publish(params, function(err, data){
  if(err){
    console.log(`error: ${err}`);
  }
  else{
    console.log("success?");
    //context.succeed(event);
  }
});

A: I'm not sure if this is what you meant, but here is an example on how to subscribe to a topic using the javascript sdk:
var awsIot = require('aws-iot-device-sdk');

//
// Replace the values of '<YourUniqueClientIdentifier>' and '<YourCustomEndpoint>'
// with a unique client identifier and custom host endpoint provided in AWS IoT.
// NOTE: client identifiers must be unique within your AWS account; if a client attempts
// to connect with a client identifier which is already in use, the existing
// connection will be terminated.
//
var device = awsIot.device({
   keyPath: <YourPrivateKeyPath>,
  certPath: <YourCertificatePath>,
    caPath: <YourRootCACertificatePath>,
  clientId: <YourUniqueClientIdentifier>,
      host: <YourCustomEndpoint>
});

//
// Device is an instance returned by mqtt.Client(), see mqtt.js for full
// documentation.
//
device
  .on('connect', function() {
    console.log('connect');
    device.subscribe('topic_1');
    device.publish('topic_2', JSON.stringify({ test_data: 1}));
  });

device
  .on('message', function(topic, payload) {
    console.log('message', topic, payload.toString());
  });

You can see more examples at here: https://github.com/aws/aws-iot-device-sdk-js#jobs


text:
Q: Retrieving Data from Databse with OOP and MySQL Function? I am building a small web tool to track all calls maked by callcenter agents. I would like to know, how to write the code in an effective way, so that changes can be done very easy later on. But since I am very new to OOP, I am struggling with this bit of code. What am I doing wrong?
 //DB Connection
class _GlobalFunctions {

  //Querys
  public function getfromDB($query_string) {
  global $mysqli;
  $mysqli->query("SET lc_time_names = 'de_DE'");
  if($query = $mysqli->query($query_string)) {
          return $query;
          } else {
        return 0;
        }
  }
}

//Tasks
class _Tasks extends _GlobalFunctions {

    public $overdue = "";
    public $open = "";
    public $done = "";

    private function OverdueTasks()
       {
          $query = getfromDB('SELECT * FROM tasks WHERE taskstst =0 AND  taskduedate < NOW() AND taskrspnsble ='.$_SESSION["user_id"]);
          if ($query){
              $this->overdue = (int)$query;
              }  else {
                  $this->overdue = 'n/a';
                  }

       }

       public function OpenTasks()
       {
           $query = 'SELECT * FROM tasks WHERE taskstst =0 AND  taskduedate > NOW() AND taskrspnsble ='.$_SESSION["user_id"];
            return $this->getfromDB($query);

       }
}

//Output
$tasks = new _Tasks;

if(!empty($tasks->overdue)) {
    echo  $tasks->overdue;
};


text:
Q: How to write simple test cases for testing a Login Api in android? I have been trying to write test cases for my APIS, all I have written so far is a unit test cases of a function email validation which is just for a sample.
What I actually want is stated as below -
I want to write an android test case for Login API that accepts email and password.
I have followed a lot of tutorials but every of link is saying to include a lot of dependencies like expresso,mockito etc.
So Isn't there any simpler process that I could integrate this directly into my pre-build Application.

A: To create test cases for a Login API (not a registration API), you only have to consider the possibility of your API returning success or failure. A user is either going to be providing a correct email and password, or an incorrect email and password and your api will respond accordingly.
To test, you could potentially create the following 4 test cases :

*

*Valid email, valid password

*Incorrect email, correct password (for the user associate to the password)

*Correct email, incorrect password

*Incorrect email, incorrect password.

Seeing as though you are not testing a registration API and you want to test the login api specifically as the question stated, there's no need to test whether or not the user enters valid data for email or password according to business logic.
As a brief example, you could do something like this :
@Test
public void testExampleWithCorrectValues() {
    String validEmail = "email";
    String validPassword = "password";

    boolean responseOfExecutingYourApiWithCorrectValues = how you get a response from the api

    Assert.assertEquals(true, responseOfExecutingYourApiWithCorrectValues);

}

@Test
public void testExampleWithIncorrectEmail() {
    String invalidEmail = "email1";
    String validPassword = "password";

    boolean responseOfExecutingYourApiWithIncorrectValues = how you get a response from the api

    Assert.assertEquals(false, responseOfExecutingYourApiWithIncorrectValues);

}

@Test
public void testExampleWithIncorrectPassword() {
    String validEmail = "email";
    String invalidPassword = "password1";

    boolean responseOfExecutingYourApiWithCorrectValues = how you get a response from the api

    Assert.assertEquals(false, responseOfExecutingYourApiWithCorrectValues);

}

@Test
public void testExampleWithIncorrectValues() {
    String invalidEmail = "email1";
    String invalidPassword = "password1";

    boolean responseOfExecutingYourApiWithIncorrectValues = how you get a response from the api
    Assert.assertEquals(false, responseOfExecutingYourApiWithIncorrectValues);
}

However, you have to note that your tests will then be hitting your actual API (making a service call) just to be ran and this is bad practice, that is why people tell you to use mockito and other frameworks to mock out your api call or responses


text:
Q: Cannot change dock widget padding I'm trying to create a QTabWidget contained within a QDockWidget with no padding so the tab widget reaches the edges of the QDockWidget.
You can see in the image below the problem. The QTabWidget on the right inside the layout clearly has no padding but the QTabWidget on the left inside the QDockWidget does.

This padding is there using all the default styles, cleanlooks, plastique and the OSX style.
I have tried adding the following qss to the QTabWidget, QDockWidget, QWidget, QMainWindow but the padding between the dock widget and the tab widget always remains!
padding: 0;
margin: 0;

Does anybody know what I need to do to remove this space.

A: I discovered that the cause of this is the main layout of the QtabWidget. There is no way to alter the padding in qss but you can alter it directly in QtDesigner or in the code. To do so edit the contents layout of the tab widget and change all layout margins to 0.
This can be done in QtDesigner here:


text:
Q: Slack polls with HTTP Response I'm trying to have my backend create a poll for a given user and when the user responds to the poll receive the response on the backend. However I cannot find a way to do the second part with an API available.
I know I can use Incoming Webhooks to send a command to users slackbot channel: /poll .. ... ... however I'm unsure how to receive a response from when user selects one of the options in the poll.

A: OK, one approach would be

*

*Slash command for the /pollcommand, it will send a request to your app every time a user enters the command

*Your app can then sends the actual message containing the poll details back to the channel incl. message menus simply by responding to the slash request or with Web API e.g. chat.PostMessage

*User chooses polls option from message menus. Chosen option is send back to your app by Slack.

This is just one approach. Alternatively you could also show the options as message buttons or open a Dialog for the user.
I would advise against using outgoing webhooks, since its no longer part of the main features (and slash commands and interactive menus will send a request directly to your app anyway). Also Web API / chat.PostMessage is better than Incoming webhooks.


text:
Q: How to upgrade SharePoint 2007 to 2010 A SharePoint solution consists of 2 parts:

*

*What is installed in production

*The solution in Visual Studio

The infrastructure consultants recommend running in the in place upgrade. But then what happens to the solution, and what happens next time you try and deploy the solution.
The dev consultants recommended upgrading the sollution, installing to new production environment and transfering contents.
Question is how to upgrade? Is one of these approaches better, or is there another way?

A: I'd expect that the product is ready for these type of changes. Meaning that the product is ready to expect that the manifest.xml of a solution can change because of newly added options with 2010. Also the changes of the feature.xml is, hopefully, supported.
So.. I'd recommend to go with the infrastructure recommendation when doing the upgrade of your environment.

A: Well, I would say there is no single best answer to your question. If you look for general answer then yes in-place approach might be better.
However it really depends on your situation. In case you are running your SharePoint on Windows 2003 32bit upgrading in-place on that platform is not recommended (you would have to upgrade Windows and everything else first). Even if you are running on Windows 2008 64bit now, you still need to check the HW reqs to see if you have good hardware for the new version.

A: At the time of my Ignite training it wasn't working like a charm yet. As you know, in VS 2010 there are now SharePoint templates. The conversion process does convert your VS 2008 project to a SharePoint 2010 project, but it's still a bit messy and you'll have to do come cleaning.
What does work though is just converting your project the oldschool way (like you convert normal dev projects) so that it can be opened with Visual Studio 2010. Then you will be able to convert your solution on your SharePoint 2010 environment.
Take into account that the UI will not be changed. So if you develop webparts they may look outdated.


text:
Q: displaying Oracle table's column names Is there a one-liner out there for this task? Note that I won't be using Oracle's SQL Plus.

A: This statement will select all the columns for a table, just replace 'TABLE_NAME' with the actual name of the table.  Keep in mind that the tables names are uppercase.
select utc.column_name
  from user_tab_columns utc
 where utc.TABLE_NAME = 'TABLE_NAME'
 order by utc.COLUMN_ID

A: SELECT COLUMN_NAME FROM USER_TAB_COLUMNS WHERE TABLE_NAME='TABLE_NAME'


text:
Q: react-three-fiber scene background brighter than original image My react-three-fiber background is supposed to be a dark starry sky. But in the scene it is very bright. Here is the original image:

This is the code for the skybox:
const { scene } = useThree();

const texture = useLoader(TextureLoader, "textures/skybox.jpg");

scene.background = texture;

This is what the scene rendered:

(Don't worry about the blurriness. It is just because I took a screen shot of such a small area of my screen.)
I am asking about the brightnessI asked in the Poimandres Discord server and one of the admins said that it may be an encoding error and to ask here.

Edit:
Thanks to Marquizzo for solving the issue. I just added texture.encoding = THREE.sRGBEncoding; and the background became this:

A: It might be an issue with your texture encoding property. By default textures use linear, but for a straight background JPG that doesn't interact with lighting you could use sRGB.
const texture = useLoader(TextureLoader, "textures/skybox.jpg");
texture.encoding = THREE.sRGBEncoding;
scene.background = texture;


text:
Q: R markdown with RGL gives "You must enable Javascript to view this page properly" error I have a downloadHandler() in Shiny that generates an html document using R markdown. This document generates rgl plots, which are added to the document using hook_webgl. The application is running on a Shiny server. Everything works fine the first time the download button is used, but on the following occasions I get the error "You must enable Javascript to view this page properly". I am using rglwidgets, but I get the same issues using shinyRGL.
> sessionInfo()
R version 3.2.4 Revised (2016-03-16 r70336)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.4 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] shiny_0.13.2       rmarkdown_0.9.5    knitr_1.12.3       rglwidget_0.1.1434
[5] rgl_0.95.1441

loaded via a namespace (and not attached):
 [1] htmlwidgets_0.6 magrittr_1.5    R6_2.1.2        tools_3.2.4
 [5] htmltools_0.3.5 Rcpp_0.12.4     jsonlite_0.9.19 digest_0.6.9
 [9] xtable_1.8-2    httpuv_1.3.3    mime_0.4


text:
Q: Save to cassandra in spark, parallelize method is not availble in java I am trying to save one row only to a cassandra table using spark in java (this comes as a result after long processing in spark), I am using the new method to connect to cassandra using spark session as follows:
     SparkSession spark = SparkSession
          .builder()
          .appName("App")
          .config("spark.cassandra.connection.host", "cassandra1.example.com")
          .config("spark.cassandra.connection.port", "9042")
          .master("spark://cassandra.example.com:7077")
          .getOrCreate();

The connection is successful and works well as I have Spark installed on the same nodes as cassandra, after reading some RDDs from cassandra I want to save to another table in cassandra, so I am following the documentation here, namely, the part to save to cassandra as follows:
List<Person> people = Arrays.asList(
    new Person(1, "John", new Date()),
    new Person(2, "Troy", new Date()),
    new Person(3, "Andrew", new Date())
);
JavaRDD<Person> rdd = spark.sparkContext().parallelize(people);
javaFunctions(rdd).writerBuilder("ks", "people", mapToRow(Person.class)).saveToCassandra();

The problem which I am facing is that parallelize method is not accepted, and only a scala version looks avaiable, the error is:
The method parallelize(Seq<T>, int, ClassTag<T>) in the type
SparkContext is not applicable for the arguments (List<Person>)

How can I use that in Java to save to cassandra table?

A: To parallelize java.util.List you can use JavaSparkContext (not SparkContext) , something like this:
import org.apache.spark.api.java.JavaSparkContext;

JavaSparkContext sc = new JavaSparkContext(spark.sparkContext());
sc.parallelize(people);


text:
Q: Destination Controller Showing without Navigation Bar This is driving me crazy! I am creating a segue from one of the UITableViewCells to another UITableViewController. A Navigation controller sits between them as shown in the screenshot below:

When I reach the Samples UITableViewController it appears without the NavigationBar as shown below:

Am I doing something wrong?

A: Your first UITableViewController is in a navigation controller too right ?
If not, it's normal, see this post.
If your first UITableViewController is in a navigation controller, I had the same problem, if you use the push segue (deprecated) it should resolve your problem.


text:
Q: Replacing HTML code with character entity I have String which contains HTML code like " & ' etc. I want to replace it with respective entity set like (" & ') in Java. I have tried following code.

if (StringUtils.isNotBlank(string)) {
    string = StringEscapeUtils.unescapeXml(string);
    string = StringEscapeUtils.unescapeHtml(string);
    string = string.replaceAll("<.*?>", "");
    string = string.trim();
}

Input String :
brief is a tie side, string style embellished with shimmering silver sequins.
Dangling gunmetal chain tassels decorate the end of each hip tie. Model&apos;s
Measurements   Height 5&apos;10.5&quot; Hips 36&#148; Waist 23.5&#148;
Model wears size 2

I am getting following output which contains BadEncoding:
brief is a tie side, string style embellished with shimmering silver
sequins. Dangling gunmetal chain tassels decorate the end of each hip tie. Model's
Measurements   Height 5'10.5" Hips 36<94> Waist 23.5<94> Bust 35<94> Model wears size 2

Required Output:
brief is a tie side, string style embellished with shimmering silver sequins.
Dangling gunmetal chain tassels decorate the end of each hip tie. Model's
Measurements   Height 5'10.5" Hips 36" Waist 23.5" Bust 35" Model wears size 2

Kindly suggest.

A: If your concern is just numeric character escapes, the number is a character number and can be used fairly directly by just converting it to an int and thence to a char. See http://www.w3.org/International/questions/qa-escapes


text:
Q: Duplicate generator name warning when using base entity in Spring Boot In a Java (Spring Boot + Spring Data JPA) app, use a basic entity and build the inheritance as shown below:
@MappedSuperclass
public abstract class CookBase extends BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cook_base_gen")
    private long id;

    // other fields
}

The following entities are inheriting from base entity:
@Entity
@SequenceGenerator(name = "cook_base_gen", sequenceName = "curb_side_id_seq", allocationSize = 1)
public class CurbSide extends CookBase {

    public CurbSide(@NotNull UUID groupUuid, @NotNull String name) {
        super(groupUuid, name);
    }
}

@Entity
@SequenceGenerator(name = "cook_base_gen", sequenceName = "room_id_seq", allocationSize = 1)
public class Room extends CookBase {

    public Room(@NotNull UUID groupUuid, @NotNull String name) {
        super(groupUuid, name);
    }
}

When running the app, I get the following warning on the console:

Duplicate generator name cook_base_gen
Duplicate generator name cook_base_gen

I think there may be a mistake regarding to the configuration of inheritance, but @SequenceGenerator(name = "cook_base_gen", sequenceName = "room_id_seq") seems ok I think. Any idea?


text:
Q: NetBeans: How to change the look and feel with respect to Operating System I developed a small desktop application in Netbeans using Java. The application is working as expected. I developed it under WIN7.
When i run it on Microsoft Windows, the look and feel of UI is similar to Win XP Metal theme and when i run it on MAC it shows me the same theme. I want to change that theme with respect to operating system. Right now the theme is ok for windows i am looking for solution on MAC.

A: try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}
catch(Exception e){}

A: If you're using Swing, then this should work:
try {
  UIManager.setLookAndFeel(
    UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}

A: Read the secton from the Swing tutorial on How to Set the Look and Feel for information about setting/changing the LAF.


text:
Q: Serve static assets with an efficient cache policy - Google PageSpeed Insights I am using OctoberCMS and I have apache server and using AWS and when I do PageSpeed testing https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fwww.rosterelf.com%2F&tab=desktop I am keep getting this errror saying

Serve static assets with an efficient cache policy

Here is my .htaccess file code to counter this error.
.htaccess
<IfModule mod_rewrite.c>

    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    <IfModule mod_headers.c>
        <If "%{REQUEST_SCHEME} == 'https' || %{HTTP:X-Forwarded-Proto} == 'https'">
            Header always set Strict-Transport-Security "max-age=31536000"
        </If>
    </IfModule>

    ### MY OTHER DEFAULT CODE OF OCTOBERCMS WHICH IS NOT RELATED TO COMPRESSION ETC ...

</IfModule>

# TN START GZIP COMPRESSION
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# TN END GZIP COMPRESSION

# TN START DEFLATE COMPRESSION
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/rdf+xml" \
"application/rss+xml" \
"application/schema+json" \
"application/vnd.geo+json" \
"application/vnd.ms-fontobject" \
"application/x-font" \
"application/x-font-opentype" \
"application/x-font-otf" \
"application/x-font-truetype" \
"application/x-font-ttf" \
"application/x-javascript" \
"application/x-web-app-manifest+json" \
"application/xhtml+xml" \
"application/xml" \
"font/eot" \
"font/otf" \
"font/ttf" \
"font/opentype" \
"image/bmp" \
"image/svg+xml" \
"image/vnd.microsoft.icon" \
"image/x-icon" \
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \
"text/vcard" \
"text/vnd.rim.location.xloc" \
"text/vtt" \
"text/x-component" \
"text/x-cross-domain-policy" \
"text/xml"
</IfModule>
# END DEFLATE COMPRESSION

# TN START ENABLE KEEP ALIVE
<ifModule mod_headers.c>
Header set Connection keep-alive

# WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=604800, public"
</FilesMatch>

# WEEK
<FilesMatch "\.(js|css|swf)$">
    Header set Cache-Control "max-age=604800"
</FilesMatch>

</ifModule>
# TN END ENABLE KEEP ALIVE

# TN - START EXPIRES CACHING #
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType image/svg "access 1 year"
ExpiresByType audio/ogg "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
ExpiresByType video/ogg "access plus 1 year"
ExpiresByType video/webm "access plus 1 year"
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/xhtml-xml "access 1 month"
ExpiresByType text/x-component "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"

# Fonts
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"

ExpiresDefault "access 1 month"
</IfModule>
# TN - END EXPIRES CACHING #

But still its keeping this error with 77 resources.
I have tried many things as you can see by adding so much code but yet error count not reducing and its keep getting .js, .png, .css files as well.
Can someone guide me what I am missing here in my code.
Thanks

Updated HTACCESS FILE
<IfModule mod_rewrite.c>

    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    <IfModule mod_headers.c>
        <If "%{REQUEST_SCHEME} == 'https' || %{HTTP:X-Forwarded-Proto} == 'https'">
            Header always set Strict-Transport-Security "max-age=31536000"
        </If>
    </IfModule>

    RewriteEngine On

    ##
    ## You may need to uncomment the following line for some hosting environments,
    ## if you have installed to a subdirectory, enter the name here also.
    ##
    # RewriteBase /

</IfModule>

# TN START GZIP COMPRESSION
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# TN END GZIP COMPRESSION

# TN START DEFLATE COMPRESSION
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/rdf+xml" \
"application/rss+xml" \
"application/schema+json" \
"application/vnd.geo+json" \
"application/vnd.ms-fontobject" \
"application/x-font" \
"application/x-font-opentype" \
"application/x-font-otf" \
"application/x-font-truetype" \
"application/x-font-ttf" \
"application/x-javascript" \
"application/x-web-app-manifest+json" \
"application/xhtml+xml" \
"application/xml" \
"font/eot" \
"font/otf" \
"font/ttf" \
"font/opentype" \
"image/bmp" \
"image/svg+xml" \
"image/vnd.microsoft.icon" \
"image/x-icon" \
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \
"text/vcard" \
"text/vnd.rim.location.xloc" \
"text/vtt" \
"text/x-component" \
"text/x-cross-domain-policy" \
"text/xml"
</IfModule>
# END DEFLATE COMPRESSION

# TN START ENABLE KEEP ALIVE
<IfModule mod_headers.c>
    Header set Connection keep-alive

</IfModule>
# TN END ENABLE KEEP ALIVE

# TN - START EXPIRES CACHING #
<IfModule mod_expires.c>
ExpiresActive On

ExpiresDefault "access plus 1 month"

ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 month"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType image/svg "access plus 1 year"
ExpiresByType audio/ogg "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
ExpiresByType video/ogg "access plus 1 year"
ExpiresByType video/webm "access plus 1 year"
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/xhtml-xml "access plus 1 month"
ExpiresByType text/x-component "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"

# Fonts
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"

  <IfModule mod_headers.c>
          Header append Cache-Control "public"
  </IfModule>

</IfModule>

<IfModule mod_headers.c>
  Header unset ETag
</IfModule>
FileETag None

<IfModule mod_headers.c>
  Header unset Last-Modified
</IfModule>

# TN - END EXPIRES CACHING #

A:
But still its keeping this error with 77 resources.

Bear in mind that some of these resources are on external domains for which you have no control.
As stated in the linked document from the PageSpeed results:

When possible, cache immutable static assets for a long time, such as a year or longer.

For one of your .jpg resources .../images/rosterelftechsupport.jpg which is reported by Google's pagespeed insights as being cached for "30 d" it has the following HTTP response headers:

cache-control: max-age=2592000, public
expires: Thu, 12 May 2022 16:05:33 GMT

Whilst the expires header states a cache time of 1 year, the max-age directive of the cache-control header states 30 days (2,592,000 seconds). All modern browsers will prioritise the cache-control: max-age header, so "30 days" is the cache time.

ExpiresByType image/jpeg "access 1 year"

This mod_expires directive sets both the expires and the cache-control: max-age headers on .jpg (mime-type: image/jpeg) files. So, this does seem to be honoured, since the expires header is set correctly and you aren't explicitly setting this anywhere else.

<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=604800, public"
</FilesMatch>

However, any Header set Cache-Control (mod_headers) directive, such as this, will override the Cache-Control header set by mod_expires and affect the cache time. So, it would seem you may still have a rogue Header directive?
You certainly don't need both. If you are using mod_expires then only use mod_expires. You do not need mod_headers for this. In other words, you should remove all <FilesMatch ...> Header set Cache-Control ... </FilesMatch> blocks (such as that above) since they are directly conflicting with the mod_expires directives (ie. ExpiresByType).
The only reason to use a mod_headers Header set Cache-Control ... directive is if mod_expires was not available on your server. The only reason to use both mod_expires and mod_headers here is if you are installing your application on multiple servers and it is expected that mod_expires is not installed on all servers (unlikely). In which case, the mod_headers directives should be enclosed inside a <IfModule !mod_expires.c> container (ie. "if mod_expires is not available"), otherwise mod_headers will always take priority (as mentioned above).
You need to make sure the browser and any intermediary proxy caches are clear before testing, since this resource has been cached for "30 days".

UPDATE:

I have removed FilesMatch from file and also checked in my "Private Window" of my browser and opened the website and then ran the "Pagespeed Insights" .. but its still showing around 56 resources not cached including png images etc.

All the .jpg and .png images served from your domain are no longer present in that report, so they would seem to be "resolved".
The remaining 8 .png images that are still showing in the report and have no Cache-Control or Expires headers are being served directly from s3-ap-southeast-2.amazonaws.com - which your directives are not necessarily going to influence. You may need to check the settings on your S3 bucket?

...config/176…?v=2.9.39&r=stable(connect.facebook.net)        20m

You have 7 resources served from external 3rd parties (such as this) which you have no control over.

...industries/nonprofit.svg(www.rosterelf.com)                30 d

ExpiresByType image/svg+xml "access plus 1 month"

You have 22 .svg images served from your domain. These are all served with a image/svg+xml content-type. As you can see from the above ExpiresByType directive these are "only" set to be cached for a period of "1 month" (ie. 30 days). If you want these to be cached for a longer period then change the above directive as you have already done for JPEG and PNG files.

...js/swiper-bundle.min.js(www.rosterelf.com)                 30 d

ExpiresByType application/javascript "access plus 1 month"

You have 11 .js files served from your domain - all served with an application/javascript content-type. Change the above ExpiresByType directive accordingly if you want these files to be cached for longer.
HOWEVER, you should note that Google's PageSpeed report is only a "suggestion". Only change this (and other caching directives) if it makes sense for your system. You will have issues if these files need to be changed before the cache expires unless you have implemented some other cache-busting technique.
This also means that the following directives are entirely superfluous and can be removed:

ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"

Your server is sending .js responses with the correct application/javascript mime-type, so setting caching directives for text/javascript and text/x-javascript as well is not required.

...css/custom.min.css(www.rosterelf.com)                     30 d

ExpiresByType text/css "access plus 1 month"

You have 6 .css files served from your domain. The same applies above as for .js files.

... fonts/social-media-icon.ttf?lvmhu5(www.rosterelf.com)    30 d

You have 6 .ttf (font) files. Yes, these should certainly be cached for a longer period. These are all served with an application/font-sfnt*1 mime/content-type. However, you do not explicitly have a directive that covers this, so it will default to the ExpiresDefault (ie. 1 month). You need to add the appropriate directive for this mime-type. For example:
ExpiresByType application/font-sfnt "access plus 1 year"

(*1 application/font-sfnt is actually deprecated in favour of font/sfnt.)
This might mean that all the following (font-caching) directives are superfluous, if you are not serving these file-types?

ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"

# Fonts
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"

And to emphasise my comment above... the results from Google's PageSpeed report (and any other SEO report) are only advisory... a possible suggestion. It is not necessarily "wrong" to serve resources with a shorter cache time. These "suggestions" are not meant to be followed blindly. Do not implement long cache times to simply satisfy the report. Only if it makes sense to your application should these resources be cached for longer periods.


text:
Q: Can someone give intuition behind understanding $i^i = e^{\frac{-\pi}{2}}$ and more so on complex powers? I have no problem accepting that $$i^i = e^{\frac{-\pi}{2}} $$ Here im assuming that $-\pi\leq \theta \leq \pi$
But what I am wondering is that, can someone give me some intuition behind understanding taking powers of a complex number where the power is also complex ? Like I am curious what you used to get an understanding of this property ? I chose $i^i$ because it seems like an easy example to give intuition behind but I am also looking at this from the point of view of also trying to understand say: $$(4+5i)^{(2-3i)}$$ Like how do you get an intuitive understanding of this ?

A: To calculate $z^u=(4+5i)^{2-3i}$ you have to use three formulas

*

*convert $z=(4+5i)$ from rectangular form to polar form $z=re^{i\theta}$

*calculate $\ln(z)=\ln(r)+i\theta+2ik\pi\qquad k\in\mathbb Z$

*calculate $\displaystyle z^u=e^{u\ln(z)}$

Let's go:
$r^2=|z|^2=4^2+5^2=41\implies r=\sqrt{41}$
Since $z$ is in the first quadrant then $\theta=\tan^{-1}(\frac 54)$
$\begin{array}{ll}z^u &=\exp\bigg((2-3i)\left(\ln(r)+i\theta+2ik\pi\right)\bigg)\\&=\exp\bigg(\left(2\ln(r)+3\theta+6k\pi\right)+i\left(-3\ln(r)+2\theta+4k\pi\right)\bigg)\\ &=r^2\ e^{3\theta}\ e^{6k\pi}\bigg(\cos\big(2\theta-3\ln(r)\big)+i\sin\big(2\theta-3\ln(r)\big)\bigg) \end{array}$
And from there you can calculate a numerical value by replacing $r,\theta$ by their respective value:

$(4+5i)^{2-3i}\approx e^{6k\pi}\left(-484.77 + 358.42\,i\right)$

Note that $\ln(z)$ is multivalued since it is the reciprocal function of exponential which is $2i\pi$ periodic.
So in the end you get a factor $e^{6k\pi}$ and a principal value $[z^u]_{k=0}=-484.77+358.42i$

You need to keep this factor for things like $z^u\times z^v=z^{u+v}$ to stay true.
If you only consider the principal value then $[z^u]_{k=0}\times[z^v]_{k=0}=[z^{u+v}]_{k=0}$ may be false.
You have to see it like $\exists (k_1,k_2,k_3)\in\mathbb Z^3\mid\  [z^u]_{k=k_1}\times [z^v]_{k=k_2}=[z^{u+v}]_{k=k_3}$

Now that you understood the principle, let's do it for $i^i$ :
$\displaystyle i^i=\exp\bigg(i\ln(e^{i\frac{\pi}2})\bigg)=\exp\bigg(i(\ln(1)+i\frac{\pi}2+2ik\pi)\bigg)=\exp\bigg(-\frac{\pi}2-2k\pi\bigg)=e^{-\frac{\pi}2}e^{-2k\pi}$
So the principal value is $[i^i]_{k=0}=e^{-\frac{\pi}2}$ and the factor is $e^{2k\pi}$
[note that since $k$ is arbitrary, $2k\pi$ or $-2k\pi$ does not matter].

To conclude let's calculate $i^2$. Should it also have multiple values ?
$\displaystyle i^2=\exp\bigg(2\ln(e^{i\frac{\pi}2})\bigg)=\exp\bigg(2(\ln(1)+i\frac{\pi}2+2ik\pi)\bigg)=\exp\bigg(i\pi-2ik\pi\bigg)=\underbrace{e^{i\pi}}_{-1}\underbrace{e^{2ik\pi}}_{1}=-1$
This time it has only one value as expected $i^2=-1$, because the factor $e^{2ik\pi}=1$ for any value of $k$.

A: I am afraid that the  intuition you ask for gets lost somewhere on the way.
We may start by defining $$ \tag 1a^b:=\underbrace{a\cdot \ldots \cdot a}_b$$
for $b\in \Bbb N$ (or maybe define $a^b$ as the cardinality of the set of maps from a set of cardinality $b$ to a set of cardinality $a$, which allows us to use some infinite $b$-values, but poses a restriction on the $a$'s used; for this discussion. I'll stick with $(1)$ as a starting point) and then extend the definition step by step to larger domains, based on a permanence principle: For $(1)$ we prove rules such as $$\tag2a^{b+c}=a^ba^c$$ and extend the definition in  a way that (among others) these rules remain valid. For example, this forces us to define $a^{-b}=\frac1{a^b}$ when extending to $b\in\Bbb Z$ (and which also shows that we cannot define $0^b$ for $b<0$).
Sooner or late, the only way of extending the domain is via the exponential function
$$\exp(x)=\sum_{k=0}^\infty\frac{x^k}{k!} $$
which is fortunately convergent for all $c\in\Bbb C$ (and even in many situations where $x$ is not even a number, thus allowing us to define exponentiation even in some at the first glance strange areas).
Among the many fascinating properties of $\exp$ is
$$\exp(x+y)=\exp( x)\exp (y),$$
just as needed for $(2)$.
But that requires us to use the inverse function $\ln$ and set
$$\tag3a^b=\exp(b\ln a).$$
This is all fine, but $\ln a$ cannot be defined at for at $a=0$ (thus we better still use $(1)$ instead of $(3)$ in that case) and $\ln$ can only be defined "consistently" in a simply connected domain (not containing $0$). The most common convention(!) to pick  such a domain as large as possible is to remove the non-positive reals from $\Bbb C$. That is, for all other $z$, $\ln z$ is a complex number $w$ with $\exp(w)=z$ and $-\pi<\arg w<\pi$. As $\exp$ is its own derivative, we quickly find that $\exp''(ix)+\exp(ix)=0$ and by comparing the initial conditions, find $\exp(ix)=\cos(x)+i\sin(x)$. Hence $\exp(i\frac\pi2)=i$, so that our chosen convention tells us $\ln(i)=i\frac\pi2$ and ultimately $$ i^i=\exp(i\cdot i\tfrac\pi2)=\exp(-\tfrac\pi2).$$
I think it is the forced use of some convention when picking a good domain in $\Bbb C$ which ultimately kills the intuition you are looking for.
Note that I consequently wrote $\exp(x)$, not $e^x$ in order to avoid the idea that the exponential function "is" taking some number dubbed $e$ to some power.


text:
Q: Align div right in Bootstrap 3 Is there a way in Bootstrap 3 to right align a div?
I am aware of the offsetting possibilitys but I want to align a formatted div to the right of its container while it should be centered in a fullwidth mobile view. The class 'pull-right' is not working anymore. Did they forgot to replace it or am I missing something obvious?

      left content

right content

Shure I know how to do this in CSS, but can it be done in pure bootstrap 3?

A: The class pull-right is still there in Bootstrap 3
See the 'helper classes' here
pull-right is defined by
.pull-right {
  float: right !important;
}

without more info on styles and content, it's difficult to say.
It definitely pulls right in this JSBIN
when the page is wider than 990px - which is when the col-md styling kicks in,
Bootstrap 3 being mobile first and all.
Bootstrap 4
Note that for Bootstrap 4 .pull-right has been replaced with .float-right
https://www.geeksforgeeks.org/pull-left-and-pull-right-classes-in-bootstrap-4/#:~:text=pull%2Dright%20classes%20have%20been,based%20on%20the%20Bootstrap%20Grid.

A: i think you try to align the content to the right within the div, the div with offset already push itself to the right, here some code and LIVE sample:
FYI: .pull-right only push the div to the right, but not the content inside the div.
HTML:

      left content

right content

CSS:
.someclass{ /*this class for testing purpose only*/
    border:1px solid blue;
    line-height:2em;
}

.totheright{ /*this will align the text to the right*/
  text-align:right;
}

.yellow_background{
    background-color:yellow;
}

Another modification:
...

  right content

image also align-right

...

hope it will clear your problem

A: Do you mean something like this:
HTML

      left content

        text

right content

CSS
.yellow-background {
  background: blue;
}

.pull-right {
  background: yellow;
}

A full example can be found on Codepen.

A: Bootstrap 4+ has made changes to the utility classes for this. From the documentation:

Added .float-{sm,md,lg,xl}-{left,right,none} classes for responsive floats and removed .pull-left and .pull-right since they're redundant to .float-left and .float-right.

So use the .float-right (or a size equivalent such as .float-lg-right) instead of .pull-right for your right alignment if you're using a newer Bootstrap version.

A: Add offset8 to your class, for example:

aligns to the right


text:
Q: IOS: handle nsstring I have two problem:
first:
I have a NSSTring as @"abcdef\n" , I want to delete from this string "\n", how can I do?
second:
if I have a string as @"abcdef    \n", I don't know how is long space, but I want only text of this nsstring
thanks

A: [@"abcdef\n" stringByReplacingOccurrencesOfString:@"\n" withString:@""];
[@"abcdef \n" stringByReplacingOccurrencesOfString:@" " withString:@""];
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html

A: Just replace all occurrences of \n with empty string like this:
myString = [myString stringByReplacingOccurrencesOfString:@"\n" withString:@""];