text:
Q: Netlify / React front end not connecting to Node.js / Express / MongoDB Atlas / Heroku backend but works in development/locally FIX: after following some advice I ditched the setupProxy and put the full API urls into the axios request. This threw a cors error so I imported CORS & added app.use(cors()) into my index.js & when I redeployed the app ran as intended
I am trying to deploy a MERN stack practise project for the first time. I am quite a new coder.
My project works perfectly fine in development/locally. My React app running on localhost:3000 connects to the Node/Express/MongoDB Atlas API that I deployed to Heroku & can make requests successfully.
However when I open the deployed Netlify app it fails to load any data & the Heroku logs show no activity which suggests it's not connecting to the backend at all.
Here are some bits of code that may be relevant:
-----------Backend---------------
environment.js (info in <> redacted)
export const dbURI = process.env.MONGODB_URI || 'mongodb+srv://<name>:<password>@festivalist.iyq41.mongodb.net/festivalist?retryWrites=true&w=majority'
export const port = process.env.PORT || 4000
export const secret = process.env.SECRET || '<secret>'

index.js
import express from 'express'
const app = express()
import mongoose from 'mongoose'
import router from './config/router.js'
import { port, dbURI } from './config/environment.js'

const startServer = async () => {
  try {
    await mongoose.connect(dbURI, { useNewUrlParser: true, useCreateIndex: true, useUnifiedTopology: true })
    console.log(' Database has connected successfully')

    app.use(express.json())

    app.use((req, _res, next) => {
      console.log(` Incoming request: ${req.method} - ${req.url}`)
      next()
    })

    app.use('/api', router)

    app.listen(port, () => console.log(` Express is up and running on port ${port}`))
  } catch (err) {
    console.log(' Something went wrong starting the app')
    console.log(err)
  }
}
startServer()

package.json
{
  "name": "sei-project-three",
  "version": "1.0.0",
  "main": "index.js",
  "dependencies": {
    "bcrypt": "^5.0.1",
    "dotenv": "^10.0.0",
    "express": "^4.17.1",
    "jsonwebtoken": "^8.5.1",
    "mongo": "^0.1.0",
    "mongoose": "^5.12.0",
    "nodemon": "^2.0.14"
  },
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "seed": "node db/seeds.js",
    "dev": "nodemon",
    "start": "node index.js"
  },
  "devDependencies": {
    "eslint": "^7.22.0"
  },
  "engines": {
    "node": "16.8.0"
  }
}

-------------Front end --------------
setupProxy.js
const { createProxyMiddleware } = require('http-proxy-middleware')

module.exports = function (app) {
  app.use(createProxyMiddleware('/api', { target: 'https://festivalist-api.herokuapp.com', "changeOrigin": true }))
}

example request
const ArtistIndex = () => {
  const [artists, setArtists] = useState([])

  useEffect(() => {
    const getData = async () => {
      const { data } = await axios.get('/api/artists')
      setArtists(data)
    }
    console.log('artists2', artists)
    getData()
  }, [])

package.json
{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.21.1",
    "http-proxy-middleware": "^1.0.5",
    "mapbox-gl": "^2.2.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-map-gl": "^5.2.5",
    "react-mapbox-gl": "^5.1.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.3",
    "sass": "^1.42.1",
    "semantic-ui-css": "^2.4.1",
    "semantic-ui-react": "^2.0.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^4.25.0",
    "@typescript-eslint/parser": "^4.25.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^7.27.0",
    "eslint-config-react-app": "^6.0.0",
    "eslint-plugin-flowtype": "^5.7.2",
    "eslint-plugin-import": "^2.23.3",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-react": "^7.23.2",
    "eslint-plugin-react-hooks": "^4.2.0"
  }
}

Some notes:

*

*I have whitelisted all IP addresses in MongoDB Atlas 0.0.0.0/0

*I'm unsure why but I have to put '/api/' on the end of the heroku api url to get the data ie: https://festivalist-api.herokuapp.com/api/festivals

*I added Config Vars in Heroku but I think that stopped my app from working locally so I deleted them. Also not fully sure I understand what they do.

I have been trying to deploy this for days now so any advice would be a help or any troubleshooting tips since I am new to coding! Thanks

A: You have to put '/api' in at the end of heroku API because that's what you've used in your backend index.js app.use('/api', router)
The problem seems like something to do with the middle-wear setupProxy.js since you can ping the API already. One workaround is to just update your requests to use the full URI. i.e
const ArtistIndex = () => {
  const [artists, setArtists] = useState([])

  useEffect(() => {
    const getData = async () => {
      const { data } = await axios.get('https://festivalist-api.herokuapp.com/api/artists')
      setArtists(data)
    }
    console.log('artists2', artists)
    getData()
  }, [])


text:
Q: Value assignment for complete, transitive relation on uncountably infinite set Consider a set $A$ and a relation $r$.
The relation $r$ is complete, i.e., for any $a,b\in A$, we have $arb$ or $bra$ or both.
The relation $r$ is transitive, i.e., for any $a,b,c\in A$, if $arb$ and $brc$, then $arc$.
Must there exist a function $f:A\rightarrow\mathbb{R}$ such that for any $a,b\in A$, we have $arb$ if and only if $f(a)\geq f(b)$?
If $A$ is countably infinite, the answer is yes. I'm wondering what about if $A$ is uncountably infinite? I'm almost sure there must be a counterexample, but I don't know how to find one. (For example, if $A=\mathbb{R}$, then the trivial map $f(x)=x$ works.)

A: The answer is no.
What you asking is basically, whether $A/{\sim}$ can be embedded into $\langle\mathbb{R},\leq\rangle$, where
$$x \sim y \quad\text{ if and only if }\quad x\ r\ y \land y\ r\ x.$$
A counterexample might be $\langle\mathbb{R}^2,\leq_\text{lex}\rangle$, that is,
$$(x_1,y_1) \leq_\text{lex} (x_2,y_2) \quad\text{ if and only if }\quad x_1 < x_2 \lor (x_1 = x_2 \land y_1 \leq y_2).$$
Here $\sim$ would be just identity, so we are trying to map lexicographical order on $\mathbb{R}^2$ into standard order of $\mathbb{R}$. Why these two are different? Suppose there exists an order-preserving mapping $f : \mathbb{R}^2 \to \mathbb{R}$ and define
\begin{align}
a_x &= f(x,0) \\
b_x &= f(x,1)
\end{align}
and observe that $a_x \lneq_\text{lex} b_x$ and for $x < y$ also $b_x \lneq_\text{lex} a_y$. In other words $\{(a_x,b_x) \mid x \in \mathbb{R}\}$ would constitute an uncountable set of disjoint open intervals, which is impossible (e.g. because rational numbers are countable).
I hope this helps $\ddot\smile$

redpajama_set_name: RedPajamaStackExchange


text:
Q: Shortest code to make INITEX produce printable output What is the shortest sequence of characters that will lead to a printable page of output when processed by INITEX? Meaning no formats like plain.tex preloaded, and with output of positive width and height. The best I could do so far are the following 19 characters:
\font\@=cmr9\@A\end

Is there any typesettable material that does not require a font to be loaded and that can occur on its own at the top of the page?

A: This is 19 characters and no fonts
\hrule width9in\end

Or if you are allowed to scroll past errors save 2 characters so (17)
\hrule width9\end

where if you scroll past the missing units error you get a 9pt rule.
This is same output as yours, but one less character input (18)
\font\@cmr9\@A\end

and changing the font gets down to 17 characters
\font\@pxr\@A\end

There are several three letter fonts in texlive, but no two or one letter ones but if renaming (any) font is allowed so that z.tfm is available then the count comes down to 15
\font\@z\@A\end

Or 14 with a font with name of length 0 (tex is happy, your dvi driver might be less so)
cp /usr/local/texlive/2019/texmf-dist/fonts/tfm/public/cm/cmr10.tfm .tfm
cp /usr/local/texlive/2019/texmf-dist/fonts/pk/ljfour/public/cm/dpi600/cmr10.pk .pk

Then you can use (14)
\font\@\@A\end

In comments the OP asks about
\hrule1\end

which is shorter but doesn't produce visible output but two blank pages.
the generated box structure is:
Completed box being shipped out [0]
\vbox(0.0+0.0)x0.0
.\glue(\topskip) 0.0
.\rule(0.4+0.0)x*

Completed box being shipped out [0]
\vbox(0.0+0.0)x0.0
.\glue(\topskip) 0.0
.\hbox(0.0+0.0)x0.0
..\hbox(0.0+0.0)x0.0
..\penalty 10000
..\glue(\parfillskip) 0.0
..\glue(\rightskip) 0.0
.\hbox(0.0+0.0)x0.0
.\glue 0.0 plus 1.0fill

 )

\vsize is 0pt so more or less any feasible break point will be taken, here on the first page you get the hrule which has non zero height but zero width as hsize is  zero, then the second page has the paragraph generated by the text 1 except that it is set in nullfont so nothing gets typeset.


text:
Q: What is to be the resolution of button for all drawable folder in android? Button which i created for my app is of resolution 166*169. But it doesn't look perfect on my app when placed directly from drawable folder. So i created other drawable folders, but what is to be the resolution among them doesn't know. I do google that but nothing find which is relevant to me.

A: You need to create different png files for different drawables such as hdpi or mdpi.  I recommend you do use 9-patch images.  It is simple now that you can use a 9-patch generator, just put your image it will generate 9-patch images for all your drawable folders and you just need to import them.

A: Use SVG instead of PNG or JPEG in drawable, android support svg and this Link will help you


text: Q: How to use Spearman correlation for global sensitivity analysis? Could anyone provide a simple example on Spearman correlation for sensitivity analysis? like ranking the importance of variables in a function. Thanks in advance!


text:
Q: Prove that $\{a,b,c\} \subseteq \{1,4\}$
Prove that if $$a^n+b^n+c^n \equiv \alpha +\beta \cdot 4^n \pmod{p}$$ for all positive integers $n$, some prime $p>2$, and positive integers $a,b,c$ where $\alpha,\beta$ are constants, then $\{a,b,c\} \subseteq \{1,4\}$  taken modulo $p$.

Attempt:
Note: $t_n \equiv \alpha +\beta \cdot 4^n \pmod p$ and all equivalences here are taken modulo $p$.
Using the geometric series we get $$\frac{1}{1-az} + \frac 1{1-bz} + \frac 1{1-cz} = \sum_{n\ge 0}t_nz^n = \frac{\alpha}{1-z} + \frac{\beta}{1-4z}.$$ Now the LHS is $$\dfrac{(1-bz)(1-cz)+(1-az)(1-cz)+(1-az)(1-bz)}{(1-az)(1-bz)(1-cz)}$$ while the RHS is $$\dfrac{\alpha(1-4z)+\beta(1-z)}{(1-z)(1-4z)}.$$ I think some argument about the degree of the denominator might work.
Context:
I was originally solving this question.

Let $a$, $b$, $c$ be positive integers and $p$ be a prime number. Assume that $$a^n(b+c)+b^n(a+c)+c^n(a+b)\equiv 8\pmod{p}$$ for each nonnegative integer $n$. Let $m$ be the remainder when $a^p+b^p+c^p$ is divided by $p$, and $k$ the remainder when $m^p$ is divided by $p^4$. Find the maximum possible value of $k$.

Solution:
Assume that $p$ is odd and let $t_n \equiv a^n+b^n+c^n \pmod p$. Plugging in $n=0$ and $n=1$ into the given congruence gives us $$a+b+c \equiv ab+bc+ca \equiv 4 \pmod p.$$ We also see that the given congruence is equivalent to $t_{n+1} \equiv 4t_n-8 \pmod p$ since $$a^n(b+c)+b^n(a+c)+c^n(a+b) =(a+b+c)\left(a^n+b^n+c^n\right) - a^{n+1}-b^{n+1}-c^{n+1}\equiv 8\pmod p.$$ Then, by shifting the index we obtain $t_n \equiv 4t_{n-1}-8 \pmod p$ and subtracting it from the original we get $t_{n+1}\equiv 5t_n-4t_{n-1} \pmod p$. This implies that $t_n \equiv \alpha+\beta \cdot 4^n \pmod p$.
Lemma 1. We have that $a,b,c \not \equiv 0 \pmod{p}$.
Proof. Firstly, we have \begin{align*}
(ab+bc+ca)t_n &= abc \cdot t_{n-1} + \sum_{\text{sym}} a^{n+1}b \\
&\equiv abc\cdot t_{n-1} + 8 \pmod p \\
t_n &\equiv \frac14 abc\cdot t_{n-1} + 2 \pmod p. \\
\end{align*}
Thus, letting $n=2$ and since $S_2 \equiv 8 \pmod p$ we obtain \begin{align*}
8 &\equiv \frac14 abc \cdot 4 + 2 \pmod p \\
abc &\equiv 6 \pmod p.
\end{align*}
Therefore $a,b,c$ are not equal to $0$ modulo $p$.
Lemma 2. We have that $\{a,b,c\} \subseteq \{1,4\}$.
This is where my question comes in.

A: I did an actual check for primes bigger than $3,$ always worked. It is a finite check. Worth attempting a genuine proof. Note that it is also possible to have $a \equiv b \equiv c \equiv \alpha \equiv \beta \equiv 0 \pmod p.$ I told the program to have $a,b,c$ nonzero $\pmod p.$
jagy@phobeusjunior:~$
prime  5           a  1  b  1  c  1  alpha  3  beta  0
prime  5           a  1  b  1  c  4  alpha  2  beta  1
prime  5           a  1  b  4  c  4  alpha  1  beta  2
prime  5           a  4  b  4  c  4  alpha  0  beta  3

prime  7           a  1  b  1  c  1  alpha  3  beta  0
prime  7           a  1  b  1  c  4  alpha  2  beta  1
prime  7           a  1  b  4  c  4  alpha  1  beta  2
prime  7           a  4  b  4  c  4  alpha  0  beta  3

prime  11           a  1  b  1  c  1  alpha  3  beta  0
prime  11           a  1  b  1  c  4  alpha  2  beta  1
prime  11           a  1  b  4  c  4  alpha  1  beta  2
prime  11           a  4  b  4  c  4  alpha  0  beta  3

prime  13           a  1  b  1  c  1  alpha  3  beta  0
prime  13           a  1  b  1  c  4  alpha  2  beta  1
prime  13           a  1  b  4  c  4  alpha  1  beta  2
prime  13           a  4  b  4  c  4  alpha  0  beta  3

prime  17           a  1  b  1  c  1  alpha  3  beta  0
prime  17           a  1  b  1  c  4  alpha  2  beta  1
prime  17           a  1  b  4  c  4  alpha  1  beta  2
prime  17           a  4  b  4  c  4  alpha  0  beta  3

prime  19           a  1  b  1  c  1  alpha  3  beta  0
prime  19           a  1  b  1  c  4  alpha  2  beta  1
prime  19           a  1  b  4  c  4  alpha  1  beta  2
prime  19           a  4  b  4  c  4  alpha  0  beta  3

prime  23           a  1  b  1  c  1  alpha  3  beta  0
prime  23           a  1  b  1  c  4  alpha  2  beta  1
prime  23           a  1  b  4  c  4  alpha  1  beta  2
prime  23           a  4  b  4  c  4  alpha  0  beta  3

prime  29           a  1  b  1  c  1  alpha  3  beta  0
prime  29           a  1  b  1  c  4  alpha  2  beta  1
prime  29           a  1  b  4  c  4  alpha  1  beta  2
prime  29           a  4  b  4  c  4  alpha  0  beta  3

prime  31           a  1  b  1  c  1  alpha  3  beta  0
prime  31           a  1  b  1  c  4  alpha  2  beta  1
prime  31           a  1  b  4  c  4  alpha  1  beta  2
prime  31           a  4  b  4  c  4  alpha  0  beta  3

prime  37           a  1  b  1  c  1  alpha  3  beta  0
prime  37           a  1  b  1  c  4  alpha  2  beta  1
prime  37           a  1  b  4  c  4  alpha  1  beta  2
prime  37           a  4  b  4  c  4  alpha  0  beta  3

prime  41           a  1  b  1  c  1  alpha  3  beta  0
prime  41           a  1  b  1  c  4  alpha  2  beta  1
prime  41           a  1  b  4  c  4  alpha  1  beta  2
prime  41           a  4  b  4  c  4  alpha  0  beta  3

prime  43           a  1  b  1  c  1  alpha  3  beta  0
prime  43           a  1  b  1  c  4  alpha  2  beta  1
prime  43           a  1  b  4  c  4  alpha  1  beta  2
prime  43           a  4  b  4  c  4  alpha  0  beta  3

prime  47           a  1  b  1  c  1  alpha  3  beta  0
prime  47           a  1  b  1  c  4  alpha  2  beta  1
prime  47           a  1  b  4  c  4  alpha  1  beta  2
prime  47           a  4  b  4  c  4  alpha  0  beta  3

prime  53           a  1  b  1  c  1  alpha  3  beta  0
prime  53           a  1  b  1  c  4  alpha  2  beta  1
prime  53           a  1  b  4  c  4  alpha  1  beta  2
prime  53           a  4  b  4  c  4  alpha  0  beta  3

prime  59           a  1  b  1  c  1  alpha  3  beta  0
prime  59           a  1  b  1  c  4  alpha  2  beta  1
prime  59           a  1  b  4  c  4  alpha  1  beta  2
prime  59           a  4  b  4  c  4  alpha  0  beta  3

prime  61           a  1  b  1  c  1  alpha  3  beta  0
prime  61           a  1  b  1  c  4  alpha  2  beta  1
prime  61           a  1  b  4  c  4  alpha  1  beta  2
prime  61           a  4  b  4  c  4  alpha  0  beta  3

prime  67           a  1  b  1  c  1  alpha  3  beta  0
prime  67           a  1  b  1  c  4  alpha  2  beta  1
prime  67           a  1  b  4  c  4  alpha  1  beta  2
prime  67           a  4  b  4  c  4  alpha  0  beta  3

prime  71           a  1  b  1  c  1  alpha  3  beta  0
prime  71           a  1  b  1  c  4  alpha  2  beta  1
prime  71           a  1  b  4  c  4  alpha  1  beta  2
prime  71           a  4  b  4  c  4  alpha  0  beta  3

prime  73           a  1  b  1  c  1  alpha  3  beta  0
prime  73           a  1  b  1  c  4  alpha  2  beta  1
prime  73           a  1  b  4  c  4  alpha  1  beta  2
prime  73           a  4  b  4  c  4  alpha  0  beta  3

prime  79           a  1  b  1  c  1  alpha  3  beta  0
prime  79           a  1  b  1  c  4  alpha  2  beta  1
prime  79           a  1  b  4  c  4  alpha  1  beta  2
prime  79           a  4  b  4  c  4  alpha  0  beta  3

prime  83           a  1  b  1  c  1  alpha  3  beta  0
prime  83           a  1  b  1  c  4  alpha  2  beta  1
prime  83           a  1  b  4  c  4  alpha  1  beta  2
prime  83           a  4  b  4  c  4  alpha  0  beta  3

prime  89           a  1  b  1  c  1  alpha  3  beta  0
prime  89           a  1  b  1  c  4  alpha  2  beta  1
prime  89           a  1  b  4  c  4  alpha  1  beta  2
prime  89           a  4  b  4  c  4  alpha  0  beta  3

prime  97           a  1  b  1  c  1  alpha  3  beta  0
prime  97           a  1  b  1  c  4  alpha  2  beta  1
prime  97           a  1  b  4  c  4  alpha  1  beta  2
prime  97           a  4  b  4  c  4  alpha  0  beta  3

prime  101           a  1  b  1  c  1  alpha  3  beta  0
prime  101           a  1  b  1  c  4  alpha  2  beta  1
prime  101           a  1  b  4  c  4  alpha  1  beta  2
prime  101           a  4  b  4  c  4  alpha  0  beta  3

prime  103           a  1  b  1  c  1  alpha  3  beta  0
prime  103           a  1  b  1  c  4  alpha  2  beta  1
prime  103           a  1  b  4  c  4  alpha  1  beta  2
prime  103           a  4  b  4  c  4  alpha  0  beta  3

prime  107           a  1  b  1  c  1  alpha  3  beta  0
prime  107           a  1  b  1  c  4  alpha  2  beta  1
prime  107           a  1  b  4  c  4  alpha  1  beta  2
prime  107           a  4  b  4  c  4  alpha  0  beta  3

prime  109           a  1  b  1  c  1  alpha  3  beta  0
prime  109           a  1  b  1  c  4  alpha  2  beta  1
prime  109           a  1  b  4  c  4  alpha  1  beta  2
prime  109           a  4  b  4  c  4  alpha  0  beta  3

prime  113           a  1  b  1  c  1  alpha  3  beta  0
prime  113           a  1  b  1  c  4  alpha  2  beta  1
prime  113           a  1  b  4  c  4  alpha  1  beta  2
prime  113           a  4  b  4  c  4  alpha  0  beta  3

prime  127           a  1  b  1  c  1  alpha  3  beta  0
prime  127           a  1  b  1  c  4  alpha  2  beta  1
prime  127           a  1  b  4  c  4  alpha  1  beta  2
prime  127           a  4  b  4  c  4  alpha  0  beta  3

prime  131           a  1  b  1  c  1  alpha  3  beta  0
prime  131           a  1  b  1  c  4  alpha  2  beta  1
prime  131           a  1  b  4  c  4  alpha  1  beta  2
prime  131           a  4  b  4  c  4  alpha  0  beta  3

prime  137           a  1  b  1  c  1  alpha  3  beta  0
prime  137           a  1  b  1  c  4  alpha  2  beta  1
prime  137           a  1  b  4  c  4  alpha  1  beta  2
prime  137           a  4  b  4  c  4  alpha  0  beta  3

prime  139           a  1  b  1  c  1  alpha  3  beta  0
prime  139           a  1  b  1  c  4  alpha  2  beta  1
prime  139           a  1  b  4  c  4  alpha  1  beta  2
prime  139           a  4  b  4  c  4  alpha  0  beta  3

prime  149           a  1  b  1  c  1  alpha  3  beta  0
prime  149           a  1  b  1  c  4  alpha  2  beta  1
prime  149           a  1  b  4  c  4  alpha  1  beta  2
prime  149           a  4  b  4  c  4  alpha  0  beta  3

jagy@phobeusjunior:~$


text:
Q: Objective C - wantsFullScreenLayout not covering TabBarController I've been trying to get a section of my TabBarController to go fullscreen for a while but still can't figure out this 1 last piece.
So I'm able to put the UIViewController behind UINavigationBar using the code below.
self.navigationController.navigationBar.translucent = YES;
self.wantsFullScreenLayout = YES;

Also able to hide the UINavigationBar & TabBarController using the code below.
[self.navigationController setNavigationBarHidden:YES animated:NO];
[self.tabBarController.tabBar setHidden:YES];

However, my UIViewController's height still wouldn't extend behind where the TabBarController is before I hide it. So it looks as though there is a blank space below.
Image attached.

I tried changing self.tabBarController.view.frame and bound. Still doesn't do it. Seems like something is preventing it to cover that bottom portion.
How can I achieve that?
Thank you,
Tee

A: UITabBarController is not designed to allow its subview to go "behind" the tab bar, probably because a tab bar cannot be translucent. And although [self.tabBarController.tabBar setHidden:YES] does hide the tab bar, it doesn't tell the UITabBarController to lay out your view in the space that is normally occupied by the tab bar. In fact, there is no really supported way to do this.
OTOH, it is easy enough to reposition the tab bar manually if you are willing to risk things breaking in a future version of iOS. The UITabBarController's view has two subviews: one is the tab bar, and the other is the content view (which contains the view from the currently active view controller). Just resize the content view to occupy the space; you could even animate the tab bar moving off the bottom of the screen if you'd like.


text:
Q: Monitoring with Wireshark on Wirless Networks I'm a beginner and started working with Wireshark and hacking and I have some questions about it.
The monitoring of a particular computer does not always work immediately.
Why does the monitoring of a particular computer only work when it reconnects to the network or waits for some time?
And is it possible to force a reconnection of the target computer to the network?
Is there a difference that can observe in monitored traffic for encrypted and unencrypted connections?

A:
Why does the monitoring of a particular computer only work when it reconnects to the network or waits for some time?

If the target isn't connected to the network, it obviously isn't sending traffic that you could trace. Since we're talking about WiFi traffic, it might be possible that the target device shuts down the WiFi connection or even disables the WiFi adapter after certain amount of inactivity time. WiFi is pretty expensive powerwise, so for example Apple devices tend to do this. That's one of the sources of the stellar battery times.

And is it possible to force a reconnection of the target computer to the network?

Not with Wireshark or any other monitoring tool I'm aware of.

Is there a difference that can observe in monitored traffic for encrypted and unencrypted connections?

I'm not sure I understand the question. Data in an unencrypted connection is, well, unencrypted. As an example you can analyze HTML traffic, and from the payload directly read the content of the packets; meaning you can basically re-create an entire webpage just by snooping the payloads, should you be so inclined. In encrypted traffic the only thing you can see is sender/receiver addresses etc. Since the payload is encrypted, it's showing up as unintelligible garbage.


text:
Q: Substructure such that $\operatorname{cof}(\sup(B \cap \omega_m))= \omega_1$ Let $\mathcal{L}=\{\in, \preceq\}$. Let $\mathcal{A}=(V_\theta, \in)$ (where $\theta > \omega$) be an $\mathcal{L}$-structure which interprets $\preceq^\mathcal{A}$ by some fixed well-ordering on $V_\theta$.

Does there exist an elementary substructure $\mathcal{B}$ of $\mathcal{A}$ satisfying the following: $\operatorname{cof}(\sup(B \cap \omega_m))= \omega_1$ for all $m \in \mathbb{Z}^+$?

For each $S \subseteq V_\theta$, let $\mathcal{B}_S$ be the Skolem hull of $A$ in $\mathcal{A}'$. Observe each $\mathcal{B}_S$ is an elementary substructure of $\mathcal{A}$. Perhaps we form an elementary chain from some subcollection of these $\mathcal{B}_S$ structures and take the union, but what would work? And how would I be able to know it satisfies the property?

A: Yes, this is true (modulo the detail that I think you want $\theta\ge\omega_\omega$, not $\theta>\omega$, since only the former ensures $\omega_m\in \mathcal{A}$ for all $m\in\omega$).
Fix $\theta\ge\omega_\omega$. The proof breaks into two key facts, one in the construction stage and one in the verification stage. The latter is essentially trivial but it is worth highlighting.
The first key fact we use is the following:

$(*)\quad$ Suppose $\mathcal{M}$ is a countable elementary substructure of $\mathcal{A}$ with underlying set $M$. Then there is a countable elementary substructure $\mathcal{M}'$ of $\mathcal{A}$ such that $\mathcal{M}\preccurlyeq\mathcal{M}'$ and $\sup(\mathcal{M}'\cap\omega_m)>\sup(\mathcal{M}\cap\omega_m)$ for all $m$.

Proof: just apply Lowenheim-Skolem to build a countable elementary substructure of $\mathcal{A}$ containing the countable set $M\cup\{\sup(M\cap\omega_m): m\in\omega\}$. (Note that for each $m$, $\sup(M\cap \omega_m)$ is a single ordinal, so this whole set is indeed countable.) $\quad\Box$
It may help to think of $(*)$ as addressing $\omega$-many requirements, one for each $\omega_m$ ($m<\omega$). We then apply $(*)$ $\omega_1$-many times to build the desired model $\mathcal{B}$ as the union of an elementary chain of countable models of length $\omega_1$: let $\mathcal{B}_0$ be any countable elementary submodel of $\mathcal{A}$, let $\mathcal{B}_\lambda=\bigcup_{\alpha<\lambda}\mathcal{B}_\alpha$ for $\lambda$ a countable limit, and let $\mathcal{B}_{\alpha+1}=\mathcal{B}_\alpha'$ per $(*)$ above. We then set $$\mathcal{B}=\bigcup_{\alpha<\omega_1}\mathcal{B}_\alpha.$$
Since $\mathcal{B}$ is constructed as the union of an elementary chain we have $\mathcal{B}\preccurlyeq\mathcal{A}$, so we just need to show that for each $m$ we have $cf(\mathcal{B}\cap\omega_m)=\omega_1$ as desired. This will follow from the following general observation:

$(\dagger)\quad$ Suppose $\gamma$ is an uncountable ordinal and, for each $\eta<\omega_1$, $W_\eta$ is a countable sub-ordering of $\gamma$ such that $\delta<\eta<\omega_1\implies W_\delta\subset W_\eta$ and $\sup(W_\delta)<\sup(W_{\delta+1})$. Then $\bigcup_{\eta<\omega_1}W_\eta$, as a suborder of $\gamma$, has cofinality $\omega_1$ regardless of the specific $\gamma$ we started with.

(Note that the above is false if we replace "cofinality" with "ordertype" - this, together with the proof of $(\dagger)$ in the first place, is a good exercise.) To analyze $\mathcal{B}$ we apply $(\dagger)$ "$\omega$-many times," once for for each $m<\omega$: take $\gamma=\omega_m$ and $W_\eta=\mathcal{B}_\eta\cap\omega_m$ to get $cf(\mathcal{B}\cap\omega_m)=\omega_1$ as desired.

Incidentally, more complicated versions of this question - involving "big but locally small" models, which raise problems for greedy strategies like the above - raise the following interesting general question:

Suppose $\mathcal{X}\preccurlyeq \mathcal{T}$ with $\mathcal{T}$ a "reasonably closed" transitive set (possibly + other structure). Under what conditions does $\mathcal{X}$ have a top extension $\mathcal{Y}$ with $\mathcal{X}\prec\mathcal{Y}\preccurlyeq\mathcal{T}$?

Here $\mathcal{Y}$ is a top extension of $\mathcal{X}$ if every element of $\mathcal{Y}\setminus\mathcal{X}$ has rank greater than that of every element of $\mathcal{X}$. E.g. nontrivial forcing extensions are always end-extensions but never top-extensions of their ground models. In a sense the question above is trivial ("exactly when there is some $a\in\mathcal{T}$ of high rank and some family of Skolem functions such that [stuff]"), but getting it to gel nicely can be rather messy if memory serves.


text:
Q: Device admin confirm before DEACTIVATE I want to ask a confirmation before disabling/deactivating device admin for my application. I searched a lot about it but not fing any proper solution for this.
In short, I want to detect a callback when user click DEACTIVATE button from device admin and I want to ask a confirmation to use that whether are you sure you want to deactivate device admin ? If use press cancel then device admin should not be deactivated.
If you observer  AppLock application by DoMobile Lab from google play store, you can find that this app is doing the same thing. So there must be some secret behind it.

A: You can do it by overriding onDisableRequested() method of DeviceAdminReceiver
public class AdminReceiver extends DeviceAdminReceiver {
    @Override
    public CharSequence onDisableRequested(Context context, Intent intent) {
        return "Are you sure you want to disable the Device admin?";//OR whatever message you would like to display
    }

}

As per documentation

Called when the user has asked to disable the administrator, as a result of receiving ACTION_DEVICE_ADMIN_DISABLE_REQUESTED, giving you a chance to present a warning message to them. The message is returned as the result; if null is returned (the default implementation), no message will be displayed.

This will show a popup with OK and cancel button, along with the text returned.


text:
Q: RichTextBox removes linebreaks from Email Headers So I am trying to put together a simple add in for outlook which will read email headers. Getting the headers of the email is trivial enough and I have made a windows form with a RichTextBox in order to show the header (currently I am just pushing the full raw headers in, in the future I'd like to format them and make them a bit easier to read, highlight the more important parts etc, hence the RichTextBox).
The problem I am having is that once I set the textbox.Rtf, it loses the natural new lines which are in the headers, which makes them a mess. If I do textbox.Text, they have the linebreaks so they are much nicer to read.
I've tried a few different things in order to try and force the new lines to show (by using \line and \par for example) but it never seems to come through once I use .Rtf.
   Public Class showHeaders

        Public Shared Sub MyMsg(msg As String)
            Dim MsgUserForm1 As New MsgUserForm
            With MsgUserForm1
                MsgUserForm1.Text = "Email headers:"
                .RichTextBox1.Text = msg
                .RichTextBox1.Rtf = .RichTextBox1.Text
                .Show()
                Dim sSaveFolder As String = "C:\headers\"
                .RichTextBox1.SaveFile(sSaveFolder & "Headers.txt")
            End With
        End Sub

        Private Shared Function parseHeaders(inputHeader As String) As String
            inputHeader = inputHeader.Replace("\r\n", "\line")
            inputHeader = inputHeader.Replace("\n", "\line")
            inputHeader = inputHeader.Replace("Received:", "\b Received:\b0")
            inputHeader = "{\rtf1\ansi " + inputHeader + "}"
            Return inputHeader
        End Function

    End Class

Any help would be welcome as I don't understand why RichTextBox is behaving the way it is.

A: Vb.net doesn't allow you to use \ to escape the \r\n or \n characters to to represent the respective Chr(13) and Char(10) characters
Instead you need to do this.
 inputHeader = inputHeader.Replace(VbNewLine, "\line")
 inputHeader = inputHeader.Replace(VbLF, "\line")

Alternately you can use  Control.Chars.CrLf and Control.Chars.Lf


text:
Q: Android Layout for calendar control I am looking to build a layout as above using linear/relative layouts with textbox.
Any help is appreciated.

A: Add background style to root layout for rounded corner and done
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#999999"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="2dp"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:background="#FFFFFF"
            android:text="25"
            android:padding="5dp"
            android:textColor="#000000"
            android:textSize="60sp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:text="Sept \n2016"
            android:padding="5dp"
            android:textSize="25sp" />

    </LinearLayout>

</LinearLayout>

A: <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#999999"
    android:layout_margin="20dp"
    android:orientation="vertical"
    >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <View
            android:layout_width="5dp"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:background="#999999"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:background="#FFFFFF"
            android:padding="10dp"
            android:text="25"
            android:textColor="#000000"
            android:textSize="60sp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:text="Sept \n2016"
            android:textColor="@android:color/white"
            android:padding="10dp"
            android:textStyle="bold"
            android:textSize="35sp" />

    </LinearLayout>

</LinearLayout>


text:
Q: cbind with do.call stores dataframe name in column variable Why do I have different column names here for test1 and test2? If I change the data frame to only one column, they have the same name. I would like to have them the same name but use the do.call function.
a <- data.frame(col1 = c(1,2,3), col2 = c(1,2,3))
b <- data.frame(col3 = c(1,2,3), col4 = c(1,2,3))

test1 = cbind(a, b)

dataframe_name = c("a", "b")
test2 <- do.call(cbind, mget(dataframe_name, envir = .GlobalEnv))

colnames(test1)
colnames(test2)

# only one column
a=a[1]
b=b[1]
test1 = cbind(a, b)
test2 <- do.call(cbind, mget(dataframe_name, envir = .GlobalEnv))
colnames(test1)
colnames(test2)


text:
Q: Series describe function pandas ploting I have question for you. Which plot is a best to show describe result in series pandas
filter = genderage['Customer_Gender'] == "F"
genderage[filter]
genderage[filter].describe()

    Customer_Age
count   54724.000000
mean    36.168993
std 10.910622
min 17.000000
25% 28.000000
50% 35.000000
75% 43.000000
max 87.000000

A: A boxplot will combine nearly all of this information into a single visualization. It won't plot the mean by default but you can add that as a dashed line with meanline and showmeans.
The whiskers extrend from the max to the min. The dashed line is the mean. The box extends from the 25% to 75% and the solid line in the box is the median (50%). You just miss the standard deviation and the counts, which can be added as text if you wanted.
import numpy as np
import pandas as pd

np.random.seed(123)
s = pd.Series(np.random.chisquare(34, 100))

s.describe()
#count    100.000000
#mean      34.674010
#std        8.393988
#min       15.306646
#25%       29.043357
#50%       33.556184
#75%       40.380201
#max       56.930963
#dtype: float64

s.to_frame('data').boxplot(meanline=True, showmeans=True)


text:
Q: NoSql Design, AWS (DynamoDB) or Azure(DocumentDB)? I am planning on moving our people/address/telephone database from Sql Server into a NoSQL db for scalability reasons.
We currently have all our infrastructure on AWS and Azure and we are planning on keeping it that way. Hence, I started researching the tools provided by both AWS and Azure but I am in doubt and wish I could get some help.
Here's the basic structure of our tables:
Person
ID,
Name,
Surname,
DOB,
Job,
EmailAddress,
Nationality,
CityOfBirth,
Etc...
Address
PersonId,
Street,
Number,
ZipCode,
City,
etc...
Telephone
PersonId,
Number,
AreaCode,
Carrier,
etc...

Queries:
The main query that we perform is to obtain people based on columns from Person (DOB, Job, etc), Address (ZipCode Range, State, City, etc) and Telefone (Carrier, Telefone Type, etc) tables. We filter need to select millions of records on a daily basis to generate the data to be processed by our app.
My typical query returns the following columns:
Person Table: ID, Name, Surname, DOB, Job, EmailAddress, Nationality, CityOfBirth
Address Table: Street, Number, ZipCode, City, State
Telephone Table (5 phone numbers per person): Number, AreaCode, Carrier
Queries usually return from 5k~15k records, and we need to obtain the full resultset.
We also perform updates on the telephone data on a weekly basis, adding/removing/updating phone numbers. We do it on the weekend to avoid impacting performance on the production application.
I understand that I would have to denormalize this structure to facilitate querying and improve read performance. So I starting assessing both cloud providers for the possible solutions:
AWS DynamoDB
From what I could understand I cannot implement queries on multiple attributes and there is a limit on Indexes that can be created. I couldn't think of a way to model the data to allow for fast querying using the filters mentioned.
It seems to me that I could perform query on the most important fields and then apply filtering on the rest. I am not sure if it would be optimal, given that I have 50 million + records.
Or is there another AWS Service that could assist me on achieving the desired behavior?
Azure DocumentDB
Since it stores JSON objects which are indexed by all attributes I could be the way to go. I is supposed to be less performant than KEY/Value Tables and I am not aware of the actual performance when querying for millions of records on a daily basis.
Again, I am not sure if is there another service that could prive better results on Azure.
Conclusion:
I would like to get some insight that could lead me into the right direction. I've seem some questions regarding Elasticsearch and etc that could assist in this, but I am not sure if it would give the performance I was hoping for and if it is actually its purpose.
Objective
What is driving us to look for alternatives is to take advantage of cloud's flexibility. Nowadays we keep a large SQL Server 24/7 to host this core data of our application. We are hoping to improve query performance and reduce server costs.
Not sure what if NoSQL is the way to go, or remaining on SQL Server with changes on the data structure.
Any help would be appreciated!
Thanks in advance!


text:
Q: Unpivot a pandas groupby dataframe I have a dataset of weekly sales of a few stores, which looks something similar to :

store_id
item_id
week
sales

store1
item1
2021-01
3

store1
item2
2021-01
2

store2
item1
2021-01
10

store2
item3
2021-01
1

store1
item1
2021-02
5

store1
item2
2021-02
1

store2
item1
2021-02
11

store1
item3
2021-03
6

store1
item1
2021-04
7

store2
item3
2021-04
2

I did a pivot on this data frame like :
df.groupby(['store_id', 'item_id', 'week'])['sales'].mean().unstack() which generates a new dataframe like the one below :

store_id
item_id
2021-01
2021-02
2021-03
2021-04

store1
item1
3
5
0
7

store1
item2
2
1
0
0

store1
item3
0
0
6
0

store2
item1
10
11
0
0

store2
item3
1
0
0
2

I have performed the needed modifications to this new dataframe.
How do we get back the original dataframe structure from this modified pivot dataframe. such that I can represent each week number as a separate row rather than columns as in this dataframe.
Edit :
I tried using melt as an example from Convert columns into rows with Pandas:
df.melt(id_vars=["store_id", "item_id"],
        var_name="week",
        value_name="sales")

But I get the error :
The following 'id_vars' are not present in the DataFrame: ['store_id', 'item_id']. This seems probably because my df has multi-indices and not in serialised form.
Output of df.index
MultiIndex([('store1', 'item1'),
            ('store1', 'item2'),
           ....
           ....
           names=['store_id', 'item_id'], length=15305)

A: You can use df.melt. Using the below dataframe:
df = pd.DataFrame({'store_id' : ['store1', 'store1', 'store1', 'store2', 'store2'],
                  'item_id' : ['item1', 'item2', 'item3', 'item1', 'item3'],
                  '2021-01' : [3, 2, 0, 10, 1],
                  '2021-02' : [5, 1, 0, 11, 0],
                  '2021-03' : [0, 0, 6, 0, 0],
                  '2021-04' : [7, 0, 0, 0, 2]})

  store_id item_id  2021-01  2021-02  2021-03  2021-04
0   store1   item1        3        5        0        7
1   store1   item2        2        1        0        0
2   store1   item3        0        0        6        0
3   store2   item1       10       11        0        0
4   store2   item3        1        0        0        2

You can then melt, using store and item id as id_vars, and values are the date columns:
df.melt(id_vars=['store_id', 'item_id'], var_name='week', value_name='sales')

This will give the below:
   store_id item_id     week  sales
0    store1   item1  2021-01      3
1    store1   item2  2021-01      2
2    store1   item3  2021-01      0
3    store2   item1  2021-01     10
4    store2   item3  2021-01      1
5    store1   item1  2021-02      5
6    store1   item2  2021-02      1
7    store1   item3  2021-02      0
8    store2   item1  2021-02     11
9    store2   item3  2021-02      0
10   store1   item1  2021-03      0
11   store1   item2  2021-03      0
12   store1   item3  2021-03      6
13   store2   item1  2021-03      0
14   store2   item3  2021-03      0
15   store1   item1  2021-04      7
16   store1   item2  2021-04      0
17   store1   item3  2021-04      0
18   store2   item1  2021-04      0
19   store2   item3  2021-04      2


text:
Q: How do I center align the items in my menu? How do I center align the items WITHIN in my menu? (The lis) I managed to center the menu (ul) within the page of my website but I can't center the actual items in the menu (Home, About, etc.)
You can edit my HTML/CSS here: http://jsfiddle.net/66reH/
To see the results
CSS/HTML:

#nav {
 font-family: Century Gothic, Arial, Helvetica, sans-serif;
 font-size: 15px;
 color: #fff;
 margin-left:auto;
 margin-right:auto;
 background-color: #eee;
 padding: 5px;
 height: 38px;
 width: 913px;
 font-weight: bold;
 border-style:solid;
 border-width:4px;
 border-color: #000;
}
#nav ul {
 padding: 0px;
 margin-top: 0px;
 margin-right: 0px;
 margin-bottom: 0px;
 margin-left: 170px;
}
#nav ul li {
 list-style-type: none;
 text-align: center;
 float: left;
 margin: 0px;
}
#nav ul li a {
 text-decoration: none;
 color: #000;
 text-align: center;
 display: block;
 padding: 10px;
 margin: 0px;
}
#nav ul li a:hover {
 color: #CD0000;
}

HOME

ABOUT

TOUR

NEWS

PRESS

PHILANTHROPY

JOBS

CONTACT

A: *

*remove the align property on the #nav div

*Add text-align: center; to the #nav selector CSS

*remove the margin-left property for the ul selector CSS

*add 'text-align: center; to the ul selector CSS

*remove the float: left; property on the li selector CSS

*add display: inline-block; to the li selector CSS

You didn't have a centered menu there. You simply added 170px to the left of the UL in the CSS so it sort of looked centered. But it wasn't.
DEMO HERE

A: CSS/HTML

#nav {
    font-family: Century Gothic, Arial, Helvetica, sans-serif;
    font-size: 15px;
    color: #fff;
    margin-left:auto;
    margin-right:auto;
    background-color: #eee;
    padding: 5px;
    height: 38px;
    width: 913px;
    font-weight: bold;
    border-style:solid;
    border-width:4px;
    border-color: #000;
}
#nav ul {
    padding: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
#nav ul li {
    list-style-type: none;
    text-align: center;
    float: left;
    margin: 0px;
}
#nav ul li a {
    text-decoration: none;
    color: #000;
    text-align: center;
    display: block;
    padding: 10px;
    margin: 0px;
}
#nav ul li a:hover {
    color: #CD0000;
}
.outer {
    float: right;
    right: 50%;
    position: relative;
}
.inner {
    float: right;
    right: -50%;
    position: relative;
}
.clearboth {
    clear:both;
}

HOME

ABOUT

TOUR

NEWS

PRESS

PHILANTHROPY

JOBS

CONTACT

demo
Read more on centering:
Centering a div


text:
Q: View pager images(fragments) slider from the start I have implemented slider in ViewPager its working fine when click on play button, but now I am trying to implement slider from last item button "play form start again", but I am stuck how can I implement this I have implemented slider to play form current item, but I can't not do it from last item to play again I am using Executors this is my code for sliding
  /**
 * starts the slide show with 2 seconds frequency
 */
public void startTimer(final boolean isStartFromCurrentItem) {
    isTimerPlaying = true;
    btn_pause_play.setImageResource(R.drawable.ic_action_pause);
    scheduler =
            Executors.newSingleThreadScheduledExecutor();

    scheduler.scheduleAtFixedRate
            (new Runnable() {
                public void run() {
                    // call service

                    Message msg = new Message();

                    Log.i("change", "change");

                    hanleMessage(msg, isStartFromCurrentItem);

                }
            }, 0, 2, TimeUnit.SECONDS);

}
/**
 * UI Handler of background thread, this handler called after every two seconds to show next item as slide view
 *
 * @param message
 * @param isStartFromCurrentItem
 */
private void hanleMessage(Message message, final boolean isStartFromCurrentItem) {
    Handler msg_handler = new Handler(getMainLooper()) {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);

            if (viewpager != null) {
                if (viewpager.getCurrentItem() == cursor.getCount() - 1) {
                    //Toast.makeText(getApplicationContext(), getString(R.string.slide_show_comp), Toast.LENGTH_LONG).show();
                    stopSchedueler();
                    btn_pause_play.setImageResource(R.drawable.ic_action_play);

                } else {

                    if (isStartFromCurrentItem) {
                        int old_pos = viewpager.getCurrentItem();
                        viewpager.setCurrentItem(old_pos + 1, true);
                    } else {

                        Log.e("getCurrentItem", viewpager.getCurrentItem() + "");
                        viewpager.setCurrentItem(0, true);

                        //for starting slide show from beginning

                    }
                }
            }

        }
    };

    msg_handler.sendMessage(message);

}

If I want to play slides form current item simply call startTimer(true) and handling in second method is working fine and when I call this method from last item where is button "play again" I call tartTimer(false) how can I start slider from beginning by changing in this method after passing false can someone please give me optimised solution thanks.

A: you can set viewPager.setcurrentitem(0) to start your viewpager from start when you press play form start again button


text:
Q: Слайд двух страничек Есть две страницы( enter.html  - вход на сайт и index.html- главная страница). На странице enter   по середине логотип. Хочу сделать что бы при нажатии на логотип страница enter.html  слайдом уезжало вверх а index.html появлялось слайдом снизу. Как можно такое реализовать.  Заранее спасибо! )
A: Кладите контент enter.html в div, по входу грузите страницу index.html через ajax, кладите её в див, сделайте анимацию смены дивов.
Что надо почитать из документации jquery:

*

*$.ajax

*$.slideUp

*$.slideDown

*$.animate

A: index.html

1312312
12312323

enter.html

1312312
12312323


text:
Q: Problems when creating new notes in Simplenote using Simperium I'm creating an Open Source C# client for Simplenote using Simperium API. Almost everything is ready, but I am facing problems when creating a new note.
How I can create a new note in Simplenote using Simperium API?

A: Once you have the app id and API key you can create new notes just like creating any Simperium object as referenced in the documentation.
The bucket to post to is note and it'll also need to conform to the schema in the following sample note:
{
    "tags" : [ "todo", "later" ],
    "systemTags" : [],
    "creationDate" : 1335390338.091436,
    "modificationDate" : 1335390338.091436,
    "deleted" : false,
    "shareURL" : "",
    "publishURL" : "",
    "content" : "new note content!"
}

All fields are needed when creating, but you can just specify the fields that have changed when updating.


text:
Q: Who are the first dystopian science fiction writers? My first thought is that in order to have science fiction in the middle age you need science. But magic and science aren't opposites, Amazonian tribes have a unique knowledge and a accurate taxonomy of the green world --ie a scientific method is needed. So it's more about the place of science than the technology milestones that are important. Nowadays science holds an authority figure more than ever.
I would be interested to know if there's any dystopian science fiction writer before the XVIth century.

A: We, by Yevgeny Zamyatin, was written in 1924 in Russia. It is the story of a spaceship engineer in a totalitarian society set sometime after the year 2900. This was one of the very earliest "dystopian" science fiction novels, and inspired Orwell and Huxley in the creation of their own dystopian stories.

A: This is going out on a limb (is more fantasy than Sci-Fi), but the Hell in Inferno by Dante is pretty nasty and could have some of the common themes of a dystopia. A large subjugated populous and evil overlords controlling them.
It was written about 1320, before the printing press was invented so it wasn't published as such until 1470.

A: Plato, with The Republic, written circa 380BC. Plato may have intended it as a utopia, but it looks distinctly dystopian to modern eyes (e.g. those of Jo Walton in The Just City).

A: A play from 1861 might be a partial answer.
The Tragedy of Man has several scenes which can be considered science-fiction: set in the future, it describes a different human society which uses futuristic technology, and the relation between technology and society forms an important plot point in the story.
The story goes through many eras of human history, from biblical times, through classical antiquity, middle ages and the author's present, but the last scenes are set in the future. Scene 12 presents a highly technocratic society, where poetry and emotions are banned, every member has one and only one job through their entire life, and people are referred to only by numbers. Any form of emotional relationship is banned, babies are separated from their mothers and raised in a communal nursery. That society is based on extreme utilitarianism: nothing is tolerated which is not immediately practically useful. Poetry is banned, flowers are extinct, and so are almost all species of animals and plants. The only remaining land animals are heavily genetically engineered:
What lives is what is useful or what science
Has found no adequate substitute for yet
Like pigs and sheep, but not in the poor state
The nature so ineptly left them in.
One's living fat, the other meat and wool,
They serve our needs, exactly like these test-tubes.

Like many modern dystopian works, on first glance it seems like a utopia, and the protagonist at first thinks it is one, and only later does the inhumanities come to surface.
Not only is this society dystopian, it is so by necessity, because the world itself became dystopian due to severe resource exhaustion by preceding civilizations.
Later, it turns out,

 even these drastic measures were unable to save human civilization. A scene set a few thousand years later shows a snowball Earth, with barely survivable arctic climate around the Equator (and completely dead everywhere else) where the last few human survivors eke out a miserable living, degraded back to the stone age, heading inevitably towards complete extinction.


text:
Q: Handlerbars access Array variable I'm working with Handlebars in an Express application.
From the server-side I'm passing an array of dates as strings:
reqCtrl.dateController = async (req, res) => {
...
var dates = [
    "2020-09-27",
    "2020-09-28",
    "2020-09-29",
    "2020-09-30",
    "2020-10-01",
    "2020-10-02",
    "2020-10-03",
    "2020-10-04",
  ];

  console.log(dates);
  //Resulting in: ['2020-09-27', '2020-09-28', '2020-09-29', '2020-09-30', '2020-10-01', '2020-10-02', '2020-10-03', '2020-10-04']
  res.render("requests/...",
    dates
  });
}

However, on the client side, with the following expression I get different values.

Am I missing something? How can I render the correctly formatted date?

A: What would happen if you rendered
{{dates}}
, instead of console logging it? Either way, you will likely want to iterate through arrays to render when using handlebars. This is done with #each.

  {{ #each dates}}

{{this}}

  {{/each}}


text:
Q: prevent display duplicate titles on main page I am using a automatic rss post reader on my website and there is a problem with this plugin that sometimes publish duplicate posts.I can't do anything to this plugin but at least it is better if I could prevent to display the same titles on main page.
here is my code

<?php
                    $portfolio = new WP_Query(array(
                    'post_status' =>'publish',
                    'post_type' =>'post',
                    'cat' =>''.$link1.'',
                    'posts_per_page' =>'9'
                    ));
 if($portfolio->have_posts()) :
                    while($portfolio->have_posts()) : $portfolio->the_post();
                                    ?>

<a href="<?php the_permalink() ?>" target="_blank"><?php the_title(); ?>

<?php endwhile; endif; wp_reset_query(); ?>

A: Your code should look like this to exclude duplicate titles

    <?php
    // Initial counter for displayed posts.
    $counter = 1;
    // Initial empty array of displayed titles.
    $titles = [];

    $portfolio = new WP_Query([
        'post_status' => 'publish',
        'post_type' => 'post',
        'cat' => '' . $link1 . '',
        // Because we don't know the number of duplicate titles, fetch all.
        'posts_per_page' => -1,
    ]);

    if ( $portfolio->have_posts() ) :

        // Start the loop.
        while ( $portfolio->have_posts() ) : $portfolio->the_post();

            // If the current title has not been displayed already, display it.
            if ( ! in_array( get_the_title(), $titles ) ) {
                ?>

                    <a href="<?php the_permalink(); ?>" target="_blank">
                        <?php the_title(); ?>

                <?php
                // Mark current title as displayed by adding it to the titles array.
                $titles[] = get_the_title();
                // Increase counter.
                $counter++;

            }

            // When we have displayed 10 posts the loop should stop.
            if ( $counter == 10 ) {
                break;
            }

        endwhile; endif;
    wp_reset_query(); ?>

I hope this may help!

A: You somehow have to get hold of the post IDs you want to exclude. By calling the plugin's WP_Query again for example and at best let you return only post IDs by 'fields' => 'ids' this time.
Then you can use the result to exclude these posts from your other queries by passing an array of post IDs to 'post__not_in'. So let's assume you created an array of the posts you want to exclude that looks like that $exlcude = [ 123, 456, 789 ] then the query needs to look like this:
$args = array(
    'post_status' =>'publish',
    'post_type' =>'post',
    'cat' => $link1,
    'posts_per_page' => '9',
);

if ( ! empty( $exclude ) ) {
    $args['post__not_in'] = $exclude;
}

new WP_Query($args);


text:
Q: z-index / border related issue with nav menu http://jsfiddle.net/FS4zT/
If you visit the above link you see what am describing below.
Summary: I have set the z-index of the submenu to 99 and the z-index top level menu to 9..
So basically i was thinking when i move the mouse over to the 1st menu, the 1st submenu will stay in focus when i move the mouse over the items of the submenu.
But for some reason in Firefox 11.0 it switches over to the 2nd Top Level Menu when i try to move my mouse over the 2nd/3rd/4th items of the first sub menu.
In IE 7 : It works as desired by i can still see the border of the 2nd Top Level Menu overlapping the items of the sub-menu even tho their z-index is higher. The border problem can be even seen in firefox.
Can someone shed some light where i might be going wrong?

A: This should fix it, I hope.
#menu li ul li {
position: relative;
}

A: Beware of the stacking context of the z-index. What you want is not working for parent-child z-indices.
The problem is that the parent li of the submenu is not as wide as the submenu (4x times smaller). So if you hover to the right, the li loses focus.
One way to solve this, is setting z-index: 0 on al ul submenus and z-index: 1 on the current submenu. The submenu's should have position: absolute.
Update: Solution with position: relative (accepted answer) is really a good one. This is working because the lis of the submenu do not make the parent container larger since they are left floated.

A: You must change the height in #menu li
#menu li {
    width: 140px;
    height: 25px;
    float: left;
    border-right: 1px inset white;
    z-index: 9;
}

The other way you can go to keep your borders at 50px is when you add to the CSS something like this.
#menu li:hover ~ li{
    height:25px;
}


text:
Q: How do I enable logging of detailed information about garbage collection through the command line? I need to log info about GC through Java. How is it done and what exactly is the command to be used.
Thank you

A: For details regarding GC calls you can enable it by passing these arguements to the command line
-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps

Sample output logs will look something like below
2015-05-26T14:45:37.987-0200: 151.126: [GC (Allocation Failure) 151.126: [DefNew: 629119K->69888K(629120K), 0.0584157 secs] 1619346K->1273247K(2027264K), 0.0585007 secs] [Times: user=0.06 sys=0.00, real=0.06 secs]
2015-05-26T14:45:59.690-0200: 172.829: [GC (Allocation Failure) 172.829: [DefNew: 629120K->629120K(629120K), 0.0000372 secs]172.829: [Tenured: 1203359K->755802K(1398144K), 0.1855567 secs] 1832479K->755802K(2027264K), [Metaspace: 6741K->6741K(1056768K)], 0.1856954 secs] [Times: user=0.18 sys=0.00, real=0.18 secs]

To understand the above logs, take

*

*2015-05-26T14:45:37.987-0200 – Time when the GC event started.

*151.126 – Time when the GC event started, relative to the JVM startup time. Measured in seconds.

*GC – Flag to distinguish between Minor & Full GC. This time it is indicating that this was a Minor GC.

*Allocation Failure – Cause of the collection. In this case, the GC is triggered due to a data structure not fitting into any region in Young Generation.

*DefNew – Name of the garbage collector used. This cryptic name stands for the single-threaded mark-copy stop-the-world garbage collector used to clean Young generation.

*629119K->69888K – Usage of Young generation before and after collection.

*(629120K) – Total size of the Young generation.

*1619346K->1273247K – Total used heap before and after collection.

*(2027264K) – Total available heap.

*0.0585007 secs – Duration of the GC event in seconds.

*[Times: user=0.06 sys=0.00, real=0.06 secs] – Duration of the GC event, measured in different categories:

*

*user – Total CPU time that was consumed by Garbage Collector threads during this collection

*sys – Time spent in OS calls or waiting for system event

*real – Clock time for which your application was stopped. As Serial Garbage Collector always uses just a single thread, real time is thus equal to the sum of user and system times.

A: For a detailed information you need to pass all the arguments that I will list below. These options make Java to log garbage collector activities into specified file. All records will be prepended with human readable date and time. Meanwhile you should avoid using -XX:+PrintGCTimeStamps as it will prepend record with useless timestamp since the moment Java application start. Read more about GC arguments here and here.
-XX:+PrintGCDateStamps //adding DateStamps to log
-verbose:gc  //activates the a "simple" GC logging
-XX:+PrintGCDetails //we activate the "detailed" GC logging mode

Sometimes it is interesting to know how long your application
runs between garbage collections. That can be calculated from the
GC logs but a convenient way to see that information is through
the the output that the next two flags produce. Read more.
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCApplicationConcurrentTime

Enable log rotating. It's important. The reasons is whenever the application is restarted, old GC log file will be over-ridden by the new GC log file as the file path is same (i.e. /home/GCEASY/gc.log). Read more about GC log rotating.
Also, GC log files rotation makes analysis of garbage collection problems easier, also it guaranties that disk is protected from space overconsumption.
-XX:GCLogFileSize=2M //default will be set to 512K
-XX:+UseGCLogFileRotation //must be used with -Xloggc:<filename>
-XX:NumberOfGCLogFiles=10 //must be >=1, default is one

And the file to write log into:
-Xloggc:$LOG_DIR/gc.log

Pass all of those in one line like:
XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=2M -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -verbose:gc -XX:+PrintGCDetails -Xloggc:$LOG_DIR/gc.log

A: You can enable it with -XX:+PrintGC or -verbose:gc. For full details see https://blog.codecentric.de/en/2014/01/useful-jvm-flags-part-8-gc-logging/

A: As stated in http://www.oracle.com/technetwork/articles/java/vmoptions-jsp-140102.html

*

*-XX:-PrintGC Print messages at garbage collection. Manageable.

*-XX:-PrintGCDetails  Print more details at garbage collection. Manageable. (Introduced in 1.4.0.)

*-XX:-PrintGCTimeStamps   Print timestamps at garbage collection. Manageable (Introduced in 1.4.0.)


text:
Q: Modifiable Array of strings in PostgreSQL I am looking to store an Array of strings in a table which I can then append more data to.
My table looks like this:
CREATE TABLE users (id SERIAL, username varchar(32), password char(40), name varchar(64), age integer, successful_logins varchar(32)[10], failed_logins varchar(32)[10], roles text[3]);

I have tried this but it doesnt do anything:
UPDATE users SET successful_logins = array_append(successful_logins, :timestamp) WHERE username = :username;

The :varname comes from a JDBI Driver I am using, but I am passing in a String. Why doesnt this work? Is there a better way to get the same result?
EDIT:
Here is the driver I am using:
<dependency>
    <groupId>postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>9.1-901.jdbc4</version>
</dependency>

I get no error and it seems to be releted to my DAO or driver.
Here is the DAO code:
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.SqlUpdate;

@SqlUpdate("UPDATE users SET successful_logins=ARRAY_APPEND((SELECT successful_logins FROM users WHERE username=:username),:timestamp)WHERE username=:username")
void addSuccessfulLogin(@Bind("timestamp") String timestamp, @Bind("username") String username);

When I try this in psql with the vars replaces with values it works. I am wondering if this this a casting issue? Do I need to cast my String to something?

A: I am not familiar with your JDBI library, but I tried this in the Postgres console and it worked:
UPDATE mytable SET successful_logins =
ARRAY_APPEND(
    (
     SELECT successful_logins FROM mytable WHERE id=1),
    'Some additional value'
     )
WHERE id=1

Perhaps the problem is that you need to select the existing successful_logins value before you pass it to the array_append.
EDIT: Well, it looks like you're missing a space between ARRAY_APPEND() and WHERE...

A: When I was making the call to addSuccessfulLogin I was doing:
addSuccessfulLogin(username, timestamp);

instead of
addSuccessfulLogin(timestamp, username)

So it was trying to find a username based on a timestamp, which doesnt exist. This is why there were no errors. SO make sure you call your own API correctly!


text:
Q: mex file run out of memory I wrote a mexfunction on c++ code, then compiled it to get mexa64 file. After I used mexa64 file for many times, my PC memory run out.
Here is my mexfunction:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
//  double *res ;// the final result index
    int status1,status2,status3;
    double *res ;
    double *out_mat;
    double *x_idx,*y_idx,*width_idx,*height_idx;
    char* sequence_path;// the tracking image sequences
    char* sequence_name;// the tracking image sequences

    char* output_path;// save the output
    int start_frame=(int)mxGetScalar(prhs[0]);
    int end_frame=(int)mxGetScalar(prhs[1]);
    int Max_track_number=(int)mxGetScalar(prhs[2]);

     /* Extract the inputs */
    int buflen1=(mxGetM(prhs[3])*mxGetN(prhs[3]))+1;
    sequence_path= (char *)mxCalloc(buflen1,sizeof(char));
    status1=mxGetString(prhs[3],sequence_path,buflen1);

    int buflen2=(mxGetM(prhs[4])*mxGetN(prhs[4]))+1;
    sequence_name= (char *)mxCalloc(buflen2,sizeof(char));
    status2=mxGetString(prhs[4],sequence_name,buflen2);

    int buflen3=(mxGetM(prhs[5])*mxGetN(prhs[5]))+1;
     output_path= (char *)mxCalloc(buflen3,sizeof(char));
     status3=mxGetString(prhs[5],output_path,buflen3);
         if(status3!=0)
    mexWarnMsgTxt("Not enough space. String is truncated.");

    float x=(float)mxGetScalar(prhs[6]);
    float y=(float)mxGetScalar(prhs[7]);
    float width=(float)mxGetScalar(prhs[8]);
    float height=(float)mxGetScalar(prhs[9]);

     x_idx=mxGetPr(prhs[6]);
     y_idx=mxGetPr(prhs[7]);
     width_idx=mxGetPr(prhs[8]);
     height_idx=mxGetPr(prhs[9]);

     mexPrintf("the dimension is %f,%f,%f,%f\n",*x_idx,*y_idx,*width_idx,*height_idx);

    int N1=mxGetM(prhs[6])*mxGetN(prhs[6]);
    int N2=mxGetM(prhs[7])*mxGetN(prhs[7]);
    int N3=mxGetM(prhs[8])*mxGetN(prhs[8]);
    int N4=mxGetM(prhs[9])*mxGetN(prhs[9]);
    if(N1!=N2|N2!=N3|N3!=N4)
    mexErrMsgTxt("the dimension of the initial bounding box parameter is wrong");
    int NN=N1;

     plhs[0] = mxCreateDoubleMatrix(Max_track_number*5*NN,1,mxREAL);
     out_mat = mxGetPr(plhs[0]);

     plhs[1] = mxCreateDoubleMatrix(1,1,mxREAL);
     res = mxGetPr(plhs[1]);

 *res=struck_track(start_frame,end_frame,Max_track_number,sequence_path,sequence_name,output_path,out_mat,x_idx,y_idx,width_idx,height_idx,NN);

}

Is there some problems that may cause the exhaustion of memory?

A: you should use mxFree whenever using the following:
mxCalloc
mxMalloc
mxRealloc
mxArrayToString
I can see from your code that you are using mxCalloc but there is no corresponding mxFree for the same.

A: Besides using mxFree you can also increase the Java Heap Size. You can find it under settings, general, java heap memory.


text:
Q: Xamarin/Visual Studio 2015: Custom Proguard configuration I need to make a customized Proguard configuration. However I cannot find out how to do that. When building a new configuration file is copied into the /obj/release/proguard folder. How can this configuration file be customized?

A: The above answer is 100% correct on how to add the file.
To make sure you file gets picked up you can check the output logs, it will contain something like this:
ProguardConfigurationFiles:
      {sdk.dir}tools\proguard\proguard-android.txt;
      {intermediate.common.xamarin};
      {intermediate.references};
      {intermediate.application};
         Proguard.cfg;

NOTE: Make sure that you set your MSBuild output verbosity to Detailed for this (Tools > Options > Build and Run)

A: *

*Just put your Proguard.cfg into your Project

*Right click on Proguard.cfg > "Build Action" > "ProguardConfiguration"


text:
Q: Good Example .Net Open Source Solution Using a Composite UI I'm learning about composite UIs at the moment and I wondered if anyone could recommend a good open source project that utilises a composite UI that I could take a look at?
I've got the Prism framework and have gone through the samples. I'm looking for an actual project that has used them in a non-sample application.
Thanks in advance :-)

A: Tasks.Show is a to-do app written by PixelLab with an amazing UI. It uses Prism v4. It is technically a "reference" app to show off WPF features, but it isn't a trivial sample.
Here it is on Github:
https://github.com/thinkpixellab/Tasks.Show


text:
Q: Outlook AppointmentItem-- how do I add some data into the RTF mail body when "send" is clicked I develop an outlook Add-in use the VSTO with C#.
Step 1: I create a ribbon for appointment explore,when the ribbon button is clicked,read a .rtf file and insert the .rtf file into the Appointment body.
 try
 {
 Outlook.Inspector insp = Globals.ThisAddIn.Application.ActiveInspector();
 Outlook.AppointmentItem meetingItem = insp.CurrentItem() as Outlook.AppointmentItem;
  if(meetingItem == null){
      MessageBox.Show("the meeting is null,create a meeting Item");
      meetingItem = (Outlook.AppointmentItem)insp.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
    }
   if(meetingItem != null) {
    meetingItem.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
    object missing = System.Reflection.Missing.Value;
    Word.Application wordAppl;
    Word.Document wordDoc;
    Word.Selection wordSel = null;
    wordDoc = (Word.Document)insp.WordEditor;
    wordAppl = wordDoc.Parent as Word.Application;
    wordDoc.Activate();
   String path = "D://WordSendTest//template//en_US.rtf";
     String fileName = path.ToString();
     wordSel = (Word.Selection)wordAppl.Selection;
     wordSel.Range.Delete(ref missing, ref missing);
    object falseRef = false;
    wordSel.Range.InsertFile(fileName, ref missing, ref falseRef, ref falseRef, ref falseRef);
    }
   }
    catch (Exception ex)
     {
       MessageBox.Show("Robbin click error!"+ ex.ToString());
     }

step 2: when user click the "send button",capture the ItemSend Event.
 private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            this.Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
        }

Step 3:insert some "string text" into the end of the email body.
  void Application_ItemSend(object Item, ref bool Cancel)
        {
            Outlook.Inspector insp = Globals.ThisAddIn.Application.ActiveInspector();
            Outlook.AppointmentItem meeting = insp.CurrentItem as Outlook.AppointmentItem;
            Word.Document wordDoc = insp.WordEditor as Word.Document;
            Word.Application wordApp = wordDoc.Parent as Word.Application;
            Word.Selection wordSel =(Word.Selection) wordApp.Selection;
            object missing = System.Reflection.Missing.Value;
            object units = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            object findEnd = (object)"~-----~~-----~-----~-----~-----~-----~\r";
            object wholeWord = true;
            wordSel.HomeKey(ref units, ref missing);
            if(wordSel.Find.Execute(ref findEnd,ref missing,ref wholeWord,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing))
            {
            wordSel.MoveUp(ref missing,ref missing,ref missing);
            wordSel.TypeText("--=Head for Insert info =--\n");
            wordSel.TypeText("when user click the <send button>,the Tex info will be insert and show here \n");
            wordSel.TypeText("--=End for Insert info=--\n");
            }
            else {
               MessageBox.Show("not fonud the END tag");
            }
        }

Problem:
in debug model,add Text is insert into the body successfully when the send button is clicked.
but, the mail which is actually sent out is not changed,only same before the "send button" is clicked.
when I open the appointment in calendar, the body is OK,text is insert into the end of the mail body successfully.
so ,who know why?why the mail is not sent out with the update body ,but the update mail body is saved in the calendar.

A: What is your code that modifies the text? When is it executed?
Keep in mind that appointments are never sent. When you click Send, Outlook creates a MeetingRequest obejct and sends it instead. The only time you can modify that object is when you process the Application.ItemSend event.


text:
Q: Referencing .NET6 application from .net framework 4.8 app I'm trying to make references between my projects, two of them are in .net 6 and the third is my old project, in .net framework 4.8. Upgrading it is not an option for now. I'm in a context of an hexagonal architecture implementation. So :
ProjectLibrary1 (core) : .net6
ProjectLibrary2 (infrastructure) : .net6, reference ProjectLibrary1
Framework : .net 4.8, reference ProjectLibrary 1 and 2
Here my csproj :
ProjectLibrary 1 & 2 (updated after the comments) :
  <PropertyGroup>
    <OutputType>Library</OutputType>
    <TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

Framework :
Screenshot of my config in vs studio
The problem :
I have errors with the version of C#. It seems like it compile for .net 6 (with global using for example), but I have errors.
Errors "project targeting 6.0 can't referenced by project targeting 4.8"
I would highly appreciate some help, I tried a lot of solutions but it didn't work.
Edit :

To summarize the answers I made :
The idea behind this architecture is to migrate the code step by step into new modern and cleaned application. We have a huge codebase, a huge technical debt and no budget to rework all the app. So my idea was to use modern apps and migrate the actual code base, to end with a clean architecture made of a "modern" core and an "old" framework. What would you advice in my context ?
In my apps, I already have projects shared between dotnet 4.8 and dotnet core 3 projects. Why would it be possible with core 3 and not 6 ? Both of them have compatibility with dotnet standard 2.0, according to this page (https://learn.microsoft.com/fr-fr/dotnet/standard/net-standard?tabs=net-standard-2-0).

A: To my knowledge, this is not possible, you can only reference a dotnet framework or dotnetstandard project from your 4.8 framework project.

A: You can't have both TargetFramework TargetFrameworks.
You should either have TargetFrameworks with both .NET6 and .NET2.0, or a single TargetFramework with .NET2.0.


text:
Q: switch actionbar Style with fragments I have a non swipe-able pager in a main activity with 6 fragments that appears on it, the main activity's Action bar has a specific style and actions, I need to change the style, buttons and the actions for each fragment.
any simple short to the point ideas ?
my project mini API is 11


text:
Q: Multi variable gradient descent in matlab I'm doing gradient descent in matlab for mutiple variables, and the code is not getting the expected thetas I got with the normal eq. that are:
theta =
   1.0e+05 *
    3.4041
    1.1063
   -0.0665
With the Normal eq. I have implemented.
And with the GDM the results I get are:
theta =
   1.0e+05 *
    2.6618
   -2.6718
   -0.5954
And I don't understand why is this, maybe some one can help me and tell me where is the mistake in the code.
Code:
function [theta, J_history] = gradientDescentMulti(X, y, theta, alpha, num_iters)

m = length(y); % number of training examples
J_history = zeros(num_iters, 1);
thetas = size(theta,1);
features = size(X,2)

mu = mean(X);
sigma = std(X);
mu_size = size(mu);
sigma_size = size(sigma);

%for all iterations
for iter = 1:num_iters

tempo = [];

result = [];

theta_temp = [];

%for all the thetas
for t = 1:thetas
    %all the examples
    for examples = 1:m
       tempo(examples) = ((theta' * X(examples, :)') - y(examples)) * X(m,t)
    end

    result(t) = sum(tempo)
    tempo = 0;

end

%theta temp, store the temp
for c = 1:thetas

    theta_temp(c) = theta(c) - alpha * (1/m) * result(c)
end

%simultaneous update
for j = 1:thetas

    theta(j) = theta_temp(j)

end

% Save the cost J in every iteration
J_history(iter) = computeCostMulti(X, y, theta);

end

theta
end

Thanks.
EDIT: Data.
  X =
    1.0000    0.1300   -0.2237
    1.0000   -0.5042   -0.2237
    1.0000    0.5025   -0.2237
    1.0000   -0.7357   -1.5378
    1.0000    1.2575    1.0904
    1.0000   -0.0197    1.0904
    1.0000   -0.5872   -0.2237
    1.0000   -0.7219   -0.2237
    1.0000   -0.7810   -0.2237
    1.0000   -0.6376   -0.2237
    1.0000   -0.0764    1.0904
    1.0000   -0.0009   -0.2237
    1.0000   -0.1393   -0.2237
    1.0000    3.1173    2.4045
    1.0000   -0.9220   -0.2237
    1.0000    0.3766    1.0904
    1.0000   -0.8565   -1.5378
    1.0000   -0.9622   -0.2237
    1.0000    0.7655    1.0904
    1.0000    1.2965    1.0904
    1.0000   -0.2940   -0.2237
    1.0000   -0.1418   -1.5378
    1.0000   -0.4992   -0.2237
    1.0000   -0.0487    1.0904
    1.0000    2.3774   -0.2237
    1.0000   -1.1334   -0.2237
    1.0000   -0.6829   -0.2237
    1.0000    0.6610   -0.2237
    1.0000    0.2508   -0.2237
    1.0000    0.8007   -0.2237
    1.0000   -0.2034   -1.5378
    1.0000   -1.2592   -2.8519
    1.0000    0.0495    1.0904
    1.0000    1.4299   -0.2237
    1.0000   -0.2387    1.0904
    1.0000   -0.7093   -0.2237
    1.0000   -0.9584   -0.2237
    1.0000    0.1652    1.0904
    1.0000    2.7864    1.0904
    1.0000    0.2030    1.0904
    1.0000   -0.4237   -1.5378
    1.0000    0.2986   -0.2237
    1.0000    0.7126    1.0904
    1.0000   -1.0075   -0.2237
    1.0000   -1.4454   -1.5378
    1.0000   -0.1871    1.0904
    1.0000   -1.0037   -0.2237

y =
      399900
      329900
      369000
      232000
      539900
      299900
      314900
      198999
      212000
      242500
      239999
      347000
      329999
      699900
      259900
      449900
      299900
      199900
      499998
      599000
      252900
      255000
      242900
      259900
      573900
      249900
      464500
      469000
      475000
      299900
      349900
      169900
      314900
      579900
      285900
      249900
      229900
      345000
      549000
      287000
      368500
      329900
      314000
      299000
      179900
      299900
      239500

Full dataset.

A: The line where you calculate tempo is wrong. It should be
tempo(examples) = ((theta' * X(examples, :)') - y(examples)) * X(examples,t)

Also try using matrix operations in MATLAB. Your code will be faster and it will also be easier to understand. For example, you can replace your nested loop with
E = X * theta - y;
for t = 1:thetas
    result(t) = sum(E.*X(:,t));
end

You can replace your subsequent two loop for updating theta into one line
theta = theta - alpha * (1/m) * result';


text:
Q: why threading not working? here is my code:
using System;

using System.Collections;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Linq;

using System.Threading;
using System.Threading.Tasks;

using System.IO;
using System.IO.MemoryMappedFiles;

namespace CopyFile
{
class Program
{
    static void Main()
    {
        long length = 0;
        byte[] buffer;
        string source_path, dest_path;
        source_path = Console.ReadLine();
        dest_path = Console.ReadLine();
        FileInfo fi = new FileInfo(source_path);
        length = (int)fi.Length;
        // Create disk file
        using (FileStream fs = File.Create(dest_path))
        {
            fs.Close();
        }
        // Create unnamed MMF
        var mmf1 = MemoryMappedFile.CreateFromFile(source_path, FileMode.OpenOrCreate, null, length);
        // Create reader to MMF
        var reader = mmf1.CreateViewAccessor(0, length, MemoryMappedFileAccess.Read);
        // Create unnamed MMF
        var mmf2 = MemoryMappedFile.CreateFromFile(dest_path, FileMode.Create, null, length);
        // Create writer to MMF
        var writer = mmf2.CreateViewAccessor(0, length, MemoryMappedFileAccess.Write);

        int read_block = int.Parse(Math.Min(length, 512 * 1024).ToString());//4k
        int end_read_block = int.Parse(length.ToString()) % read_block;

        int[] offset_array = new int[int.Parse((length - read_block).ToString()) / read_block];
        for (int offset = 0,i=0; i < int.Parse((length - read_block).ToString()) / read_block; i++,offset += read_block)
        {
            offset_array[i] = offset;
        }

        /*
        Parallel.ForEach<int>(offset_array, offset =>
        {
            // Read from MMF
            buffer = new byte[read_block];
            reader.ReadArray<byte>(offset, buffer, 0, read_block);
            // Write to MMF
            writer.WriteArray<byte>(offset, buffer, 0, read_block);
        });
         */
        foreach (int offset in offset_array)
        {
            // Read from MMF
            buffer = new byte[read_block];
            reader.ReadArray<byte>(offset, buffer, 0, read_block);
            // Write to MMF
            writer.WriteArray<byte>(offset, buffer, 0, read_block);
        }

        buffer = new byte[end_read_block];
        reader.ReadArray<byte>(length - end_read_block, buffer, 0, end_read_block);
        // Write to MMF
        writer.WriteArray<byte>(length - end_read_block, buffer, 0, end_read_block);

    }
}
}

i try to copy one file and paste it in another location
it is working
but when i try to use Parallel.foreach or Parallel.for when it copy one file
copied file is different with source file
(I commented Parallel.foreach section)
i can't understand why
thanks

A: In your code;
Parallel.ForEach<int>(offset_array, offset =>
{
    // Read from MMF
    buffer = new byte[read_block];
    reader.ReadArray<byte>(offset, buffer, 0, read_block);
    // Write to MMF
    writer.WriteArray<byte>(offset, buffer, 0, read_block);
});

buffer is a shared variable, so all threads will share it. For example, thread 1 will assign buffer, read from the file, thread 2 will reassign buffer and read the file, thread 1 will write the contents of thread 2's buffer.
To make it work better, have buffer be a local variable in the loop, a'la;
Parallel.ForEach<int>(offset_array, offset =>
{
    // Read from MMF
    byte[] buffer = new byte[read_block];
    reader.ReadArray<byte>(offset, buffer, 0, read_block);
    // Write to MMF
    writer.WriteArray<byte>(offset, buffer, 0, read_block);
});

That will allow all threads to have their own, local, buffer.
Looking at the documentation though makes things look bleak, any instance method (ReadArray/WriteArray) are not guaranteed to be thread safe. In other words, even if you fix the buffer problem, there is no guarantee that things will work.

A: Your approach to copying a file is not good. Beside problem which Joachim Isaksson described, problem is that you are accessing file streams from multiple threads at the same time. This means that it could happen that one thread T1 reads data, then scheduler passes control to thread T2 which reads data and then writes it to destination. When control is returned to T1 and it writes read data, you will get a corrupt file.
There is no reason to use concurrency to copy a file as CPU is not bottleneck for this operation. You will not get faster results, you will only waste CPU cycles.


text:
Q: How to get the selected row from table model? How to get the selected row from table model?
 I tried the following....
checkBoxes[t].addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent  e) {

    int index = -1;
    for (int i = 0; i < checkBoxes.length; i++) {
      if (checkBoxes[i] == e.getSource()) {

        String Status=null ;
        DbUtility ViewAbsenties=new DbUtility();
        ViewAbsenties.loadDriver();
        ViewAbsenties.connect();

        TableModel tm;
        tm = table3.getModel();

        if (checkBoxes[i].isSelected() == true) {
          Status  =(String) tm.getValueAt(i,8);
          System.out.println("Status : " + Status );

        }
      }
    }
  }
}

when i run the above code, iam getting the following error.
  Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1 >= 1
    at java.util.Vector.elementAt(Unknown Source)
    at javax.swing.table.DefaultTableModel.getValueAt(Unknown Source)
    at EmployeeLeave$10$1.actionPerformed(EmployeeLeave.java:490)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.JToggleButton$ToggleButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

A: *

*there are three potential issues

*

*JTables view could be Sorted or Filtered then you have to convertRowIndexToModel

*Array(s) started with zero (getValue(0, 0) is 1st. row from 1st. column)

*have to set javax.swing.ListSelectionModel properly or determine all selected rows

*for better help sooner post an SSCCE


text:
Q: Redirect all Android traffic via VPN I have a task to write an application that can redirect all traffic to Android via VPN. As I understand it can be included in the android through the settings, but i need to do it programmatically.
I learned VpnServis, and as I understood, with it I can create a application that can work with own created Vpn service, I can also assign vpn always on to other applications with the Vpn service created with it.
But I wonder if it is possible to do this for all installed applications, and if possible, how. And also interseting possibility assign vpn always on setting on all installed applications. Thanks!

A: When you use VpnService, you need to use VpnService.Builder to create it. While adjusting VpnService.Builder parameters, you need to assign what traffics you are interested in. This is done by adding a route through addRoute() method.
if you use 0.0.0.0/0 as your route, you will capture all traffic from all apps.
VPN always on is only supported from API level 24, so make sure if you want to use it. You need another approach (for example job) for creating this feature in lower API levels.


text:
Q: Bokeh "source" with multiple connected plots I am of the assumption that this is not possible with Dataframes and ColumnDataSource but interested in any ideas:
To LinkedBrush data between plots I would like to use "source" eg:
p1.rect(x="X1", width="W",y=1, height="Val1" source = SourcesfromDF )
p1.rect(x="X1", width="W",y=2, height="Val2" source = SourcesfromDF )
p1.rect(x="X1", width="W",y=3, height="Val3" source = SourcesfromDF )
...
p1.rect(x1="X1", width="W",y=1000 height="Val1000" source = SourcesfromDF )

each row in the df needs to have a value for this to work eg:
X1  W   Val1   Val2  ... Val1000
12 13    41     52  ...   2100

But my data is actually of the structure
X1  W   Val1   Val2 ... Val1000
12 13           52  ...   2100
10 11    41         ...    210
 2 14    91     62  ...
92 13            2  ...

(Which can not be plotted)
originating from a dictionary list-with a dictionary:
[{'x1':12 , 'x2':13, 'values':{'val2':52 ,'val31':310, 'val1000':2100}}, ...]

Which I essentially convert to an un-nested dictionary
[{'x1':12 , 'x1':13, 'val2':52 ,'val31':310, 'val1000':2100}
...]

to create the above data structure witch has a whole lot of undefined values in it.
To plot the X1 W against each 'val' I create individual plots
from an extracted subset:
ValSubset=MyBigDF.loc[MyBigDF[ValX] > 0 ]
# looking to do this as generically so my 'vals' may be strings etc,
# so the expression should be something like != NaN

*

*a) A nice solution would be to plot all the X1-W values repeatedly against every val1 to valN that is not NaN from a single 'source' in a single plot in a single call.

*b) My second best solution would be to have a single source full on NaN that I can use on multiple plots that allows highlighting of selected glyphs from the common 'source'. (i.e. how can I get a subset of the 'source' that ignores the NaN for the 'vals' I want to plot) (I was reading that Bokeh may support NaN, but read nothing about multiple plots against the same values - but can see a workaround with multiple plot on the same axis)

*c) both a)&b) require a large dataframe/ColumnDataSource that has many NaN fields and for each new "Val_" added each row needs another NaN. Ideal situation would be to plot against a Dictionary (or list) of "Vals"


text:
Q: An approximation of $\sqrt{1 + x}$ or $\sqrt{x}$ with connections to combinatorics or random walk? I am looking for an approximation of $\sqrt{1 + x}$ or $\sqrt{x}$.
We know $\sqrt{1 + x}$  has a Taylor expansion:
${\displaystyle {\sqrt {1+x}}=\sum _{n=0}^{\infty }{\frac {(-1)^{n}(2n)!}{(1-2n)(n!)^{2}(4^{n})}}x^{n}=1+{\frac {1}{2}}x-{\frac {1}{8}}x^{2}+{\frac {1}{16}}x^{3}-{\frac {5}{128}}x^{4}+\cdots ,}$
But for the problem I am working on, (a problem in random walk), I would like to get an alternative approximation of $\sqrt{1 + x}$ or $\sqrt{x}$, and hope it has some natural connections to combinatorics or probability or random walk.
Is there an approximation of $\sqrt{1 + x}$ or $\sqrt{x}$ which has some connections to combinatorics or probability or random walk ?


text:
Q: Set Mac Address in QEMU/KVM properties file I'm trying to set the mac address for my virtual machine in the virtual machine properties file. The properties file '102.conf' currently looks like this:
name: vm1.mydomain.com
bootdisk: ide0
ostype: w2k8
ide0: local:102/vm-102-disk-1.raw
memory: 1500
sockets: 1
ide1: local:iso/virtio-win-0.1-mm34.iso,media=cdrom
vlan0: rtl8139=96:83:DA:A0:06:34

Where and how in this file can I set the mac address for my virtual machine?

A: In this line
vlan0: rtl8139=96:83:DA:A0:06:34

the 96:83:DA:A0:06:34 is a MAC address. Changing that value should change your MAC address.
If you are generating your own MAC addresses you should use a value that contains 2,6,A or E as the second number as this defines a locally administered MAC address.
x2:xx:xx:xx:xx:xx
x6:xx:xx:xx:xx:xx
xA:xx:xx:xx:xx:xx
xE:xx:xx:xx:xx:xx


text:
Q: Mozilla "add on" sdk, simple-pref module, dynamic options (options that depend on previous options) I wrote a Firefox add-on using the Mozilla add-on SDK that changes the color of certain websites based on their category.  I have four categories, and 10 websites in each.  I would like an radio option to be the first preference, and then the following preferences be dependent on whether the first preference is category 1, category 2, etc, etc.  Is this possible with simple-pref?  I cannot find any add-on sdk tutorials online besides Mozillas documentation (which is very sparse)

A: That is not possible. Simple-prefs are static. You'd have to create your own html site and open that with a button from simple-prefs for a dynamic preferences interface for example.


text:
Q: Creating & accessing a simple Ruby on Rails Form I want to create the following:
The user types a text into a TextField and clicks 'submit'.
The text is then given to my ruby application which modifies certain bits of it and then displays it on the website.
The problem I am having is that I do not know how to create this textfield and how to access the content of that textfield in my application.
(All the tutorials I have looked at that use forms use a Model. Michael Hartl in chapter 7 for example writes signup page and just uses user/new as his signup page. Do I have to create a Model for my textfield as well then? It seems a bit over the top to create a model just for a simple form?)

A: You can just use form_tag helper to create form not connected to any model like:
<%= form_tag '/some_action_url' do %>
  <%= text_field_tag 'my_field' %>
  <%= submit_tag 'Send' %>
<% end %>

You can grab value of text field from params[:my_field] in your controller.


text:
Q: Merge multiple dataframes by multiple id columns in Pandas I have 5 dataframes as follows:
df1:
  provinceCode   provinceName
0    11          XXX
1    12          XXX
2    13          XXX
3    14          XXX
4    15          XXX

df2:
   cityCode  cityName  provinceCode
0  1101       XXX            11
1  1201       XXX            12
2  1301       XXX            13
3  1302       XXX            13
4  1303       XXX            13
df3:
  areaCode  areaName  cityCode  provinceCode
0  110101    XXX      1101            11
1  110102    XXX      1101            11
2  110105    XXX      1101            11
3  110106    XXX      1101            11
4  110107    XXX      1101            11
df4:
   streetCode    streetName  areaCode  provinceCode  cityCode
0  110101001       XXX       110101       11      1101
1  110101002       XXX       110101       11      1101
2  110101003       XXX       110101       11      1101
3  110101004       XXX       110101       11      1101
4  110101005       XXX       110101       11      1101
df5:
   villageCode    villageName         streetCode  provinceCode  cityCode  areaCode
0  110101001001   XXX   110101001            11      1101    110101
1  110101001002   XXX   110101001            11      1101    110101
2  110101001005   XXX   110101001            11      1101    110101
3  110101001006   XXX   110101001            11      1101    110101
4  110101001007   XXX   110101001            11      1101    110101

I hope to merge all dfs together especially their name and drop codes columns. I have tried merge them one by one which is quite inefficient. Just wonder if there is a better way to do that? Thanks.
Here is what I have tried:
df6 = df5.merge(df4[['code', 'name']], left_on = 'provinceCode', right_on = 'code', how = 'left')
df7 = df6.merge(df3[['code', 'name']], left_on = 'areaCode', right_on = 'code', how = 'left')
df8 = df7.merge(df2[['code', 'name']], left_on = 'areaCode', right_on = 'code', how = 'left')
df = df8.merge(df1[['provinceCode', 'provinceName']], left_on = 'provinceCode', right_on = 'code', how = 'left')

A: Updated answer courtesy @OP:
dfs = [df1, df2, df3, df4, df5]
from functools import partial
outer_merge = partial(pd.merge, how='outer')
reduce(outer_merge, dfs)

(Old Answer - don't use)
You don't have to create a variation each circle. Chain them:
 df= df5.merge(df4[['code', 'name']],
            left_on='provinceCode',
            right_on='code',
            how='left'
            ).merge(df3[['code', 'name']],
            left_on='areaCode',
            right_on='code',
            how = 'left'
            ).merge(df2[['code', 'name']],
            left_on='areaCode',
            right_on='code',
            how ='left'
            ).merge(df1[['provinceCode', 'provinceName']],
            left_on='provinceCode',
            right_on='code',
            how='left')

Update: Reduce is awesome in simplicity and speed, but for readability, it is less readable compared to mergers: We could DRY the code:
common_joins = dict(right_on='code', how='left')
common_columns = ['code', 'name']

df= df5.merge(df4[common_columns],
            left_on='provinceCode',
            **common_joins
            ).merge(df3[common_columns],
            left_on='areaCode',
            **common_joins
            ).merge(df2[common_columns],
            left_on='areaCode',
            **common_joins
            ).merge(df1[['provinceCode', 'provinceName']],
            left_on='provinceCode',
            **common_joins)