text:
Q: How to check if a stream is empty at the current moment in time in Rust? Suppose I have a type implementing Stream (I'm using async-tungstenite for context). Everything works (yay!), except my tests (boo! – I suppose that also means that not everything works).
I create a stream:
let (ws_stream_3, _) = connect_async(ws_addr).await.expect("Failed to connect");
let (mut write_3, mut read_3) = ws_stream_3.split();

Later on in the program I'd like to check that this stream has not had any messages sent to it. My first thought was:
assert!(read_3.next().await.is_none());

(it was a very brief thought – not for the program though, which runs forever like this - a good sign that no message is being received, but not very helpful for a unit test).
Is there a way to check if there are items in the stream right now (rather than waiting for the next one to arrive, which doesn't work because I want to make sure that it doesn't arrive).
I was able to fix this for this case by just using select! on that future (and a sleep of n seconds), but I think my intuitions are wrong here.
Is there a better way to do this?

A: You can call now_or_never on the next element, which will evaluate and consume the future immediately, rather than waiting for a result:
use futures::FutureExt;

assert!(read_3.next().now_or_never().is_none());


text:
Q: Some algebraic inequalities with the binomial theorem. I am working on proving the following limits.

1), $\lim_{n \to \infty}  \sqrt[n]{n} = 1$
2), If $p >0$ and $\alpha \in \Bbb R$, then $\lim_{n \to \infty} {n^{\alpha}\over{(1+p)^n}} =0$

And I am trying to follow the proof but I am stuck on understanding the following inequalities regarding the binomial theorem.
Put $x_n = \sqrt[n]{n} -1$. then $$n = (1+x_n)^n \ge {n(n-1) \over 2}x_n^2 $$
I understand that the right side of the inequality probably comes from $$1 + nx_n + {n \choose 2}x_n^2 + ・・・+x_n^n$$
and taking all the terms after ${n \choose 2}x_n^2$.
But to know this I think that $x_n^k$ has to be greater than $x_n^2$ for $k > 2$, am I right?
Since we can only say that $x_n > 0$, I'm a little puzzled.
For the second one,$$(1+p)^n > {n \choose k}p^k = {n(n-1)・・・(n-k+1) \over {k!}}p^k > {n^kp^k \over {2^k k!}}$$
is supposedly true when $n > 2k$.
I understand the left three expressions, but how does the right side of the inequality work ?

A: The first confusion is just a misunderstanding. If you have $A=B+C$ with $B,C$ greater than $0$, then no matter what happens to $B,C$'s relationship, $A>B$ is always true.
For the second one all you need to show is $(n-k+1)\ge \frac{n}{2}$ if $n\ge 2k$. But this should be clear to you via some algebraic manipulations.

A: For the first one: since it is true that $\,\sqrt[n] n\ge 1\;\;\forall\,n\in\Bbb N\,$ (why?) , we can write
$$\sqrt[n] n=1+c_n\;,\;\;0\le c_n\in \Bbb R\implies $$
$$\implies n=(1+c_n)^n=\sum_{k=0}^n\binom nkc^k_n\ge\binom n2c_n^2=\frac{n(n-1)}2c_n^2\implies$$
$$\implies 0\le c_n\le\sqrt{\frac2{n-1}}\xrightarrow[n\to\infty]{}0$$
The squeeze theorem then gives
$$c_n\xrightarrow[n\to\infty]{}0\implies \sqrt[n]n=1+c_n\xrightarrow[n\to\infty]{}1$$

redpajama_set_name: RedPajamaStackExchange


text:
Q: Computer won't boot, hard drive not recognized I have a Dell Dimension E310 which has crashed. When I turn it on it gives me two options:
F2 (System Setup)
F12 (Boot from USB, CD-ROM, Floppy, Hard Drive, NIC)

I have a Dell Resource CD and a Windows XP setup CD. I tried running some diagnostic test using the Resource CD, and they all passed except the drive related ones.
When I try to repair or install Windows, the partition is not recognized because there is no drive assigned. The drive appears as "unknown" and I get the following error:

An error has occurred while setup was updating partition information on:
  476938 MB Disk 0 at ID 0 on bus 0 on atapi [MBR].
  Setup cannot continue. To quit setup, press F3.

My only option from here on is to press F3 to quit, reboot and go to the command screen "recovery console" which requires and advices to setup with guidance and help of a Dell certified technician.
I tried to contact Dell support to guide me with command prompts and repair the disk, and they provided me the some information which seems obsolete now.
What steps do I need to take from here onwards to get this computer operational?
System info

System Dell DV051
BIOS version A04 (04/04/06)
Processor info:

*

*Type Intel (R) Pentium (R) 4 CPU 2.80 GHz

*Clock speed 2.80 GHz

*Bus speed 800 MHz

*L2 cache 1 MB

*ID 0f49

*Hyperthreading Yes

*64-bit tech Yes (Intel EM64T)

  Memory info:

*

*Installed 512 MB

*Speed 533 MHz

*Channel mode Single

*Technology DDR2 SDRAM

  Drives

*

*Diskette drive

*Drive 0 SATA-0

*Drive 1 SATA-2

*Drive 2 PATA-0

*Drive 3 PATA-1

A: Boot from the Ultimate Boot Disk and run the various HDD diagnostics (and anything else that takes your fancy).
If you get any sign of life from Disk 0 (which appears to be the problem) post back. I assume that this disk is borked, in which case, you'll need to buy another or install Windows on one of the other three disks.
PS. You've got a P4 (circa 2005/2006) - it isn't surprising that a disk has packed in after 9 years - perhaps time to upgrade?


text:
Q: mysql get query by named variable I have created a new mysql table, i want to get the values by named variable.
in the below code select * from test where name := animalname; fails to run in mysql workbench. Do advise. thank you so much
CREATE TABLE test (
id INT AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);

insert into test(name) values ('bat');
insert into test(name) values ('cat');
insert into test(name) values ('rat');

SET @animalname := 'cat';
select * from test where name := animalname;

A: select * from test where name = @animalname;

:= actually sets a variable. You want to compare in your SELECT so use =.
And you missed the @


text:
Q: ASP.Net Treeview CSS not working I am trying to change the CSS style and color of the Treeview nodes in ASP.Net web page.  I can change the font-size but I couldn't manage to change the color of the nodes.  Could you please help me?
<style type="text/css">
    .treeNode {
        color: #070707;
        font: 14px Arial, Sans-Serif;
    }

    .rootNode {
        font-size: 18px;
        width: 100%;
        color: #f00;
    }

    .leafNode {
        padding: 4px;
        color: #070707;
    }

    .selectNode {
        font-weight: bold;
    }
</style>

<asp:TreeView ID="tvData" runat="server" OnSelectedNodeChanged="tvData_SelectedNodeChanged" ShowLines="True">
    <LeafNodeStyle CssClass="leafNode" />
    <NodeStyle CssClass="treeNode" />
    <RootNodeStyle CssClass="rootNode" />
    <SelectedNodeStyle CssClass="selectNode" />
    <Nodes>
        <asp:TreeNode Text="Root" Value="0">
            <asp:TreeNode Text="Products">
                <asp:TreeNode Text="First Product" />
                <asp:TreeNode Text="Second Product" />
            </asp:TreeNode>
        </asp:TreeNode>
    </Nodes>
</asp:TreeView>

A: apply this bit of css and you will get an idea.
<style type="text/css">
    .treeNode
    {
        color: #070707;
        font: 14px Arial, Sans-Serif;
    }

    .rootNode
    {
        font-size: 18px;
        padding:5px;
        color: red;
        background-color:#DDD;
        border-radius:10px;
    }

    .leafNode
    {
        padding: 4px;
        color: #070707;
        background-color:Silver;
    }

    .selectNode
    {
        font-weight: bold;
        background-color:Black;
        color:White;
        border-radius:5px;
    }
</style>

thank you


text:
Q: What is $\frac{\partial^2(g\circ f)}{\partial x_i \partial x_j}(c)$ If $f:A\to \mathbb R^k$ and $g:B\to \mathbb R$ are two functions of class $C^2$ and their composition is well defined.
For $c \in A$ what is $$\frac{\partial^2(g\circ f)}{\partial x_i \partial x_j}(c)$$
Is it just $$\frac{\partial^2(g\circ f)}{\partial x_i \partial x_j}(c)=\frac{\partial^2g}{\partial x_i \partial x_j}(f(c))\frac{\partial^2f}{\partial x_i \partial x_j}(c)
$$
If it is how to prove it.
I get from
$$\frac{\partial^2(g\circ f)}{\partial x_i \partial x_j}(c)=\frac{\partial}{\partial x_i}\frac{\partial(g\circ f)}{ \partial x_j}(c)=\frac{\partial}{\partial x_i}\left( \frac{\partial g}{ \partial x_j}(f(c))\frac{\partial f}{\partial x_j}(c)\right)$$
but not sure how to calculate this, is this a product rule?

A: We consider open sets  $A\subseteq \mathbb{R}^n$,  $B\subseteq \mathbb{R}^k$ and  $C^2$  functions  $f$ and  $g$
\begin{align*}
&f:A\subseteq      \mathbb{R}^n\to\mathbb{R}^k\\
&g:B\subseteq  f(A)\to\mathbb{R}
\end{align*}
We have real-valued functions
\begin{align*}
&f_1\left(x_1,\ldots,x_n\right),\ldots,f_k\left(x_1,\ldots,x_n\right)\\
&g\left(f_1,\ldots,f_k\right)
\end{align*}
and obtain
\begin{align*}
\frac{\partial\left(g\circ f\right)}{\partial x_j}
&=\frac{\partial g}{\partial  f_1}\,\frac{\partial f_1}{\partial  x_j}
+\frac{\partial g}{\partial  f_2}\,\frac{\partial f_2}{\partial  x_j}+\cdots+\frac{\partial g}{\partial  f_k}\,\frac{\partial f_k}{\partial  x_j}\\
&=\sum_{q=1}^k\frac{\partial g}{\partial f_q}\frac{\partial f_q}{\partial x_j}\tag{1}
\end{align*}
More verbose we can write (1) as
\begin{align*}
\frac{\partial\left(g\circ f\right)}{\partial x_j}\left(x_1,\ldots,x_n\right)
&=\sum_{q=1}^k\frac{\partial g}{\partial f_q}\left(f_1\left(x_1,\ldots,x_n\right),\ldots,f_k\left(x_1,\ldots,x_n\right)\right)\cdot\frac{\partial f_q}{\partial x_j}\left(x_1,\ldots,x_n\right)
\end{align*}

We calculate from (1) the second partial  derivative:
\begin{align*}
\color{blue}{\frac{\partial^2\left(g\circ  f\right)}{\partial  x_i\,\partial x_j}}
&=\frac{\partial  }{\partial x_i}\left(\frac{\partial\left(g\circ f\right)}{\partial x_j}\right)\\
&=\frac{\partial  }{\partial x_i}\left(\sum_{q=1}^k\frac{\partial g}{\partial f_q}\frac{\partial f_q}{\partial x_j}\right)\tag{2}\\
&=\sum_{q=1}^k\frac{\partial  }{\partial x_i}\left(\frac{\partial g}{\partial f_q}\frac{\partial f_q}{\partial x_j}\right)\\
&=\sum_{q=1}^k\left[\left(\frac{\partial }{\partial  x_i}\left(\frac{\partial  g}{\partial  f_q}\right)\right)\frac{\partial  f_q}{\partial x_j}
+\frac{\partial  g}{\partial  f_q}\frac{\partial}{\partial   x_i}\left(\frac{  \partial f_q}{\partial  x_j}\right)\right]\tag{3}\\
&=\sum_{q=1}^k\left(\frac{\partial^2  g}{\partial f_1\partial  f_q}\frac{\partial f_1}{\partial x_i}
+\cdots+\frac{\partial^2  g}{\partial f_k\partial  f_q}\frac{\partial f_k}{\partial x_i}\right)
\frac{\partial  f_q}{\partial x_j}
+\sum_{q=1}^k\frac{\partial g}{\partial f_q}\frac{\partial ^2 f_q}{\partial  x_i\partial x_j}\tag{4}\\
&\,\,\color{blue}{=\sum_{q=1}^k\sum_{r=1}^k\frac{\partial^2 g}{\partial f_r\partial f_q}
\frac{\partial f_r}{\partial x_i}\frac{\partial  f_q}{\partial  x_i}
+\sum_{q=1}^k\frac{\partial g}{\partial f_q}\frac{\partial ^2 f_q}{\partial  x_i\partial x_j}}
\end{align*}

Comment:

*

*In (2) we apply (1).

*In (3) we apply the product  rule for partial derivatives.

*In (4)  we  apply  the chain rule for partial derivatives according to (1).

A: Edit this is what I got from 1 day of thought :D
$f : A \to B, g: B \to \mathbb R^m, A\subseteq \mathbb R^n, B\subseteq \mathbb R^k$
$
\begin{aligned}\frac{\partial^2(g\circ f)}{\partial x_i\partial x_j}(x)
&=\frac{\partial}{\partial x_i}\left(\frac{\partial(g\circ f)}{\partial x_j}(x)\right) \\&=\frac{\partial}{\partial x_i}\left(\nabla (g\circ f)(x)e_j \right) \\&=\frac{\partial}{\partial x_i}\left(\nabla g(f(x))\nabla f(x)e_j) \right)
\\&=\frac{\partial}{\partial x_i}\left(\nabla g(f(x)) \frac{\partial f}{\partial x_j}(x) \right)\\&
=\frac{\partial}{\partial x_i}\left(\sum_{p=1}^k  \frac{\partial g}{\partial x_p}(f(x))\frac{\partial f_p}{\partial x_j}(x)\right)
\\&=\sum_{p=1}^k\frac{\partial}{\partial x_i}\left(\frac{\partial g}{\partial x_p}(f(x))\frac{\partial f_p}{\partial x_j}(x) \right)\\
&=\sum_{p=1}^k\left[ \frac{\partial}{\partial x_i}\left(\frac{\partial g}{\partial x_p}(f(x)) \right)\frac{\partial f_p}{\partial x_j}(x)+\frac{\partial g}{\partial x_p}(f(x)) \frac{\partial^2f_p}{\partial x_i\partial x_j}(x) \right]\\
&= \sum_{p=1}^k \frac{\partial}{\partial x_i}\left(\frac{\partial g}{\partial x_p}(f(x)) \right)\frac{\partial f_p}{\partial x_j}(x)+ \sum_{p=1}^k \frac{\partial g}{\partial x_p}(f(x)) \frac{\partial^2f_p}{\partial x_i\partial x_j}(x)\\
&=\sum_{p=1}^k\sum_{l=1}^k\frac{\partial^2g}{\partial x_l\partial x_p}(f(x))\frac{\partial f_l}{\partial x_i}(x)\frac{\partial f_p}{\partial x_j}(x)+\sum_{p=1}^k \frac{\partial g}{\partial x_p}(f(x)) \frac{\partial^2f_p}{\partial x_i\partial x_j}(x)\end{aligned}
$
Also from this we get
$\begin{aligned}D^2(g\circ f)(x)(h,k)&=\sum_{i=1}^n\sum_{j=1}^n\frac{\partial^2(g\circ f)}{\partial x_i\partial x_j}(x) h_ik_j\\
&=\sum_{i=1}^n\sum_{j=1}^n\left(\sum_{p=1}^k\sum_{l=1}^k\frac{\partial^2g}{\partial x_l\partial x_p}(f(x))\frac{\partial f_l}{\partial x_i}(x)\frac{\partial f_p}{\partial x_j}(x)+\sum_{p=1}^k \frac{\partial g}{\partial x_p}(f(x)) \frac{\partial^2f_p}{\partial x_i\partial x_j}(x) \right)h_ik_j\\
\\&=\sum_{i=1}^n\sum_{j=1}^n\left(\sum_{p=1}^k\sum_{l=1}^k\frac{\partial^2g}{\partial x_l\partial x_p}(f(x))\frac{\partial f_l}{\partial x_i}(x)h_i\frac{\partial f_p}{\partial x_j}(x)k_j\right)\\+ \sum_{i=1}^n\sum_{j=1}^n\left(\sum_{p=1}^k \frac{\partial g}{\partial x_p}(f(x)) \frac{\partial^2f_p}{\partial x_i\partial x_j}(x)h_ik_j \right)\\
\\&=\sum_{p=1}^k\sum_{l=1}^k\frac{\partial^2g}{\partial x_l\partial x_p}(f(x))\left(\sum_{l=1}^n\frac{\partial f_l}{\partial x_i}(x)h_i\right)\left(\sum_{p=1}^n\frac{\partial f_p}{\partial x_j}(x)k_j \right)\\
+\sum_{p=1}^k \frac{\partial g}{\partial x_p}(f(x))\left(\sum_{i=1}^n\sum_{j=1}^n \frac{\partial^2f_p}{\partial x_i\partial x_j}(x)h_ik_j\right)\\
&=\sum_{p=1}^k\sum_{l=1}^k\frac{\partial^2g}{\partial x_l\partial x_p}(f(x))(Df_l(x)h)(Df_p(x)k)\\+\sum_{p=1}^k \frac{\partial g}{\partial x_p}(f(x))D^2f_p(x)(h,k)\\&
=\sum_{p=1}^k\sum_{l=1}^k\frac{\partial^2g}{\partial x_l\partial x_p}(f(x))(Df(x)h)_l(Df(x)k)_p\\+\sum_{p=1}^k \frac{\partial g}{\partial x_p}(f(x))\left(D^2f(x)(h,k)\right)_p\\&=D^2g(f(x))(Df(x)h,Dg(x)k)+Dg(f(x))(D^2f(x)(h,k))
\end{aligned}$
That is  we get
$$D^2(g\circ f)(x)(h,k)=D^2g(f(x))(Df(x)h,Dg(x)k)+Dg(f(x))(D^2f(x)(h,k))$$


text:
Q: How do I make a persistent live USB of Ubuntu 16.04? I need the persistent live Ubuntu of preferably 16.04 because I need to rescue my whole encrypted HDD of 16.04 as discussed in the thread How do I add myself back in sudo group in Encrypted HDD of 16.04?
I create here a new persistent Live Ubuntu 16.04 with some bugs described at the end with Videonauth.

*

*sudo apt-get install gksu debootstrap

*gksudo gparted. Make USB with ext4 leaving only 1GB as free memory, and set 1GB for Linux Swap; Manage flags > only boot.

*Prepare the OS by and run in the USB stick
sudo mkdir /mnt/stick
sudo mount /dev/sdb1 /mnt/stick/
sudo debootstrap --arch=amd64 xenial /mnt/stick http://de.archive.ubuntu.com/ubuntu/
sudo mount -o bind /dev /mnt/stick/dev
sudo mount -o bind /dev/pts /mnt/stick/dev/pts
sudo mount -t sysfs /sys /mnt/stick/sys
sudo mount -t proc /proc /mnt/stick/proc
sudo cp /proc/mounts /mnt/stick/etc/mtab
sudo cp /etc/resolv.conf /mnt/stick/etc/resolv.conf
sudo chroot /mnt/stick/

*Prompt looks like root@masi-CM6340:/#. Set locales.
%locale-gen en_US en_US.UTF-8
%dpkg-reconfigure locale
dpkg-rekonfigure locales % two above commands cause a bug in gnome-terminal; choose here your locales and set environment en_US.UTF-8
dpkg-reconfigure keyboard-configuration
localedef -i en_US -c -f UTF-8 en_US.UTF-8

*apt-get install linux-image-generic. You get /dev/sda [NotThisOne, your HDD], 2 /dev/sdb (31474 MB; ???) 2b - /dev/sdb1 (30398 MB; /). Choose /dev/sdb1 and /dev/sdb. Choese here Linux kernel what you like. I keep Linux kernel 4.6 most stable which you can download as described at the end of the body.

*apt-get install vim wget

*blkid, copy to clipboard, vim /etc/fstab. Remove sda lines so only two sdb lines. Edit them to like UUID="..." swap swap defaulst 0 0 and UUID="..." / ext4 defaults 0 1.

*Paste the following to the file /etc/apt/sources.list
#deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://de.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://de.archive.ubuntu.com/ubuntu/ xenial universe
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial universe
deb http://de.archive.ubuntu.com/ubuntu/ xenial-updates universe
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://de.archive.ubuntu.com/ubuntu/ xenial multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://de.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://de.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner

deb http://security.ubuntu.com/ubuntu xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse

*Do
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl
apt-get update
% Comment this out if ubuntu-desktop is wanted
apt-get install ubuntu-desktop
% Comment out if ubuntu-server is wanted
% apt-get install ubuntu-server
adduser --home /home/masi masi

*Add masi to the existing groups usermod -aG adm,cdrom,sudo,dip,plugdev,lpadmin,sambashare masi where you can leave out sambashare.

*Ignore drivers because USB stick not made for one PC.

*For recovering the encrypted HDD, install the packages apt-get ecryptfs-utils schroot testdisk where testdisk for preparing discs and the other two for recovering the whole disc encrypted Ubuntu 16.04.

*sudo echo 'GRUB_DISABLE_OS_PROBER="true"' >> /etc/default/grub; update-grub

*Finalize the install. Do
rm /sbin/initctl
dpkg-divert --local --rename --remove /sbin/initctl

Test your Installation of Persistent Live Ubuntu 16.04 [alpha]

*

*Start your new Persistent Ubuntu. In terminal, do sudo true. If you get Unable to resolve host * Connection refused, do
# https://askubuntu.com/q/59458/25388
sudo vim /etc/hostname
masi

sudo vim /etc/hosts
127.0.0.1    localhost.localdomain masi
[...]

*Possible complication: Ubuntu starts in $(inittramfs)$. Do ...
Result: USB starts up Ubuntu Desktop GUI and UI

*

*you can open LibreOffice, Firefox, ...

*masi is in sudo group; groups correct.

*Locales set correctly when chroot to stick.

*If you have a bug in gnome-terminal i.e. opening it in GUI, do sudo dpkg-rekonfigure locales again in TTY1. It resolves the case.

Bugs which are reported to Videonauth
Always update-and-upgrade system in doing the tests: sudo apt-get update && sudo apt-get upgrade.

*

*Ubuntu's Internet Browser. Launching it crashes the system. Mouse only works but no signal can be send to the TTY.

*Firefox. Launching it gives a warning about [profile exists] so cannot open. Temporary fix rm -r ~/.mozilla && rm -r ./.cache/mozilla only for one session. The problem persists on every login. Better working fix: sudo mv -v /home/masi /home/masi_backup, sudo mkdir -v /home/masi, sudo chown masi:masi /home/masi, sudo chmod 755 /home/masi and sudo reboot because some ownerships of home-folder causes the bug. Run the command of  the source and you get the following differences

*/etc/hostname fails to match /etc/hosts after some time

*Sometimes, starts up to (inittramsfs)
Output of vimdiff <(find /home/masi -printf "%P %u:%g %m\n" | sort) <(find /home/masi_backup -printf "%P %u:%g %m\n" | sort)
%LHS-file
.bash_history masi:masi 600
.cache/compizconfig-1/animation.pb masi:masi 664
.cache/compizconfig-1/commands.pb masi:masi 664
.cache/compizconfig-1/compiztoolbox.pb masi:masi 664
% here many files not existing in the RHS

%RHS-file (fresh installation)
.bash_history root:root 600
.bash_logout masi:masi 664
.bashrc masi:masi 644
.cache root:root 700

where I do not understand which caused the bug.
Upgrade to Linux Kernel 4.6
Do as instructed here. There is an universal bug with resume/suspend in Linux kernel 4.4. Upgrading to 4.6 solves it and makes the system much better.
System: 14.04, 16.04
Linux kernel: 4.4 - 4.6

A: Here are some details. (Someone else should write a more independent review about the pros and cons.)

*

*Cloning: dd is a very powerful but also very dangerous tool, often nicknamed 'disk destroyer' or 'data destroyer'. dd is used to clone an iso file to a USB pendrive. When creating live-only USB boot drives, mkusb 'wraps a safety belt around dd'. This method works for all hybrid iso files, and most modern linux distros provide this kind of iso files. The new Ubuntu Startup Disk Creator in 16.04 LTS uses the cloning method too.

*Many other tools extract the content of the iso file to a FAT32 partition, for example Rufus and Unetbootin. (Rufus has also a cloning dd mode.)

*mkusb is a linux tool. It does not work in Windows.

*mkusb is a bash script, that uses several standard tools, available in most linux distros. mkusb uses zenity for a graphical user interface when available.

*mkusb-nox (No X) works in text mode, for example in Ubuntu Server. mkusb-dus (alias mkusb version 12) can work in text mode too with dialog text mode menus or with a plain text interface.

*Some of the other tools consist of compiled code.

*mkusb can create persistent live systems for Debian and Ubuntu. These systems are booted via grub2, and the iso file is cloned to a separate partition. A casper-rw partition will be created for persistence and a usbdata partition will be created for storing data and sharing data with computers running Windows. These persistent live systems can boot in UEFI and BIOS mode.

*mkusb-nox and mkusb-dus (alias version 12) can create a USB installer for Windows 7-10 via extraction. It uses the grub-pc package to install grub2, which makes the USB pendrive boot in BIOS mode. This system can boot in UEFI and BIOS mode.

*mkusb does not create multi-boot USB drives. There are other tools for that purpose.

*mkusb can also wipe confusing data and/or restore a USB boot drive to a standard storage device with an MSDOS partition table and a FAT32 file system.
See the following links if you want more details,

*

*mkUSB-quick-start-manual

*mkusb-Persistent live systems

A: Wow that sounds complex, mkusb can do a Live Persistent install much faster than I can read either procedure above. They also sound like Full installs not Persistent Live installs. A persistent install uses a casper-rw file or partition. It is called persistent install because the word persistent in the boot file is used to activate persistence.
See: https://help.ubuntu.com/community/mkusb for details of mkusb.
A USB drive made with mkusb also has no problem doing a Full install to HDD or USB.

A: To make yourself a complete normal Ubuntu installation on an USB or an external HDD you can follow the procedure I describe here.
You want to start by doing some preparatory installations, you need gksudo which is in the package gksu, schroot and debootstrap. Those packages are not installed by default, so type in a terminal (ctrl+alt+t):
sudo apt-get install gksu debootstrap schroot

Now you can start preparing your USB/HDD for installation by:
gksudo gparted

First you want to go to the devices menu and select create partition table, when asked for the type choose msdos. Now you should see an entry for unallocated space. Click on this and choose new and make it ext4 leaving only 1GB as free memory, then again click on the unallocated space entry and make it 1GB for Linux Swap. After this you apply your settings to the USB/HDD. Then right-click on the ext4 entry and choose manage flags and there you tick the check-mark on boot and leave.
Now you need to prepare your chroot environment to work in by doing the following commands one by one:
sudo mkdir /mnt/stick
sudo mount /dev/sdb1 /mnt/stick/
sudo debootstrap --arch=amd64 xenial /mnt/stick http://archive.ubuntu.com/ubuntu/
sudo mount -o bind /dev /mnt/stick/dev
sudo mount -o bind /dev/pts /mnt/stick/dev/pts
sudo mount -t sysfs /sys /mnt/stick/sys
sudo mount -t proc /proc /mnt/stick/proc
sudo cp /proc/mounts /mnt/stick/etc/mtab
sudo cp /etc/resolv.conf /mnt/stick/etc/resolv.conf
sudo chroot /mnt/stick/

Your prompt should now look like this:
root@HOSTNAME:/#

Now you can begin your real installation process, start by setting the locale setting and the keyboard-configuration and installing the kernel.
locale-gen en_US.UTF-8
dpkg-reconfigure locale
dpkg-reconfigure keyboard-configuration
localedef -i en_US -c -f UTF-8 en_US.UTF-8

apt-get install linux-image-generic

While this installation GRUB asks you for which device to be installed for. you will see a selection like this:
[ ]/dev/sda [NotThisOne, this is your HDD]
[ ]/dev/sdb (31474 MB; ???)
[ ]/dev/sdb1 (30398 MB; /)

Choose /dev/sdb1 and /dev/sdb by moving to the respective field using the arrow keys and pressing space then finally hit return. Now after this installation is completed you can install your editor of choice, I do here as example nano and vim:
apt-get install nano vim

Now you can edit your /etc/fstab file, for this first get a list of the UUIDS in your system by:
blkid

This should give you an output like this:
/dev/sda1: UUID="8f8f130f-e127-43b6-b797-8bfa3f1e1631" TYPE="ext4" PARTUUID="06bd4abe-01"
/dev/sda5: UUID="8469c58b-b2bb-4551-b47d-c1a7d21e9ebd" TYPE="swap" PARTUUID="06bd4abe-05"
/dev/sdb1: UUID="b08ab271-5619-479c-aa21-8aea7f4e6f3b" TYPE="ext4" PARTUUID="5872a1f8-01"
/dev/sdb2: UUID="c3309cee-731e-4030-93b9-f1d88c12c806" TYPE="swap" PARTUUID="5872a1f8-02"

For easier editing you can copy the output from terminal by selecting it with your mouse and pressing ctrl+shift+c, then open your editor of choice by typing (I choose nano here for example):
nano /etc/fstab

You can paste the lines after you cleared out the files' contents by pressing ctrl+shift+c. Now delete the lines marked with /dev/sda which is most likely your HDD and change the other two lines around so they finally look like this:
UUID=18055918-6045-42e9-9492-66e3fd29c199 swap swap defaults 0 0
UUID=69b5fb9c-774d-4d35-82f2-6a17faa446a1 / ext4 defaults 0 1

Then press ctrl+x to end your editing, choose y to save and hit enter
As next you need to fill your /etc/apt/sources.list, you can do so with copy and pasting the following block to your terminal and hit enter once.
cat > /etc/apt/sources.list << "EOF"
deb http://archive.ubuntu.com/ubuntu/ xenial main restricted
deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb http://archive.ubuntu.com/ubuntu/ xenial universe
deb http://archive.ubuntu.com/ubuntu/ xenial-updates universe
deb http://archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-updates multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
EOF

As for the final configuration packages must be installed which require starting services via Upstart, these must be disabled in the chroot temporarily:
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl

Now run an update and you can install either ubuntu-server or ubuntu-desktop or even both as long you do server before desktop.
apt-get update
# Comment this out if ubuntu-desktop is not wanted
apt-get install ubuntu-desktop
# remove comment if ubuntu-server is wanted
# apt-get install ubuntu-server

and finally add your user and put him into the proper groups:
adduser --home /home/<username> <username>

usermod -aG adm,cdrom,sudo,dip,plugdev,lpadmin,sambashare <username>

Where you can leave out sambashare if it gives you errors. Check if the group settings are correct by:
less /etc/group

You should see for each group listed in the above usermod command and entry like this (example sudo):
sudo:x:27:<username>

If not add the groups one by one with the above usermod command. Now it is time to maybe install drivers and useful tools, I list here only a few for your case necessary ones.
apt-get ecryptfs-utils testdisk schroot

To make GRUB only recognize your stick as OS and not adding the System you have build the stick on do:
echo 'GRUB_DISABLE_OS_PROBER="true"' >> /etc/default/grub
update-grub

Finalize the install by:
rm /sbin/initctl
dpkg-divert --local --rename --remove /sbin/initctl

Now you can reboot onto your USB and have a fully installed Ubuntu system to work with. If you run into the trouble of not being able to start the terminal which seems to be related to a bug in gnome-terminal you can check in TTY (ctrl+alt+f1 and login with your username and password) the content of /var/log/syslog if it contains lines like this:
May 7 22:30:00 NEXUS-TWO org.gnome.Terminal[1432]: Non UTF-8 locale (ISO-8859-1) is not supported!

To fix this it seem to be enough to execute sudo dpkg-reconfigure locales within TTY and choosing explicitly UTF-8. or set the language and so on within the GUIs settings. Afterwards reboot.


text:
Q: Table below figure, spanning two columns In one of my documents, I am attempting to put have a table inside of a figure environment, and have one caption that refers to both of the above (I am trying to have the table act as a separate panel). I haven't been able to make this work however.
I am going to borrow code from another question that was asked here before, since I think it would do essentially what I want to do. However, if someone knows how to a) have the "combined figure" span two columns (which I think is just a matter of adding a star inside {figure}) and b) have the image and table widths automatically span the width of the two columns, that would be great.
The code that I'm referring to is Zarko's answer here How to add a table below a figure in \figure environment
Thanks!

A: In order to obtain a figure that uses the width of both columns in a twocolumn document, use figure* instad of figure. In order to make the table and image as wide as the textwidth, replace \columnwidth by \textwidth.
\documentclass[twocolumn]{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\usepackage{tabularx}
\usepackage{lipsum}

\begin{document}
\begin{figure*}[ht]
    \centering
    \begin{subfigure}{.7\textwidth}
        \includegraphics[width=\linewidth]{example-image}
    \caption{picture}
    \end{subfigure}

    \bigskip
    \begin{subfigure}{\textwidth}
        \centering
        \renewcommand\tabularxcolumn[1]{m{#1}}
        \renewcommand\arraystretch{1.3}
        \setlength\tabcolsep{2pt}
    \begin{tabularx}{\linewidth}{*{4}{>{\centering\arraybackslash}X}}
    \hline
\textbf{Links} & \textbf{Scenario 1} & \textbf{Scenario 2} & \textbf{Scenario 3}  \\
      ???      &    (tree)           &    (Graph)          &  (Matrix)            \\
    \hline
    \end{tabularx}
        \caption{table}
    \end{subfigure}
\caption{Some wonderful words.}
    \label{my label}
\end{figure*}
\lipsum \lipsum
\end{document}


text:
Q: How can I include a Sibling Project in my Gradle Project? I have two Gradle projects with the following directory structure:
/baseDir
  /first
  /first/build.gradle
  /second
  /second/build.gradle

Both firstand secondare on the same hierarchy. From the Gradle User Guide I found only a way to include sub projects. This is not the case here.
How can I include sibling Project second in project first?

A: Try to use a settings.gradle with the following content:
 includeFlat "second"


text:
Q: Extract json data in Spark/Scala I have a json file with this structure
root
 |-- labels: struct (nullable = true)
 |    |-- compute.googleapis.com/resource_name: string (nullable = true)
 |    |-- container.googleapis.com/namespace_name: string (nullable = true)
 |    |-- container.googleapis.com/pod_name: string (nullable = true)
 |    |-- container.googleapis.com/stream: string (nullable = true)

I want to extract the four .....googleapis.com/... into four columns.
I tried this:
import org.apache.spark.sql.functions._
df = df.withColumn("resource_name", df("labels.compute.googleapis.com/resource_name"))
       .withColumn("namespace_name", df("labels.compute.googleapis.com/namespace_name"))
       .withColumn("pod_name", df("labels.compute.googleapis.com/pod_name"))
       .withColumn("stream", df("labels.compute.googleapis.com/stream"))

I also tried this, making the labels an array which has solved the first error that it said the sublevels are not array or map
df2 = df.withColumn("labels", explode(array(col("labels"))))
        .select(col("labels.compute.googleapis.com/resource_name").as("resource_name"), col("labels.compute.googleapis.com/namespace_name").as("namespace_name"), col("labels.compute.googleapis.com/pod_name").as("pod_name"), col("labels.compute.googleapis.com/stream").as("stream"))

I still get this error
org.apache.spark.sql.AnalysisException: No such struct field compute in compute.googleapis.com/resource_name .....

I know Spark thinks that each dot is a nested level, but how I can format compute.googleapis.com/resource_name that spark recognises as a name of the level rather than a multilevel.
I also tried to solve as stated here
How to get Apache spark to ignore dots in a query?
But this also did not solve my problem. I have labels.compute.googleapis.com/resource_name, adding backticks to the compute.googleapis.com/resource_name still gives same error.

A: Renaming the columns (or sublevels), then do the withColumn
val schema = """struct<resource_name:string, namespace_name:string, pod_name:string, stream:string>"""
val df1 = df.withColumn("labels", $"labels".cast(schema))

A: You can use back apostrophe ` to isolate the names that contain special characters like '.'. You need to use backtick after the labels, as it is parent tag.
val extracted = df.withColumn("resource_name", df("labels.`compute.googleapis.com/resource_name`"))
    .withColumn("namespace_name", df("labels.`container.googleapis.com/namespace_name`"))
    .withColumn("pod_name", df("labels.`container.googleapis.com/pod_name`"))
    .withColumn("stream", df("labels.`container.googleapis.com/stream`"))

  extracted.show(10, false)

Output:
+--------------------+-------------+--------------+--------+------+
|labels              |resource_name|namespace_name|pod_name|stream|
+--------------------+-------------+--------------+--------+------+
|[RN_1,NM_1,PM_1,S_1]|RN_1         |NM_1          |PM_1    |S_1   |
+--------------------+-------------+--------------+--------+------+

UPDATE 1
Full working example.
import org.apache.spark.sql.functions._
val j_1 =
  """
    |{ "labels" : {
    |   "compute.googleapis.com/resource_name" : "RN_1",
    |   "container.googleapis.com/namespace_name" : "NM_1",
    |   "container.googleapis.com/pod_name" : "PM_1",
    |   "container.googleapis.com/stream" : "S_1"
    |             }
    |}
  """.stripMargin

  val df = spark.read.json(Seq(j_1).toDS)
  df.printSchema()

  val extracted = df.withColumn("resource_name", df("labels.`compute.googleapis.com/resource_name`"))
    .withColumn("namespace_name", df("labels.`container.googleapis.com/namespace_name`"))
    .withColumn("pod_name", df("labels.`container.googleapis.com/pod_name`"))
    .withColumn("stream", df("labels.`container.googleapis.com/stream`"))

  extracted.show(10, false)


text:
Q: Make paired delimiter with prefix for Re and Im I'm trying to make a new command for something like this:
\operatorname{Re}\left\lbrace\num{1+2i}\right\rbrace

Because I'm using the mathtools package already I tried to do something like this:
(And I have to undefine the previous \Re and \Im commands, because they are ugly and this command should be obviously called \Re and \Im.)
\let\Re\undefined
\let\Im\undefined
\DeclarePairedDelimiter\Re{\operatorname{Re}\lbrace}{\rbrace}
\DeclarePairedDelimiter\Im{\operatorname{Im}\lbrace}{\rbrace}

This will work, but will also spit put many errors. Like: Missing { inserted. \end{align} and so on.
Then I thought: Yes, this is probably, because the font can not scale (and shouldn't), like the \lbrace and \rbrace. And I tried something like this:
\let\Re\undefined
\let\Im\undefined
\DeclarePairedDelimiter\braces{\lbrace}{\rbrace}
\newcommand{\Re}{1}{\operatorname{Re}\braces*{#1}}
\newcommand{\Im}{1}{\operatorname{Im}\braces*{#1}}

But this will produce:

Missing $ inserted. \newcommand{\Re}{1}{\operatorname{Re}
Missing \begin{document}. \newcommand{\Re}{1}{\operatorname{Re}

Inserting \ensuremath or something like that doesn't help much.
Last try:
\let\Re\undefined
\let\Im\undefined
\newcommand{\Re}{1}{\operatorname{Re}\left\lbrace #1 \right\rbrace}
\newcommand{\Im}{1}{\operatorname{Im}\left\lbrace #1 \right\rbrace}

Missing $ inserted. \newcommand{\Re}{1}{\operatorname{Re}
Missing \begin{document}. \newcommand{\Re}{1}{\operatorname{Re}
You can't use `macro parameter character #' in math mode. ...nd{\Re}{1}{\operatorname{Re}\left\lbrace #

It can't be this hard to make something like this work, or can it? I really don't know what I should try next, or what am I even doing wrong.

A: You have the incorrect syntax for \newcommand.
\newcommand{\Re}{1}

should be
\newcommand{\Re}[1]

A: You can use the \DeclarePairedDelimiterXPPfrom mathtools. It will define  \Reand \Im commands, which have a star version (adds a pair of implicit \left \right in front of the delimiters), but they also accept an optional argument among \big, \Big, \bigg and \Bigg, which adds a pair oof implicit \bigl \bigr, &c.
\documentclass[10pt]{article}
\usepackage{mathtools} %
\let\Re\undefined
\let\Im\undefined
 \DeclarePairedDelimiterXPP\Re[1]{\operatorname{Re}}{\lbrace}{\rbrace}{}{#1}
 \DeclarePairedDelimiterXPP\Im[1]{\operatorname{Im}}{\lbrace}{\rbrace}{}{#1}

\begin{document}

   \[ \Re*{\frac{z-1}{z + 1}}\qquad \Im[\Big]{\frac{z-1}{z + 1}} \]%

\end{document}


text:
Q: Using Powershell and Regex to rename files I have a bunch of files named in the following pattern:

*

*Test.config.gcp.json

*Test.config.release.json

*Test.release.json

*Test.windows.2019.dev.json

I need to remove the environment names (e.g. gcp, release and dev) from the file name:

*

*Test.config.json

*Test.config.json

*Test.json

*Test.windows.2019.json

I'm not familiar with regex so not sure how to tackle this.


text:
Q: Getting Columns Checked in GridView with jQuery I have a GridView and am needing to grab column 1 and 2 (the text therein) and put that text elsewhere in the page, another textbox.
Here is what I have thus far:
 var checked = $('input:checkbox').click(function(e) {
            //place airport in textbox, txtAirport
            var loc = $("tr:has(:checkbox:checked) td:nth-child(1)");
            var ac = $("tr:has(:checkbox:checked) td:nth-child(2)");

            // txtAirport.Text = loc + ac;
            $("#<%= txtAirport.ClientID%>").val(loc + ac);
        });

the problem is I am getting {Object object} {Object object} in my textbox where I'm expecting to get a city, st and an airport. How do I clarify my "loc" and "ac" variables to give me what I need? I've tried .text and .val() to no avail.
Here is the HTML (ASP.NET Gridview):
 <asp:DataGrid ID="dgSearch" runat="server" AllowPaging="False" AllowSorting="False"
                            CellPadding="3" CellSpacing="2" ShowFooter="False" GridLines="None" AutoGenerateColumns="false">
                            <AlternatingItemStyle Wrap="False" CssClass="HeaderRowAlternate"></AlternatingItemStyle>
                            <ItemStyle Wrap="False"></ItemStyle>
                            <HeaderStyle Font-Bold="True" Wrap="False" CssClass="HeaderRowStyle"></HeaderStyle>
                            <Columns>
                                <asp:TemplateColumn HeaderText="Select">
                                    <HeaderStyle CssClass="HEADERSTYLE"></HeaderStyle>
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkLookup" runat="server" CssClass="checkbox"></asp:CheckBox>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                                <asp:BoundColumn Visible="False" DataField="AirportID"></asp:BoundColumn>
                                <asp:BoundColumn Visible="False" DataField="City"></asp:BoundColumn>
                                <asp:BoundColumn DataField="Loc" HeaderText="Location">
                                    <HeaderStyle Wrap="False" CssClass="HEADERSTYLE"></HeaderStyle>
                                    <ItemStyle Wrap="False"></ItemStyle>
                                </asp:BoundColumn>
                                <asp:BoundColumn DataField="AirportCode" HeaderText="Airport Code">
                                    <HeaderStyle Wrap="False" CssClass="HEADERSTYLE"></HeaderStyle>
                                    <ItemStyle Wrap="False"></ItemStyle>
                                </asp:BoundColumn>
                                <asp:BoundColumn DataField="AirportName" HeaderText="Airport Name">
                                    <HeaderStyle Wrap="False" CssClass="HEADERSTYLE"></HeaderStyle>
                                    <ItemStyle Wrap="False"></ItemStyle>
                                </asp:BoundColumn>
                                <asp:BoundColumn DataField="MilesFromSource" HeaderText="Distance">
                                    <HeaderStyle Wrap="False" CssClass="HEADERSTYLE"></HeaderStyle>
                                    <ItemStyle Wrap="False"></ItemStyle>
                                </asp:BoundColumn>
                            </Columns>
                        </asp:DataGrid>

A: jQuery selectors return wrapped sets containing the selected DOM elements, so you'll need to use .text() or .html()
EDIT: OK, I've replicated your code, what you need is
$("tr:has(:checkbox:checked) td:nth-child(2)");
$("tr:has(:checkbox:checked) td:nth-child(3)");

And then to do
$("#<%= txtAirport.ClientID%>").val(loc[0].innerHTML + ac[0].innerHTML);

This will give you the text in the first and second columns (after the checkbox) of the first row (loc[1] and ac[1] for second rows etc.). The issue you had was td:nth-child(0) was returning the DOM object of the checkbox's <td> element
To loop through checked checkboxes only:
for (var i = 0; i < loc.length; i++) {
    alert(loc[i].innerHTML + " " + ac[i].innerHTML);
}

You don't need to check the checkbox is checked since the jQuery selector already does that for you

A: jQuery returns an array or matched objects so you need to use loc[0].innerHTML or loc.html() or loc.text() instead of loc (or ac respectively).
   var checked = $('input:checkbox').click(function(e) {
        //place airport in textbox, txtAirport
        var loc = $("tr:has(:checkbox:checked) td:nth-child(2)");
        var ac = $("tr:has(:checkbox:checked) td:nth-child(3)");

        // txtAirport.Text = loc + ac;
        $("#<%= txtAirport.ClientID%>").val(loc.html() + ac.html());
    });

It is probably necessary to change numbers of cells too (1,2 -> 2,3) see http://jsfiddle.net/vXtKq/
It can be that you selector is not specific enough but if you post result of upper code or rendered HTML (from page source in your browser) the finding of solution is easier.


text:
Q: React Web Carousel Component Issue I have included the react coverflow component to use a nice looking carousel in my project. It's loading fine but whenever I am clicking on the images it's showing me the following error:

I'm having the following code. Did any of you faced the same issue.
Note: I've tried using npm install after installing the react coverflow component. Even after that it's showing the same error on click. Is there any dependency issue? Any help?
import React, { Component } from 'react';
import Coverflow from 'react-coverflow';
import { StyleRoot } from 'radium';

class GetCarousel extends Component {

    constructor(props) {
        super(props);
        this.state = { isActive: 0 };
    }

    handleCarousal(e) {
        // console.log(e.currentTarget.id);
        // var text = e.currentTarget.id;
        var number = Number(e.currentTarget.id);
        this.setState({
            isActive: number
        });
    }

    render() {
        return(

                {/**/}

        );
    }
}

export default GetCarousel;


text:
Q: Increasing the range of cheap RF module I am trying to increase the working range of cheap arduino 433 mhz RF link modules like these https://www.sparkfun.com/products/10534.
The page says they have range of 500 feet in perfect conditions however in my case it's more like several feet.
So I know I can extend the range by simply applying more powerful power supply, but I thought if I can take the Tx output and feed it into some sort of high frequency amplifier.
I can't buy any here so I'll have to make my own. I am interested if it is even worth trying or will it be so complicated I am better of doing something else?

A: I used to sell modules that look like they came from the same reference design, and found they were normally good for about 100 meters but out of thousands sold here are the most common problems with range:

*

*The SparkFun pages say lists them as being a 5V module but the datasheet says the operating voltage is up to 12V, you should definitely use that.

*Those simple ASK transmitter / receiver pairs need to have a balanced signal to work well like Manchester or NRZ encoding, but the VirtualWire library you've mentioned in a comment should take care of that.

*The bitrates they mention are probably somewhat optimistic, try lowering it so something like 1200bps and experiment with going even lower.

*They also need a preamble for the receiver to lock on, but once again the VirtualWire  library should take care of that.

*Also take a took at sending the data multiple times and additional error detection - that may help if the packets are mostly received but you get the odd inteference from being on an ISM frequency.
On the receiver side you can also look at using a larger antenna that won't have any regulatory implications. As Olin mentioned a proper ground plane for the antenna is worth looking at if practical.

A: Using a more "powerful" power supply is a bad idea.  It will probably just fry something.
If you are getting very low range, then the first thing to look at are both the transmitting and receiving antennas, and their ground planes if appropriate.
Otherwise, adding out of spec antennas or a RF power amplifier will violate whatever license this product has, and may cause emissions past the legal limit.  Not a good idea.


text:
Q: How to create a global variable for render_template()? I have a simple task: to pass the same variable for different routes in the render_template() function. This value is in the base template and I need to pass it on every render_template() function. Can I set this value as a global so that I don't have to set it in every function for different routes?
@app.route('/hello')
def hello(name=None):
    return render_template('hello.html', value=value)

@app.route('/bye')
def bye(name=None):
    return render_template('bye.html', value=value)

A: To make variables available to templates without having to burden your routes with passing those variables, use Flask context processors. See https://flask.palletsprojects.com/en/2.1.x/templating/#context-processors for details an an example.
Here's one that I use to 'cache bust' CSS so that browsers won't accidentally use stale versions.
style_css_path = os.path.join(os.path.dirname(__file__), 'static', 'style.css')
style_css_mtime = int(os.stat(style_css_path).st_mtime)

@app.context_processor
def cache_busters():
    return {
        'style_css_mtime': style_css_mtime,
    }

The base template can then do
<link rel="stylesheet"
      href="{{ url_for('static', filename='style.css') }}?v={{ style_css_mtime }}" />

Any template that uses base.html inherits this behavior without routes that use that template having to pass style_css_time.

A: You could use a partial from functools like this:
from functools import partial

# Define a function that takes 2 parameters
def someFunc(a,b):
   print(f'Called with a:{a} and b:{b}')

# Define a "partial" where the parameters are partially pre-filled in
p1 = partial(someFunc, b="I was added for free")

# Now call the already partially defined function "p1"
p1("Hello")

Result
Called with a:Hello and b:I was added for free

A: I found the correct solution to my question in the Flask documentation:

Context Processors
To inject new variables automatically into the context of a template, context processors exist in Flask. Context processors run before the template is rendered and have the ability to inject new values into the template context. A context processor is a function that returns a dictionary. The keys and values of this dictionary are then merged with the template context, for all templates in the app:

@app.context_processor
def inject_user():
    return dict(user=g.user)

The context processor above makes a variable called user available in the template with the value of g.user. This example is not very interesting because g is available in templates anyways, but it gives an idea how this works.


text:
Q: Can't get access to PHPmyAdmin after setting a root password and using Instant Rails Wanted to get started with Ruby on Rails so I installed instant rails and set up a mysql password. Problem is now I can't get access to phpmyadmin.
From the rails control panel, when I go to configure >> database (via PhpMyadmin) it opens up phpmyadmin with the message

Error

MySQL said: Documentation
#1045 - Access denied for user 'root'@'localhost' (using password:

NO)

When I used to use XAMPP after setting a password instead of taking me directly within phpmyadmin (as it did without a password) it took me to the login screen instead. With instant rails that's not the case. Anyone had this problem when they first set a mysql password and using the instant rails package?

A: Check following lines in config.inc.php in phpmyadmin directory
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'yourpassword';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

if your root account dont use any password set 'AllowNoPassword' to 'TRUE'

A: Try to restart your browser after changing the config file.

A: Go to this directory "xampp/phpmyadmin" and open config.inc.php file. On a Mac, go to /Applications/XAMPP/xamppfiles/phpmyadmin. Then change and configure the below code with your desired requirements. It worked with me. I installed both MySQL and XAMPP and worked successfully.
$cfg['Servers'][$i]['controluser']  = 'Your Username';
$cfg['Servers'][$i]['controlpass']  = 'Your passwaord';
$cfg['Servers'][$i]['auth_type']    = 'config';
$cfg['Servers'][$i]['user']         = 'Your Username';
$cfg['Servers'][$i]['password']     = 'Your password';

A: $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

was missing from configuration.

A: I faced similar problem and found an easy way out.
After changing the password in config.inc.php,
phpmyadmin did not start and message was access denied for user xyz@localhost
Step by step solution:

*

*imp: do not change password directly from config.inc.

*in the config.inc.php keep the password blank
$cfg['Servers'][$i]['password'] = '';
this will allow phpmyadmin to open without password.

*Under tab USERS click editpriviliges for root->followed by change password.

*Now if you again try and open localhost/phpmyadmin, it shows error access denied

*Now open config.inc.php and set the same password for user that you set in phpmyadmin
example:
$cfg['Servers'][$i]['password'] = 'xyz@abc';

*Now open phpmyadmin and it works!!

A: Edit your phpmyadmin config.inc.php file :
Path For Config Page is wamp\apps\phpmyadmin3.4.5\config.inc.php
$cfg['Servers'][$i]['verbose'] = 'localhost';

$cfg['Servers'][$i]['host'] = 'localhost';

$cfg['Servers'][$i]['port'] = '3306';

$cfg['Servers'][$i]['socket'] = '';

$cfg['Servers'][$i]['connect_type'] = 'tcp';

$cfg['Servers'][$i]['extension'] = 'mysqli';

$cfg['Servers'][$i]['auth_type'] = 'config';

$cfg['Servers'][$i]['user'] = '**your-root-username**';

$cfg['Servers'][$i]['password'] = '**root-password**';

$cfg['Servers'][$i]['AllowNoPassword'] = true;

A: I had same problem after i changed password in phpmyadmin. Iam usind xampp and windows. After i changed password in my phpmyadmin showed "access denied" and then after changes descripted below phpmyadmin showed blank page.  I tried all advices and combinations given here, but problem still remained. I solved it through "config.inc.php", where i changed these lines
$cfg['Servers'][$i]['password'] = 'new_changed_password';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

and then and final key - clear cache in your browser! good luck.

A: This problem made me crazy.After a full day of wasting time I fixed it. I'm using WAMP.

*

*Password was removed using console.

*WAMP was uninstalled.

*Computer was restarted.

*WAMP was re installed.(Now i was able to open PhpMyadmin correctly)

*Then the Password was set using PhpMyadmin privileges.

*" $cfg['Servers'][$i]['password'] = ''; " in " C:\wamp\apps\phpmyadmin3.4.5\config.inc.php " was edited like this " $cfg['Servers'][$i]['password'] = 'Password given in PhpMyadmin privileges '; "

*Now there was not any problem to open PhpMyadmin even with root password.

*This video may helpfull. >> http://www.youtube.com/watch?v=lBvfa1wmlbI

A: I had this issues. I have fixed by changing phpmyadmin ini files configuration.
As per xampp folder structure I found phpmyadmin configuration file in this location: C:\xampp\phpMyAdmin\config.inc.php
Just changing these line my problem solved.
$cfg['Servers'][$i]['password'] = '';
to
$cfg['Servers'][$i]['password'] = 'password';
Thank You !

A: Check following lines in config.inc.php in phpmyadmin directory
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'yourpassword';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

The above worked for me.After editing the above file,i restarted the wamp and it was all fine

A: You have a root account with no password. It would be best to have a look into the conf file located in your phpmyadmin directory and check with the password.

A: rails-mysql-lost-password
If you are rails developer and you have lost password for mysql :
This answer is in connection with Ruby on Rails framework where this behavior occurred

*

*have mysql with user root and password

*bootstrap new rails project
using with mysql "rails new projectname
    -d mysql"

*do not modify config/database.yml - defaults credentials for server are name: root, password is blank

*rake db:create prompt show up - asking for root password and then when you provide root password

the answer is in GRANT command on line 68 in here
basically it executed GRANT command with credentials matches your current database.yml
I have discussed this topic and behavior will improved and it is taken and reported as a bug.

A: I was looking for an answer but it's really easy to solve...
Open XAMPP App -> Go to General then open Terminal
execute the following command:
mysqladmin --user=root --password=[OLD_PASSWORD] password ""
But how to set a root password? without losing access to to phpmyadmin ?

A: In case you want to reset password to NULL do following:

*

*Run MySQL Console

*It will ask you the password you set. Enter password.

*Run following command:
mysql>UPDATE mysql.user
    ->SET Password=PASSWORD("")
    ->WHERE User="root";
mysql>FLUSH PRIVILEGES;

*You may now access your phpMyAdmin again with PASSWORD not set for root.


text:
Q: Cannot access Class methods from previous windows form - C# I am writing an app, still, where I need to test some devices every minute for 30 minutes. It made sense to use a timer set to kick off every 60 secs and do whats required in the event handler.
However, I need the app to wait for the 30 mins until I have finished with the timer since the following code alters the state of the devices I am trying to monitor.
I obviously don't want to use any form of loop to do this. I thought of using another windows form, since I also display the progress, which will simply kick off the timer and wait until its complete.
The problem I am having with this is that I use a device Class and cant seem to get access to the methods in the device class from the 2nd (3rd actually - see below) windows form.
I have an initial windows form where I get input from the user, then call the 2nd windows form where it work out which tests need to be done and which device classes need to be used, and then I want to call the 3rd windows form to handle the timer.
I will have up to 6-7 device classes and so wanted to only instantiate them when actually requiring them, from the 2nd form.
Should I have put this logic into the 1st windows form (program class ??) ?
Would I not still have the problem of not being able to access device class methods from there too ?
Anyway, perhaps someone knows of a better way to do the checks every minute without the rest of the code executing (and changing the status of the devices) or how I should be accessing the methods in the app ??
Hi,
The following is the "calling" form -
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;

namespace TestCall

{
    public partial class Form1 : Form
    {
        NDTClass NDT = new NDTClass();

        public Form1()
        {
            InitializeComponent();

            NDT.NDTOpen();
            NDT.NDT1_CMD1();
            (new Form2()).ShowDialog();
            NDT.NDTClose();

        }

        public class NDTClass
        {
            public static double SWVolt = 0.5;
            public static string Rxstring = "";
            public SerialPort port = new SerialPort("COM4", 9600, Parity.None, 8, StopBits.One);

            public string NDTOpen()
            {
                port.Open();
                port.Write("CURRENT ?\r\n");
                return Rxstring;
            }

            public void NDTClose()
            {
                port.Close();
            }

            public void NDT1_CMD1()
            {
                port.Write("DUAL MODE\r\n");
            }
        }
    }
}

The following is the called form -
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestCall
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
            Form1.NDTClass.SWVolt = 99;
            NDT.NDT1_CMD1();
        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }
    }
}

The NDT.NDT1_CMD1() in the called form gives me the following error in the build -
Error   1   The name 'NDT' does not exist in the current context

The use of the variable SWVolt within the NDTClass works fine but the use of the method in the class is not possible.
What have I done wrong ??
Thanks, George. (I hope the formatting comes out corrrectly too).

A: Form1.NDTClass.SWVolt = 99; works because you are referencing a public static field in the Form1.NDTClass class.  It is not tied to any instance.  However for `NDT.NDT1_CMD1();, that doesn't work because:

*

*NDT1_CMD1() is an instance method and you need an instance of that class to call it.

*There is no instance of your class named NDT in Form2.  Form1 contains a private field named NDT, but that is not accessible from Form2.  You need to declare Form1.NDTClass NDT = new Form1.NDTClass() in Form2.

I think you need to make sure you understand variable scope.
Let me attempt an alternate explanation:
SWVolt as a public static field, has global scope.  It is accessible from anywhere in the application.  NDT as a private instance field has the scope of a single instance of Form1.  That is it is only accessible from inside an instance of Form1.  Any code that is not part of Form1 cannot see it, which of course includes the code in Form2.


text:
Q: Enable X509 Certificate User Authentication In Keycloak With Kubernetes I'm fairly new to kubernetes, so forgive me for my ignorance on this topic.
I am trying to set up x509 authentication in keycloak. This guide indicates that I need to edit a standalone.xml file and add my configurations there.
I'm not too sure how to edit this file on launch of the instance and copy my Java Key Store into the container image.

A: Replica of How to edit standalone.xml file dynamically in keycloak
You're going to need to dynamically create a keycloak image, then use that image for your configs.


text:
Q: Excel search and lookup I have a case where I need to extract a Weight based on the Data Range. The problem is that I can only enter Data and not range. I have shown this in the image below. What I would like to do is to implement the formula mentioned, so that I get the correct Weight based on the Range. What methods are available for this, in Excel?
Weight and Data Range

A: You can try the formula below. It assumes that the 1st data is in A1. Drag it to fill the other cells. Data above 10 but less than 20 are given a weight of 3.
=IF(A1<=5,1,IF(AND(A1>10,A1<20),3,2))

A: These sorts of issues are frequently handled with a lookup table.
Below, I hard-coded the table into the formula, but you can list it separately on the worksheet and refer to it by a range reference.
It provides good flexibility and ease of modification, should that be necessary.
For example:
=VLOOKUP(A7,{0,1;6,2;11,3;20,"undefined"},2)

Data Table (to be used if you prefer)

If you set up a separate table, you would use a formula like:
=VLOOKUP(A7,$F$5:$G$9,2)

if your table is in F5:G9


text:
Q: Pass by value or reference . Simple View
Possible Duplicate:
Is Java pass by reference?

After reading the discussion on this topic, can one conclude that when Java passes a variable, say A (excluding primitive type), it means it passes the object, which the variable (A) is referencing. So any changes made on that object reflects in variable (A). So at last does it work as pass by reference in general term?

A: See Is Java "pass-by-reference" or "pass-by-value"?
Java is always calls-by-value. In the case of when objects are passed it passes the "value of the reference" which gives Java the semantics of call-by-object-sharing (it does this through call-by-value-of-the-reference though!).
I like to say: When an object is passed it is not copied. Then, since it is the same object on the inside of the method -- the variable is just a different "name" for it -- if you change the object (not the variable!) inside the method, you change that object outside -- everywhere, really -- as well. (It is the same object, ater all :-)
Please note that variables are never passed. They are evaluated as expression and the values that they evaluate to are passed.
Some languages like C++ support call-by-reference. This is different than either call-by-value or call-by-object-sharing because these functions are called with (a generally restricted set of) "lvalues" as arguments and reassignment to the parameters in the function will affect the "lvalues" on the outside. "lvalues" are normally variables and support for this kind of calling convention differs by language (many do not support it!).
Happy coding.

A: No, that's not correct.
Everything is passed by value in JAVA - no exceptions!
However it's crucial to understand that what you pass is not the object, but a reference to it.
This reference is passed by value (so you can't change it in the method).
You indeed can alter the objects data through this reference, but as I said - you can't change the reference to refer to a different object (or null for that matter).

A: Java passes parameters to methods using pass by value semantics. That is, a copy of the value of each of the specified arguments to the method call is passed to the method as its parameters.
Note very clearly that a lot of people confuse the "reference" terminology with respect to Java's references to objects and pass by reference calling semantics. The fact is, in dealing with Java's references to objects, a copy of the reference's value is what is passed to the method -- it's passed by value. This is, for example, why you cannot mutate the (original, caller's) reference to the object from inside the called method.
"pass by reference" means if you pass a variable into a method, its value can be modified. This is possible in many languages, like Pascal, Ada, and C++, but not in many other languages like C and Java.
here is a good discussion about it . http://www.jguru.com/faq/view.jsp?EID=430996

A: Java does not pass by reference. It also does not pass objects. It passes object references by value. Inside a method, you can make changes to the object that was passed, but you cannot change the reference itself in the calling code.
void foo(Object obj) {
    foo = new Object();
}

Object obj = new Object();
Object obj2 = obj;
foo(obj2);
System.out.println("obj2 passed by " + (obj == obj2 ? "value" : "reference"));

This code will print "pass by value".

A: I would conclude more along the lines of:
Java passes all parameters, primitive and non-primitive, by value.  In the case of non-primitive types, what Java actually passes is a pointer (or "reference") to the object instance, by value.  This means that the caller's copy of the reference itself (i.e. the memory location that the pointer actually points to) cannot be changed.  But at the same time, any state internal to the referenced object instance that the callee modifies will be modified in the caller's "copy" of the object as well, because there is in fact only a single instance of the object that both the caller and callee share.


text:
Q: Sending bash script variables to sed first time poster here and I searched for quite some time but didn't find a thread I could understand well enough to solve my problem.
I have a loop in my script that generates certain variables via cut -d delimitation and I wan to use that variables as input for sed to alter a file differntly each iteration. My current script is:
My current script looks like:
for input in $(tail -n 3 filea)
do
        a="$(echo $input | cut -d "," -f 1)"
        b="$(echo $input | cut -d "," -f 2)"
        c="$(echo $input | cut -d "," -f 3)"

        echo $a
        echo $b
        echo $c

        tail -n 1 fileb | sed 's,'$a','$c',2'
done

With an output of:
K
26
T
KTTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
P
27
E
KKTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
S
31
P
KKTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Where for example the string on position 31 should be replaced with S if it is P.
My current status is that I get the variables a and c correctly transfered into the sed command and respective strings get replaced but changing it to sed 's,'$a','$c','$b'' stops any replacement and the native (last) line of fileb gets prompted.
I know that asking a good question is a whole other topic, but I hope somebody can help me to understand the writing here so I can continue to learn programming as I often step over mistakes like these.

A: Notes:

*

*don't use for for reading lines of a file

*use IFS and read to split a line using a separator

*be more rigourous about quoting variables.

Given:
$ cat filea
K,26,T
P,27,E
S,31,P

$ cat fileb
-------------------------TE---P---

then
tail -n 3 filea | while IFS=, read -r replacement position character; do
    printf -v regex '^(.{%d})%s' $((position - 1)) "$character"
    printf -v repl  '\\1%s' "$replacement"

    echo "$regex"
    echo "$repl"

    tail -n 1 fileb
    tail -n 1 fileb | sed -E "s/$regex/$repl/"
done

outputs:
^(.{25})T
\1K
-------------------------TE---P---
-------------------------KE---P---
^(.{26})E
\1P
-------------------------TE---P---
-------------------------TP---P---
^(.{30})P
\1S
-------------------------TE---P---
-------------------------TE---S---

But, this is something that bash can do without sed, using the ${var:offset:length} form of Parameter Expansion:
tail -n 3 filea | while IFS=, read -r replacement position character; do
    echo "$replacement   $position   $character"
    line=$(tail -n 1 fileb)
    echo "$line"
    if [[ "${line:position - 1:1}" == "$character" ]]; then
        line=${line:0:position - 1}${replacement}${line:position}
    fi
    echo "$line"
done

outputs
K   26   T
-------------------------TE---P---
-------------------------KE---P---
P   27   E
-------------------------TE---P---
-------------------------TP---P---
S   31   P
-------------------------TE---P---
-------------------------TE---S---


text:
Q: Resolving an Xpath query Hi I have a doubt related to XPath.
My xml file looks as follows.
<?xml version="1.0" encoding="UTF-8"?>

<name xmlns="http://localhost/book" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://localhost/book books.xsd">
Java and XML
</name>

here is the xpath query and its result
/* - returns element "name"
/*/text() - returns text "Java and XML"
/name - no result
/name/text() - no result
Why specifying name is not giving any result?

A: That is because element name is declared in http://localhost/book. Therefore in XPath query you should specify it. As a rule you should pass to your XML engine namespace and it prefix, then query your XML using full-qualified name, i.e.:
/ns:name/text()

However you can use other technique specifying namespace in query, i.e.:
/*[local-name() = 'name' and namespace-uri() = 'http://localhost/book']

A: Read about the NamespaceManager and how to use it in EditX here: http://www.japisoft.com/doc-editix/manual/index.html#mozTocId544189


text:
Q: PushViewController to the left - Simple? I'm trying to get my ViewController to slide from Left to Right at the same speed as the standard PushViewConrtoller, I'm not using a NavBar and don't want to use Modal, is there a simple way to do this, I've seen a lot of variations on different threads, but none of them work correctly!
I'm using a Navigation Controller with the following code for my Push right...
- (IBAction)launch1990:(id)sender {

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"1990Storyboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"1990"];
[self.navigationController pushViewController:vc animated:YES];
}

A: UIStroryBoard when you push view controllers, or segues, it doesn't let you customize too much. What I ended up doing was override the perform method and used QuartzCore Animations to customize our transitions.  I subclassed UIStoryBoardSegue and overwrote the perform function.
Below to customize for Push or Pop then for Segues. (For segues remember to change the class to the custom class in IB).
To do it from a normal pop or push (this does cross fade animation, adjust it for yours):
    #import <QuartzCore/QuartzCore.h>

 - (IBAction)launch1990:(id)sender {
    CATransition* transition = [CATransition animation];
    transition.duration = .45;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionFade;
    [self.navigationController.view.layer addAnimation:transition forKey:kCATransition];

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"1990Storyboard" bundle:nil];
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"1990"];
    [self.navigationController pushViewController:vc animated:NO];
  }

To do it from segue:
//ZHCustomSegue.h
#import <Foundation/Foundation.h>

@interface ZHCustomSegue : UIStoryboardSegue

@end

//  ZHCustomSegue.m
#import "ZHCustomSegue.h"
#import "QuartzCore/QuartzCore.h"

@implementation ZHCustomSegue

-(void)perform {

    UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
    UIViewController *destinationController = (UIViewController*)[self destinationViewController];

    CATransition* transition = [CATransition animation];
    transition.duration = .45;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionFade; //kCATransitionMoveIn; //, kCATransitionPush,   kCATransitionReveal, kCATransitionFade
   //transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom

    [sourceViewController.navigationController.view.layer addAnimation:transition
                                                            forKey:kCATransition];

    [sourceViewController.navigationController pushViewController:destinationController animated:NO];

}
@end

A: Use   CATransition with subtype: kCATransitionFromLeft
CATransition *transition = [CATransition animation];
    transition.duration = .3;
    transition.type = kCATransitionMoveIn;
     transition.subtype= kCATransitionFromLeft;
    [self.navigationController.view.layer addAnimation:transition forKey:nil];

A: Do the normal navigation vc push, but beforehand:
vc.navigationBar.hidden = YES;


text:
Q: Flask problem when the user looks at the page source code I have noticed that after a POST, if you look at the page source via "control + U" flask opens the source page also again via POST and does all tasks again. Is there any way I can prevent this?
@app.route("/", methods=["POST", "GET"])
def event_page():
if request.method == "POST":
   do_something()

when I view the source page the do_something() function is trigger t again.

A: Not really a Flask problem. The simplest solutions would be not to use CTRL+U but F12 - inspector or network tab


text:
Q: Not able to install Ubuntu 12.04 using wubi I am trying to install Ubuntu 12.04 in my windows machine using Wubi. It's not the first time I am trying to install using Wubi, I have done that before but I am facing some issues this time...
I have downloaded ubuntu-12.04.4-desktop-amd64.iso(in zip) from the Ubuntu's website.

After extracting all the files when I am trying to run wubi.. it's giving an error :

With my internet connection on, wubi downloads a file..

But at the end of downloading, this gives "Permission Denied" error.
I also searched a lot, and tried different ways like putting the latest wubi in the folder. But nothing worked for me.. Any suggestion ??
A question here, I have already downloaded iso zip but wubi still searching for another disc image file.Doesn't it come in the iso zip files??

A: Donwload Ubuntu 12.04.4 LTS 32bit iso image, and after that download wubi installer, place both files in the same folder on your desktop or somewhere else and run wubi.exe with your Internet connection down. Don't forget that you cannot allocate more than 30GB for Ubuntu installation when using wubi installer. It should work fine. You can use wubi installer in the same manner to install inside windows Xubuntu 12.04.4 and also Lubuntu 12.04.4 (better choice for older machines than Ubuntu 12.04.4 which runs in a Gnome session and can create lots of issues after first system upgrade and also after you update your video driver).


text:
Q: Initialize a multidimensional array as a class Member in c++ I have a class, let' say:
class Foo
{
    public:

         unsigned int Index;
         float Size;
         Foo(const unsigned int index);
         ~Foo();

    private:
         int Children[2][2];

};

And I want to initialize the Children parameter in the constructor:
Foo::Foo(const unsigned int index) : Index(index)
{
    this->Size = 0.5 / index;
    this->Children = {};

    if (index < MAX_DIVS) {
        for (int _x = 0; _x < 2; _x++) {
            for (int _y = 0; _y < 2; _y++) {
                this->Children[_x][_y] = 0;
        }

    }

}

I can assign the initial value to Size doing this->Size= 0.5/Index, but I cannot initialize Children;
Visual Studio gives me an error on this->Children = {} saying: "Expression must have a modifiable lvalue". Why is it?

A: As @L.F. and @UnholySheep pointed out, to have a default value for the Children Variable, it should be added to the member initializer list, like this:
Foo::Foo(const unsigned int index) : Index(index), Children(), Size(0.5/index) {}

This will initialize the variable Children as an all 0 array which can be then further modified in the constructor.


text:
Q: Docker-Compose Nakama Console Ports not working when access from other device in the same WI-FI I made containers with docker-compose which one of service direct to localhost port: 7351.
This is the part of my docker-compose.yml:
nakama:
    build: .
    # image: heroiclabs/nakama:3.11.0
    depends_on:
      - postgres
    volumes:
      - ./data/:/nakama/data
    entrypoint:
      - "/bin/sh"
      - "-ecx"
      - >
        /nakama/nakama migrate up --database.address postgres:localdb@postgres:5432/nakama &&
        exec /nakama/nakama --config /nakama/data/local.yml --database.address postgres:localdb@postgres:5432/nakama
    expose:
      - "7349"
      - "7350"
      - "7351"
    #network_mode: "host"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7350/"]
      interval: 10s
      timeout: 5s
      retries: 5
    links:
      - "postgres:db"
    ports:
      - "7349:7349"
      - "7350:7350"
      - "7351:7351"
    restart: unless-stopped

So the 7351 port is for Admin Web Page.
It works well when I enter it from the localhost.
Like 127.0.0.1:7351 or 192.168.75.102:7351(IPv4 address)
But When I enter from android device which is in the same Wi-Fi to 192.168.75.102:7351, it doesn't response.

Is there a setting for it, or way to debug what is happening?
I'm using Docker Desktop on Windows 10.
As I understand, if it is in same Wi-Fi, It should work the same as localhost. is it wrong?
Additionally, When I run Nakama server natively from the Windows, not through docker, It works fine when access from the android device in same Wi-Fi.
But in native windows, I can't build golang modules for the server. So I need to run it on Linux Container.


text:
Q: Ansible: how to get dynamic service state with a variable within another I'm new to Ansible and trying to get a service state where the service name is dynamic and set by set_fact before in the playbook.
How can you build a variable within another variable?
I wish I could use something like that to display my service state :
{{ ansible_facts.services['{{ servicename }}'].state }}

But well it doesn't work.
So I tried this way with vars :
  - name: set service name
    ansible.builtin.set_fact:
      servicename: "'myservice'"
    when: ansible_distribution_major_version == "7"

  - name: print service state
    debug: msg={{ vars['ansible_facts.services[' + servicename + '].state'] }}
    vars:
      servicename: "{{ servicename }}"

I got the following error :
fatal: [myhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute u\"ansible_facts.services['myservice'].state\"\n\nThe error appears to be in '/etc/ansible/playbook/myplaybook.yaml': line 20, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n  - name: print service state\n    ^ here\n"}

When the following works just fine :
  - name: print service state
    debug:
      msg: "{{ ansible_facts.services['myservice'].state }}"

A: Inside a {{ … }} block, you can access the variables directly. And from my point of view, you can leave the ansible_facts out, as well as the variable assignment in the second task.
This will do what you want (and as Zeitounator already wrote):
- hosts: localhost
  vars:
    services:
      myservice:
        state: foo
  tasks:
    - name: set service name
      ansible.builtin.set_fact:
        servicename: "myservice"

    - name: print service state
      debug:
        msg: "{{ services[servicename].state }}"


text:
Q: Taking sum/average of columns in mongoosejs I have a MongoDB collection "Marks" with fields student_id,Subject,Mark.
I want to the average value of marks scored by a particular student.
My project is in NodeJs and I am using MongooseJS for object modeling.
How to query the this using MOngooseJS?
EXAMPLE
     Student_id   Subject  Mark
     111          AAA      9
     111          BBB      5
     111          CCC      7
     222          AAA      10
     222          CCC      6
     222          BBB      8

I want average of marks scored by student(id) 111 i.e((9+5+7)/3)=7)

A: This sounds like the poster child example of a Map/Reduce operation in MongoDB.
What you want to do is first run a map step where you emit all grades that belong to student id 111.
Then you run the reduce step where you average these.
The monogdb code should look similar to this:
var map = function() {
  emit(this.Student_id, this.Mark);
}
var reduce = function(key, values) {
  var result = { studentid: key, mark_sum: 0, count: 0, avg_mark: 0 };
  values.forEach(function(v) {
    r.mark_sum += v;
    r.count += 1;
  });
  return r;
}

var finalize = function(key, value) {
  if (value.count > 0) {
    value.avg_mark = value.mark_sum / value.count;
  }
  return value;
}

And the execution of the mapReduce in Mongo syntax:
var command = db.runCommand( { mapreduce:"<your collection>",
                  map: map,
                  reduce: reduce,
                  query: { Student_id: 111 },
                  out: { reduce: "session_stat" },
                  finalize: finalize
                });

The result of the map_reduce is written to session_stat. Where you can query it.
To see how to use MapReduce in Mongoose please look at this Question: mongoose mapreduce()

A: If you're using MongoDB 2.2 you can use the aggregation framework for this:
var Mark = mongoose.model('mark', new Schema({
    Student_id: Number,
    Subject: String,
    Mark: Number
}));

Mark.aggregate([
        { $group: {
            _id: '$Student_id',
            markAvg: { $avg: '$Mark'}
        }}
    ], function (err, results) {
        if (err) {
            console.error(err);
        } else {
            console.log(results);
        }
    }
);

Output:
[ { _id: 222, markAvg: 8 }, { _id: 111, markAvg: 7 } ]


text:
Q: Possible to output console result into text file? I am required to store the below console data into a text file:
enter image description here
However, the name of the textfile of where the output will be placed in is typed in by the user. I am unable to find a proper way to store all the console data in the requested text file. Since I use width and special spaces I am unsure how to go about doing this.
My Code:
 if(message == "5"){
                cout << "\n[View Data...]" << endl;
                cout << "filtering criteria:" << optionTwo << endl;
                cout << "sorting criteria:" << optionThree << endl;
                cout << "sorting order:" << optionFour << endl;
                cout << "" << endl;

            if(optionTwo == "Point2D"){

                std::cout.width(5); std::cout << std::right << "X";
                std::cout.width(6); std::cout << std::right << "Y";
                std::cout.width(9); std::cout << std::right << "Dist.";
                std::cout.width(3); std::cout << std::right << "Fr" ;
                std::cout.width(7); std::cout << std::right << "Origin" << endl;
}
}

if(message == "6"){

            cout << "Please enter filename: " ;
            cin >> message6;

        }

A: You can use filestreams for this:
std::cin >> message6;           // read file name from the user
std::ofstream file {message6};  // open file with that name
file << "hello world";          // write data to the file

Similar to writing data to cout, you can use stream modifiers for file as well.

A: When you are sending text into cout you are basically writing to a file already, just a system standard one called stdout. You simply need to open a different output file stream and send the output the same way.
#include <iostream>
#include <fstream>
using namespace std;

ofstream out = ofstream("file.txt", ios::out);

out.width(5);
out << std:;right << "X";

You do not strictly need to include the ios::out since it is the default mode for ofstream objects. You can read more at the cppreference

A: I don't know what kind of string you're using but, you can use the std::ostream for that:
 ofstream myfile;
 cout << "Please enter filename: " ;
 cin >> message6;
 myfile.open (message6);

Then instead of using cout, you'd use:
myfile << "Your string.\n";

But if you want to redirect he actual standard output of the program to a file. You can do it through calling arguments. And that can be set in the execution panel in your IDE or the terminal when the program is called
your_program >> output_file.txt


text:
Q: Run script on a runat=server control how can you run a script on a control that has a runat=server attribute?
Removing the runat=server makes the script run smoothly, but I wouldn't be able to access the control.
Here's the script. Any idea?
<input runat="server" type="text" id="txthSchedTime" readonly="true" class="asclock" style="width:100px; background-color:lightyellow" onclick="setTimePicker();" />
<script>
$("#txthSchedTime").AnyTime_picker(
{
format: "%h:%i %p", labelTitle: "Schedule Time",
labelHour: "Hour", labelMinute: "Minutes"
});
</script>

thanks

A: You can call the function from code behind like this :
yourForm.aspx.cs:
    protected void txthSchedTimeEvent(....)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "myFunction();", true);
    }

yourForm.aspx
        <html xmlns="http://www.w3.org/1999/xhtml">
            <head id="Head1" runat="server">
                <title>My Page</title>
                <script type="text/javascript">
                    function myFunction(){
                    $("#txthSchedTime").AnyTime_picker(
                    {
                    format: "%h:%i %p", labelTitle: "Schedule Time",
                    labelHour: "Hour", labelMinute: "Minutes"
                    });
                    }
                </script>
            </head>
            <body>
                <form id="form2" runat="server">
                <table>
                    <tr> <td>
                     <asp:TextBox ID="txthSchedTime" runat="server"
                        style="width:100px; background-color:lightyellow">
                     </asp:TextBox>
                    </td> </tr>
                </table>
                </form>
            </body>
        </html>

A: Try using this for example :
 <input runat="server" type="text" id="txthSchedTime" readonly="true" class="asclock" style="width:100px; background-color:lightyellow" onclick="setTimePicker();" />
<script>
    $("#<%=txthSchedTime.ClientID %>").val('test');

</script>

Just tested it on my local machine. The input gets the value "test".

A: After several attempts and trials it leads me to this.
<script type="text/javascript">
        function setTimePick() {
            var tp = document.getElementById('<%=((HtmlInputText)fvVIPDtls.FindControl("txthSchedTime")).ClientID%>');
            $(tp).AnyTime_picker(
            {
                format: "%h:%i %p", labelTitle: "Schedule Time",
                labelHour: "Hour", labelMinute: "Minutes"
            });
        }
    </script>

then i just call the function i made
<input runat="server" readonly="true" type="text" id="txthSchedTime" class="asclock" style="width:100px; background-color:lightyellow" onfocus="setTimePick();" />


text:
Q: how to get seesion in page.js file in next 13 I am not able to get session data to call API on page
in next 12 > getsession(")was working
in next 13 > ??
tried these two methods and getting initial data
getsession()
usesession()

A: in next js 13 version a new method is ad getserversession()
we can now use this method
how t house
call getserversession(authO)
here authO is a function which we have create in next auth and exported


text:
Q: Why is the size and values of this OpenCV Matrix incorrect? I use the following function to return a weight matrix of values between 0 and 1 depending on how close to the center a particular matrix position is. Also after a threshold the values are all 1 (it is like plateau with the points closer to center having value 1 and points away from center after a threshold of distance linearly fall from 1 to 0 at the edges)?
cv::Mat2f getWeightsMatrix(int N, int M, float r){
    cv::Mat2f weights = cv::Mat2f(N,M);
    int i,j;
    for(i=0;i<N;i++){
        for(j=0;j<M;j++){
            if(i<=floor(N*(1-r)/2)){
                if(j<=floor(M*(1-r)/2)){
                    weights[i][j]=((float)(i/N-j/M)/(1-r));
                }
                else{
                    weights[i][j]=(2*(float)(i/N)/(1-r));
                }
            }
            else if (i>=floor(N*(1+r)/2)){
                if(j>=floor(M*(1+r)/2)){
                    weights[i][j]=(((float)((N-i)/N))-((float)((M-j)/M)))/(1-r);
                }
                else{
                    weights[i][j]=(2*(float)((N-i)/N)/(1-r));
                }
            }
            else{
                if(j<=floor(M*(1-r)/2)){
                    weights[i][j]=(2*(float)(j/M)/(1-r));
                }
                else if(j>=floor(M*(1+r)/2)){
                    weights[i][j]=(2*(float)((M-j)/M)/(1-r));
                }
                else{
                    weights[i][j]=1;
                }
            }
        }
    }
    cout << weights << endl;
    return weights;
}

Now my problem is that I am having some casting issues and only values 0 and 1 are being returned (no floats). Also my matrix size displayed by the cout is 20x10 when I call the function with N=10, M=10 and r=0.5.
Please helP!
EDIT: This is the output
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

A: Your matrix consists only if integers because when you do basic operations on integers, the results gets rounded automatically.
For example: when you write
weights[i][j]=((float)(i/N-j/M)/(1-r));

The result of i/N is rounded to a integer, j/M is also rounded to an integer, and finally, the division by (1-r) is also rounded. Your (float) cast is a good idea but it's applied too late.
You can do several things:

*

*Cast inside elementary operations, for instance, float(i)/N instead of i/N

*Use float numbers instead of integers: write 1.0 instead of 1

*Use floats inside your loops and statements

For example:
for(float i = 0; i < N-0.5; i++) {
    for(float j = 0; j < M-0.5; j++) {
        if(i <= floor(N*(1.0-r)/2.0)) {
            // ...

It's important you understand that because of floating point precision, a test such as i < N might or might not pass when float i = N. This is why I did a little trick by substracting 0.5 from your loop bounds N and M.


text:
Q: What is the QNX kernel binary name I'm working on a project where underlying Kernel is from QNX and all the Kernel sources are coming as binary ,for example CAM layer for block drivers is present as libcam.a but could not find the exact kernel binary which should be there in whole source tree of project.
Can anybody tell me what is the way to find it out??

A: The running kernel is going to be the process with PID of 1. Use ps -e to see it.
In my case, it's procnto. If you are running the instrumented kernel (for debugging) it's procnto-instr.
 ps -e
       PID TTY          TIME CMD
         1 ?        12:25:42 procnto
      4098 ?        00:00:00 pci-bios
      4099 ?        03:40:47 io-usb
      4100 ?        00:00:00 io-hid
      4101 ?        00:00:00 devc-con-hid
      4102 ?        00:58:14 devb-eide
     20487 ?        00:00:00 /sbin/tinit
     20488 ?        00:00:00 slogger
     24585 ?        00:00:25 pipe
     28682 ?        00:10:22 mqueue

Depending on how you make your IFS file, you could have a .build file that includes something like the following:
#
# The build file for QNX Neutrino booting on a PC
#
[linker="ntox86-ld -T$QNX_TARGET/x86/lib/nto.link %(h!=0, -Ttext 0x%t%)%(d!=0, -Tdata 0x%d%) -o%o %i %[M -L%^i -uinit_%n -lmod_%n%]"]
[virtual=x86,bios +compress] boot = {
    startup-bios

    # PATH is the *safe* path for executables (confstr(_CS_PATH...))
    # LD_LIBRARY_PATH is the *safe* path for libraries (confstr(_CS_LIBPATH))
    #    i.e. This is the path searched for libs in setuid/setgid executables.
    PATH=/proc/boot:/bin:/usr/bin:/opt/bin LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll:/opt/lib procnto

}
   ...
That last procnto is what tells the bootloader which kernel to use. Look at mkifs for more information.