text:
Q: Probability and Distribution Consider a random sample from a distribution with the p.d.f. (for some $c > 0$)
\begin{equation} f(x) = cx^2 (1 − x), \text{if } 0 < x < 1; \end{equation}
\begin{equation} 0, \text{ elsewhere}. \end{equation}
What is an approximate distribution of $\bar{X}_n$ ? For a sample of size 45, find approximate mean and variance for $\bar{X}_n$ ? Find an approximate distribution of $\bar{X}^3_n$.
How should I go about solving this problem ? More importantly, I'd like to have an intuition of this question. I'm new to statistics so more details would help me more. This may be naive/dumb but we know that we are taking a sample from uniform distribution and why would we want to find its distribution again and how is it leading to an another distribution ? I'm very confused.

A: Shai Covo's answer shows you how to find the solutions to your homework problems; the key idea is to use the central limit theorem.  My answer is going to address your big picture question about intuition behind why one would care about the central limit theorem and about the distribution of the sample mean.
The central limit theorem says that the mean of a sufficiently large random sample from any distribution with finite variance has approximately a normal distribution.  This is an extremely surprising and powerful result.  It is probably the most important theoretical result in statistics.
It's surprising because many simple transformations of random variables don't have "nice" (i.e., named) distributions.  Even adding two independent and identically distributed random variables from the same distribution rarely yields a nice distribution, and when it does, it yields something different depending on the original distribution (e.g., the sum of two geometrics is negative binomial, the sum of two exponentials is gamma, the sum of two bernoullis is binomial).  But the central limit theorem says that if you add up enough independent random variables from the same distribution, regardless of what that distribution is, the resulting sum has approximately a normal distribution.  (Again, the original distribution must have finite variance.)  There is no a priori reason that one would expect a result like this.
The central limit theorem is powerful because knowing the approximate distribution of the sample mean makes it much easier to use the sample to draw inferences about the original population.  To take an example, suppose the water quality in a stream is good if its mean oxygen content is about 5 mg per liter.  Suppose your random sample of 45 observations has a mean of 4.62 mg per liter.  Assuming no flaws in your sampling design, the difference between what your sample produces and what you were hoping it would produce is either due to chance or due to the stream actually having poorer water quality.  Knowing that the sample mean has approximately a particular normal distribution allows you to say what the probability is that the difference is due to chance.  If, say, $\sigma = 0.92$ mg per liter, then you can determine that the probability that the difference is due to chance is about 0.28%.  Thus it's extremely likely that the difference is not due to chance and that the stream's water quality actually is lower than it should be.  (What I've described here is what's called a test of significance.  There are other inference procedures that the sample mean can be used for, too.  You should know that in practice, the picture with statistical inference is generally more complicated than what I've described here.  For instance, you normally don't know $\sigma$, which causes more problems.  But this is the basic idea.)

A: First of all, the p.d.f $f$ corresponds to a beta distribution with parameters $\alpha=3$ and $\beta=2$ (hence, not a uniform distribution). Now, by the central limit theorem, $\frac{{\sum\nolimits_{i = 1}^n {X_i }  - n \mu }}{{\sigma \sqrt n }}$ converges in distribution to the ${\rm N}(0,1)$ distribution, where $\mu = {\rm E}(X_1)$ and $\sigma^2 = {\rm Var}(X_1)$. This means that, for $n$ sufficiently large (for example, $n=45$), we may write $
\sum\nolimits_{i = 1}^n {X_i }  \approx n \mu + \sigma \sqrt n Z$, where $Z \sim {\rm N}(0,1)$. Dividing by $n$ thus gives $\bar X_n \approx \mu + (\sigma/{\sqrt{n}})Z$. Thus, $\bar X_n$ is approximated by the normal distribution with mean $\mu$ and small variance $\sigma^2/n$ (this is exactly the distribution of the right-hand side, $\mu + (\sigma/{\sqrt{n}})Z$). As for the mean and variance of $\bar X_n$, this is a simple exercise, and you should be able to show that the mean is $\mu$ and the variance is $\sigma^2/n$. Finally, to find approximate distribution of $\bar X_n^3$, you may use the approximation $\bar X_n \approx \mu + (\sigma/{\sqrt{n}})Z$.


text:
Q: Docusign - How to ExportAuthoritativeCopy of a signed envelope using REST API I need to export an authoritative copy of a signed envelope out of docusign in order to be able to delete it later. I'm using DocuSign REST API v2.0 in PHP
Thank you.

A: I don't believe it's currently possible to do so with the DocuSign REST API -- instead, you'll need to use the DocuSign SOAP API.  See documentation starting with "ExportAuthoritativeCopy" on page 168 of the DocuSign SOAP API Guide.

redpajama_set_name: RedPajamaStackExchange


text:
Q: when implementing ErrorProtocol, keep getting error 1) use of undeclared type ErrorProtocol 2) type does not conform to protocol RawRepresentable I'm learning swift by following the swift programming lanuguage 3.0 handbook. In the error handling chapter, when one want to declare an error type, you implement the ErrorProtocol protocol. As shown below:
enum VendingMachineError: ErrorProtocol{
    case invalidSelection
    case insufficientFuns(coinsNeeded: Int)
    case outOfStock
}

But in xcode playground, I keep getting the error message
1) use of undeclared type ErrorProtocol
2) type VendingMachineError does not conform to protocol RawRepresentable
Why is this happening? I'm simply coping the code from the book.

A: It's not ErrorProtocol, it's ErrorType, you declare that when creating error enum


text:
Q: SendKeys(Keys.Enter) not working in Appium I have entered text in a text box. And now I want to press Enter key. To do that, I am passing sendKey(Keys.Enter) which just cut the text from the text box and does nothing.
 driver.findMobileElement("id", setLocationTextBoxId).sendKeys(parkingLocation+"\n");
 driver.getKeyboard().sendKeys(Keys.ENTER);

Note: "\n" is not working already. sendKeyEvent/pressKeyEvent method is not available.

A: To press ENTER key on Android device, you need to use Android KeyEvent codes. The key code for ENTER is 66. You can use the below code snippet.
driver.longPressKeyCode(66);

To get the all Android KeyEvent codes please refer this official link

A: Try this! I have the same problem like you, and i got frustated untill i found this. Hope this will help you out!
    public void pressEnterEditText(String elementName, String value) {
    AndroidElement tempElement = getAndroidElement(elementName);
    tempElement.click();
    driver.pressKey(new KeyEvent(AndroidKey.ENTER));
}


text:
Q: MongoNotConnectedError: MongoClient must be connected to perform this operation. How to handle this error? cmd
How can i solve this. Just showing  MongoClient must be connected to perform this operation
    at getTopology ..... at collection.insertOne .... at maybePromise..

const express = require('express');
const {MongoClient} = require('mongodb');
const password = 'NLJXkuGFhUd68@9';

const uri = "mongodb+srv://organicUser:NLJXkuGFhUd68@9@cluster0.px7rc.mongodb.net/organicdb?retryWrites=true&w=majority";
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });

const app = express();

app.get('/', (req, res) => {
    res.send("Hello, I am Working");
})

client.connect(err => {
  const collection = client.db("organicdb").collection("products");

  // perform actions on the collection object
  const product = {name: "Modhu", price: 120, quantity: 30};
  collection.insertOne(product)
  .then(result => {
      console.log("One product added");
  })
  console.log("database connected");

});

app.listen(8000)

A: Just comment the code or remove client.close()
 finally {
           // await client.close();
        }

A: I needed to replace @ with %40 in the database password

A: I had the same issue and I have changed the method to be await and async, and I added await to the operation.
So the operation will be finished then the connection will be close

A: As I'm struggling with this, the author is referring to the idea that if your password contains certain characters, you must change them out for percent based codes: If the username or password includes the following characters:
: / ? # [ ] @
those characters must be converted using percent encoding.
https://www.mongodb.com/docs/manual/reference/connection-string/


text:
Q: Ubuntu Code of Conduct updated – should I? I signed the Ubuntu Code of Conduct a good while back. I don't remember exactly when, and Launchpad doesn't tell me which version it is I've signed. Now there is a new version in the works. Should I sign the new one? Does it have any practical consequences either way?

A: Do note that I'm adding this as a half-answer, because I can't fit this into a comment as a close reason. >.<
As of right now, it is not, repeat not finalized.
Even then, any answer that this question might receive would be the following:
Sign on your conscience.
Basically, what that boils down to is this:
Read it yourself. Figure out if you agree with it. If you do, sign it. Otherwise, don't.
That's all I have to say.


text:
Q: How am I supposed to react if ThreadPool.QueueUserWorkItem() returns FALSE? I'm using ThreadPool.QueueUserWorkItem(). From MSDN I see that it can return FALSE if queuing failed. How am I supposed to react then? Wait a bit and try to queue again, hoping that a thread from th pool will be available then?

A: That's game over. Tell your user what happened and terminate your app.

A: It is unlikely to return false (See here: When ThreadPool.QueueUserWorkItem returns false). If it does - treat it as a failure and do not keep retrying.
Normally you would get a NotSupportedException.


text:
Q: Changing an fixed element's class depending on what section of the page is currently visible (jQuery) Hello fellow developers!
I've had a big scan of the web, including StackOverflow and cannot seem to find anything documenting what I want, nor anything remotely similar to what I want.
I'm building a site with a fixed navbar, however the navbar doesn't actually have a background color (transparent). Within the navbar there are two elements that are visible;

*

*Client's logo; I have created this using a custom font so I am actually able to control all formatting with css and classes applied via JS.

*Menu toggle button; This is also all element based and I have full control with css and classes applied via JS.
The page structure is
 based, and each section is either an "off-white" or "black".
For example
...
 will have a black background (dur).

The issue
The menu button and client logo are also black, so I need a way of tracking what the current visible/scrolled section's class is ("dark" or "light") and then apply a class to the navigation via JS.
So if the current section has the class of "light" then the menu button and logo are black, if the current section has the class of "dark" then the menu button and logo change to  white.

I am completely aware of the plugins available such as "scrollorama" that have the section spying capabilities but I really only need to utilise a tiny part of the functionality so it's going to be more efficient to just write a custom function. Also open to suggestion.

A: I'm looking for same as you and I found this:
slideshow with changing font color on each slide + callback font to set color on scroll
Hope it can give you some hint!


text:
Q: Java Event Handling : Significance of using this keyword in Event Listeners import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class Appwindow extends Frame{
    String keymsg="This is a test";
    String mousemsg="";
    int mouseX=0, mouseY=0;
    public Appwindow()
    {
            addKeyListener(new MyKeyAdapter(this));
        addMouseListener(new MyMouseAdapter(this));
        addWindowListener(new MyWindowAdapter());
    }

    public void paint(Graphics g)
    {
        g.drawString(keymsg,10,40);
        g.drawString(mousemsg,mouseX,mouseY);
    }

    public static void main(String args[])
    {
        Appwindow ap = new Appwindow();
        ap.setSize(new Dimension(300,300));
        ap.setTitle("Application");
        ap.setVisible(true);
    }
}

class MyKeyAdapter extends KeyAdapter{
    Appwindow a;
    public MyKeyAdapter(Appwindow a)
    {
       this.a=a;
        }
    public void keyTyped(KeyEvent e)
    {
    a.keymsg += e.getKeyChar();
    a.repaint();
   }
}

class MyMouseAdapter extends MouseAdapter{
Appwindow a;
public MyMouseAdapter(Appwindow a)
{
    this.a=a;
}
public void mousePressed(MouseEvent e)
{
    a.mouseX=e.getX();
    a.mouseY=e.getY();
    a.mousemsg="Mouse down at" + a.mouseX+ "," + a.mouseY;
    a.repaint();
}
}

 class MyWindowAdapter extends WindowAdapter{
  public void windowClosing(WindowEvent e)
 {
    System.exit(0);
}
}

this is a simple code to make a frame based window program. I just want to ask what is the significance of using this while registering an event listener...like in addMouseListener(new MyMouseAdapter(this));
Please explain to me what actually is happening in this line of code.

A: Where ever you use that always this  references to the current object.
MyMouseAdapter(this));

That means  passing current Appwindow  to the  method
 public MyMouseAdapter(Appwindow a)

So that you can do some task in  MyMouseAdapter method on Appwindow

A: You are telling the action listener to tell you when an event happens on an object (this) (your window). You key in for events sent by the mouse. It's like you are subscribing to a television channel. You say, "hey listener, when a mouse event happens on the window, tell me."  You'll be told in the interface method you have to implement for this listener

A: this is a reference that is only available in an instance context. That is, it references the current object you are operating in. A Frame can register a number of listeners (KeyListener, MouseListener, etc.). Your custom class implementations want to have some reference to the Frame you are registering them on. One way to achieve that is by passing the reference to the current Frame (ie. AppWindow) object with this through the class' constructor.

A: Ok, so, you're registering a listener, that is, a class that implements a certain listener interface or, as in your case, inherits from a certain class (in your case MouseAdapter).
Because MyMouseAdapter is of type MouseAdapter, Java can count on it having a method mousePressed(MouseEvent e).
That's the first half.
Now, it just so happens that your particular implementation of this mouse adapter wants to do something when the mouse it's pressed, and that something includes adding a message to your window, so, it needs to have access to that window (AppWindow to be precise). You could pass that on each call to mousePressed, but you don't get to define that interface. Instead, what you are doing is passing the AppWindow instance at the constructor of the MouseAdapter.
Now, it just so happens that you're doing this from the AppWindow, so, from your code's point of view, when you call addMouseListener(new MyMouseAdapter(this)); this refers to the current object, i.e. the AppWindow
Hope that helps!

A: I know this question is old but I was wondering about the same and came across this question. The answers provided did help me but did not provide me a complete picture.
I understood the concept from the following program on which I have put comments
so that others with the same question can understand the concept more easily.
 public class MousePressedDemo extends Applet {

   public void init(){

  //question was why we are passing "this" in line below
  //at this point just understand like any use of "this" keyword
  // it points to current
  //object of class MousePressedDemo or current applet window
  //we are passing it to the constuctor of MyMouseAdapter class

  addMouseListener(new MyMouseAdapter(this); // why we pass this in this line

  }

 } // closing class MousePressedDemo

 class MyMouseAdapter extends MouseAdapter{

 // line below creates ref var of class MousePressedDemo
 //to which we can assign an object of type class MousePressedDemo

 MousePressedDemo mousePressedDemo;

 //below constructor taking object of class MousePressedDemo as parameter.
 public MyMouseAdapter(MousePressedDemo mousePressedDemo){

  // the line below is the answer we are looking for. The object of class
  // or applet window  We pass as "this" is now passed to a ref variable in
  // this class. now using this reference var we can access the original
  // applet window. look below to see how it is used to show message
  // on status bar of original window

   this.mousePressedDemo = mousePressedDemo;

}// closing constuctor

 public void mousePressed(MouseEvent me){

 // show message on status window of original applet class

mousePressedDemo.showStatus("MOuse Pressed");

 } // close method

} // closing class MyMouseAdapter


text:
Q: Appending Bytes puts spaces I'm trying to loop through an array of byte and copy the contents to a new list of bytes, and display them back. please see the code below.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim myByte() As Byte = New Byte() {65, 66, 67}
    Dim newByte() As Byte = New Byte() {}
    Dim tempByteList As New List(Of Byte)
    For i As Integer = 0 To 2
        ReDim newByte(1)
        Array.Copy(myByte, i, newByte, 0, 1)
        tempByteList.AddRange(newByte)
    Next
    Dim str1 As String = System.Text.UnicodeEncoding.UTF8.GetString(tempByteList.ToArray())
 End Sub

I want to see str1 as "ABC" but the out put i get is "A B C" (ie with spaces between letters)
Please note: I have to copy(chunks) within a loop and get the result at the end, this is just a sample to reproduce my real issue.
any help will be appreciated

A: The problem is in your ReDim statement.  Microsoft's definition of ReDim states that the array bounds specified always go from 0 to the bound specified (in your case 1), so you are essentially ReDim-ing a 2 item array, which is why you're seeing "spaces" in between the A, B, and C elements.  Change your ReDim statement to
ReDim newByte(0)

and all should be well as you will then be declaring the newByte array to go from 0 to 0 (a single item array), which is what you want.

A: You could also use the Array.CreateInstance method in VB.Net and not need to do the redim as createInstance makes it exactly the size that you specify. (Only other thing is do you need to build your TempByteList or do you know at the start of the loop the size you require, because you could just create your Final bytearray initially and Array.Copy them into the correct offset rather than append to a list then .ToArray()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim myByte() As Byte = New Byte() {65, 66, 67}
    Dim newByte() As Byte = CType(Array.CreateInstance(GetType(Byte), 1), Byte())
    Dim tempByteList As New List(Of Byte)
    For i As Integer = 0 To 2
        Array.Copy(myByte, i, newByte, 0, 1)
        tempByteList.AddRange(newByte)
    Next
    Dim str1 As String = System.Text.UnicodeEncoding.UTF8.GetString(tempByteList.ToArray())
End Sub


text:
Q: Importing .dta to R I'm currently trying to import data from .dta to R. The data is also available in .tab format. How can I import the variables as labels?
The code that I am using:
data <- read_dta("file.dta")

or
data <- read.table("file.tab", header = F, sep = "\t", fill = TRUE)

Is there a way to import the variables in such a way that R recognizes the label?

Sample data
structure(list(sn1 = structure(c(1, 1, 1, 1, 1, 1), label = " point number  ", format.stata = "%8.0g"),
    wjob12s5 = structure(c(NA, NA, 0, 0, 0, 0), label = " day 5/ twelfth job line starts at  ", format.stata = "%8.0g", labels = c(` 4:01 4:15 ` = 1,
    ` 4:16 4:30 ` = 2, ` 4:31 4:45 ` = 3, ` 4:46 5:00 ` = 4,
    ` 5:01 5:15 ` = 5, ` 5:16 5:30 ` = 6, ` 5:31 5:45 ` = 7,
    ` 5:46 6:00 ` = 8, ` 6:01 6:15 ` = 9, ` 6:16 6:30 ` = 10,
    ` 6:31 6:45 ` = 11, ` 6:46 7:00 ` = 12, ` 7:01 7:15 ` = 13,
    ` 7:16 7:30 ` = 14, ` 7:31 7:45 ` = 15, ` 7:46 8:00 ` = 16,
    ` 8:01 8:15 ` = 17, ` 8:16 8:30 ` = 18, ` 8:31 8:45 ` = 19,
    ` 8:46 9:00 ` = 20, ` 9:01 9:15 ` = 21, ` 9:16 9:30 ` = 22,
    ` 9:31 9:45 ` = 23, ` 9:46 10:00 ` = 24, ` 10:01 10:15 ` = 25,
    ` 10:16 10:30 ` = 26, ` 10:31 10:45 ` = 27, ` 10:46 11:00 ` = 28,
    ` 11:01 11:15 ` = 29, ` 11:16 11:30 ` = 30, ` 11:31 11:45 ` = 31,
    ` 11:46 12:00 ` = 32, ` 12:01 12:15 ` = 33, ` 12:16 12:30 ` = 34,
    ` 12:31 12:45 ` = 35, ` 12:46 13:00 ` = 36, ` 13:01 13:15 ` = 37,
    ` 13:16 13:30 ` = 38, ` 13:31 13:45 ` = 39, ` 13:46 14:00 ` = 40,
    ` 14:01 14:15 ` = 41, ` 14:16 14:30 ` = 42, ` 14:31 14:45 ` = 43,
    ` 14:46 15:00 ` = 44, ` 15:01 15:15 ` = 45, ` 15:16 15:30 ` = 46,
    ` 15:31 15:45 ` = 47, ` 15:46 16:00 ` = 48, ` 16:01 16:15 ` = 49,
    ` 16:16 16:30 ` = 50, ` 16:31 16:45 ` = 51, ` 16:46 17:00 ` = 52,
    ` 17:01 17:15 ` = 53, ` 17:16 17:30 ` = 54, ` 17:31 17:45 ` = 55,
    ` 17:46 18:00 ` = 56, ` 18:01 18:15 ` = 57, ` 18:16 18:30 ` = 58,
    ` 18:31 18:45 ` = 59, ` 18:46 19:00 ` = 60, ` 19:01 19:15 ` = 61,
    ` 19:16 19:30 ` = 62, ` 19:31 19:45 ` = 63, ` 19:46 20:00 ` = 64,
    ` 20:01 20:15 ` = 65, ` 20:16 20:30 ` = 66, ` 20:31 20:45 ` = 67,
    ` 20:46 21:00 ` = 68, ` 21:01 21:15 ` = 69, ` 21:16 21:30 ` = 70,
    ` 21:31 21:45 ` = 71, ` 21:46 22:00 ` = 72, ` 22:01 22:15 ` = 73,
    ` 22:16 22:30 ` = 74, ` 22:31 22:45 ` = 75, ` 22:46 23:00 ` = 76,
    ` 23:01 23:15 ` = 77, ` 23:16 23:30 ` = 78, ` 23:31 23:45 ` = 79,
    ` 23:46 0:00 ` = 80, ` 0:01 0:15 ` = 81, ` 0:16 0:30 ` = 82,
    ` 0:31 0:45 ` = 83, ` 0:46 1:00 ` = 84, ` 1:01 1:15 ` = 85,
    ` 1:16 1:30 ` = 86, ` 1:31 1:45 ` = 87, ` 1:46 2:00 ` = 88,
    ` 2:01 2:15 ` = 89, ` 2:16 2:30 ` = 90, ` 2:31 2:45 ` = 91,
    ` 2:46 3:00 ` = 92, ` 3:01 3:15 ` = 93, ` 3:16 3:30 ` = 94,
    ` 3:31 3:45 ` = 95, ` 3:46 4:00 ` = 96), class = c("haven_labelled",
    "vctrs_vctr", "double"))), row.names = c(NA, -6L), class = c("tbl_df",
"tbl", "data.frame"))

A: If read_dta fails at it, you could create a lookup table with the help of the "labelled" package. Note that I use here an abridged and slightly tweaked version of your sample dataframe:
library(labelled)
library(tidyverse)
df <-
    structure(list(sn1 = structure(c(1, 1, 1, 1, 1, 1),
                         label = " point number  ",
                         format.stata = "%8.0g"),
                   wjob12s5 = structure(c(NA, NA, 0, 1, 2, 3),
                              label = " day 5/ twelfth job line starts at  ",
                              format.stata = "%8.0g",
                              labels = c(` 4:01 4:15 ` = 0, ` 4:16 4:30 ` = 2, ` 4:31 4:45 ` = 3),
                              class = c("haven_labelled", "vctrs_vctr", "double"))),
                   row.names = c(NA, -6L),
                   class = c("tbl_df","tbl", "data.frame"))

lookup_table <- data.frame(
                   code = val_labels(df$wjob12s5),
                   labels =  val_labels(df$wjob12s5) %>% names())

df %>% left_join(lookup_table, by = c("wjob12s5" = "code"))


text:
Q: Zend Framework: set Module as Subdomain I want to create routes to also get links like:

*

*my.site.com(/:controller/:action)

*admin.site.com(/:controller/:action)

I tried to add:
resources.router.routes.www.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.www.route = ":module.nameofmysite.com"
resources.router.routes.www.defaults.module = "default"
resources.router.routes.www.chains.index.type = "Zend_Controller_Router_Route"
resources.router.routes.www.chains.index.route = ":controller/:action/*"
resources.router.routes.www.chains.index.defaults.controller = "index"
resources.router.routes.www.chains.index.defaults.action = "index"

But nothing happens.. (Server not found), how do I fix this?
I've read the zend documentation about this but I still can't get it to work.

A: I had a similar problem using wildcard subdomains on a local enviroment. I was sure of my routing however the hosts file didin't contain the subdomain. This worked for me
127.0.0.1  mydomain.local
127.0.0.1  subdomain.mydomain.local


text:
Q: What are the differences between Amazon Redshift and the new AWS Glue datawarehousing services? I am confused about these two services. It looks that they are offering the same service. Probably the only difference is that the Glue catalog can contain a wider range of data sources. Does it mean that AWS Glue can replace Redshift?

A: The Comment is right , These two services are not same AWS Glue is ETL Service while AWS Redshift is Data Warehousing service.
According to AWS Documentation :
Amazon Redshift is a fast, fully managed, petabyte-scale data warehouse service that makes it simple and cost-effective to efficiently analyze all your data using your existing business intelligence tools. It allows you to run complex analytic queries against petabytes of structured data, using sophisticated query optimization, columnar storage on high-performance local disks, and massively parallel query execution.
According to AWS Documentation :
AWS Glue is a fully managed ETL (extract, transform, and load) service that makes it simple and cost-effective to categorize your data, clean it, enrich it, and move it reliably between various data stores
You can Refer the Documentation Provided by AWS for Details but essentially these are totally different services.


text:
Q: STM32 unaligned access Periodically, the program enters the HardFault_Handler. In the register HFSR set bit FORCED and in UFSR register set UNALIGNED.
The project uses STM32F417, FreeRtos, LWIP. In most cases, the error in the stack are LWIP function. The error occurs rarely once
a few days.
The program is compiled with the flag --no_unaligned_access.
It is unclear why there is such an error - while --no_unaligned_access flag is enabled and even every few days, and second whether it is possible to process or ignore this error and continue the program?

A: (I know this is years after the OQ. Posting in case it's still helpful.)
I'm working on a project that is using LWIP 1.4.1 that does have at least one unaligned access fault; I've just now fixed it. (I'm here researching if this is a known issue.)
In src/netif/etharp.c: etharp_request()
  return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, &ethbroadcast,
                (struct eth_addr *)netif->hwaddr, &netif->ip_addr, &ethzero,
                ipaddr, ARP_REQUEST);

The cast (struct eth_addr *)netif->hwaddr is causing the non-alignment of netif->hwaddr to be discarded. A subsquent memcpy() inside etharp_raw() then faults.
The solution I've shoe-horned in is to allocate temporary storage that is aligned and pass that instead:
  struct eth_addr hwaddr;
  memcpy(hwaddr.addr, netif->hwaddr, ETHARP_HWADDR_LEN);

  return etharp_raw(netif, &hwaddr, &ethbroadcast,
                &hwaddr, &netif->ip_addr, &ethzero,
                ipaddr, ARP_REQUEST);

A quick check through the rest of etharp.c reveals quite a number of such casts, some of which are harmless but at least one or two others are also likely to fault.

A: lwIP 2.x has been released since mid-last year (2018). My experience is that changing over from 1.4x to 2.x did not cause any/much issues, so it's best to switch over. That sort of problems (if they are actual problems) might have been fixed.
Also, the F4x series is Cortex-M4, so they can do unaligned access. It would only cause problems if you are using F0xx or L0xx series that uses the Cortex-M0+ core.

A: I don't know if this is already resolved. But I ran into same problem with (STM32F746) during one of the project.
Solution: Just add following line in int main()
SCB->CCR = SCB->CCR & ~(1<<3);//Resetting the 3rd bit (meant for enabling hardfault for unaligned access)

Check if it is still relevant for you.
In my case I was using packed structures which was causing this problem. After above mentioned fix with option 1, it got away for me.


text:
Q: How to make Office Home and Business 2013 Click-to-run work with Google Apps Sync I'm a big fan of the Stack Exchange community and this is my first question, hope it is appropriate to ask it here.
I've bought four retail boxes of Office Home and Business 2013, just to find out after a lot of research that it is a "click-to-run" version, which is not compatible with Google Apps Sync. I've called Google Apps support and they say I have to ask Microsoft for an .msi based version, which I did, to no avail: each Microsoft support agent said something different; one pointed me to forum pages, another said he had never heard of .msi versions, and yet another one told me I had to find an .msi "transformer", which was from third parties, and when asked where to get it, said he could not reference or offer help for third party software.
One of the links provided by the Microsoft agent pointed to this article which applies to Office 2010 versions, not office 2013. (http://office.microsoft.com/en-us/excel-help/click-to-run-switch-to-using-an-msi-based-office-edition-HA101850538.aspx).
Another one directed to a forum which then directed to a preview version of Office Professional Plus 2013 (http://technet.microsoft.com/en-us/evalcenter/jj192782.aspx), which is of no use to me.
I've found links to original ISOs for Office Professional Plus 2013 in this site, apparently from legit sources (http://www.heidoc.net/joomla/technology-%20science/microsoft/73-office-2013-direct-download-links), and they have .IMG files for Office Home and Business 2013, but after downloading the IMG I found out it was another click-to-run version.
Anyway, to summarize, does someone here know if what I'm looking for even exists?
Thanks a lot in advance.

A: The steps provided in this link http://productforums.google.com/forum/#!topic/apps/b6q0wCG3ag0 work.
I installed it on Windows 8 64 bits.
What I did was:

*

*Download and install Microsoft Office Professional Plus 2013 from here - install only Home & Business apps: Word, Excel, Powerpoint, OneNote, Outlook.

*Download and install Google Apps Sync from [here] (https://tools.google.com/dlpage/gappssync), configure the profile(s) needed.

*Run Outlook and check it is working

*Install your Click-to-run copy of Microsoft Office Home and Business 2013

*Check Outlook

*Uninstall Microsoft Office Professional Plus 2013
At this point, all the shortcuts on the Start screen disappeared; in order to add them back I searched for each application and ran it once. Later I figured out that a better idea was to look for the executables which on my system are located in C:\Program Files\Microsoft Office 15\root\office15
Thanks again to @Ramhound for his link.
UPDATE (03-03-2013)
Google now provides an updated version of the Google Apps Sync software that works with Click-to-run versions of their software.
Here is the link: http://tools.google.com/dlpage/gappssyncstandalone


text:
Q: How can I install a separate perl without disturbing the existing one? How I should install 32-bit Perl on 64-bit machine without affecting the existing applications that uses 64-bit Perl? Is it possible to have a single  application (Read: Single file) use different version of Perl for different tasks?

A: You might also be interested in perlbrew by Kang-min Liu. It allows you to easily install multiple versions of perl.
After downloading it and installing it, run
perlbrew -h

to see the options. Looking at the documentation, it seems to be able to use the -D options as Sinan and Mark mentioned.

A: You can't use two versions of perl for a running program for what should be fairly obvious reasons. Without knowing why you want to do that, here are a few ideas:

*

*You can compile a 32 bit perl that uses 64 bit ints and floats (-Duselongdouble -Duse64bitint);

*You could have two processes, one using your 64 bit perl the other using 32 bit and pass data between them using pipes or shared memory.

If you need 64 bit precision but also need to link with 32 bit libraries #1 might help. #2 is obviously a more general solution but potentially harder and/or slower since the communication point could be a bottleneck.

A: Install the custom perl in a different directory, say /opt/perl-5.10.1-32bit and specify that path in the scripts which you want to use this custom version:
#!/opt/perl-5.10.1-32bit/perl

as the first line of your script.
For example, just a few minutes ago, I did:

$ ./configure -Dprefix=/opt/perl-5.11.0


text:
Q: Kotlin Spring Boot: database is empty despite creating a table in schema.sql I'm following this very simple tutorial to setup a REST API using Kotlin, Gradle and Spring Boot:
https://kotlinlang.org/docs/jvm-spring-boot-restful.html
But when I run the app (by clicking play) and visit localhost:8080 I get an error saying that the table "MESSAGES" is not found and the database is empty.
I know for sure that my application.properties is read because changing server.port worked,
I've tried many things like moving schema.sql directly under main/resources, adding spring.jpa.hibernate.ddl-auto=none in application.properties or marking the resources folder as "Source" but to no avail.
It seems my schema.sql is not being executed and I can't figure out why !
Versions: Windows 10, IntelliJ IDEA 2022.2.2, Java 17, Spring 2.7.4
Main file gist
application.properties:
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:file:./data/testdb
spring.datasource.username=sa
spring.datasource.password=password
spring.datasource.schema=classpath:sql/schema.sql
spring.datasource.initialization-mode=always

sql/schema.sql:
CREATE TABLE IF NOT EXISTS messages (
  id     VARCHAR(60)  DEFAULT RANDOM_UUID() PRIMARY KEY,
  text   VARCHAR      NOT NULL
);

A: Solved it !
This IntelliJ tutorial was written for Spring 2.6 (no longer available in Spring Initializr) and in 2.7 these 2 keys changed in application.properties:
spring.datasource.initialization-mode -> spring.sql.init.mode
spring.datasource.schema  -> spring.sql.init.schema-locations
full list of key changes
Replacing them in my application.properties worked !
New application.properties:
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:file:./data/testdb
spring.datasource.username=sa
spring.datasource.password=password
spring.sql.init.schema-locations=classpath:sql/schema.sql
spring.sql.init.mode=always

A: Try adding these in your application.properties
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true


text:
Q: GAE Python2.7 client authentication by certificate I'm writing an application on GAE that is exposing a RESTlike API to a fixed number of remote servers which may be using any OS/software. At the moment I'm pondering how to identify and authenticate these remote servers painlessly.
I'm trying to avoid having to program too much of this myself for obvious security concerns.
If I'd were on an Apache or nginx I'd use SSL client certificates and let the clients choose whatever they want to contact the API, curl, webapp, whatever.
I understand that, at this time, GAE doesn't provide checking client certificates this way.
Is there any other way to do this in GAE with Py2.7?
If this is not possible or a very big hassle, can anyone point me to another good way to identify and authenticate remote servers in a situation like this?
I can only post two links of what I checked
https://groups.google.com/forum/?fromgroups=#!topic/google-appengine-python/c5PHMrAMAcI
https://sites.google.com/site/oauthgoog/authenticate-google-app-engine-app
plus much more over the last few days. I found some questions which are similar to mine, but none with a satisfying answer, to me at least.

A: I'd suggest looking into Google Cloud Endpoints, which is currently in the trusted tester phase. I discuss it in more detail in this answer, but the main things you'll get are:

*

*An easy way to define your API

*Automatic support for OAuth 2

We're primarily targeting developers building APIs in their application backends, but other "same party" (e.g. you're the API developer and consumer) uses should work equally well.


text:
Q: Get href value from  who is store in a variable ERB My entire code :
<% query.inline_columns.each do|column| %>
    <% if column.css_classes.to_s != "assigned_to" %>
         <td class="<%= column.css_classes %>"> <%= column_content(column, issue) %>
    <% else %>
         <td class="<%= column.css_classes %>"> <%= test = column_content(column, issue) %>
    <% end %>
<% end %>

I have something like that:
test = column_content(column, issue)

and when i go on the website it give me something like that:
Test

My question is how can I get the value of href ?
I tried test.href, test.link_to and test.link but don't work.
And after when we have the href it's possible to only have the id in href ? (In the href above it's 5)
BUT I don't want to go on page and get the id, I just want to have it so I can load the picture of user in the table.
I'm beginner in ERB language, thank's for help !
EDIT:
My solution to get the id :
test.to_s.split("href=\"").last.to_s.split("\"").first.to_s.split("/").last.to_s

Thank's guy to try to help me !

A: The Request cycle:
In Rails and in MVC every request follows a cycle:
Let's say you type in http://localhost:3000/users.

*

*The request hits your Rails server and goes through Rack to your routes.

*Rails picks a controller and action which matches the request.

*Rails runs your UsersController#index and renders the view.

*The rendered html is sent back to the client.

So why am I telling you this?
It has nothing to do with ERB.
You simply render the view and send it to the client - all done. The client can interact by clicking links or submitting forms. But it's not your actual view communicating back.
When the user clicks the link it starts a whole new request - it's a whole new process*.
Routes & Params
Routes are kind of like regular expressions - with superpowers.
If you want your rails app to handle the request to /users/1 you need to create a route:
 # config/routes.rb
 get `/users/:id`, to: 'users#show'

See the :id part? That means we can get the ID passed in the url from params[:id].
class UsersController
  def show
    @user = User.find(params[:id])
  end
end

Of course writing your routes like that is pretty tedious. So instead we write:
resources :users

Try running rake routes from the console to see what it does.


text:
Q: Sax parsing throwing Unexpected token Exception I am trying to read an Xml file like this.
String soapResponse = readFile();
                System.out.println(soapResponse);
                //TMP END
                InputDataXMLParser inputParser = new InputDataXMLParser(soapResponse, database);    //Exception at this line
                inputParser.saveInputFiles();
            } catch (Exception exception) {
                exception.printStackTrace();}

My readFile() method
private String readFile() throws Exception{

            AssetManager assetManager = activity.getAssets();
            InputStream ims = assetManager.open("temp/gssoOutbound.xml");

            StringBuffer fileContent = new StringBuffer("");

            byte[] buffer = new byte[1024];

            while (ims.read(buffer) != -1) {
                fileContent.append(new String(buffer));
            }

            return fileContent.toString();
        }

//Stack Trace
11-05 09:58:15.766: W/System.err(21020): org.xml.sax.SAXParseException: Unexpected token (position:TEXT
11-05 09:58:15.766: W/System.err(21020): URRICANE DISH D...@2:237 in java.io.StringReader@2bed3b20)
11-05 09:58:15.786: W/System.err(21020):    at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:146)
11-05 09:58:15.786: W/System.err(21020):    at org.col.gsso.sap.parser.InputDataXMLParser.getDomElement(InputDataXMLParser.java:510)
11-05 09:58:15.786: W/System.err(21020):    at org.col.gsso.sap.parser.InputDataXMLParser.saveInputFiles(InputDataXMLParser.java:106)
11-05 09:58:15.786: W/System.err(21020):    at com.gps.colpal.ToPalmDownloadAsycTask.doInBackground(ToPalmDownloadAsycTask.java:102)
11-05 09:58:15.786: W/System.err(21020):    at com.gps.colpal.ToPalmDownloadAsycTask.doInBackground(ToPalmDownloadAsycTask.java:1)
11-05 09:58:15.786: W/System.err(21020):    at android.os.AsyncTask$2.call(AsyncTask.java:264)
11-05 09:58:15.786: W/System.err(21020):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11-05 09:58:15.786: W/System.err(21020):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11-05 09:58:15.786: W/System.err(21020):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-05 09:58:15.786: W/System.err(21020):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-05 09:58:15.786: W/System.err(21020):    at java.lang.Thread.run(Thread.java:856)
11-05 09:58:15.886: W/IInputConnectionWrapper(21020): finishComposingText on inactive InputConnection

But it's throwing Unexcepted exception, any one any idea about it.


text:
Q: Google Map Info Windows Automatically Sizing, New Issue No Changes Made To Code http://www.lindsaymantzel.com/googlemap/maptest12.html
Please see my map application. If you click on a red marker multiple times you will see that the info window is changing size until it's abnormally huge, then it all the other windows will be that size. I have a version of my code from 1 month ago, and 3 months ago on a different server that I know never had this issue. All three copies now demonstrate this issue. I can see that the element.style has an undesired height and when I try to edit it with chrome's developer tool it immediately changes the window back to the originally undesired height.
Since no code changes are made I have to assume that google api has changed or something along those lines but haven't found any documentation that may help me.

A: Your problem is that you don't have the correct version specified. The most stable version is 3.17. Try changing your script import to :
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.17&sensor=false"></script>

A: You should use new google.maps.InfoWindow({ width: 500, height: 500 }); to set the size for information window.


text:
Q: Recuva for OS X? I'm looking for a file recovery utility for OS X, like Recuva for Windows. (Assuming Time Machine wasn't configured) Is there anything similar?

A: I have used a product called Disk Drill
I personally successfully made good use of this product about a month ago when a simple mistake caused me to erase a drive I had no intention of erasing.  Basically, I added the drive I used to back up all my files as part of my CoreStorage for a DIY fusion drive.  So, I didn't just delete the files, I deleted the entire portion.
While I had most things backed up, I had several files that only existed on that drive.  I was able to recover every one of them.


text:
Q: Can someone help me understand the variance part of this theorem? This is distribution of the sample mean when $\sigma$ is known
Theorem 6.1: Let $X_1, ..., X_n$ be a random sample from a distribution with mean $\mu$ and standard deviation $\sigma$
Then Var($\bar{X})$ = $\cfrac {\sigma^2}{n}$
Proof in the book: By independence, Var($\bar{X})$ = Var($\sum_{i=1}^n \cfrac{X_i}{n}$) = $\cfrac{1}{n^2}$Var($\sum_{i=1}^nX_i$) = $\cfrac {1}{n^2}(n\sigma^2) = \cfrac{\sigma^2}{n}$
Now I know sample mean is just ($\sum_{i=1}^n \cfrac{X_i}{n}$)
But where does the $\cfrac {1}{n^2}$ and $n\sigma^2$come from?

A: Note that $Var(kY)=k^2Var(Y)$, hence when we move $\frac1n$ out from the variance term, we get $\frac1{n^2}$.
Also for independent random variable, the sum of the variance is equal to the variance of the sum. $$Var(\sum_{i=1}^n X_i) = \sum_{i=1}^nVar( X_i)=n\sigma^2$$

A: If you look at the basic formulas:  $E(Y^k)=\int y^kdF(y)$ where $F(y)$ is the distribution function of a random variable $Y$.  The variance  of $Y$ is $E(Y^2)-E(Y)^2$.  Now let $Y=\frac{X_i}{n}$ so $Var(\frac{X_i}{n})=\frac{E(X_i)^2}{n^2}-\frac{E(X_i)^2}{n^2}=\frac{Var(X_i)}{n^2}=\frac{\sigma^2}{n^2}$.
Since  the $X_i$ are independent, the variance of the sum is $n\frac{\sigma^2}{n^2}$


text:
Q: How can I stop iterating "n" before the end of a map when the iterators aren't random-access? I would like to traverse a map in C++ with iterators but not all the way to the end.
The problem is that even if we can do basic operations with iterators, we cannot add or compare iterators with integers.
How can I write the following instructions? (final is a map; window, an integer)
for (it=final.begin(); it!=final.end()-window; it++)

A: You cannot subtract from a map iterator directly, because it is an expensive operation (in practice doing --iter the required number of times). If you really want to do it anyway, you can use the standard library function 'advance'.
map<...>::iterator end = final.end();
std::advance(end, -window);

That will give you the end of your window.

A: std::map<T1, T2>::iterator it = final.begin();
for (int i = 0; i < final.size()-window; ++i, ++it)
{
  // TODO: add your normal loop body
}

Replace T1 and T2 with the actual types of the keys and values of the map.

A: Why don't you make 'it' an iterator as well ?
See the example here : http://www.cplusplus.com/reference/stl/map/begin/

A: Another solution:
size_t count=final.size();
size_t processCount=(window<count?count-window:0);
for (it=final.begin(); processCount && it!=final.end(); ++it, --processCount)
{
  // loop body
}

This one is a bit safer:

*

*It takes care of the case when your map is actually smaller than the value of window.

*It will process at most processCount elements, even if you change the size of your map inside your loop (e.g. add new elements)

*According to STL, size() can take O(n) time to compute, although usual implementations can do this in O(1). To be on the safe side, it is better not to call size() many times, if it is not necessary.

*'end()' on the other hand has amortized constant time, so it should be OK to have it in the for-loop condition

*++it may be faster than it++. The post-increment operator creates a temporary object, while the other - does not. When the variable is a simple integral type, compiler can optimise it out, but with iterators it is not always the case.


text:
Q: Grafana Docker entrypoint script stops with "No such file or directory", but file is there I'm trying to run Grafana on my Raspberry Pi 3 with docker. My docker-compose entry for it is pretty straightforward:
version: '3.7'

services:
grafana:
    container_name: grafana
    image: grafana/grafana
    restart: always
    ports:
      - "3000:3000"

But the container stops shortly after start with "
/run.sh: line 80: /usr/share/grafana/bin/grafana-server: No such file or directory". Opening a terminal in a copy of the container per https://stackoverflow.com/a/39329138/6252186 shows that the file exists:
/usr/share/grafana/bin $ ls -lh
total 58M
-rwxr-xr-x    1 root     root       17.4M Oct 16 13:19 grafana-cli
-rw-r--r--    1 root     root          33 Oct 16 13:19 grafana-cli.md5
-rwxr-xr-x    1 root     root       40.6M Oct 16 13:19 grafana-server
-rw-r--r--    1 root     root          33 Oct 16 13:19 grafana-server.md5

The run.sh script is this: https://github.com/grafana/grafana/blob/master/packaging/docker/run.sh
Checking the interpreter of run.sh using readelf in a copy of the container yields: Requesting program interpreter: /lib/ld-linux-armhf.so.3. In contrast, /lib only contains the following:
apk ld-musl-armhf.so.1 libcrypto.so.1.1 libz.so.1 mdev firmware libc.musl-armv7.so.1 libssl.so.1.1 libz.so.1.2.11

This might be the problem. What would be the best way to fix this?
PS: I wasn't sure if this was better suited for Superuser or Stackoverflow, so please tell me if I went to the wrong site :)

A: In the commits for the Grafana Docker image I found that someone already reported this issue and it already got fixed: https://github.com/grafana/grafana/issues/19585. The fix will be included in the next release (6.5.0) in a few weeks and is already available in nightly builds (grafana/grafana:master).


text:
Q: Making C++ pause Is there a C++ equivalent to Python's time.sleep()?

A: The following code will sleep for 10 milliseconds.

boost::this_thread::sleep(boost::posix_time::milliseconds(10))

Refer to boost::posix_time::time_duration for more ways to construct the duration.

A: Use boost::this_thread::sleep
// sleep for 5 seconds
boost::this_thread::sleep(boost::posix_time::seconds(5));

A: I'm not aware of any portable function, but mainstream OSes have usleep for *nix and Sleep for Windows.

A: Please note that the code above was tested on Code::Blocks 12.11 and Visual Studio 2012
on Windows 7.
For forcing your programme stop or wait, you have several options :

*

*sleep(unsigned int)
The value has to be a positive integer in millisecond.
That means that if you want your programme wait for 2 second, enter 2000.
Here's an example :
#include <iostream>     //for using cout
#include <stdlib.h>     //for using the function sleep

using namespace std;    //for using cout

int main(void)
{
   cout << "test" << endl;
   sleep(5000);         //make the programme waiting for 5 secondes
   cout << "test" << endl;
   sleep(2000);         // wait for 2 secondes before closing

   return 0;
}

If you wait too long, that probably means the parameter is in second. So change it like that :
sleep(5);

For those who get error message or problem using sleep try to replace it by _sleep or Sleep especially on Code::Bloks.
And if you still getting probleme, try to add of one this library on the biggining of the code.
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <dos.h>
#include <windows.h>

*

*system("PAUSE")
A simple "Hello world" programme on windows console application would probably close before you can see anything. That the case where you can use system("Pause").
#include <iostream>

using namespace std;

int main(void)
{
    cout << "Hello world!" << endl;

    system("PAUSE");

    return 0;
}

If you get the message "error: 'system' was not declared in this scope" just add
the following line at the biggining of the code :
#include <cstdlib>

*

*cin.ignore()
The same result can be reached by using cin.ignore() :
#include <iostream>

using namespace std;

int main(void)
{
    cout << "Hello world!" << endl;

    cin.ignore();

    return 0;
}

*

*cin.get()
example :
#include <iostream>

using namespace std;

int main(void)
{
    cout << "Hello world!" << endl;

    cin.get();

    return 0;
}

*

*getch()
Just don't forget to add the library conio.h :
#include <iostream>
#include <conio.h>    //for using the function getch()

using namespace std;

int main(void)
{

    cout << "Hello world!" << endl;

    getch();

    return 0;
}

You can have message telling you to use _getch() insted of getch


text:
Q: How to change default object field size? I've created new App called Library with Books objects.
I have very long book name. After type in this long title into Book Name field and click Save button i have following:
        Data Storage Limits Exceeded
    Your company currently has exceeded its data storage limits
 including an extra overflow buffer. Per our terms and conditions,
 we cannot permit additional data creation within our system until
 your company first reduces its current data storage.
 Please contact your company's salesforce.com administrator to resolve this.
 We apologize for any inconvenience this may cause.

Is it possible to increase field size with simple name and not to contact the administrator?

A: This error has nothing to do with the data you are trying to save. Go try to save a record of any type, and you will see the same error.
When you go over the limit of storage usage for your organization, you're blocked from creating any new data. You have two basic approaches to resolve this issue, though it's likely only the former is tenable as a long-term strategy:

*

*Aggressively remove unused data
It is likely that you have data in your org which hasn't been looked at for months/years. You might even have entire objects which are obsolete but were never removed. See what you can trim down.

*Petition support to increase your storage usage limit
I have heard of it being a limit on which Salesforce can be a bit more lenient (for a cost) but never tried to acquire more storage myself.


text:
Q: PDF generated with ghostscript (no output fonts) has defects (missing outlines) Following of question: Convert PDF to get vectorized text ("convert all text to outlines")
The PDF generated with the gs -o outputPath.pdf -dNoOutputFonts -sDEVICE=pdfwrite inputPath.pdf has a defect. Around some font characters, some outlines have disappeared when I inspect it deeply with Inkscape (View / Display Mode / Outlines). See:

Link of the file for further inspection: https://filetransfer.io/data-package/nwsra9yl#link
How to solve this? Is there an option in the ghostscript command that I could add to solve this? Thanks.


text:
Q: NoSuchElementException in Selenium WedDriver Test I am new to selenium and written a basic test to launch a website, click on link, fill form and submit.
Once it reaches to sign up page it is unable to find the "FirstName" text box. I double checked using the firebug and it is available only at one place. I even tried to identify element with xpath still getting the same error.
Here is the code using the xPath to identify first name text box.
package Default;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
//import org.openqa.selenium.firefox.FirefoxDriver;

public class FirstWDWithoutRecording {

@Test
public void SouthWestSignUp() throws InterruptedException
{

    //Open the FF/Chrome browser
    //FirefoxDriver oBrw = new FirefoxDriver();
    ChromeDriver oBrw = new ChromeDriver();

    //Maximize Browser
    oBrw.manage().window().maximize();

    //Open/Launch www.southwest.com
    System.setProperty("webdriver.chrome.driver", "E://chromedriver.exe");
    oBrw.get("http://www.southwest.com/");

    //Click on Sign up and Save
    //Recognising
    oBrw.findElement(By.linkText("Sign up")).click();

    Thread.sleep(7000);

    //Enter First Name
    oBrw.findElement(By.xpath("//input[@id='FIRST_NAME']")).clear();
    oBrw.findElement(By.xpath("//input[@id='FIRST_NAME']")).sendKeys("abc");

    //Enter Last Name
    oBrw.findElement(By.id("LAST_NAME")).clear();
    oBrw.findElement(By.id("LAST_NAME")).sendKeys("Kish123");

    //Enter Email ID
    oBrw.findElement(By.id("EMAIL")).clear();
    oBrw.findElement(By.id("EMAIL")).sendKeys("abc@Kish123.com");

    //Selecting Home Airport
    Select uiHomeAp = new Select(oBrw.findElement(By.id("HOME_AIRPORT")));
    uiHomeAp.deselectByVisibleText("Atlanta, GA - ATL");

    //Accepting Conditions
    oBrw.findElement(By.id("IAN")).click();

    //Click Submit
    oBrw.findElement(By.id("submit")).click();

   }

}

A: Your sign up form is located within an <iframe>. For Webdriver to be able to 'see' the form you'll first need to switch to that iframe.
driver.switchTo().frame(0);   //'0' as it is the only iframe on the page, the value is the index of all iframes on the page
//do your login actions
//after return
driver.switchTo().defaultContent();


text:
Q: How to change a field value on selection in Tableau I have a Tableau viz which looks like this:

It is required to change the value of a "Checked" column of a particular record to "Yes" by clicking on it.
Can this be achieved in Tableau? What are the options that I can use in Tableau to achieve this functionality.


text:
Q: How to iterate lines from a text file in python? I update my question because At first I think that I have the best solution However, I don't have it until now.It was my mistake in execution. I think that the error comes from the loop while in the file C.
I am trying to read lines from a text file"Plaintext.txt".
e0370734313198a2885a308d3243f6a8
ccddeeff8899aabb4455667700112233
8e73b0f7da0e6452c810f32bc4567a22

It contains now tow lines, I put just two in order to make simple test, but I must put more then 1000 texts (means more than 1000 lines)  I want to read each line then send it to the uart where I will do encryption for every plaintext (The encryption algorithm is in C): This is my script:
I edit it as you tell me but I still have the encryption of one line
    import string
import serial
import time
from array import array
import struct
import binascii

ser = serial.Serial(
                    port='COM4',\
                    baudrate=230400,\
                    parity=serial.PARITY_NONE,\
                    stopbits=serial.STOPBITS_ONE,\
                    bytesize=serial.EIGHTBITS,\
                    timeout=0)

f = open(r'C:\\Users\\user\\Plaintxt.txt', 'r')
for a in f:
   plaintxt_16b=a[0:32]
   plaintext=binascii.unhexlify(plaintxt_16b)
   clear_msg=b'\x24'+b'\x73'+b'\x10'+plaintext

ser.write(clear_msg)
time.sleep(0.4)

while True:
  print(ser.read(70))
ser.close()                # close ports

In the C file:
   while(1)
    {
        int rx_length = dev_uart_ptr->uart_read((void*)rx_buffer, 19);

        if (rx_length <19)
        {

            if (rx_buffer[0]=='\x24')
            {
                if (rx_buffer[1]=='\x73')
                {
                    if (rx_buffer[2]=='\x10')
                    {
                        plaintext[0] = (rx_buffer[3] << 24)  |
                                (rx_buffer[4] << 16)  |
                                (rx_buffer[5] << 8)   |
                                rx_buffer[6];
                        plaintext[1] = (rx_buffer[7] << 24)  |
                                (rx_buffer[8] << 16)  |
                                (rx_buffer[9] << 8)   |
                                rx_buffer[10];
                        plaintext[2] = (rx_buffer[11] << 24) |
                                (rx_buffer[12] << 16) |
                                (rx_buffer[13] << 8)  |
                                rx_buffer[14];
                        plaintext[3] = (rx_buffer[15] << 24) |
                                (rx_buffer[16] << 16) |
                                (rx_buffer[17] << 8)  |
                                rx_buffer[18];

                        xprintf("**************************\n");
                        xprintf("%8x %8x %8x %8x \n",plaintext[0],plaintext[1],plaintext[2],plaintext[3]);
                        aes2_set_msg((unsigned int *)plaintext);    /** Reset AES message buffer */
                        aes2_set_key128((unsigned int *)key128);    /** Put the key 128 into AES */
                        /** Configure  AES register  to enable IRQ and ENCODE */
                        regs_aes2_ptr-> CFG =  AES2_CFG_ENC_DEC_BIT | AES2_CFG_IRQ_MASK_BIT;
                        /** Reset AES internaly */
                        regs_aes2_ptr-> CTRL = AES2_CTRL_SWRESET_BIT;

#if DEBUG
                        xprintf("Go encrypt..\n");
#endif
                        /** Start the ENCODE function */
                        regs_aes2_ptr-> CTRL = AES2_CTRL_START_BIT;

                        while(!aes2_irq_flag); /** Wait for irq flag */
                        aes2_irq_flag=0;    /** Reset irq flag */

#if DEBUG
                        xprintf("Encrypt done..\n");
#endif

                        aes2_get_msg((unsigned int *)ciphertext);   /** Retrieve encrypted message */
                        xprintf("%8x %8x %8x %8x \n",ciphertext[0],ciphertext[1],ciphertext[2],ciphertext[3]);
                        xprintf("**************************\n");

                    }
                    else
                    {
                        printf ("false");
                    }

                }
                else
                {
                    printf ("false");
                }
            }

        }

    }// End While

}//end of C_Entry

So the problem is that It takes just the last line and repeat all the time the same encryption of that line:
    $**************************
ccddeeff 8899aabb 44556677   112233
Go encrypt..
Encrypt do
ne..
d6e4d64b 27d8d055 c5c7573a 8df4e9aa
**************************
******************
********
ccddeeff 8899aabb 44556677   112233
Go encrypt..
Encrypt done..
d6e4d64b 27d
8d055 c5c7573a 8df4e9aa
**************************
**************************
ccddeeff
 8899aabb 44556677   112233
Go encrypt..
Encrypt done..
d6e4d64b 27d8d055 c5c7573a 8df
4e9aa
**************************
**************************
ccddeeff 8899aabb 44556677
   112233
Go encrypt..
Encrypt done..
d6e4d64b 27d8d055 c5c7573a 8df4e9aa
**********
****************
**************************
ccddeeff 8899aabb 44556677   112233
Go enc
rypt..
Encrypt done..
d6e4d64b 27d8d055 c5c7573a 8df4e9aa
....................

I would be very grateful if you could help me.

A: You may want to do as following:
f = open("your_file", "r")
for line in f:
    do_something(line)
f.close()

or as the comment pointed out:
with open("your_file", "r") as f:
    for line in f:
        do_something(line)

Python will iterate over every line and give the string of the line as variable line here. You can handle every line in the file this way. Also, doing so, python reads one line each time, so it is effective for larger files.

A: During your for loop
for a in range (0,2):

   line_array=lines[a]
   plaintxt_16b=line_array[0:32]

   plaintext=binascii.unhexlify(plaintxt_16b)
   clear_msg=b'\x24'+b'\x73'+b'\x10'+plaintext

your overwrite the variable clear_msg in each iteration.
Once you leave the loop it contains the last value. In your case the last line (encrypted). Then you send the variable clear_msg several times without changing its content.
You need to indent the following block as well:
print(clear_msg)
ser.write(clear_msg)
time.sleep(0.4)

A: According to this, calling readlines() makes your code slower, less explicit, less concise, for absolutely no benefit.
A good approach to open a file without the need of closing it is by using while
with open(file) as f:
    line = f.read().splitlines()

line is a list that contains all the lines of your file. You can iterate and get any entry as you would do in a list

A: The problem was spaces in python file: the for loop  must contains
       ser.write(clear_msg)
       time.sleep(0.4)
       print(ser.read(70))

By that way, it will not take just the last plaintext from the plaintext file.
import string
import serial
import time
from array import array
import struct
import binascii

ser = serial.Serial(
                    port='COM4',\
                    baudrate=230400,\
                    parity=serial.PARITY_NONE,\
                    stopbits=serial.STOPBITS_ONE,\
                    bytesize=serial.EIGHTBITS,\
                    timeout=0)

f = open(r'C:\\Users\\user\\Plaintxt.txt', 'r')
for a in f:
   plaintxt_16b=a[0:32]
   plaintext=binascii.unhexlify(plaintxt_16b)
   clear_msg=b'\x24'+b'\x73'+b'\x10'+plaintext
   ser.write(clear_msg)
   time.sleep(0.4)
   print(ser.read(70))
ser.close()                # close ports

My problem is resolved. Thank you very much for your help.


text:
Q: Using Workspace variables in a GUI matlab I have a workspace called finalnet. Inside the workspace i have a neural network called net. and I want to use the network in one of the functions in my GUI.
Is there a way to do that?
I tried to use  evalin function : network = evalin('finalnet','net')
but i get this error:

Error using evalin Unknown command option.

A: From the wording of your problem it sounds like finalnet is a previously stored workspace such that finalnet.mat is located in some directory. Let's assume the current directory.
In this case you need to load the workspace into your GUI. Assuming that's in some random callback function, you want to call load finalnet or load('finalnet.mat'). Now that the workspace is locally available to your callback function you may access your net.
If you call load finalnet before you run your GUI then you would need to access net using net = evalin('base','net') inside your function. If you make any changes to net or other variables in the base workspace and you want those changes maintained even after exiting the GUI then you must call assignin('base','net'), or whichever variable you changed.

A: You have something wrong here. As far as i know, there are only following types of Matlab workspace:

*

*Base workspace:

*

*Store variables which you created directly from Command Window, or using assignin('base', 'varname', value)

*You can access base workspace's variables from anywhere with var = evalin('base', 'varname'), or use them directly from Command Window

*Function workspace:

*

*Each function creates its own workspace when it is being launched. It is separated with base workspace. Within this function, you can still access the base workspace variables as mentioned in 1)

*There is no way to access the function workspace variables from Command Window unless you call the function

*If your function (supposed test1) calls another function (supposed test2), within function test2 you can access test1's workspace variable by var = evalin('caller', 'varname_in_test1_workspace'). If you want the function test2 to use the variables in test1's workspace, pass them as input arguments for test2

*Global workspace:

*

*Store variables that can be used (shared) by multiple workspaces.

*You must declare them using global varname in all workspaces that you want to use. (i.e in both functions test1 and test2, with same global varname command, even in Command Window (base workspace) if you want to access the variable from Command Window)

Back to your question: I believe there is no way to have a workspace called finalnet in Matlab. You got error because there is no such finalnet workspace in Matlab. You might misinterpreted between the .mat file which you got by saving your base workspace variables last time and the workspace itself. So probably you need to load the the .mat file at first, the variables inside will be loaded to Matlab's base workspace, and then you can access them from your functions as you want.


text:
Q: _UIFallbackPresentationViewController I keep getting the following error when I dismiss the dictionary that opens from tapping Define on the UIMenuController in a UIWebView on the iPhone:-
Unbalanced calls to begin/end appearance transitions for <_UIFallbackPresentationViewController: 0x10ab9640>.

And after this error, the UIMenuController stops showing up, in any UIWebView.
Any ideas what's going on here?
UPDATE: The error actually shows up when the dictionary view is opening, not when dismissing it.
UPDATE 2: The error is app wide. Anywhere there is selectable text (i.e. webview, textview etc.) I can only use the define dictionary once. This error shows up & then, I have to quit the app & start it again, to use the dictionary.

A: Finally found an answer for this.  When the dictionary gets presented by the system, its window gets focus (see makeKeyAndVisible: in UIWindow), which is great.  The problem comes when dismissing where the window holding the dictionary doesn't properly give the main application window back focus.
If you print out the [UIApplication sharedApplication].keyWindow before and after the dictionary gets presented then you'll see how before your application window was keyAndVisible and afterwards it is a different window.  For me, I had a separate window for app messages that lived on top of the status bar, and that one was what was keyAndVisible after the dictionary was dismissed.
So all I had to do to fix it was have the following override method in my UIWindow subclass that incorrectly received focus:
- (void) makeKeyWindow {
  AppDelegate * appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  [appDelegate.window makeKeyAndVisible];
}

I'm not sure how this will work for those if you without your own UIWindow that gets focused on, but absolute worst case you could add a dummy UIWindow that would receive focus and add the exact same piece of code from above.

A: The error message suggests you start a transition but the call to the corresponding end method is missing.

*

*Have you tried doing the transition without animation? (animated:
NO)

*Sometimes this behavior appears when using a switch statement and
forgetting the break;

*If you are performing a seque, do it in -viewDidAppear instead of -viewWillAppear
Hope it helped a bit! :)


text:
Q: Data insert from front-end duplicate data can't protected in WordPress At first, I created a custom template and wrote the following script.
I was trying to protect duplicate values using isset but didn't get the solution and logic working. Can you tell me how to fix it?
if ( isset( $_POST['submit'] ) ) {
    if ( 'POST' == $_SERVER['REQUEST_METHOD'] && ! empty( $_POST['action'] ) ) {
        if ( isset( $_POST['title'] ) ) {
            $title = $_POST['title'];
        } else {
            echo 'Please enter a title';
        }
        if ( isset( $_POST['description'] ) ) {
            $description = $_POST['description'];
        } else {
            echo 'Please enter the content';
        }

        $post = array(
            'post_title'   => $title,
            'post_content' => $description,
            'post_status'  => 'draft',
            'post_type'    => 'portfolio',
        );
        $pid  = wp_insert_post( $post );
    }
}

?>
<form action="" method="post">

        Titolo

        <input type="text" id="title" value="" tabindex="1" size="20" name="title" />

        Testo

        <textarea id="description" tabindex="3" name="description" cols="50" rows="6"></textarea>

        <input type="submit" value="submit" id="submit" name="submit"/>

    <input type="hidden" name="post_type" id="post_type" value="domande" />
    <input type="hidden" name="action" value="post" />
    <?php wp_nonce_field( 'new-post' ); ?>
</form>


text:
Q: Can I convert a string to float in HTML with Javascript and get Square Root? I'm quite new to JavaScript and I have a problem. I want a user to input a number into a text input box and when they click a button, an alert box appears telling the Square Root of their number. The problem is, when the box appears, the message says 'NaN'? Can somebody help?
function convert(){
  var userInput = Number(document.getElementById("sqrinput"));
  alert(Math.sqrt(parseFloat(userInput)));
}

Thanks!

A: You want the value of the #sqrinput element:

function convert() {
  var userInput = Number(document.getElementById("sqrinput").value);
  alert(Math.sqrt(parseFloat(userInput)));
}
document.getElementById("btn").addEventListener("click", convert);
<input id="sqrinput" />
<button id="btn">Square</button>


text:
Q: get current top left bottom and right position of a screen I need to get the current left, top, bottom and right position of a screen, so i can animate my object perfectly. Is there anything to get current location? Any help would be nice.
object position set:
 $(this).animate
 ({
     left: $(window).scrollLeft(),
     top: $(window).scrollTop(),
     width: $(window).scrollLeft() + $(window).width(),
     height:  $(window).scrollTop() + $(window).height(),
 }, 500,

this issue now remain the bottom part after changing my code to @chad.

A: there is something in jQuery
The .position() method allows us to retrieve the current position of an element relative to the offset parent. Contrast this with .offset(), which retrieves the current position relative to the document. When positioning a new element near another one and within the same containing DOM element, .position() is the more useful.
Returns an object containing the properties top and left.
https://api.jquery.com/position/

A: API? Whats this got to do with an API?
check out http://css-tricks.com/jquery-ui-position-function/ - this may be of some help!


text:
Q: C++ editing delete function of a class In my program, the function void UnsortedType::DeleteItem(ItemType item) deletes the user specified item, however it crashes if the user specified item doesn't exist.
void UnsortedType::DeleteItem(ItemType item)
// Pre:  item's key has been initialized.
//       An element in the list has a key that matches item's.
// Post: No element in the list has a key that matches item's.
{
    int location = 0;
    while (item.ComparedTo(info[location]) != EQUAL)
        location++;
    info[location] = info[length - 1];
    length--;
}


text:
Q: Efficient way to filter an object by key value I need to create a candle value of an object with sorted keys:
 var obj = [{1: 'a'}, {2:'b'}, {3:'c'}, {4:'d'}, {5:'e'},{6: 'a'}, {7:'b'},{8:'c'}, {9:'d'}, {10:'e'}]

What is the most efficient way to filter this object based on the key?
For instance, I want: the obj filtered with 2 < keys <5  or 6 < keys < 9
(in reality, the keys are timestamp and the values are price data)
EDIT:
Here is the object. That is what I meant by sorted
 var obj = [{1: 'a'}, {2:'b'}, {3:'c'}, {4:'d'}, {5:'e'},{6: 'a'}, {7:'b'},{8:'c'}, {9:'d'}, {10:'e'}]

A: You can use Object.keys to get the keys and reduce to create a new object with kv pair that met the condition

var obj = {1: 'a', 2:'b', 3:'c', 4:'d', 5:'e',6: 'a', 7:'b',8:'c', 9:'d', 10:'e'}
var res = Object.keys(obj).reduce((acc, elem) => {
 if (elem > 2 && elem < 5) acc[elem] = obj[elem]
 return acc
}, {})
console.log(res)

looks like the obj has been changed
you can filter the new obj a simple .filter()
var res = obj.filter(elem => Object.keys(elem)[0] > 2 && Object.keys(elem)[0] < 5)

if you decided to use the structure in comment
var obj = [{time: 1, value: 'a'},{time: 2, value: 'b'},{time: 3, value: 'c'},{time: 4, value: 'd'}]
var res = obj.filter(elem => elem.time > 2 && elem.time < 5)

A: Simple Objet.keys and reduce to create the new Object with the limited set of keys.

var obj = {1: 'a', 2:'b', 3:'c', 4:'d', 5:'e',6: 'a', 7:'b',8:'c', 9:'d', 10:'e'}

var filtered = Object.keys(obj).reduce((o, k) => {
  const num = Number(k)
  if (num > 4 && num < 9) {
   o[k] = obj[k]
  }
  return o
}, {})

console.log(filtered)

And just a warning that the object keys may not be in order of the numbers. So when you are outputting them, it is not guaranteed that 5 will be before 6.

A: If you are using lodash it is as simple as follows:
const _ = require('lodash');
var obj = {1: 'a', 2:'b', 3:'c', 4:'d', 5:'e',6: 'a', 7:'b',8:'c', 9:'d', 10:'e'};
filtered = _.pickBy(obj,(val,key) =>{return ((key > 2) && (key < 5))})

A: what you need is to sort first the keys and then create new object with the filter and sorted values
i changed it to Map as object keys are not guaranteed to be sorted

const obj =  {1: 'a', 2:'b', 4:'c', 3:'d', 5:'e',6: 'a', 7:'b',8:'c', 9:'d', 10:'e'};

const newObj = new Map();
Object.keys(obj).filter(key =>{

    return (key > 2 && key < 5)
    }).sort().forEach(key=>{
      newObj.set(key,obj[key])

    })

A: As I see, you have an array not an object. Using filter and Object.keys and a condition like ((2<key && key<5) || (6<key && key< 9))

var arr = [{1: 'a'}, {2:'b'}, {3:'c'}, {4:'d'}, {5:'e'},{6: 'a'}, {7:'b'},{8:'c'}, {9:'d'}, {10:'e'}]

var newArr = arr.filter((o=>{
    let k = Object.keys(o);
    if((2<k[0] && k[0]<5) || (6<k[0] && k[0]< 9)){
        return true;
    }
}))

console.log(newArr)

A: like this?
keys() will give you an array of object keys, that you can filter
var obj = {1: 'a', 2:'b', 3:'c', 4:'d', 5:'e',6: 'a', 7:'b',8:'c', 9:'d', 10:'e'};
keys(obj).filter((a)=> parseInt(a) > 2 && parseInt(a) <5 );


text:
Q: Philosophically, why can't markup be binary data? i.e. Why can't we compile HTML for the web? Given the vast efforts to make the web as efficient as possible, why can't HTML (and all the various other plain text files e.g. CSS, JavaScript) be compiled into a single resource and sent down the wire? (I'm aware of .chm files - these are along the lines of this concept).
I understand the open nature of the web - an effort I stand behind - but one could conceive of an open specification that requires multiple resources compile down into binary. Decomplication by the user-agent could be required by the specification (this allowing individuals to view the DOM etc.)
I guess I'm just surprised, given the efforts at performance in other areas, we're still relying on plain text to push around pages, or am I just over-estimating the savings a binary format would provide?

A: An important factor for the development of the web has been the extensibility of the web languages. Browser vendors can support more functionality than the standards require. Although this has always been a hassle for developers, it has helped the web forward.
By compiling the web pages you would limit the capabilities to the set that the compiler supports. It would not be possible to use any new features in any browser until the compiler catches up with the development. This would slow down the development of the web.

A: Often web "text" assets (HTML, CSS, JavaScript, XML, JSON) are "binary", since they are served GZIPped: http://duckduckgo.com/?q=gzip+files+server
Hard to get more optimized than that; able to be read by a human, while very compressed.

A: There have been attempts at this - see WBXML. However, the problem comes when someone tries to extend the XML definition - does an ID of 35 correspond to the microsoft extension <foo>, or the netscape <bar>?
It's also a lot harder to read the binary when you are trying to work out what bit of the HTML you got wrong.
The main issue of data size was solved by gziping the data before it leaves the web server.


text:
Q: Prevent WAMP from loading external requests I need to prevent wamp from loading external links in order to have a better performance
I'm using PrestaShop and sometimes it looks for updates and currency rates etc which slows down loading the page and I get "Waiting for localhost..."
I need a configuration for apache or php that blocks any external request


text:
Q: Why am I getting null pointer exception in this program when using enhanced for loop I am getting a null pointer exception in the selectAllStudent Method.
When I am using foreach loop but When I am using a normal loop it is working fine.
Please explain the reason. Thank you
Driver Class
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Test {

    public static void main(String[] args) {
        Student[] sdb = new Student[2];
        try {
            for (Student s : sdb) {
                s = takeInput();
            }
        } catch (IOException ioe) {
            System.err.println(ioe.getMessage());
        }
        selectAllStudent(sdb);
    }

    static void selectAllStudent(Student[] sdb) {
        for (Student s : sdb) {
            s.printStudentDetails();               // Getting NullPOinterException here
        }
    }
    public static Student takeInput() throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Enter the details ");
        System.out.print("ROLL      :"); int rollno = Integer.parseInt(in.readLine());
        System.out.print("NAME      :"); String name = in.readLine();
        System.out.print("BRANCH    :"); String branch = in.readLine();
        return (new Student(rollno,name,branch));
    }
}

Student Class
public class Student {

    private int rollno;
    private String name;
    private String branch;

    Student(int rollno, String name, String branch) {
        this.rollno = rollno;
        this.name = name;
        this.branch = branch;
    }

    void printStudentDetails() {
        System.out.println("ROLLNO  :" + rollno);
        System.out.println("NAME    :" + name);
        System.out.println("BRANCH  :" + branch);
        System.out.println("-------------------");
    }
}

A: You are not assigning a new Student to the array in this for loop.
for (Student s : sdb) {
    s = takeInput();
}

The takeInput method is returning a Student properly, but you've assigned it to a local reference s, not as an element in the array sdb.  The elements of the array remain null, and the NullPointerException comes from attempting to call printStudentDetails on null in the selectAllStudent method.
You can convert the enhanced for loop to a standard for loop, assigning the Student with an array access expression.
for (int i = 0; i < sdb.length; i++)
{
    sdb[i] = takeInput();
}


text:
Q: Rendering django cms page as json I have a django CMS page, I want the rendered html to be made into a json object(dump the CMS html into JSON), is this possible? I'd like it to look something like this:

How would I go about this?
So after some digging , this is what I managed.
CMS has a views.py which has a function "details(request, slug)"
I used this method to render the required page, by passing the slug of the page I need rendered , got the response and put it into a JSON object and returned this.
from cms.views import details

 def index(request, topic):

if topic == 'home':
    template = details(request, '')
else:
    template = details(request, topic)

content = ''
if hasattr(template, 'render'):
    # TemplateResponse must call render() before we can get the content
    content = template.render().content
else:
    # HttpResponse does not have a render() method
    content = template.content

# Send JSON response
return JsonResponse({
    'createdAt': datetime.datetime.now(),
    'content': content
})

Any better way of doing the same?

A: I think this should be fairly easy. Instead of returning the rendered output from the template, put it in a dictionary. Then just from json import dumps or dump and dump(dictionary) / dumps(dictionary) depending on your purpose. dumps gives you a string. dump gives you something fancier.


text:
Q: Javascript: most efficient way to store/retrieve data on flat file I'm creating light weight web-applications based on HTML and Javascript (for example a contact book with around 500 to 1000 entries). I have a simple HTML form to search in the contact list based on a few letters.
I want to store the entries on a flat file (.csv, .xml, . json or so) and then manipulate it with javascript to retreive the contact informations without any Ajax+php call.
My questions are:

*

*Which is the best flat format to be manipulated with Javascript?

*Is Javascript siutable for this kind of use, or I'm going to crash the user browsers by performing data research in my page?

Thanks for your advices! Nicolas

A: json is best option and it is designed for javascript.
Below are the sample json structure that  you can use.
{
 users: [ { un: 'johndoe', contactno: 123456 }, {un: 'acme', contactno: 4523456 }... ]
}
json list can support large number of records and performance in performing operation on json list is quite fast.
make sure you are not performing dom manipulation during operation other performance degrades.


text:
Q: AM Demodulation in Tikz, how to implement a lowpass function
I want to draw the following picture in tikz. Number 1 is simple its a sin(X)*sin(Y) and Number 2 is just abs(sin(X)*sin(Y)). Number 4 is obviously easy too. A similar example could be found here:
https://github.com/PetarV-/TikZ/tree/master/Amplitude%20modulation
However, has somebody a clue how to draw Number 3? It's basically a lowpassfiltering of the signal Number 2. Has tikz this capability? I know somebody might say, just plot it in Matlab. But it must be done in LaTeX! Of course, I can do it somehow manually in Tikz with splines etc. But it would be nice if we could get the real system's behaviour in this picture.

A: I solved by using Octave/Matlab and the tool matlab2tikz https://github.com/matlab2tikz/matlab2tikz


text:
Q: Hibernate Bi-Directional ManyToMany Updates with Second Level cache I have a bidirectional many-to-many class:
public class A{
 @ManyToMany(mappedBy="listA")
 private List<B> listB;
}
public class B{
 @ManyToMany
 private List<A> listA;
}

Now I save a listA into B:
b.setListA(listA);

This all works fine until I turn on second-level caching on the collection a.ListB. Now, when I update the list in B, a.listB does not get updated and remains stale.
How do you get around this?
Thanks,
Dwayne

A: Are you setting both sides of your bidirectional link between A and B correctly? A typically approach is to use defensive methods like this:
public class B {
    @ManyToMany
    private List<A> listA;

    public void addToListA(A a) {
        this.listA.add(a);
        a.getListB().add(this);
    }

    public void removeFromListA(A a) {
        this.listA.remove(a);
        a.getListB().remove(this);
    }
}


text:
Q: How to see multiple student screens without being on a network or having a server I teach in a computer based classroom, where students are very skilled at getting around the filter and going places on the Internet that they shouldn't be.  I would like to have the capability of viewing the student screens from a second monitor on my desk.  I do not need to be able to take over their computer or control their mouse...I just want to see what they see on their screen.  I need this capability for monitoring up to 5-6 computers at once.  I cannot use a software product like LanSchool because these computers are not connected to a server that I can control. Also, these computers are not networked together.  We get our Internet through Charter Communications. Is there a way to hook the student computers into some sort of cable box, and connect that box to my computer and 2nd monitor?  What hardware would I need? Is this something a KVM switch would help solve?

A: Given long enough cables to reach from their computers to yours, you could put splitters on each machine's video out cable and run them to an input selector switch at your desk that runs to a separate monitor (or to your own, if you put yours on the switch too).  Then by changing the switch's input selector, you could switch back and forth between all the screens to see who's doing what.  This is not going to be a very cheap option, because long cables and a switch capable of handling 5-8 inputs will be expensive.
You could also use some remote desktop sharing software like VNC or TeamViewer (or a host of other options) to login remotely to view their screens.  VNC has free options (depending on which install/brand you choose) and TeamViewer is free for "non-commercial" use (not sure if they would count schools under this).  The advantage to using these options, besides being possibly free, is that you could be logged into all of them at once but shrunk to all fit on your screen at the same time.  This way, you don't have to be seeing their details, but you could tell if someone has Facebook or a game up on their screen.


text:
Q: how do I update the version of the python libraries used in a trained model I trained a model on Google colab , and dumped it, then I was finishing the project on VS Code on my system. I got an error saying the versions don't match since I had the latest version of libraries and the colab had an older version. I had the retrain the model on my system, which took a lot of time, as my System has a basic configuration. My only use of colab was to put the training stress on colab rather than my system
I didn't know there will be a version conflict as I thought Colab will have the latest version of libraries

A: I have in colab (Google) tensorflow version 2.9.2 and in my Raspberry 4 tensorflow versio 2.4.1. So diferent versions. I made in colab a pre-training model VGG19 with input_shape(220,220,3). And I classificated 2 types image
So once I have trained the model in the Colab.Google environment, then from Colab except the model and its weights.
# serialize model to JSON
model_json =  loaded_model2.to_json()
with open('/content/drive/MyDrive/dataset/extract/model_5.json', "w") as json_file:
    json_file.write(model_json)
# serialize weights to HDF5

loaded_model2.save_weights('/content/drive/MyDrive/model_5.h5')
print("Saved model to disk")

As I have indicated, then I intend to use that trained model on my Raspberry4. So I create a model on the Raspberry just like I did in Colab, but I don't do 'fit'. What I do next is load the .h5 file with the 'weights' that was generated in Colab.Google.
And in principle this has worked for me
model_new = tf.keras.Sequential()
model_new.add(tf.keras.applications.VGG19(include_top=false, weights='imagenet',pooling='avg',input_shape=(220,220,3)))
model_new.add(tf.keras.layers.Dense(2,activation="softmax"))
opt = tf.keras.optimizers.SGC(0,004)
model_new.compile(loss='categorical_crossentropy',optimizer=opt,metrics=['accuracy'])

model_new.load_weights('/home/pi/projects/models/model_5.h5)


text:
Q: EM Waves: Are $k$ and $E$ always perpendicular? I was learning about plane waves in class and it was stated that $k$-vector is perpendicular to $E$ which is also perpendicular to $B$-field.
But is this always the case?

A: $\vec{k}$ and $\vec{E}$ are perpendicular if and only if the charge density in the region is zero.  This follows from Gauss' law:
Let $\vec{E}(\vec{r},t) = \vec{E}_0 e^{i (\vec{k}\cdot\vec{r} - \omega t)}$.  Then $\vec{\nabla}\cdot\vec{E} = i\vec{k}\cdot\vec{E}$.
Gauss' law says $\vec{\nabla}\cdot\vec{E} = \rho/\epsilon_0$, and $\vec{k}\cdot\vec{E}$ is zero for nonzero $\vec{k}$ and $\vec{E}$ if and only if $\vec{k} \perp \vec{E}$, so $\vec{k} \perp \vec{E} \iff \rho = 0.$

A: In the theory of "linear wire antennas", it is pointed out that longitudinal electric field (Er) is not zero close to radiating wire antenna. See the equation (4-10a) of Balanis's book1. See below.

Of course, the charge distribution is non-zero on the metal antenna.
1 C. A. Balanis, Antenna Theory, Analysis and Design, Third Edition, Wiley.

A: The idea of the electric and magnetic fields being perpendicular to the wavevector can be seen quite nice in the Fourier representation of the fields, i.e. $$F(\vec r) = \int_{\mathbb{R}^3} F(\vec k) e^{i\vec k \vec r}$$ where $F$ stands for the fields $\vec E$ and $\vec B$, the charge density $\rho$ and the current density $\vec j$. We now express the Maxwell equations in this Fourier representation. The equations $\nabla \cdot \vec B(\vec r) = 0$ and $\nabla \cdot \vec D(\vec r) = \rho(\vec r)$ then read
$$i\vec k \cdot \vec B(\vec k) = 0 \quad\text{ and }\quad  i\vec k \cdot \vec D(\vec k) = \rho(\vec k).$$ We can already see the strict orthogonality of the wavevector $\vec k$ and the amplitude of the corresponding magnetic field mode $\vec B(\vec k)$. On the other hand, the electric displacement field $\vec D$ can be seen to be orthogonal to the wavevector if the charge density $\rho(\vec k)$ vanishes. When thinking about a "free wave" travelling through space with some charges around, one can think of this as a superposition effect, as those charges induce an electric field that is added to the wave's field.
We can already conclude, that in a linear isotropic medium (one satisfying $\vec D=\epsilon \vec E$ and $\vec B = \mu \vec H$) without free charges, both fields are orthogonal to the wave vector $\vec k$ in the sense that the respective field modes $\vec E(\vec k),\vec B(\vec k) \perp \vec k$ respectively. This, however, is not true in general. In a linear anisotropic medium (for example here) the fields $E$ and $B$ are connected to the effectiv fields $D$ and $H$ by matrix equations, i.e. $\epsilon$ and $\mu$ are not scalars anymore but matrices. Still, in this case the displacement field $\vec D$ and the magnetic field $\vec B$ are orthogonal to $\vec k$, but not necessarily the electric field $\vec E = \epsilon^{-1} \vec D$. In this case, the eigenvectors of $\epsilon$ play an important role.
Anyway, we still don't know anything about the directional relation of the electric and magnetic field to each other. For this, we transform the other two Mexwell equations, $\nabla\times\vec H(\vec r) = \partial_t \vec D(\vec r) + \vec j(\vec r)$ as well as $\nabla \times \vec E(\vec r) = -\partial_t \vec B(\vec r)$, into Fourier representation. These yield $$i\vec k \times \vec H(\vec k) = \partial_t \vec D(\vec k) + \vec j(\vec k)\quad\text{ and }\quad i\vec k \times \vec E(\vec k) = - \partial_t \vec B(\vec k).$$
We again assume a linear isotropic medium without free charge or current density. We will focus on the electric field for simplicity. From the properties of the vector product follows that its change in time $\partial_t E(\vec k)$ is perpendicular to both $\vec k$ and $\vec B(\vec k)$. On the other hand we can show that $$\epsilon\mu\partial_t^2 \vec E(\vec k) =  - (i\vec k)^2 \vec E(\vec k)$$ which is the Fourier representation of the wave equation. From these points, it's a straight foreward chain of implications to $\vec E(\vec k) \perp \vec B(\vec k)$. However, this is again not true in general if the medium is not isotropic.
To conclude, in a linear homogeneous and isotropic medium it is true that the vectors $\vec k$, $\vec E$ and $\vec B$ are perpendicular to each other in the mode decomposition, i.e. Fourier transformed representation. Free charges disturb this characteristic, but due to the linearity of electrodynamics we can extract the wave part for which this is true. I hope this helps understanding the foundations of the orthoganality. Cheers!


text:
Q: python - AttributeError: 'pyodbc.Row' object has no attribute 'JobCount' I have a query that's grabbing data from a database and returning the values so I can parse.
def executeScriptsFromFile(monitor):
    # Open and read the file as a single buffer
    fd = open(os.path.join(BASE_DIR, 'sql/{0}.sql'.format(monitor)), 'r')
    if args.alias:
        sql_query = fd.read().format("'" + args.alias + "'")
    else:
        sql_query = fd.read()
    fd.close()

    # Execute SQL query from the input file
    cursor.execute(sql_query)
    result = cursor.fetchone()
    return result

The query can differ so I'm trying to build in logic so it will skip part if JobCount isn't one of the values.
query_data =  executeScriptsFromFile(args.monitor)
print query_data
if query_data.JobCount:
    print query_data.JobCount
else:
    send_status = send_data(job_data)
    print send_status

Unfortunately I get the following traceback.  How do I ignore the value if it isn't there?
Traceback (most recent call last):
  File "tidal-zabbix.py", line 92, in <module>
    if query_data.JobCount:
AttributeError: 'pyodbc.Row' object has no attribute 'JobCount'

A: If you want to check whether 'JobCount' is an attribute of query_data use hasattr()
if hasattr(query_data, 'JobCount'):
    print query_data.JobCount
else:
    send_status = send_data(job_data)
    print send_status


text:
Q: How to process socket.io events in their incoming order I have the following setup:
async MyFunction(param) {
    //... Do some computation
    await WriteToDB()
}

io.on('connection', (socket) => {
    socket.on('AnEvent', (param) => MyFunction(param))
})

When an event comes in, it calls an asynchronous function which does some computation and in the end write the result to a database with another asynchronous call.
If MyFunction doesn't have an asynchronous call to write the database in the end, for example
MyFunction(param) {
    //... Do some computation
}

then it is obviously that all events will be processed in their incoming order. The processing of the next event will only start after the processing of the previous one finishes. However, because of the asynchronous call to the database, I don't know if those incoming events will still be fully processed in order. I am afraid that the processing of the next event starts before the previous await WriteToDB() finishes. How do I change the code to fully processing them in order?

A: You are correct that there's no guarantee that incoming events will be processed in the order.
To achieve what you are asking, you would need a "Message Queue" that will periodically check for new messages and process them one by one.
const messageQueue = [];

// SocketIO adding Message to MessageQueue
const eventHandler = (message) => {
  messageQueue.push(message);
}

const messageHandler = () => {
  if (messageQueue.length === 0) {
    return;
  }

  const message = messageQueue.shift();

  // Handle Message

  // If successful, ask for next message
  return messageHandler();
}

Of course, my example is pretty naive, but I hope it will give you a general idea of how what you are asking is accomplished.
If you are finding yourself needing a more robust message queue, Look into RabbitMQ, BullMQ, Kafka


text: Q: Visibility of faces of simple polytope from point What algorithms of computational geometry related to the topic of visibility of faces in general? Or what name of the field of study of the determination of visible faces 3D objects?