text:
Q: How to display comma if variable results are more than two and "and" in the end of the result? A code that gives the multiples of 5 in a given number by the user (x,y). If there is none to display, print "NONE". If there is two to display, separate it with "and". And if theres two or more to display, separate it with comma and "and" in the end of it.
System.out.print("Enter first number: ");
int x = new Scanner (System.in).nextInt();
System.out.print("Enter last number: ");
int y = new Scanner (System.in).nextInt();
System.out.print("The multiples of 5 from "+x+ " to " +y+ " : ");

for (;x<=y; x++) {
    if(x%5==0) {
            System.out.printf("%,d ",x);
    }
}

Sample Output:
Enter number: 1
Enter number: 4
The multiples of 5 from 1 to 4: NONE

Sample Output:
Enter number: 8
Enter number: 12
The multiples of 5 from 8 to 12: 10

Sample Output:
Enter number: 1
Enter number: 17
The multiples of 5 from 1 to 17: 5, 10, and 15.

A: EDIT: I edited my answer to match all sizes of the results-ArrayList:
class Main {

    public static void main(String[] args) {
        System.out.print("Enter first number: ");
        int x = new Scanner(System.in).nextInt();
        System.out.print("Enter last number: ");
        int y = new Scanner(System.in).nextInt();
        System.out.print("The multiples of 5 from " + x + " to " + y + " : ");
        ArrayList<Integer> results = new ArrayList<Integer>();
        for (; x <= y; x++) {
            if (x % 5 == 0) {
                results.add(new Integer(x));
            }
        }
        if (results.size() == 0) {
            System.out.println("No results to display.");
        } else if (results.size() == 1) {
            System.out.println(results.get(0));
        }  else {
            for (int i = 0; i < results.size() - 2; i++) {
                System.out.print(results.get(i) + ", ");
            }
            System.out.print(results.get(results.size() - 2));
            System.out.println(" and " + results.get(results.size() - 1));
        }
    }
}

By using the ArrayList, You can store the values and later print them out. The for-loop only prints all elements, but without the last one, which then gets printed with an " and" before it!
I hope you understand how this works.

A: The comma you use in printf isn't a simple character, it's a part of the pattern %,d.

Format String Syntax

*

*If the ',' ('\u002c') flag is given, then the locale-specific grouping separator is inserted by scanning the integer part of the string from least significant to most significant digits and inserting a separator at intervals defined by the locale's grouping size.

You need to move it out of the pattern %d and add a condition to drop a comma for the first matching number.
for (int i = 0; x <= y; x++) {
    if (x % 5 == 0) {
        System.out.printf("%s%d", (i++ == 0 ? "" : ","), x);
    }
}

Or you could write it in a fancy way
String result = IntStream.rangeClosed(x, y)
                         .filter(i -> i % 5 == 0)
                         .mapToObj(Integer::toString)
                         .collect(Collectors.joining(","));
System.out.println(result);

I have shown two working examples that use "," as the only delimiter. It gets a bit trickier for three delimiters ("," and ", and", and " and "). It's a rare case where a switch statement comes in handy.
final List<String> values = IntStream.rangeClosed(x, y)
        .filter(i -> i % 5 == 0)
        .mapToObj(Integer::toString)
        .collect(Collectors.toList());

switch (values.size()) {
    case 0:
        System.out.println("NONE");
        break;
    case 1:
        System.out.println(values.get(0));
        break;
    case 2:
        System.out.println(String.join(" and ", values));
        break;
    default:
        final String last = values.remove(values.size() - 1);
        System.out.println(String.join(", ", values) + ", and " + last);
}

A: Try this, Create a conditional base ending char.
     System.out.print("Enter first number: ");
            int x = new Scanner(System.in).nextInt();
            System.out.print("Enter last number: ");
            int y = new Scanner (System.in).nextInt();
            System.out.print("The multiples of 5 from "+x+ " to " +y+ " : ");
            if ((x<5 && y<5) || y/5 == x/5) {
                System.out.printf("NONE");
            }
            else {
                while (y > x) {
                    if (x%5==0) {
                        System.out.printf("%d", x);
                        x += 5;
                        if (x < y) {
                            if (x + 5 < y) {
                                System.out.printf(" , ");
                            } else {
                                System.out.printf(" and ");
                            }
                        }
                    } else {
                        x += 1;
                    }
                }
            }

A: This is my solution for this:
Scanner scan = new Scanner(System.in);
        System.out.print("Enter first number: ");
        int x = scan.nextInt();
        System.out.print("Enter last number: ");
        int y = scan.nextInt();
        String output = "The multiples of 5 from " + x + " to " + y + " : ";
        for (; x <= y; x++) {
            if (x % 5 == 0) {
                output = output + x + ", ";
            }
        }
        output = output.substring(0,output.length() -5) + " and "+output.substring(output.length() -4, output.length()-2);
        System.out.println(output);

A: Let me start with a few tips of your current code. You currently create two Scanners for both your user inputs. It would be best to only create this one, and re-use it. So change:
System.out.print("Enter first number: ");
int x = new Scanner (System.in).nextInt();
System.out.print("Enter last number: ");
int y = new Scanner (System.in).nextInt();
System.out.print("The multiples of 5 from "+x+ " to " +y+ " : ");

To:
Scanner scanner = new Scanner (System.in);
System.out.print("Enter first number: ");
int x = scanner.nextInt();
System.out.print("Enter last number: ");
int y = scanner.nextInt();
System.out.print("The multiples of 5 from "+x+ " to " +y+ " : ");

Next, I would advice to make the step into a variable, so it's easier to change later on (or perhaps ask from the user as input as well):
int step = 5;
...
System.out.print("The multiples of "+step+" from "+x+ " to " +y+ " : ");
...
   if(x%step == 0){
      ...

And now onto your actual problem. Let's first analyse what you want:

*

*You want the separator for most items to be ", " (base case)

*You want the separator for the second to last integer in the iteration to be " and "

*And the final integer doesn't need any separator anymore, since it's the trailing item

Let's now convert these requirements into code:
for(; x<=y; x++){
    if(x%step == 0){

       // The last `x` that will be printed, is the x where the difference between y and x
       // is smaller than the step-size:
       boolean lastNumber = y-x < step;
       // The `x` for which we want an " and " separator is the second to last item,
       // so the difference between x and y should be smaller than twice the step-size:
       boolean showAnd = y-x < 2*step;
       // And then we can use these two booleans with a simple ternary-if to determine the
       // format we'd want to use in our print:
       System.out.printf(lastNumber ? "%d\n"
                          : showAnd ? "%d and "
                          :           "%d, ",
                         x);
  }
}

Try it online.

A: consider stream api, like
IntStream.range(2, 8).mapToObj(Integer::toString).collect(Collectors.joining(", and "))


text:
Q: Can we implement C4 garbage collection mechanism in our own JVM?Or we will have to use only AZUL JVM(Zing) I just want to use C4 garbage collection mechanism as Azul is using.
To implement it,will I have to use AZUL JVM(Zing)?
Or we can implement,it in our own server.
How Can I achive it our own server.

A: The C4 collector implementation is part of the Zing JVM. You can install and run Zing on most Linux/x86 servers (including on AWS, etc.). You then just change JAVA_HOME to point to the Zing JDK, and everything gets happier.

redpajama_set_name: RedPajamaStackExchange


text:
Q: First quantization version of quantum field theory In quantum mechanics, we have the word second quantization for identical particles. However, when dealing with localized states, first quantization version of quantum mechanics is also very convenient. I wonder if there is a first quantization version of QFT which is handy in dealing with, for example, two particles that are far away from each other.
Well, I think most answers missed my point, but I do learned a lot from your answers. Now I put it in another way. Is there a way to describe two identical but localized particles without symmetrize the states like what we do in basic QM

A: I will try an answer, even if I'm not sure to understand fully what the question means. Using the second quantization formalism in QM is actually sometimes useful, but it is in some sense just a trick. Suppose you have $N$ identical $1$-dimensional bosons interacting by means of a two-body potential. The Hilbert space of the theory is $L^2_s(\mathbb{R}^N)$, the space of square integrable symmetric functions. The Hamiltonian is usually something like this:
$$H_N=-\sum_{j=1}^N \Delta_j +\frac{1}{N}\sum_{i<j} V(x_i-x_j)$$
where $V$ is symmetric and real. You can see this operator as the restriction to the $N$-particle sector of an operator in a symmetric Fock space (second quantization formalism). The Fock space is $\Gamma_s(L^2)=\bigoplus_{n=0}^\infty L^2_s(\mathbb{R}^N)$ (with the convention $L^2_s(\mathbb{R}^0)=\mathbb{C}$) and the operator is, using the usual annihilation and creation operators,
$$H=\int_{\mathbb{R}}(\nabla a)^*(x)\nabla a(x)dx +\frac{1}{2}\int_{\mathbb{R}^2}V(x-y)a^*(x)a^*(y)a(x)a(y)dxdy\; .$$
It is easy to see that $H\rvert_{L^2_s(\mathbb{R}^N)}=H_N$.
In many body theory you have a state with fixed number of particles, i.e. $\psi_N\in L^2_s(\mathbb{R}^N)$, and the evolution $U_N(t)$ generated by $H_N$ (equivalently $H$) maps $L^2_s(\mathbb{R}^N)$ on itself (preserves the number of particles). So even if you have these two ways of writing the Hamiltonian of your system, they are completely equivalent. In some sense, you have a direct sum of "theories" that do not interact, each one corresponding to a different number $n$ of particles: not only the Fock space is a direct sum, but also $H=\bigoplus_{n=0}^\infty H_n$; once the number $n=N$ is fixed and it is finite, your system will never leave the subspace $L^2_s(\mathbb{R}^N)$.
In real relativistic QFTs, the situation is radically different. The Hamiltonian does not preserve the number of particles, and has terms with an uneven number of creation and annihilation operators. So it is impossible to give a closed description of the dynamics in the subspace $L^2_s(\mathbb{R}^N)$: even if you start with a state in this space, the evolution will create and destroy particles, and you will end up with a state that spreads in general on the whole Fock space. It is therefore of no use to search for a "first quantization" (i.e. in the subspace $L^2_s(\mathbb{R}^N)$) description of QFTs.

A: The issue may arise due to the unfortunate choice of terminology, 'second quantization.' When one applies canonical quantization to a field theory, e.g. with Lagrangian,
$$\mathcal{L}=\frac{1}{2}\partial_\mu\phi\partial^\mu\phi - \frac{1}{2}m^2\phi^2$$
we treat the original theory as a classical field theory. Hence, 'second quantization' is really applying a single quantization procedure, once. The term 'first quantization' describes quantizing a theory which is not a field, such as a classical harmonic oscillator. Hence, there is no 'first quantization' of a field theory.

A:
I wonder if there is a first quantization version of QFT which is
  handy in dealing with, for example, two particles that are far away
  from each other

In the first-quantization formalism, in a many-body problem with indentical particles, you have to symmetrize (for bosons) or anti-symmetrize (for fermions) the many-body wave function.
However, it is a  heavy process and we are more interesting, for instance, in knowing how many particles having some momentum, are present in a state, so the QFT Fock state notation  $|n_{k_1}, n_{k_2}...n_{k_n}\rangle$ represents a state with has $n_{\vec k_1}$ particles with momentum $k_1$,$n_{\vec k_2}$ particles with momentum $k_2$, etc...
The notation $|k_A k_B\rangle$ is a shortcut for $|1_{k_A}1_{k_B}\rangle$, that is a state where you have one particle with momentum $k_A$ and one particle with momentum $k_B$.
Note that one is working with momenta, so there is no notion of localization, because a particle with a precise momentum extends across the whole space-time, this is just the consequence of the Heisenberg inequalities. So it does not make sense, for particles having a precise momentum, to speak about "two particles that are far away
from each other"
Practically, to compare a theorical result to experiments, you begin with amplitudes for a process with initial and final particles having a precise momentum, then you calculate cross sections from these amplitudes, so you get probabilities that you may compare to those you find from experiments.


text:
Q: PHP to SQL Insert not Working I have a simple query that I'm using to insert a record based on a form submission, but it's not writing the record to the database. It's also not throwing an error. I used a var_dump and verified that the variables are posting correctly, so I think the issue is in the query syntax, but I've checked that too.
Any help or guidance is greatly appreciated. Here is the code:
if (isset($submit)){

$user_id = $_SESSION['user_id'];
$anthem1 = $_POST['anthem1'];
$cointoss2 = $_POST['cointoss2'];

$query = "INSERT INTO mypicks (";
$query .= "  user_id, anthem1, cointoss2";
$query .= ") VALUES (";
$query .= "  '{$user_id}', '{$anthem1}', '{$cointoss2}'";
$query .= ")";
$result = mysqli_query($connection, $query);

}

A: You'll want to add some checks into your code.
First you'll want to make sure that your database connection is happening:
$connection = new mysqli('localhost', 'username', 'password', 'database');

if($connection->connect_errno > 0){
    die('Unable to connect to database [' . $connection->connect_error . ']');
}

Next thing, you'll want to make sure that your $submit variable is set, so your code block is actually firing.
If it is, make sure that your query is working:
$user_id = $_SESSION['user_id'];
$anthem1 = $_POST['anthem1'];
$cointoss2 = $_POST['cointoss2'];

$stmt = $connection->prepare("INSERT INTO mypicks ( user_id, anthem1, cointoss2 ) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $user_id, $anthem1, $cointoss2);
$stmt->execute();

if(!$result = $stmt->get_result()){
    die('There was an error running the query [' . $connection->error . ']');
}

Also don't forget to clean up after wards
$stmt->close();
$connection->close();


text:
Q: Is an access token needed for facebook fql query on link_stat In Facebook's documentation for fql link_stats (https://developers.facebook.com/docs/reference/fql/link_stat), under Permissions it says "To read the link_stat table you need - a valid app access_token"
In the browser I can do
https://graph.facebook.com/fql?q=SELECT%20url,%20normalized_url,%20share_count,%20like_count,%20comment_count,%20total_count,commentsbox_count,%20comments_fbid,%20click_count%20FROM%20link_stat%20WHERE%20url='https://medium.com/health-the-future/918b3d08f21f'

which I got from this SO Question. As you can see there is no access token in the call.
This api call is the same as the one in the linked documentation correct? So do you or do you not need an access token to query fql via this graph api call? Am I missing something here?

A: I think you're right. Surprisingly, you don't require any Access Token to the link_stat table. I've tried it with URL and as well as using the Graph Explorer (after clearing the Access Token of course) and it's working just fine.
To sum up: No, you don't require an Access Token for that.
PS: You can report this thing to Facebook, if you want.

A: You don't require any access token to access the link stats table now.(There can be restrictions later)
Regarding the app access tokens,they are largely used when posting requests to the API.
In the developer documentation,they have mentioned it to be used for certain retrieval options too.
 https://developers.facebook.com/docs/opengraph/howtos/publishing-with-app-token/


text:
Q: Setting Icon for Java Program doesn´t work import java.awt.*;
import java.net.URL;

import javax.imageio.ImageIO;
import javax.swing.*;

public class MainClass extends JFrame {

public static void main(String[] args){

    JFrame myframe = new JFrame("Mein Programm");
    myframe.setSize(600, 400);
    myframe.setVisible(true);
    myframe.add(new JLabel("Label"));

  }

}

I try to make a simple java program and I don´t know how to change the java cup icon. I tried several threads from the forum and all of them don´t work for me.
Thanks for help.

A: You aren't setting the icon there. To set it, use the JFrame.setIconImage method
myFrame.setIconImage(yourIcon);

A: Create a new package/folder called res (resources) with the subfolder icons and put your icon files with different sizes in it. The program will automatically decide at runtime which size is needed, depending on the screen resolution.
// Supply the program with different icon sizes for different resolutions
ArrayList<Image> icons = new ArrayList<>();
icons.add(ImageIO.read(getClass().getResource("/res/icons/tcc_icon-16x16.png")));
icons.add(ImageIO.read(getClass().getResource("/res/icons/tcc_icon-32x32.png")));
icons.add(ImageIO.read(getClass().getResource("/res/icons/tcc_icon-64x64.png")));
icons.add(ImageIO.read(getClass().getResource("/res/icons/tcc_icon-128x128.png")));
setIconImages(icons);


text:
Q: Error connecting to db mssql php zend 1.12 I have a problem connecting to a db with zend framework 1.12 and zend studio. The code in the application.ini to connect to the db is the following:
 resources.db.adapter = pdo_mssql

 resources.db.params.host = "IPADDRESS\SQLEXPRESS"
 resources.db.params.username = sa
 resources.db.params.password = XXXXXXXX
 resources.db.params.dbname = namedb
 resources.db.isDefaultTableAdapter = true
 resources.db.params.pdoType = dblib
 resources.db.params.charset= "utf-8"

The db is available online (I checked) but i get the following error:
 Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[01002] Adaptive Server connection failed (severity 9)

I know this error is a connection error (the pdo doesn't find the db) and i've found a tutorial in a forum which should help (it uses zend framework with the same libraries and type of db i use, on a mac). But i think the pdo type is configured somewhere elsein my machine as i don't find in my Abstract.php:
 protected $_pdoType = 'dblib';

The pdo type is set in the application.ini, the code i pasted before. The log says the error is in those lines:
 in /usr/local/zend/var/libraries/Zend_Framework_1/1.12.3/library/Zend/Db/Adapter/Pdo/Abstract.php:129

            $this->_connection = new PDO(
            $dsn,
            $this->_config['username'],
            $this->_config['password'],
            $this->_config['driver_options']
        );

But i cannot understand what I'm missing.. Any hint?

A: This article by rob allen will be usefull i think , Zf Coonect To MSSQL
as described there in detail you can use following,
resources.db.adapter = "sqlsrv"
resources.db.host = "host"
resources.db.dbname = "DatabaseName"
resources.db.isDefaultTableAdapter = true
resources.db.driver_options.ReturnDatesAsStrings = true

Hope That Helps
also relevant DOC from zend framwork official document here.

A: Try the following:
Microsoft SQL Server database connection info
db.mssqlServer.adapter          = PDO_MSSQL
db.mssqlServer.config.pdoType   = dblib
db.mssqlServer.config.host      = server_ip_or_url
db.mssqlServer.config.dbname    = database_name
db.mssqlServer.config.username  = "mssql_user"
db.mssqlServer.config.password  = "mssql_password"
db.mssqlServer.config.driver_options.PDO::ATTR_ERRMODE=PDO::ERRMODE_EXCEPTION


text:
Q: Class Objects - Hierachy and Inheritance ( NOT WORKING) I have a (People) or Users objects, of which I am using class inheritance to create the various objects.
However I am getting errors INVALID COLUMN, when I add the object, Users_Accounts which exist in the database with their respective columns below, I get the error
what am I doing wrong ?
ERROR MESSAGE
An unhandled exception occurred while processing the request.
SqlException: Invalid column name 'Users_AccountsAccountID'.
Invalid column name 'Users_AccountsAccountID'.
Invalid column name 'Users_PhonePhoneID'.
namespace Accounts.i_EF.Accounts
{
public class Users
{
    [Key]
    public int UserID { get; set; }
    public string Email { get; set; }
    public Guid UniqueID { get; set; }
    public DateTime Dates { get; set; }
    public bool IsSuspended { get; set; }

     public Users_Accounts Users_Accounts { get; set; }

}
public class Users_Accounts
{
    [Key]
    public int AccountID { get; set; }
    public string UniqueID { get; set; }
    public Title Title { get; set; }
    public string First_Name { get; set; }
    public string Last_Name { get; set; }
    public Gender Gender { get; set; }
    public Users_Phone Users_Phone { get; set; }
    public string Email { get; set; }

    public DateTime  Dates { get; set; }
    public bool IsSuspended { get; set; }
}
public enum Gender
{
    male,female

}

and my controller code
 var user = HttpContext.User.Identity.Name.ToString();
        var DataContext = _context.Users.Include(c => c.Users_Accounts);

return View(await DataContext.SingleOrDefaultAsync(c => c.Email == user && !c.IsSuspended));

A: Try this code:
namespace Accounts.i_EF.Accounts
    {
    public class Users
    {
        [Key]
        public int UserID { get; set; }
        public string Email { get; set; }
        public Guid UniqueID { get; set; }
        public DateTime Dates { get; set; }
        public bool IsSuspended { get; set; }
        public int UserAccountID { get; set; }
        [ForeignKey(nameof(UserAccountID))]
        public Users_Accounts Users_Accounts { get; set; }

    }
    public class Users_Accounts
    {
        [Key]
        public int AccountID { get; set; }
        public string UniqueID { get; set; }
        public Title Title { get; set; }
        public string First_Name { get; set; }
        public string Last_Name { get; set; }
        public Gender Gender { get; set; }
        public int UserPhoneID { get; set; }
        [ForeignKey(nameof(UserPhoneID))]
        public Users_Phone Users_Phone { get; set; }
        public string Email { get; set; }

        public DateTime  Dates { get; set; }
        public bool IsSuspended { get; set; }

        public int UserID { get; set; }
        [ForeignKey(nameof(UserID ))]
        public Users Users { get; set; }
    }
    public enum Gender
    {
        male,female

    }


text:
Q: boto3 how to upload dict / json output to s3 bucket? I have troubles to upload my output which is dict from organizations describe_policy to s3. here is my code
paginator = org.get_paginator('list_policies')
page_iterator = paginator.paginate(Filter='SERVICE_CONTROL_POLICY', PaginationConfig={'MaxItems': 10000})
for page in page_iterator:
    for id in page['Policies']:
        policyid = id['Id']
        describe = org.describe_policy(PolicyId=policyid)
        s3.put_object(Body=describe,Bucket='cf-asr-demo',Key=day_month_year+policyid+'/describe-scp.csv')

The error says that my output is dict class
botocore.exceptions.ParamValidationError: Parameter validation failed:
type: <class 'dict'>, valid types: <class 'bytes'>, <class 'bytearray'>, file-like object

How do I upload this output that is basically just a description of a policy to the bucket?

A: So I just fixed it myself, I dumped into a json
policy = json.dumps(describe)

and than it worked


text:
Q: Does 'droll' have a negative connotation? I'd taken droll to mean something like drily amusing, but without any implied negativity.
But I've often heard people say

Very droll!

in response to something that they appear to find mildly amusing but not exactly LOL territory. They certainly would not have described the comment as hilarious or very amusing, which terms would be reserved for something much funnier.
For example:

Hacker: Who else is in this department?
Sir Humphrey: Well briefly, sir, I am the Permanent Under-Secretary of State, known as the Permanent Secretary. Woolley here is your Principal Private Secretary. I too have a Principal Private Secretary and he is the Principal Private Secretary to the Permanent Secretary. Directly responsible to me are ten Deputy Secretaries, 87 Under Secretaries and 219 Assistant Secretaries. Directly responsible to the Principal Private Secretaries are plain Private Secretaries, and the Prime Minister will be appointing two Parliamentary Under-Secretaries and you will be appointing your own Parliamentary Private Secretary.
Hacker: Can they all type?
Sir Humphrey: None of us can type. Mrs MacKay types: she's the secretary.
Hacker: Pity, we could have opened an agency.
Sir Humphrey: Very droll, Minister.
Hacker: I suppose they all say that, do they?
Sir Humphrey: Certainly not Minister. Not quite all..."

(From Yes, Minister series 1, episode 1: Open Government.)
Is this a correct understanding of the term? Does it suggest a lukewarm assessment?

A: By and large, on the whole, not to put to fine a point on it, 'Very droll' is in itself, as far as one can tell, one of those phrases that speaks clearly its own meaning, when put into the context of the conversation that proceeded the remark.
When the tone of voice and body language are taken into account, one can tell quite easily the spirit in which the phrase was meant.

A: Droll came into English from the French drôle and it arrived as a noun meaning:

A funny or waggish fellow; a merry-andrew, buffoon, jester, humourist. (OED).

The OED has no examples of its use since 1876, by which time it was clearly accepted as an adjective:

a1876   G. Dawson Biogr. Lect. (1886) 94   Charles the Second
  certainly was the drollest idol ever nation set up.

A more modern interpretation is available in the Oxford Dictionary Online. Clearly the adjectival use is now more important.

Curious or unusual in a way that provokes dry amusement: his unique
  brand of droll self-mockery.

In short to describe a remark, or someone as droll would imply that they have a sense of humour which is not especially quick witted.
So in answer to the question it is negative in the sense that it suggests the speaker, or the remark was an example of dry-wit, not especially funny. (Though I very much dislike the use of the term negative in this sort of sense. Reducing people to positivity and negativity suggets that they do not exist outside of a bi-polar spectrum.)

A: To figure out what type of humor is the opposite droll humor, we need to identify the characteristics of droll humor:
"Curious or unusual in a way that provokes dry amusement"
Dry amusement means not laugh-out-loud funny. The person with a dry/droll sense of humor is not expecting laughter, hence it is important that there be no signal that a joke is about to be or has been made. This requires no pause before the amusing part so it is usually a dead-pan delivery, or at least involves no change in tone. The humor is intentional, but has to appear as if unintentional. Unintentionally droll means you didn't mean to be funny.
Since the humor is impromptu - not rehearsed or planned - the person being droll is usually quick-witted - that is one who picks up on the humorous aspect quickly and slides it into the conversation effortlessly.
Droll humor relies on the listener picking up on the humor - i.e., being able to recognize the curious or unusual nature of the thing, at least when pointed out by the witty person. On the internet you might see the comment: "I c what you did there" following a droll comment. Thus the speaker and the listener(s) must have a shared view about what is common and what is uncommon. The listener may recognize the attempt at humor, but not be amused by it because the observation is not unusual (as is the case in "Yes, Minister," because Sir Humphrey has heard "the joke" many times before). The listener may also not be amused even though the observation is unusual when it is something that should not be the subject of humor.
Thus the humorist is not expecting everyone will "get it," and is not expecting laughs. The opposite would be humor that is told for the purpose of laughs, that is commonly recognized as funny, and with a delivery that signals the humor.
So slap-stick comedy could be said to be the opposite of dry humor, as could pantomime, miming, buffoonery, and clownishness (or clowning around). A jocular person would be the opposite of a droll person. A jokester or jester could be be the opposite of droll, which is amusing given the etymology of the word. Although, some court jesters were expected to be quick-witted and sarcastic and not rely on physical comedy.

A: My old 1970's Chambers Dictionary defines the adjective to mean odd, amusing ,laughable which at first suggests something to be laughed at for its oddity , not to be seen as a clever fellow attempting  to entertain , but then offers "a jester" which seems to me to be the obverse in some sense . From my own readings of , say , Victorian English  literature I understand the word , applied to a person , is intended quite certainly to be a derogatory statement, suggesting they are to be laughed at for their odd appearance or behavior. And, in passing,the last word in my previous sentence does not appear anywhere  in my dictionary

A: I've always taken "droll" to be a bit sarcastic, especially if paired together with an emphasizing word like "very droll" or "that was most droll", said as a retort to somebody having made a poorly received joke. To me it conveys a meaning that the speaker recognizes that somebody tried to be funny, but also that they want to make it clear they don't find it funny at all. Not just "meh", but maybe off-taste or insulting or something.

A: When Brits label someone 'droll' it has a deprecating undertone, suggesting the person thus described is not to be taken seriously. Kind of an under-handed putdown originating from a superior and/or condescending mindset.


text:
Q: Debugging PHP in Visual Studio Code I am trying to debug a wamp-based website using VSC. When I start the debugger using the configuration Listen for XDebug, the Debug control panel opens.  The Step Over, Step Into and Step Out controls are not active (I assume they become active when the program starts?).  I have two breakpoints set up.
This is the launch.json file that VSC created for PHP:
"version": "0.2.0",
"configurations": [

    {
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9000
    },
    {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9000
    }
]

This is the XDebug config in php.ini
; XDEBUG Extension
[xdebug]
zend_extension ="c:/wamp64/bin/php/php5.6.31/zend_ext/php_xdebug-2.5.5-5.6-
vc11-x86_64.dll"
xdebug.remote_enable = off
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/wamp64/tmp"
xdebug.show_local_vars=0

I changed these lines as per XDebug extension docs in VSC
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

When I start(submit a form), the code executes, but the VSC debugger doesn't engage, execution doesn't stop at the breakpoints, data is inserted in some tables.  Am I missing some configuration so that the debugger does something, stops at the breakpoints?  The VSC docs here
https://code.visualstudio.com/docs/editor/debugging
only highlight debugging with Node.js debugger.  Appreciate any guidance on this.

A: I needed to ask for more info through comment section but I did not have enough reputation to do so :)
I suspect the PHP.ini file that you have modified is not the correct one. As you mentioned, you're dealing with WAMP, therefore there must be at least two PHP.ini files:

*

*Command Line Interface (CLI)

*Apache.

You should have modified the second one since you're running Apache.
I'm not quite sure about the exact path to those two files. I hope this could help.
How to know which PHP.ini is loaded?
Run phpinfo(); in your script in VSCode. It brings up your PHP configuration info. Look for: Loaded Configuration File.


text:
Q: Copy file from Application document directory and move to iPhone /Application folder- Objective C? I have one ipa/deb file there at some server and through service call I download that file and save it to my application document directory (within app sandbox). This app is not the signed one and I have to install it directly/automatically on iPhone device without the help of any third party tool like Cyberduck/iExplorer even not the terminal. So how can I accomplish the complete task with coding part only if it is to grant root access to app or install the app. You can say this app will behave like Cydia for app installation.
Thanks in advance.

A: I believe you mean /Applications instead of /root/Applications since there is no such folder (at least not on my iOS 5 device).
Since /Applications folder has is owned by root with 755 permissions. That means, non-root users can read/execute the files in that folder but not write to it. If you want to write to that folder, you need to run your app as root. The way to do this, somewhat ironically for you, is to have the app installed in /Applications folder. (I think) this is automatically done if you install the app through Cydia.
So to sum up: You can't move app to /Applications if you installed it through App Store (or ad hoc distribution). You need to install it through Cydia and it'll be installed directly in that folder.
Also, that answer you're referring to in comments, is about Mac OS, not iOS.


text:
Q: Can you call a React Context Function in a components State? I am trying to tackle an issue of re-setting a components state on browser reload.
The gist of it is there is a filter function in the React Context that uses the Router tool of "this.props.match.params" to obtain the desired image Id, then calls the filter function to find that image in the shared state that holds all the images. That is all well and good on initial mounting but once the browser reloads on the same route all the image data is lost.  The image id from 'params' seems to remain but when it calls the filter function again it gets a undefined value.
Any ideas? I have researched for this issue with no luck. Still a fairly new coder so apologies in advance if I am overlooking something.
Using React and React Context.  I have tried to use the lifecycles with no success. Also tried some very hacky function calls and/or Promise's but nothing worked.
Working lifecycle on initial mount but not on a browser reload.
export default class ImagePage extends Component {
    constructor(props) {
        super(props);
        this.state = {
            user_id: this.props.match.params.user_id,
            image_id: this.props.match.params.image_id,
                image:[],
            redirect: false
        };
    }
    //set context for component
    static contextType = PhotoGramContext;
//set component state to selected image data
    componentWillMount() {
        const user = { id: this.state.user_id };
        this.context.checkIfLoggedIn(user);

                const getImageData = this.context.getImageData;
        const image_id = this.state.image_id;

        const selectedImage = new Promise((res, rej) => {
            return res(getImageData(image_id));
        });

        this.setState({
            image: selectedImage
        });
    }

Thought something like this to set the image data right at the start but can't call the context I guess that early.
export default class ImagePage extends Component {
    constructor(props) {
        super(props);
        this.state = {
            user_id: this.props.match.params.user_id,
            image_id: this.props.match.params.image_id,
        image:this.context.getImageData(this.state.image_id),
            redirect: false
        };
    }
    //set context for component
    static contextType = PhotoGramContext;


text:
Q: Using values in 2d matrix as lookups I have a 2-D numpy array that I would like to use as a series of indexes.  The values in the array are all integer values:
array([[3, 3, 3, 2],
       [1, 5, 2, 3],
       [4, 2, 3, 2],
       [2, 3, 1, 3]])

I also have a 1D array with 5 values
array([x,y,z,q,p])

I'd like to use the cells of the 2D array as lookup values into the 1D array.  In other words, where the 2D array is equal to 1, return x.  Where it's equal to 2, return y, and so on.
This is simple enough to do in matlab, but I'd like a numpy solution that doesn't involve looping.
Thoughts?

A: Assuming x, y, z, q, p are variables (and not characters).
If you define the first array as (say, src):
src = np.array([[3, 3, 3, 2],
            [1, 5, 2, 3],
            [4, 2, 3, 2],
            [2, 3, 1, 3]])

and the second as (say, lookup):
lookup = np.array([x,y,z,q,p])

You can get the desired output using:
lookup[src - 1]

Or if you want individual outputs:
lookup[src[i, j] - 1]

where (i, j) is the 2-D index of the value that you want to look up.
Please note that the -1 here is to account for the offset (as mentioned in the comment by slothrop)


text:
Q: Virtual inheritance bug in MSVC It seems that my problem is a bug in MSVC. I'm using the Visual Studio 2008 with Service Pack 1, and my code works with GCC (as tested on codepad.org).
Any official info on this bug? Any ideas how to work around it? Is the bug fixed in VS2010? All insights would be greatly appreciated.
The code:
struct Base {
    Base(int i = 0) : i(i) {}
    virtual ~Base() {}
    virtual Base *clone() const = 0;

protected:
    int i;
};

struct A : virtual public Base {
    A() {}
    virtual A *clone() const = 0;
};

struct B : public A {
    B() {}
    B *clone() const { return new B(*this); }

    /// MSVC debugger shows that 'b' is for some reason missing the Base
    /// portion of it's object ("Error: expression cannot be evaluated")
    /// and trying to access 'b.i' causes an unhandled exception.
    ///
    /// Note: This only seems to occur with MSVC
    B(const B &b) : Base(b.i), A() {}
};

void foo(const A &elem) {
    A *a = elem.clone();
    if (a) delete a;
}

int main() {
    A *a = new B;
    foo(*a);
    delete a;
}

A: It looks as though the compiler is not correctly adjusting the this pointer when calling through A::clone. If you remove the declaration of A::clone then everything works fine.
Digging in deeper, when you have A::clone, the vtable looks like this:
    [0x0]   0x002f1136 [thunk]:B::`vector deleting destructor'`vtordisp{4294967292,0}' (unsigned int)   void *
    [0x1]   0x002f11e0 [thunk]:B::clone`vtordisp{4294967292,0}' (void)  void *
    [0x2]   0x002f12ad [thunk]:B::clone`vtordisp{4294967292,4}' (void)  void *
    [0x3]   0x002f12a3 B::clone(void)   void *

And foo calls elem.__vfptr[2], offsetting this incorrectly by -4 bytes. Without A::clone, the vtable looks like this:
    [0x0]   0x00ee1136 [thunk]:B::`vector deleting destructor'`vtordisp{4294967292,0}' (unsigned int)   void *
    [0x1]   0x00ee11e0 [thunk]:B::clone`vtordisp{4294967292,0}' (void)  void *
    [0x2]   0x00ee12a3 B::clone(void)   void *

And foo calls elem.__vfptr[1]. That does not adjust this at all (and the code assumes that this will be equal to Base instead of B).
So it looks like the compiler assumes that A::clone is a new virtual method and doesn't override Base::clone when determining whether A requires a new virtual table, but then some other code later determines that A does not need a virtual table. You can verify this by comparing sizeof(B) with or without a new virtual function:
struct A : virtual public Base {
    A() {}
    virtual A *clone() const = 0;
}; //sizeof(B)==16

struct A : virtual public Base {
    A() {}
    virtual A *clone() const = 0;
virtual const A *clone2() const { return this; }
}; //sizeof(B)==20

So it's a compiler bug.

A: It would seem (from some testing) that the bug is caused by the combination of a virtual base class with a pure virtual method using covariant return types.
Since dropping either the pure virtual method from the Base class, or making Base a non-virtual base class or making the clone() method non-covariant seems to solve the bug.
I guess this one's solved for me (after I submit a bug report to MS), and I'm even left with a few options to circumvent it. :)


text:
Q: Wordpress: Remove attachment fields How do I remove attachment fields, like description and alt in media library of Wordpress attachments?
The following code use to work on old Wordpress versions (pre 3.5):
function remove_attachment_field ( $fields ) {
    unset( $fields['image_alt'] ); // Removes ALT field
    return $fields;
}
add_filter( 'attachment_fields_to_edit', 'remove_attachment_field', 15, 1 );

But since then, I have not found a working solution.
Do anyone know a solution?
Clarification on which fields I would like to remove:

A: The styles can be printed on /wp-admin/post.php using admin_print_styles-$page, and selecting the elements using the data attribute.

It's possible to detect the current post type and only apply the rules on a given type:
foreach( array( 'post.php', 'post-new.php' ) as $hook )
    add_action( "admin_print_styles-$hook", 'admin_styles_so_25894288');

function admin_styles_so_25894288() {
    global $typenow;
    if( 'post' !== $typenow )
        return;
    ?>

    <?php
}

A: The above solution by @brasofilo should work well, but we can also use this great answer by @EricAndrewLewis as a guideline on how to override the Backbone micro templates.
Overriding the Backbone micro templates - short version:
You can override the micro Backbone template #tmpl-attachment-details with your custom #tmpl-attachment-details-custom using:
wp.media.view.Attachment.Details.prototype.template = wp.media.template( 'attachment-details-custom' );

Similarly you can override the micro template #tmpl-attachment-details-two-column with #tmpl-attachment-details-two-column-custom using:
wp.media.view.Attachment.Details.TwoColumn.prototype.template = wp.media.template( 'attachment-details-two-column-custom' );

Overriding the Backbone micro templates - long version:
Here you can get the media templates used by the WordPress core.
1) The following code example should remove the Caption, Alt Text and Description fields from the Attachments Details template:
Screenshot:

Code:
/**
 * Override the "Attachments Details" Backbone micro template in WordPress 4.0
 *
 * @see https://stackoverflow.com/a/25948448/2078474
 */

add_action( 'admin_footer-post.php', 'modified_attachments_details_template_so_25894288' );

function modified_attachments_details_template_so_25894288()
{?>

    <?php
}

2) The following code example should remove the Caption, Alt Text and Description fields from the Attachments Details Two Column template:
Screenshot:

Code:
/**
 * Override the "Attachments Details Two Column" Backbone micro template in WordPress 4.0
 *
 * @see https://stackoverflow.com/a/25948448/2078474
 */

add_action( 'admin_footer-upload.php', 'modified_attachments_details_two_column_template_so_25894288' );

function modified_attachments_details_two_column_template_so_25894288()
{ ?>

    <?php
}

You can hopefully modify this to your needs.

A: Try this:
add_action('admin_head', 'remove_attachment_field');
function remove_attachment_field() {
  echo "";
}


text:
Q: Javascript building an object directly I have these values:
let buffer = {};
let value = 'value';
let x = 1;
let y = 2;

This is what I want to do:
buffer[x][y].value = value;

This is what I need to do, in order for it to work:
buffer[x] = {};
buffer[x][y] = {};
buffer[x][y].value = value;

My guess is that there is a better, maybe built in way to create an object like this in one step instead of three.

A:
My guess is that there is a better, maybe built in way to create an object like this in one step instead of three.

What you have is fine, but you can also do it with computed properties (I'm assuming you need the values from variables) and shorthand property notation (for value):

let value = 'value';
let x = 1;
let y = 2;

let buffer = {
  [x]: {
    [y]: {
      value
    }
  }
};

console.log(buffer);

A: If you want to create nested object based on a set of keys, you could use reduceRight. Use the rest parameters syntax to get the value and the array of paths as separate variables. Set the value as the initialValue parameter and add a level of nesting in each iteration

const create = (value, ...paths) => paths.reduceRight((r, k) => ({ [k]: r }), value)

console.log(create("final value", "1", "2", "value"))
console.log(create("final value", "any", "number", "of", "keys"))

A: Like this?
const buffer = {
  1: {
    2: {
      value: 'value'
    }
  }
};

If x and y are already defined, then use computed properties:

let x = 1;
let y = 2;
const buffer = {
  [x]: {
    [y]: {
      value: 'value'
    }
  }
};

A: You could reduce the given keys and assign the value at the last step.

const
    setValue = (object, path, value) =>
        path.reduce((o, k, i, { length }) => o[k] = i + 1 === length
            ? value
            : o[k] || {}, object);

let buffer = {};
let value = 'value';
let x = 1;
let y = 2;

setValue(buffer, [x, y, value], value);
console.log(buffer);


text:
Q: Return latest value within multiple single date rows So, the issue: I have a daily finances table, where I insert all incomings and outgoings every day. Every transaction creates a new line within the spreadsheet, so many rows will begin with the same date.
What I need to do for a different spreadsheet (within the same doc) is to return the final sum on both bank accounts at the end of the day, so the latest added entry within the range of rows starting with the specific date (screenshot example: return the value from cell G20 for the 5th of January).
I've tried a rather simple version VLOOKUP, but it just returns randomly correct or incorrect results.
Here's a screenshot to explain the situation:

A: Vlookup should work if the dates are in order, plz try
=vlookup(I2,{A2:A,G2:G},2,true)

A: try:
=ARRAY_CONSTRAIN(SORTN(SORT({A2:A, G2:G, ROW(A2:A)}, 3, 0), 9^9, 2, 1, 1), 9^9, 2)


text:
Q: xyplot, Error in `[.xts`(y, id) : 'i' or 'j' out of range I am trying to scatter plot two variables, one of which is the residuals from an lm() call. The xyplot() function will not do this scatter plot and returns the error message
Error in `[.xts`(y, id) : 'i' or 'j' out of range

The residuals are an xts variable and xyplot() can in fact still plot the residuals by itself (just a time plot, not a scatter plot).
Strangely, the work around I've found so far is to use as.xts() on the already xts residuals, or to use [ ,1] indexing to refer to the first column, even though there is only one column to begin with.
MWE is below, just looking for an explanation, thanks in advance.
library('lattice')
library('xts')
a = as.xts(ts(rnorm(20), start=c(1980,1), freq=4))
b = as.xts(ts(rnorm(20), start=c(1980,1), freq=4))

c = resid(lm(a~b))
str(c) # xts object

xyplot(c~a) # does not work: Error in `[.xts`(y, id) : 'i' or 'j' out of range
xyplot(c) # xyplot can plot it by itself just fine
xyplot(as.xts(c)~a) # works, if you use as.xts() on an xts object ?
xyplot(c[ ,1]~a) # works, if you refer to the 1st column of a 1 column object ?

A: The problem is because c doesn't have a dim attribute, like most xts objects do, and how many xts functions expect xts objects to have.  Set the dim attribute and everything's okay.
dim(c) <- c(length(c),1)
xyplot(c~a)


text:
Q: Is there a way to test the locally-hosted bot without Ngrok? I develop a Microsoft Bot Framework bot and I'd like to test it in Bot Framework Emulator locally without using ngrok. Is there any way?
In the current environment, I am facing proxy related issues and cannot run 'ngrok' in my laptop due to company policies
Thanks for any clues!

A: While the Emulator is a great tool for testing local bots, it serves as its own channel and therefore cannot reliably reproduce channel-specific behavior. Using ngrok you can debug a locally-running bot on any channel. If you want another tunneling service that gives you that same kind of functionality, check out Azure Relays and the Service Bus Relay Util: https://blog.botframework.com/2019/04/16/debugging-your-locally-hosted-v4-bot-using-azure-relays/
Based on your updated question, I don't think Service Bus will solve your problem. You'll probably want to bypass ngrok for local addresses in Emulator.

A: I'm guessing you may already be using Bot Framework Emulator, which gives you lots of warnings and settings to configure ngrok. But this is not required for local testing! ngrok exposes your local bot on the internet. Unless you have components of your bot that can't access your bot on your local, or you cannot get requests out through your proxy, testing without ngrok works fine.
When you test locally, you just need one generic endpoint in the Emulator with Endpoint URL = http://localhost:3978/api/messages. I name mine "Local Bot" since I use the same configuration for all bot testing. Do not enter the application ID or password. This is what tripped me up for a while; when you're on local you don't need to do this, and it will actually cause your bot not to work if you're not using ngrok.
Now you can just start your bot locally as normal (e.g node index.js for a nodejs bot). If you are behind a proxy, you may need to account for those settings as well. Proxy settings in your console will not work. I recommend setting it in a .env file if you can so your code is not affected. I'm not sure how to do that for C# but for nodejs it's HTTPS_PROXY=http://proxy.company.com:port. I've found that setting HTTP proxy is not necessary and actually breaks my bots.

A: Have a look at the Bot Framework Emulator.

The Bot Framework Emulator is a desktop application that allows bot developers to test and debug bots built using the Bot Framework SDK. You can use the Bot Framework Emulator to test bots running either locally on your machine or connect to bots running remotely through a tunnel.

A: I am going to answer specifically about this part of your question.
I am facing proxy related issues and cannot run 'ngrok' in my laptop due to company policies
So, if they are blocking proxies, and that unfortunately includes the proxy level facilities provided by ngrok, then,

the answer is a simple no. You cannot, in the most simplest form.

My solution (not a technical one, but a pragmatic one, imagining what I would do I your situation) is to get in touch with IT and ask them to lift the restriction.
Alternatively, another solution would be run the bot on another computer, simply for the sake of testing, while keeping your code and development on your company computer.
Again, not a technical solution, but a pragmatic one.


text:
Q: Find the maximum value of $x_1x_2+x_2x_3+\cdots+x_nx_1$ Find the maximum value of $x_1x_2+x_2x_3+\cdots+x_nx_1$ if $x_1+x_2+\cdots+x_n=0$ and $x_1^2+x_2^2+...+x_n^2=1$.
I can get by Cauchy-Schwarz that $x_1x_2+x_2x_3+\cdots+x_nx_1 \leqslant 1$, but can expression $x_1x_2+x_2x_3+\cdots+x_nx_1$ be smaller?

A: This is known as the Ky Fan-Tausski-Todd inequality or a special case of the discrete Wirtinger's inequality. The proof is not that hard, but requires an ingenious change of variables. See here for the complete proof and other details.


text:
Q: How to add flowmonitor in on-off application? Can anyone suggest how to add flow monitor in on-off application in NS-3. Modified Example file build successfully but didn't write any *.xml file, Below is the code :
Any suggestions ? What is wrong here ? it looks like the API is correct.
  AsciiTraceHelper ascii;
  Ptr<OutputStreamWrapper> osw = ascii.CreateFileStream ( (tr_name + ".tr").c_str());
  UanPhyDual.EnableAsciiAll (osw);

  std::string tr_name ("ULSR");
  Ptr<FlowMonitor> flowmon;
  FlowMonitorHelper flowmonHelper;
  flowmon = flowmonHelper.InstallAll ();
  flowmon->CheckForLostPackets ();
  std::map<FlowId, FlowMonitor::FlowStats> stats = flowmon->GetFlowStats ();
  for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator m_numNodes = stats.begin (); m_numNodes != stats.end (); ++m_numNodes)
    {
        NS_LOG_UNCOND("Flow ID: " << m_numNodes->first << " Position of sink: " << sink.Get (0) << " Dst Addr " << sinkDev.Get (0));
        NS_LOG_UNCOND("Tx Packets = " << m_numNodes->second.txPackets);
        NS_LOG_UNCOND("Rx Packets = " << m_numNodes->second.rxPackets);
        NS_LOG_UNCOND("Throughput: " << m_numNodes->second.rxBytes * 8.0 / (m_numNodes->second.timeLastRxPacket.GetSeconds()-m_numNodes->second.timeFirstTxPacket.GetSeconds()) / 1024  << " Kbps");
    }

  Simulator::Stop (m_simTime + Seconds (0.6));

  Simulator::Run ();

  flowmon->SerializeToXmlFile ((tr_name + ".flowmon").c_str(), true, true);

  Simulator::Destroy ();

  return m_bytesTotal;
}

Here is the output of the command prompt:
[2772/2852] Compiling scratch/uan-rc-example.cc
[2807/2852] Linking build/scratch/uan-rc-example
Waf: Leaving directory `/home/jay/Documents/dev/workspace/ns-allinone-3.30/ns-3.30/build'
Build commands will be stored in build/compile_commands.json
'build' finished successfully (4.457s)
param=1:  Received 910000 bytes at sink

Thanks. Any help ?

A: If I'm understanding the problem correctly, you're trying to get the print statements in the for-loop to run. FlowMonitor collects statistics of the simulation as it runs. You have placed the for-loop before the Simulator::Run() call, so you are trying to print the statistics of the simulation before it has run! My guess is that flowmon->GetFlowStats() returns an empty map, so you don't have a null pointer that would cause your program to crash: the for loop simply finds that the map is empty, and doesn't run.
The solution is simple: move the following code to after the call to Simulator::Run():
flowmon->CheckForLostPackets ();
std::map<FlowId, FlowMonitor::FlowStats> stats = flowmon->GetFlowStats ();
for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator m_numNodes = stats.begin (); m_numNodes != stats.end (); ++m_numNodes)
{
      NS_LOG_UNCOND("Flow ID: " << m_numNodes->first << " Position of sink: " << sink.Get (0) << " Dst Addr " << sinkDev.Get (0));
      NS_LOG_UNCOND("Tx Packets = " << m_numNodes->second.txPackets);
      NS_LOG_UNCOND("Rx Packets = " << m_numNodes->second.rxPackets);
      NS_LOG_UNCOND("Throughput: " << m_numNodes->second.rxBytes * 8.0 / (m_numNodes->second.timeLastRxPacket.GetSeconds()-m_numNodes->second.timeFirstTxPacket.GetSeconds()) / 1024  << " Kbps");
}

You also have to move the flowmon->checkForLostPackets() call since that is how FlowMonitor will do a final roll call to determine which packets are missing (ie. dropped) after the simulation has completed running.


text:
Q: Mac OSX proxying On my mac (OS X Mavericks), I am trying to redirect all the outgoing calls to a server (192.168.1.2) to a proxy server (192.168.1.3). I am using the following command (assuming that I don't need any of the existing rules)
echo "rdr pass inet proto tcp from any to 192.168.1.2 port 8280 -> 192.168.1.3 port 9180" | sudo pfctl -ef -

However, this doesn't seem to work. Am I missing something?
Essentially, I am trying to set up a forward proxy which would be honored by all applications which communicate with an internal network.
References: https://serverfault.com/questions/102416/iptables-equivalent-for-mac-os-x?lq=1


text:
Q: Can I sync Ubuntu One contacts in Lubuntu? I'm using Lubuntu 11.10 and have contacts in Ubuntu-One, but don't know how to get them synced. The default mail client is Sylpheed, though any client would do.

A: Simple as downloading and install Ubuntu One and then get evolution to get your contacts back


text:
Q: What is the difference between Azure Landing Zone and Azure Vending machine? I am trying to setup the Infrastructure on Azure using the CAF. However, I have a requirement to deploy multiple instance of the Infrastructure specific to the Application(s), say Azure Synapse & it's related components in Dev, Stage, Prod.
I am calling everything from the Root to Connectivity as Azure Landing Zone and Application specific deployment as Azure Vending machine as it deploys multiple instance. Is this fine?
What is the difference between Azure Landing Zone and Azure Vending machine?

A: The term landing zone is a bit overloaded depending on the context it's mentioned in. Based on the official definition Microsoft uses the terms
Azure Landing Zone (sometimes with an appended "Architecture", which I think clarifies it a lot) describes the entire set up of your Azure Tenant, e.g. your management groups, subscriptions etc. Think of it as "this is where the organization lands".
Platform Landing Zone to describe the subscriptions providing central functions like an Azure vWAN Hub managing on-prem connectivity for your entire org. Think of it as "this is where shared platform services land".
Application Landing Zone to describe the subscriptions where individual applications land. In a lift & shift setting this may be one big subscription hosting multiple apps in resource group, but for something more cloud-native you'd have a subscription for each. Think of it as "this is where an individual application team lands".
The Vending Machine's job is to provision new application landing zones. I find it useful to cut down the specific jargon a bit and think of it more in terms of capabilities, i.e. a vending machine gives you the capability to provision new environments for application teams in a multi-tenant Azure landing zone – so you can call the capability tenant provisioning. The vending machine is just an automated implementation for this type of task as a self-service workflow.

A: It is almost the same, and yet it is not.
Landing Zones are your subscriptions where your workloads reside. A small environment you could call it. It includes multiple resources and is used in a larger scale to generate the Azure Landing Zone architecture.
Vending Machines are basically fully-working landing zone provisioning. A process for how you will deploy new landing zones via IaC (e.g. Terraform) that will support workload requirements. It is not just the subscription, but also the resources like VNet, Storage accounts, etc.
https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/landing-zone/


text:
Q: Evaluate Equation in Cell Array, MATLAB I have a cell array containing functions (with function handle) and I want to evaluate these inside a for-loop. I want to evaluate the differential equations:
x1'= x2,
x2' = ax2-bx1
My code is like this:
init = [0,0];
F = {@(x1,x2) x2,@(x1,x2)(a*x2-b*x1)};
X0 = init;

for i=1:10
   X = X0 + c*F(init(1),init(2));
   X0 = X;
   init[1] = {X(1)};
   init[2] = {X(2)};
end

The constants a,b and c are given.
I get the error:
Subscript indices must either be real positive integers or logicals.

Can someone help me with this?

A: F is a 1x2 cell array.  To access elements (in your case, function handles) within this array you must use the curly braces {} to do so.  For example, the first function is retrieved by F{1} and the second by F{2} using positive integer indices.
In your example, init is a 1x2 array of zeros so when the code evaluates
F(init(1),init(2));

it is trying to access something within F using indices that are not positive.  Hence the error.
I suspect that you will need to do something like the following in your for loop and evaluate each function separately
for i=1:10
    for j=1:2
        % get the jth function handle
        func = F{j};

        % evaluate
        X(j) =  X0(j) + c*func(init(1),init(2));

        % save
     end
 end

I've left the save* portion to be filled in by you because it isn't all that clear to me why there are the different init,X0 and X variables - could you consolidate them?
Note also your mixture of [] and () brackets when accessing arrays.  In MATLAB, if the array is of type cell, then we use the {} to access elements.  For all other arrays, we use the () brackets.

A: First of all, there are two other problems with your code: c is not defined and you are trying to index into init with []-brackets, which will throw:
Error: File: foo Line: 8 Column: 8
Unbalanced or unexpected parenthesis or bracket.

The subscript error occurs because you are trying to access F(0,0) because init(1) and init(2) are 0. Remember that the way you declared F, it is a cell array:
>> F = {@(x1,x2) x2,@(x1,x2)(a*x2-b*x1)};
>> whos F
  Name      Size            Bytes  Class    Attributes

  F         1x2               288  cell

Hence, F(0,0) is illegal because indexes in matlab start with 1. Your functions reside in F{1} and F{2}.
>> F{1}
ans =
    @(x1,x2)x2
>> F{2}
ans =
    @(x1,x2)(a*x2-b*x1)
>> f = F{1}
f =
    @(x1,x2)x2
>> f(0,0)
ans =
     0


text:
Q: Assembly language offsetting multiple ways to store words? I am using MIPS with the mars editor and I was wondering if something like
sw $s0,8($v0)

Is equivalent to:
sw $s0,$v0(8)

My instinct tells me this is not the case because it takes the address of whatevers in the brackets and adds the value of whatever is outside it. However in the solution posted by codeknight in the link beliw he loops through a string using:
lb $t1,mystring($t0)

which almost feels like indexing an array and doesn't make sense to me with the "add immediate to address of ()" logic. Can someone explain this?
http://www.masmforum.com/board/index.php?PHPSESSID=786dd40408172108b65a5a36b09c88c0&topic=1062.0

A: Admittedly, the syntax is a little confusing because it hints that the two parts are not on the same level, when in fact they are. Because of this, some assemblers allow you to put the brackets around the immediate part, but that's rather the exception.
imm(reg) just means memory address imm+reg, as such mystring($t0) means memory address mystring+$t0 so it's indeed indexing. Whether the immediate part is the base or the other way around, makes no difference. Both of these load the 5th (offset 4) byte of mystring:
li $t0, 4
lb $t0, mystring($t0)

or
la $t0, mystring
lb $t0, 4($t0)


text:
Q: MUI: You have provided an out-of-range value `3` for the select (name="surface_id") componen I have a problem and I know what is but I can't solve it
I have the following select
<Select
    defaultValue=""
    labelId="surfaces-label"
    id="surface_id"
    name="surface_id"
    value={surfaceId}
    onChange={handleSurfaceChange}
    label={translation.word.surface}
  >
    {surfaces.length > 0 ? (
      surfaces.map((surface) => {
        return (
          <MenuItem value={surface.id} key={surface.created_at}>
            {surface.name}
          </MenuItem>
        );
      })
    ) : (
      <MenuItem>-</MenuItem>
    )}
  </Select>

and this is loaded with data that I get from the API using the useEffect
useEffect(() => {
    if (!surfaces.length) {
      handleGetSurfaces();
    }
}, []);

The problem is when I want to edit and I add the following code to useEffect
  useEffect(() => {
    if (!surfaces.length) {
      handleGetSurfaces();
    }

    if (surfaceEditing) {
      setSurfaceId(surfaceEditing.id);
      validator.setFieldValue("surface_id", surfaceEditing.id);
    }
  }, []);

When is executed setSurfaceId(surfaceEditing.id); the data in the select doesn't exist yet because is getting from API and here is when I receive:

MUI: You have provided an out-of-range value 3 for the select
(name="surface_id") component. Consider providing a value that matches
one of the available options or ''. The available values are "".

I need to setSurfaceId(surfaceEditing.id); after surface is loaded with .map but it doesn't work

A: Loading the Data
You are going to want to use a Promise to call handleGetSurfaces() asynchronously so that you can wait for the result before continuing into your if (surfaceEditing){...
This can be achieved with async/await, but if you try to use async/await inside of useEffect() you'll get this error:

This happens because async makes the function return a Promise and useEffect is not expecting the callback function to return a Promise.
An easy solution is to do this:
const handleInitialize async () => {
    if (!surfaces.length) {
      await handleGetSurfaces();
    }

    if (surfaceEditing) {
      setSurfaceId(surfaceEditing.id);
      validator.setFieldValue("surface_id", surfaceEditing.id);
    }
}

useEffect(() => {
      handleInitialize()
}, []);

What we did in the block above is that we called another function inside of useEffect and made that function asyncronous instead of making the useEffect callback function asyncronous.
You'll have to make sure that wherever you define your handleGetSurfaces() function that you make it asyncronous as well, so that we are able to await it.

Using the Data
That covers the data loading, but we still have to handle everything property while we are waiting for that data to load. When the page first loads, the <Select> will be trying to use data that hasn't been loaded yet, so we need to fix that.
One way to handle this is to conditionally render the <Select> like this:
{
surfaceId !== undefined &&
    <Select
        defaultValue=""
        labelId="surfaces-label"
        id="surface_id"
        name="surface_id"
        value={surfaceId}
        onChange={handleSurfaceChange}
        label={translation.word.surface}
      >
        {surfaces.length > 0 ? (
          surfaces.map((surface) => {
            return (
              <MenuItem value={surface.id} key={surface.created_at}>
                {surface.name}
              </MenuItem>
            );
          })
        ) : (
          <MenuItem>-</MenuItem>
        )}
    </Select>
}

The surfaceId !== undefined && says that we will check if surfaceId is not undefined, and if it that is true (if it is not undefined) then we will render the <Select>. This is called short circuit evaluation since if the condition is false then the code will "short circuit" and not even read the next statement.


text:
Q: Create Google Charts with code Im looking to load a number of google charts depending on the data selected from my database. (The number of charts will be different depending on the selection)
I can load a single chart with the following code, but I'm struggling to load multiple charts via looping through a list
My intention is to have no charts drawn until a selection is made and data passed to the code below for each item in my list. There could be over 20 charts!
Help much appreciated, I use C# but only just getting to php and html

A: you could setup similar to following...
// load google charts
google.charts.load('current', {
  callback: getList,
  packages: ['corechart']
});

// load id list
function getList() {
  $.ajax({
    url: 'getList.php',
    dataType: 'json'
  }).done(function (listData) {

    // draw chart for each id
    listData.forEach(function (itemId) {
      drawChart(itemId);
    });

  }).fail(function (jq, text, errMsg) {
    console.log(text + ': ' + errMsg);
  });
}

// draw id chart
function drawChart(itemId) {
  $.ajax({
    url: 'getJSONdata.php',
    dataType: 'json',
    data: {
      id: itemId
    }
  }).done(function (jsonData) {

    var data = new google.visualization.DataTable(jsonData);

    var options = {
      title: 'BMU',
      width: 500,
      height: 300,
      series: {
        0: { lineWidth: 1, pointSize: 1.1 },
        1: { lineWidth: 1, pointSize: 1.1},
        2: { lineWidth: 1, pointSize: 1.1}},
      hAxis: {
        textStyle:{fontSize: 10},
        format: 'HH:mm',
      },
      vAxis: {
        textStyle:{fontSize: 10},
      },
      chartArea: {backgroundColor: '#fffff0'},
    };

    // create new div for chart
    var container = document.getElementById('charts').appendChild(document.createElement('div'));
    var chart = new google.visualization.ScatterChart(container);
    chart.draw(data, options);

  }).fail(function (jq, text, errMsg) {
    console.log(text + ': ' + errMsg);
  });
}


text:
Q: How to change null and empty string in sqlite? Here is my sqlite databse ,you can see some cell are null or  empty string when opening with sqlitemanager.
How can i change all the null and empty string into 0 (zero) in this sqlite database ,not by hand one by one (you can do it in sqlite manager,but it is stupid to change all in one database).

A: UPDATE grade SET d3 = 0
   WHERE d3 IS NULL OR d3 = ''


text:
Q: Cohomology of finite $p$-groups over integers in local fields Let $p$ be a prime, $G$ be a finite group of order $p^a$. Let $M$ be a $\mathbb{Z}[G]$-module. Then $H^n(G, M)$ is annihilated by $p^a$ for all $n \geq 1$ (see e.g. Brown, Corollary III.10.2).
In particular this is true for $\mathbb{Z}_p[G]$-modules, and I was wondering if this version of the result can be generalized to local fields other than $\mathbb{Q}_p$. More precisely, let $\mathbb{K}$ be a non-Archimedean local field with ring of integers $\mathfrak{o}$, uniformizer $\omega$, maximal ideal $\mathfrak{p}$, residue field $\mathfrak{k}$ of characteristic $p$. Let $G$ be a finite $p$-group and $M$ an $\mathfrak{o}[G]$-module. What is the least $a$ such that $H^n(G, M)$ is annihilated by $\omega^a$?
It should be easy to use the statement at the beginning of this post to generalize this to any local field of characteristic $0$, and $a$ should still be uniformly bounded, with the bound depending only on the order of $\mathfrak{k}$ and the order of $G$. But what about characteristic $p$? This case seems to be substantially different.
I think this question is interesting in general, but there is probably no chance to get a general answer without assuming anything extra. So let me point out the specific setting that I am interested in:

*

*$n = 1$ and especially $n = 2$: this comes up in an extension problem so I only really care about these degrees.

*$M$ is a free $\mathfrak{o}/\mathfrak{p}^k$-module. So I already know that $H^n(G, M)$ is annihilated by $\omega^k$, that is $a \leq k$. But I would like to get better estimates, ideally I would like to find a bound of the form $a \leq a(k)$ such that $(k - a(k)) \to \infty$ as $k \to \infty$. In characteristic $0$ I can get $a(k)$ to be a constant so this is a significant weakening, but still somewhat strong.

*Even though I am interested in the general case, I have trouble understanding even the first example: $G = \mathbb{Z}/2\mathbb{Z}$ and $\mathbb{K} = \mathbb{F}_2((X))$, so $\omega = X$ and $\mathfrak{o} = \mathbb{F}_2[[X]]$. Explicitly: if $M$ is a free $\mathbb{F}_2[X]/X^k$-module with an action of $G$, what is the least $a$ such that $X^a H^n(G, M) = 0$ for $n = 1, 2$? After trying a bit I think that one cannot do better than $a(k) = k/2$ (see the previous point), but I am not able to prove that this works.

A: If you take $G=\mathbb Z/p^a\mathbb Z$, then the cohomology of any $M$ are computed by the Tate complex $M\xrightarrow{\sigma-\mathrm{id}} M \xrightarrow{1+\sigma+\ldots+ \sigma^{p^a-1} }M\xrightarrow{\sigma-\mathrm{id}} M \xrightarrow{1+\sigma+\ldots+ \sigma^{p^a-1} }M\xrightarrow{\sigma-\mathrm{id}}\ldots$. In particular if the action on $M$ is trivial then the norm map $1+\sigma+\ldots+ \sigma^{p^a-1}$ is given by multiplication by $p^a$ and $\sigma-\mathrm{id}=0$. If $M$ is of characteristic $p$ then $H^{i}(G,M)\simeq M$ for all $i$. Note that if $M$ had a structure of an $\mathfrak o$-module this is an isomorphism of $\mathfrak o$-modules (I assume here that $G$ acts $\mathfrak o$-linearly): this shows that in general $a(k)=k$. This is also true for any $G$: you can argue inductively by considering lower central series and the Hochschield-Serre spectral sequence to reduce to the case of products of cyclic groups (where you can use Kunneth formula). In more detail the $E^{0,1}$ term there is never hit by a differential and thus by induction $H^1(G, M)$ naturally contains $M$.
Allowing $M$ (and $k$) vary for a fixed $G$ you can always make $a(k)$=0. Indeed in the case of a cyclic group $\mathbb Z/p^a\mathbb Z$ we can take $M=\mathfrak o/\omega^{i\cdot p^a}$ and the action of $\sigma$ by $1+\omega^i$. Then $\sigma^{p^a}=1$, so we have an action and $1+\sigma+\ldots \sigma^{p^a-1}=\frac{(1+\omega^i)^{p^a}-1}{\omega^i}=\omega^{i\cdot (p^a-1)}$, while $1-\sigma=\omega^i$. Looking at the Tate complex we get that $H^{>0}(G,M)=0$.  Then for any $G$ you can take the a cyclic subgroup $H$ in the center $Z(G)\subset G$ and induce the above representation to $G$. In fact you could also induce from the trivial subgroup right away (in other words just take the regular module $M=\mathfrak o[G]$). The above construction might be slightly better because there the annulating power of $\omega$ for $H^0$ also decreases (so if you also include $H^0$ in the definition of $a(k)$ you still get $a(k)\sim\frac{p^a-1}{p^a}k$)


text:
Q: How can I use Swing FlowLayout with fixed width? I'm  doing a prototype for showing some basic functions of a painting program. Now, here is how the window looks like:

The window is compound of a panel with a vertical BoxLayout, inside it, there are a custom image control and another panel with a FlowLayout containing all the buttons.
The problem is that I have to specify the height for the buttons panel (in 100px). If I delete that line, the window looks like this:

But, if I only specify the width, and I write a 0 for the height, I get this:

I want the layouts determine the correct height of the buttons panel by themselves. Here is the code that produces the first image:
public void createAndShowGui(){
    JFrame.setDefaultLookAndFeelDecorated(true);

    setTitle("SimplePaint");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setResizable(false);

    //Main container layout.
    BoxLayout mainLayout = new BoxLayout(getContentPane(), BoxLayout.Y_AXIS);
    getContentPane().setLayout(mainLayout);

    drawingPanel = new JPanel();
    drawingPanel.setLayout(null);
    drawingPanel.setPreferredSize(new Dimension(width, height));

    TextBox editor = new TextBox();
    drawingPanel.add(editor);
    editor.setVisible(false);

    canvasControl = new DrawableCanvas(editor);
    drawingPanel.add(canvasControl);
    canvasControl.setBounds(0, 0, width, height);

    getContentPane().add(drawingPanel);

    drawingSurface = canvasControl.getDrawingSurface();

    //Buttons layout.
    FlowLayout buttonsLayout = new FlowLayout();
    JPanel buttonsPanel = new JPanel(buttonsLayout);
    buttonsPanel.setPreferredSize(new Dimension(width, 100)); // <-- Not in this way

    //Buttons creation...

    pack();
}

Thanks in advance.

A:
don't know how I can make the FlowLayout to grow vertically (not horizontally) just enough for showing all the buttons

FlowLayout does not do this.
You can use the Wrap Layout, which extends FlowLayout and override the preferred size method so that the component can wrap automatically.


text:
Q: Winform/Program and how to write class 1, class 2, class 3, class 4 in array to linklabels? So my program works like this: using winforms, user enters ID number, using an array, based on the right id number, that student information and class schedule outputs in a message box!
My question is how to take the 4 classes in the message box/array and write them to the linklabel text in form 2????
My Getschedule class contains the array and is listed below:
namespace Eagle_Eye_Class_Finder
{
public class GetSchedule
{
    IDnumber[] IDnumbers = new IDnumber[3];

    public string GetDataFromNumber(string ID)
    {
        foreach (IDnumber IDCandidateMatch in IDnumbers)
        {

            if (IDCandidateMatch.ID == ID)
            {
                StringBuilder myData = new StringBuilder();
                myData.AppendLine(IDCandidateMatch.Name);
                myData.AppendLine(": ");
                myData.AppendLine(IDCandidateMatch.ID);
                myData.AppendLine(IDCandidateMatch.year);
                myData.AppendLine(IDCandidateMatch.class1);
                myData.AppendLine(IDCandidateMatch.class2);
                myData.AppendLine(IDCandidateMatch.class3);
                myData.AppendLine(IDCandidateMatch.class4);
                //return myData;
                return myData.ToString();
            }
        }
        return "";
    }

    public GetSchedule()
    {
        IDnumbers[0] = new IDnumber() { Name = "Joshua Banks", ID = "900456317", year = "Senior", class1 = "TEET 4090", class2 = "TEET 3020", class3 = "TEET 3090", class4 = "TEET 4290" };
        IDnumbers[1] = new IDnumber() { Name = "Sean Ward", ID = "900456318", year = "Junior", class1 = "ENGNR 4090", class2 = "ENGNR 3020", class3 = "ENGNR 3090", class4 = "ENGNR 4290" };
        IDnumbers[2] = new IDnumber() { Name = "Terrell Johnson", ID = "900456319", year = "Sophomore", class1 = "BUS 4090", class2 = "BUS 3020", class3 = "BUS 3090", class4 = "BUS 4290" };

    }
    public class IDnumber
    {
        public string Name { get; set; }
        public string ID { get; set; }
        public string year { get; set; }
        public string class1 { get; set; }
        public string class2 { get; set; }
        public string class3 { get; set; }
        public string class4 { get; set; }

       public static void ProcessNumber(IDnumber myNum)
            {
                StringBuilder myData = new StringBuilder();
                myData.AppendLine(myNum.Name);
                myData.AppendLine(": ");
                myData.AppendLine(myNum.ID);
                myData.AppendLine(myNum.year);
                myData.AppendLine(myNum.class1);
                myData.AppendLine(myNum.class2);
                myData.AppendLine(myNum.class3);
                myData.AppendLine(myNum.class4);
                MessageBox.Show(myData.ToString());
            }

    }

}

}
My form 2 which will contain the linklabels is listed below:
public class YOURCLASSSCHEDULE : System.Windows.Forms.Form
    {
        public System.Windows.Forms.LinkLabel linkLabel1;
        public System.Windows.Forms.LinkLabel linkLabel2;
        public System.Windows.Forms.LinkLabel linkLabel3;
        public System.Windows.Forms.LinkLabel linkLabel4;
        private Button button1;
    /// Required designer variable.

    public System.ComponentModel.Container components = null;

    public YOURCLASSSCHEDULE()
    {

        //
        InitializeComponent();

        // TODO: Add any constructor code after InitializeComponent call

    }

    /// Clean up any resources being used.
    protected override void Dispose(bool disposing)
    {
        if (disposing)
        {
            if (components != null)
            {
                components.Dispose();
            }
        }
        base.Dispose(disposing);
    }

    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(YOURCLASSSCHEDULE));
        this.linkLabel1 = new System.Windows.Forms.LinkLabel();
        this.linkLabel2 = new System.Windows.Forms.LinkLabel();
        this.linkLabel3 = new System.Windows.Forms.LinkLabel();
        this.linkLabel4 = new System.Windows.Forms.LinkLabel();
        this.button1 = new System.Windows.Forms.Button();
        this.SuspendLayout();
        //
        // linkLabel1
        //
        this.linkLabel1.BackColor = System.Drawing.SystemColors.ActiveCaption;
        this.linkLabel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
        this.linkLabel1.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.linkLabel1.LinkArea = new System.Windows.Forms.LinkArea(0, 7);
        this.linkLabel1.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
        this.linkLabel1.Location = new System.Drawing.Point(41, 123);
        this.linkLabel1.Name = "linkLabel1";
        this.linkLabel1.Size = new System.Drawing.Size(288, 32);
        this.linkLabel1.TabIndex = 1;
        this.linkLabel1.TabStop = true;
        this.linkLabel1.Text = "Class 1";
        this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
        this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
        //
        // linkLabel2
        //
        this.linkLabel2.BackColor = System.Drawing.SystemColors.ActiveCaption;
        this.linkLabel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
        this.linkLabel2.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.linkLabel2.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
        this.linkLabel2.Location = new System.Drawing.Point(467, 123);
        this.linkLabel2.Name = "linkLabel2";
        this.linkLabel2.Size = new System.Drawing.Size(288, 32);
        this.linkLabel2.TabIndex = 2;
        this.linkLabel2.TabStop = true;
        this.linkLabel2.Text = "Class 2";
        this.linkLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
        this.linkLabel2.VisitedLinkColor = System.Drawing.Color.Navy;
        this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked);
        //
        // linkLabel3
        //
        this.linkLabel3.BackColor = System.Drawing.SystemColors.ActiveCaption;
        this.linkLabel3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
        this.linkLabel3.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.linkLabel3.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
        this.linkLabel3.Location = new System.Drawing.Point(41, 311);
        this.linkLabel3.Name = "linkLabel3";
        this.linkLabel3.Size = new System.Drawing.Size(288, 32);
        this.linkLabel3.TabIndex = 3;
        this.linkLabel3.TabStop = true;
        this.linkLabel3.Text = "Class 3";
        this.linkLabel3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
        this.linkLabel3.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel3_LinkClicked);
        //
        // linkLabel4
        //
        this.linkLabel4.BackColor = System.Drawing.SystemColors.ActiveCaption;
        this.linkLabel4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
        this.linkLabel4.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.linkLabel4.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
        this.linkLabel4.Location = new System.Drawing.Point(467, 311);
        this.linkLabel4.Name = "linkLabel4";
        this.linkLabel4.Size = new System.Drawing.Size(288, 32);
        this.linkLabel4.TabIndex = 4;
        this.linkLabel4.TabStop = true;
        this.linkLabel4.Text = "Class 4";
        this.linkLabel4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
        this.linkLabel4.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel4_LinkClicked);
        //

        //
        this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
        this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
        this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
        this.ClientSize = new System.Drawing.Size(790, 482);
        this.Controls.Add(this.button1);
        this.Controls.Add(this.linkLabel4);
        this.Controls.Add(this.linkLabel3);
        this.Controls.Add(this.linkLabel2);
        this.Controls.Add(this.linkLabel1);
        this.Font = new System.Drawing.Font("OldDreadfulNo7 BT", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.Name = "YOURCLASSSCHEDULE";
        this.Text = "Your Classes";
        this.Load += new System.EventHandler(this.Form2_Load);
        this.ResumeLayout(false);

    }
    #endregion

    public void Form2_Load(object sender, System.EventArgs e)
    {
       // if (text == "900456317")
       // {

        //}

    }

    public void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
    {

        System.Diagnostics.Process.Start("http://www.georgiasouthern.edu/map/");
    }

    private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {

    }

    private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {

    }

    private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {
        Form1 form1 = new Form1();
        form1.Show();
        this.Hide();
    }
}

}

A: Move your 4 classes to static objects or business layer. Use business layer to access data across your forms.
Use it like, for instance:
YourBusinessLayer.ScheduleManager manager = new ScheduleManager();

ScheduleManager.Add(new Schedule("Name", "ID", "Class", "Timings"); //Add schedules
List<Schedule> listOfAllSchedules= manager.GetSchedules(); //Get Schedules

manager.Schedule[0].ID
manager.Schedule[0].Name
manager.Schedule[0].Class
//....

Then, access(edit/update) the your schedule manager in your any of your forms.
Btw, just as a site note, a class should'nt(read: cannot) be a GetSchedule; rather a class may contain a method (read: action) called GetSchedule().


text:
Q: Cannot add foreign key constraint - MySQL ERROR 1215 (HY000) I am trying to create database for gym management system, but I can't figure out why I am getting this error. I've tried to search for the answer here, but I couldn't find it.
ERROR 1215 (HY000): Cannot add foreign key constraint

CREATE TABLE sales(
    saleId int(100) NOT NULL AUTO_INCREMENT,
    accountNo int(100) NOT NULL,
    payName VARCHAR(100) NOT NULL,
    nextPayment DATE,
    supplementName VARCHAR(250),
    qty int(11),
    workoutName VARCHAR(100),
    sDate datetime NOT NULL DEFAULT NOW(),
    totalAmount DECIMAL(11,2) NOT NULL,
    CONSTRAINT PRIMARY KEY(saleId, accountNo, payName),
    CONSTRAINT FOREIGN KEY(accountNo) REFERENCES accounts(accountNo) ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT FOREIGN KEY(payName) REFERENCES paymentFor(payName) ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT FOREIGN KEY(supplementName) REFERENCES supplements(supplementName) ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT FOREIGN KEY(workoutName) REFERENCES workouts(workoutName) ON DELETE CASCADE ON UPDATE CASCADE
);
    ALTER TABLE sales AUTO_INCREMENT = 2001;

Here is the parent tables.
CREATE TABLE accounts(
    accountNo int(100) NOT NULL AUTO_INCREMENT,
    accountType VARCHAR(100) NOT NULL,
    firstName VARCHAR(50) NOT NULL,
    lastName VARCHAR(60) NOT NULL,
    birthdate DATE NOT NULL,
    gender VARCHAR(7),
    city VARCHAR(50) NOT NULL,
    street VARCHAR(50),
    cellPhone VARCHAR(10),
    emergencyPhone VARCHAR(10),
    email VARCHAR(150) NOT NULL,
    description VARCHAR(350),
    occupation VARCHAR(50),
    createdOn datetime NOT NULL DEFAULT NOW(),
    CONSTRAINT PRIMARY KEY(accountNo)
);
    ALTER TABLE accounts AUTO_INCREMENT = 1001;

CREATE TABLE supplements(
    supplementId int(100) NOT NULL AUTO_INCREMENT,
    supplementName VARCHAR(250) NOT NULL,
    manufacture VARCHAR(100),
    description VARCHAR(150),
    qtyOnHand INT(5),
    unitPrice DECIMAL(11,2),
    manufactureDate DATE,
    expirationDate DATE,
    CONSTRAINT PRIMARY KEY(supplementId, supplementName)
);
    ALTER TABLE supplements AUTO_INCREMENT = 3001;

CREATE TABLE workouts(
    workoutId int(100) NOT NULL AUTO_INCREMENT,
    workoutName VARCHAR(100) NOT NULL,
    description VARCHAR(7500) NOT NULL,
    duration VARCHAR(30),
    CONSTRAINT PRIMARY KEY(workoutId, workoutName)
);
    ALTER TABLE workouts AUTO_INCREMENT = 4001;

CREATE TABLE paymentFor(
    payId int(100) NOT NULL AUTO_INCREMENT,
    payName VARCHAR(100) NOT NULL,
    amount DECIMAL(11,2),
    CONSTRAINT PRIMARY KEY(payId, payName)
);
    ALTER TABLE paymentFor AUTO_INCREMENT = 5001;

Can you guys help me with this problem? Thanks.

A: Foreign Keys are a way of implementing relationships/constraints between columns in different tables.
There are different categories of constraints that influence how they're enforced when a row is updated or deleted from the parent table:
◾Cascade: If a row is deleted from the parent then any rows in the child table with a matching FK value will also be deleted. Similarly for changes to the value in the parent table.
◾Restrict: A row cannot be deleted from the parent table if this would break a FK constraint with the child table. Similarly for changes to the value in the parent table.
◾No Action: Very similar to "Restrict" except that any events/triggers on the parent table will be executed before the constraint is enforced – giving the application writer the option to resolve any FK constraint conflicts using a stored procedure.
◾Set NULL: If NULL is a permitted value for the FK column in the child table then it will be set to NULL if the associated data in the parent table is updated or deleted.
◾Set Default: If there is a default value for the FK column in the child table then it will be used if the associated data in the parent table is updated or deleted. Note that this is not implemented in this version – the constraint can be added to the schema but any subsequent deletion or update to the column in the parent table will fail.

A: If you ever want to find out, why that error was , all you have to do is run below command and look for "LATEST FOREIGN KEY ERROR"
Command to run :-
mysql> SHOW ENGINE INNODB STATUS

You will know the reason for your such errors.

A: Some times you will get this error "#1215 - Cannot add foreign key constraint" because of table TYPE (InnoDB, MyISAM,..) mismatch.
So change your table type into same and try applying for foreign key constraint
mysql> ALTER TABLE table_name ENGINE=InnoDB;
mysql> ALTER TABLE Orders
        ADD FOREIGN KEY (P_Id)
        REFERENCES Persons(P_Id)

A: For a field to be defined as a foreign key, the referenced parent field must have an index defined on it.
As per documentation on foreign key constraints:

REFERENCES parent_tbl_name (index_col_name,...)

Define an INDEX on workouts.workoutName, paymentFor.paymentName, and supplements.supplementName respectively. And make sure that child column definitions must match with those of their parent column definitions.
Change workouts table definition as below:
CREATE TABLE workouts(
    workoutId int(100) NOT NULL AUTO_INCREMENT,
    workoutName VARCHAR(100) NOT NULL,
    description VARCHAR(7500) NOT NULL,
    duration VARCHAR(30),

    KEY ( workoutName ), -- <---- this is newly added index key

    CONSTRAINT PRIMARY KEY(workoutId, workoutName)
);

Change supplements table definition as below:
CREATE TABLE supplements(
    supplementId int(100) NOT NULL AUTO_INCREMENT,
    supplementName VARCHAR(250) NOT NULL,
    manufacture VARCHAR(100),
    description VARCHAR(150),
    qtyOnHand INT(5),
    unitPrice DECIMAL(11,2),
    manufactureDate DATE,
    expirationDate DATE,

    KEY ( supplementName ), -- <---- this is newly added index key

    CONSTRAINT PRIMARY KEY(supplementId, supplementName)
);

Change paymentFor table definition as below:
CREATE TABLE paymentFor(
    payId int(100) NOT NULL AUTO_INCREMENT,
    payName VARCHAR(100) NOT NULL,
    amount DECIMAL(11,2),

    KEY ( payName ), -- <---- this is newly added index key

    CONSTRAINT PRIMARY KEY(payId, payName)
);

Now, change child table definition as below:
CREATE TABLE sales(
    saleId int(100) NOT NULL AUTO_INCREMENT,
    accountNo int(100) NOT NULL,
    payName VARCHAR(100) NOT NULL,
    nextPayment DATE,
    supplementName VARCHAR(250) NOT NULL,
    qty int(11),
    workoutName VARCHAR(100) NOT NULL,
    sDate datetime NOT NULL DEFAULT NOW(),
    totalAmount DECIMAL(11,2) NOT NULL,
    CONSTRAINT PRIMARY KEY(saleId, accountNo, payName),
    CONSTRAINT FOREIGN KEY(accountNo)
       REFERENCES accounts(accountNo)
       ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT FOREIGN KEY(payName)
       REFERENCES paymentFor(payName)
       ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT FOREIGN KEY(supplementName)
       REFERENCES supplements(supplementName)
       ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT FOREIGN KEY(workoutName)
       REFERENCES workouts(workoutName)
       ON DELETE CASCADE ON UPDATE CASCADE
);

Refer to:

*

*MySQL Using FOREIGN KEY Constraints

[CONSTRAINT [symbol]] FOREIGN KEY
      [index_name] (index_col_name, ...)
      REFERENCES tbl_name (index_col_name,...)
      [ON DELETE reference_option]
      [ON UPDATE reference_option]
reference_option:
      RESTRICT | CASCADE | SET NULL | NO ACTION

A: This might work for some people. Simply add the default character set as utf8
DEFAULT CHARACTER SET = utf8;

A: I was getting the same error. The reason was I was referring to a column in a table created with charset utf8 from a table created using charset latin.
The tables created using mySQL workbench create table utility have default charset latin.
Easy approach to find this out if you are using workbench is to view the table create statement of any table. You will have the default charset string at the end.

A: I'm not answering the above question but just for people who will run into the same mysql error.
All I did was to change the referenced table engine to innodb.

A: I encounter this error I add foreign key constraint for a column that has 'not null constraint' but I specified the 'on delete set null' in the foreign constraint.  This is a contradiction that it may not be obvious at first.
Here are my two tables:
CREATE TABLE study (
    id int(11) NOT NULL AUTO_INCREMENT primary key,
    name varchar(100) NOT NULL,
    introduction text,
    objective varchar(250) DEFAULT NULL,
    method text,
    result text,
    conclusion varchar(250) DEFAULT NULL,
    future_action varchar(100) DEFAULT NULL
);

drop table client_study;
CREATE TABLE client_study (
      id int(11) NOT NULL AUTO_INCREMENT primary key,
      client_id int(11),
      study_id int(11) not null, --If delete 'not null' error goes away!
      contact_person int(11),
      effective_date datetime DEFAULT CURRENT_TIMESTAMP,
      trial_site int(11) DEFAULT NULL,
      UNIQUE KEY unqidx_client_study (client_id,study_id)
);

ALTER TABLE client_study
ADD CONSTRAINT FOREIGN KEY (study_id) REFERENCES study(id)
ON DELETE SET NULL ON UPDATE CASCADE;

ERROR 1215 (HY000): Cannot add foreign key constraint

If you remove the NOT NULL constraint on the study_id column in the client_study table, the foreign key can be added.  The other alternative is to keep the not null constraint on the client_table, but modify the foreign key definition to on delete no action or other choices.


text:
Q: Google maps api from where we get? I want to use google maps in my ios application can anyone tell me that from where I will get google maps framework so that i can implement it in my application.
Is is free or any cost i have to pay for google map library.

A: Yes, you can find here in developer.google.com and also find below github links

*

*Link1

*Link2

A: Go to the Google Maps API page, and check out the iOS section for further information .
Cost depends on the sort of use I think, whether you want a premium access or not. Check the link for further details.


text:
Q: Estimating instrument uncertainty from the errors in the measurement of different objects I want to know the measurement uncertainty of an analytic balance. From 4 repeated measurements of a single 50 cents coin, I got a standard deviation of 0.4 mg. From 4 repeated measurements of 1 euro coin, I got a standard deviation of 1.0 mg.  Am I correct in assuming that I can obtain an estimate of the error in the balance as
$\sqrt{0.4^2+1.0^2}$   ?