text:
Q: Working of this Circuit - Reset I'm using this Ethernet transceiver PHY to study the working of the RGMII interface.
Can someone explain the working of figure 18 on page 75?
What is the purpose of D1 and D2 along with the RC?
How does it work?

A: D1 creates a power-on reset (POR) pulse.
D1 discharges capacitor C much more rapidly than resistor R would when power rail DVDDH goes to 0 V.  The idea is that if there is a power bounce, C is almost completely discharged and then charges up through R.  Without D1, the KSZ part might not see a level change and reset itself.
D2 is an OR-ing diode (actually, an AND diode).
From capacitor C's point of view, either D1 or D2 can discharge it by going low.  D2 also prevents the connection to the CPU/FPGA from holding C high during a POR event.  During a POR, D2 is reverse biased.  When the CPU RST output goes low to force the KSZ device to reset, D1 is reverse biased.
Update:
The POR part of this circuit handles one of two possible power-bounce or power-cycle scenarios.  When DVDDH goes away, it can do that by:
a) being disconnected, at which time the D1-R node is floating (not connected to any impedance or voltage/current source).  As DVDDH probably power other circuits, this probably is not the case.
b) going to 0 V relatively quickly, as in the power supply being turned off, and its own output circuit or current through other circuits and/or external loads discharging the supply's output capacitance to 0 V.  This presents a low impedance to GND the D1-R node.
The circuit works for case b.  C is discharged quickly through D1 to 0.5 V, and then more slowly down to 0 V, through whatever external impedance to GND exists.  If that impedance is low (case b), C can be discharged in milliseconds.  If it is high (case a), it might take minutes.  If power is restored before C has discharged below the KSZ device's input transition level, the device will not see a reset condition.

A: D1 is supposed to discharge C when the power supply rail falls. The input is a type Ipu (internal pullup) with a loosely specified (-40 to -120uA current) input pullup of some kind (all numbers here assuming 3.3V supply). Input low voltage is 1.3V and input high voltage 2.0V. It's not clear if the RESET_N input has Schmitt trigger functionality.
When power is re-applied the voltage at C is supposed to be less than 1.3V (so the supply should have fallen to less than about 0.6V) and then the capacitor charges through the parallel combination of the internal pullup and the external 10K resistor. The time constant of that is around 100ms, so the RESET_N input should be held active low for (very roughly) around that time.
D2 allows an external logic level (it must have a logic high level equal or similar to the  KSZ9031) to reset the KSZ9031 by pulling it low through the diode. The large 10uF capacitor will affect the external logic level transition, probably slowing it to 1ms-ish fall time, depending on the drive capability of the external logic.
This is altogether a very "cheap and nasty" reset arrangement unsuited for high reliability applications. You need a  proper reset circuit with precise voltage thresholds, guaranteed to assert a valid level down to very low supply voltage, and controlled minimum pulse width to get a reliable reset. This will work okay if the power is always 'off' for a  "long" time (depending on the external loads on the power supply to get it down to <0.6V) and if the power is switched cleanly every time. To put it bluntly, this kind of garbage circuit is responsible for much consumer frustration such as having to cycle power on routers during electrical storms.


text:
Q: Not sure where my logic error for my password checker is So for my homework assignment we are needing to make a password checker that a user can use to login to the program and says whether they are using the valid or invalid credentials.
So I have tried to compare it to all my password variants and even tried comparing it to the exact string that is the password in the file but it still dosen't seem to work and I cant to seem to find where my logic is failing within it.
My authentication program where the user enters in their username and password.:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

class Authenticator extends JPanel{
//Windows Components
private JFrame window = new JFrame("Login");
private JLabel lblUser = new JLabel("Username:");
private JLabel lblPass = new JLabel("Password:");
private JLabel lblCorrect = new JLabel("Correct Login Credentials");
private JLabel lblWrong = new JLabel("Incorrect Login Credentials");
private JTextField txtUser = new JTextField();
private JPasswordField txtPass= new JPasswordField();
private JButton btnLogin = new JButton("Login");

//TODO:  Create an instance of the PasswordChecker
private PasswordChecker check = new PasswordChecker();

//Constructor: Sets up the window
public Authenticator(){
  //Absolute layout requires null
  setLayout(null);

  //Sets x, y, w, h of each component
  lblUser.setBounds(10, 10, 200, 30);
  lblPass.setBounds(10, 50, 200, 30);
  txtPass.setBounds(120, 50, 200, 30);
  txtUser.setBounds(120, 10, 200, 30);
  lblCorrect.setBounds(10, 100, 200, 30);
  lblWrong.setBounds(10, 100, 200, 30);
  btnLogin.setBounds(220, 100, 100, 30);

  //add components to panel
  add(lblUser);
  add(lblPass);
  add(txtUser);
  add(txtPass);
  add(lblCorrect);
  add(lblWrong);
  add(btnLogin);

  lblCorrect.setVisible(false);
  lblWrong.setVisible(false);

  //Adds panel to window
  window.add(this);
  //Closes the program when window closes
  window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  window.setSize(400, 250);
  window.setVisible(true);

  btnLogin.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent ae){
        String userName = txtUser.getText();
        String passWord = txtUser.getText();
        if(check.checkLogin(userName, passWord)){
           lblCorrect.setVisible(true);
        }//end if
        else{
           lblWrong.setVisible(true);
        }//end else

       }
  });

}//Ends constructor

public static void main(String args[]){
  new Authenticator();
}
}

This is my Password checker that checks the user input and should compare what the user input to the authenticator:
import java.util.*;
import java.io.*;

class PasswordChecker{
private ArrayList<String> user = new ArrayList<>();
private ArrayList<String> pass = new ArrayList<>();

//Constructor: load the lists with the stuff from the file
public PasswordChecker(){

  String filename = "Logins.txt";
  Scanner fileIn;

  try{
     fileIn = new Scanner(new FileReader(filename));
     while(fileIn.hasNext()){
        user.add( fileIn.next() );
        pass.add( fileIn.next() );
     }
     fileIn.close();
  }
  catch(Exception e){
     System.out.println(e.getMessage());
  }//ends catch
}//ends constructor

//GetPassword
public String getPassword(String userName){
  for(int i = 0; i < user.size(); i++){
     if(user.get(i).equals(userName)){
        String password = pass.get(i);
        return password;
     }//end if
  }//end for
  return userName;
 }//end getPassword

 //Check Login
 public boolean checkLogin(String userName, String password){

  for(String s: user){
     String uName = s;
     String pWord = getPassword(s);

        if(pWord == password){
           return true;
        }//end if

  }//end while
  return false;
 }//end checkLogin

}//ends Class

Im expecting my password checker to send a true or false statement that my authenticator to input whether or not they have the right details.
In my Logins.txt i have my usernames and password similar to this.
UserName PassWord
123 123

A: In Java, string comparisons are done with the method String.equals.
In the line if(pWord == password) you used the equality operator == which checks only if two references point to the same object.
I would change if(pWord == password) to if(pWord.equals(password)).
NOTE
Java uses a caching system for strings, so sometimes using == might yield true but this is not always the case.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to insert a space between text and numbers in one cell I need to add a space in between text and numbers.  For example, I want to change MS1-27 to MS 1-27 while keeping the data in one cell. How can I do this in Excel?

A: I'm not sure what you mean by "keeping the data in one cell".
A formula requires putting the formula in a different cell.  For example:
=TRIM(REPLACE(A1,MIN(FIND({1,2,3,4,5,6,7,8,9,0},A1&"1234567890")),0," "))

will place a space before the first digit.  The TRIM wrapper is in case there already is a space.
If you need to have it happen within the cell, you will need a VBA Macro as a formula cannot alter the contents of a different cell.

A: This might be a job for regex. MS Excel allows use of VBA for search-and-replace using regular expressions, so you could specify "replace the first occurrence in a cell of a character from 0-9 with a space and that character". To enable regex, see http://www.pither.com/simon/blog/2010/01/31/regex-search-and-replace-in-excel.
regex is a rather complex subject, and there is help for MS Word at https://support.office.com/en-ca/article/Find-and-replace-text-by-using-regular-expressions-Advanced-eeaa03b0-e9f3-4921-b1e8-85b0ad1c427f. You'll need to specify more about the details of the search (as fixer1234 asks, is it simply adding a space after the second character in each cell, or is the text of variable length?). See also https://stackoverflow.com/questions/22542834/how-to-use-regular-expressions-regex-in-microsoft-excel-both-in-cell-and-loops and https://www.udemy.com/blog/vba-regex/.


text:
Q: What is the True Idle Cycles metric in Arm Developer Suite 1.2 AXD (ADS 1.2)? I am using Arm Developer Suite 1.2 (ARM7TDMI) along with AXD debugger, in order to optimize a C algorithm about image convolution.
When I am introducing the scatter file and the memory map files, I am getting two additional metrics, Wait States and True Idle Cycles.
I can understand that Wait States are introduced because of the read/write times I am using in the memory map file.
However, I am not sure what True Idle Cycles are. I checked the manual and it states that True Idle Cycles is "The number of I_Cycles less the number that are part of an I-S pair". I am not sure what that really means. What is an I-S pair, and thus what are the True Idle Cycles?


text:
Q: Cannot submit a form to back-end I would like to submit a form that has a field to upload a file. When I click on the submit button nothing happens.
I read following articles but could not resolve the issue. 1, 2
My front-end and back-end codes are as following.
<form:form action="${url}profile/edit" method="post"
                                modelAttribute="profile" role="form"
                                enctype="multipart/form-data">

                                    Photo <input type="file"
                                        name="photo" class="form-control" id="photo">

                                    Title

                                        <input type="text" name="title" id="title"
                                            class="form-control" data-toggle="dropdown"
                                            autocomplete="off">

Male

Female

                                    First Name <input type="text"
                                        name="firstName" class="form-control" id="firstName">

                                    Last Name <input type="text"
                                        name="lastName" class="form-control" id="lastName">

                                    Email

                                        @ <input type="email"
                                            id="email" name="email" class="form-control"
                                            placeholder="Enter email">

                                    <button class="btn btn-action btn-save">Save</button>

                            </form:form>

Profile
public class Profile {
    private MultipartFile photo;
    private String title;
    private String firstName;
    private String lastName;
    private String email;

    getters and setters

}

RequestHandler
@Controller
@RequestMapping("/profile")
public class ProfileController {

    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    public String editProfile(
            @ModelAttribute("profile") Profile profile, Model model) {
        System.err.println("in profile/edit" + profile);
        return "profile";
    }

}

I added 'Type' attribute to 'Button' but cannot submit the form yet.
 <button class="btn btn-action btn-save" type="submit">Save</button>

Also, I changes button to input to no avail.
 <input class="btn btn-action btn-save" type="submit">Save</input>


text:
Q: Nil value for array in Rails 3 I feel like a moron asking this, but since I'm a new to developing, and I've been sitting here for an hour making something so simple work, I need to ask.
I want to show each Widget, but I keeping getting:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each

I tried using <%= debug @widgets %> and <%= @widgets.inspect %>, but nothing shows in my command prompt or browser.
I was trying to copy the each do statement on http://guides.rubyonrails.org/layouts_and_rendering.html
In my controller, called Pages Controller, I have:
def widgets_to_show
  @widgets = Widget.all
end

In my view (pages#widgets_to_show), I have:
<% @widgets.each do |widget| %>
  <%= widget.title %>
<% end %>

*

*I have a widget model

*I also have values in the widgets table

*and I have a title field, so I'm not sure what I'm doing wrong

I'm trying to display it on a page that uses the High Voltage gem (https://github.com/thoughtbot/high_voltage) if that makes a difference.

A: As @DaveNewton suggested try accessing the widget from your console (not irb). Do the following from your terminal
# from your rails project dir
$ rails c
$ w = Widgets.all
$ puts w
$ w.each { |n| puts n.title }

If all of that works then we need more info to figure out what the problem is.
Edit:
My guess is that it has something to do with using high voltage on the same page. It's a gem for creating static pages so maybe that's interfering with showing your widgets - since what you're doing is something dynamic.


text:
Q: How to display value of custom fields in page I have a custom post type called 'software', contained within are various custom fields such as subtitle, price, screenshots, download link, etc. I created a function to allow use of the tinyMCE edit window for some of these custom fields. I have been trying to display these fields on the page but with no success.
The method I'm using is this:

<?php the_title();?>

<?php echo get_post_meta(get_the_ID(), 'subtitle', TRUE); ?>

Here is a link to the page.
Below the
 on the page is a list of all the meta created. The ONLY one of the fields which will display is 'price' for some strange reason.
Anyone have any idea what I'm missing?

A: use this code for solving your problem.
$key_name = get_post_custom_values($key = 'Key Name');
echo $key_name[0];

A: Well, you are using:
get_post_meta(get_the_ID(), 'subtitle', TRUE);

So, you are saying to Wordpress to get the meta value of the 'subtitle' field and that the returned value be in format of string. See get_post_meta() docu.
To get all meta data of a post you should use get_post_custom() function instead. For example, if you are inside the loop:
$custom = get_post_custom();
foreach($custom as $key => $value) {
     echo $key.': '.$value.'
';
}

This will return all meta data of the post. If you want to check, for example, the "price" meta field:
if(isset($custom['price'])) {
    echo 'Price: '.$custom['price'][0];
}


text:
Q: Determine Barcode type by String representation Is there any way to determine Linear Barcode type by it's string representation? I mean, I have a recognized barcode "063211012927" and what to know what type is that? (In that case it's UPC-A.) Implementation in C# would be great, but algorithm also appreciated.

A: No, because that string is simply the decoded text, it says nothing of the barcode symbology which was used to store it.
You could make some assumptions based on size and content (i.e., max data lengths and the fact that there are only numbers), but you will be wrong quite often and it's not what I would call a "solution".


text:
Q: use fastify to download big files as multipart I have a code that download big objects from S3 using multipart download. I am working now on a microservice that will hide all the s3 operations and in the future will give me the flexibility to change to any object store.I have created a nodejs service using fastify, how can I add the support of multipart download using fastify?

A: You should rewrite the parts logic of AWS-S3 service in server and client side too.
The GetObject accepts the Range
header that will limit the download of that piece of file.
So the client need to know how many pieces compose a file, using the ListParts
API usually. Then it can call the GetObject
with the range parameter:
 var params = {
  Bucket: "examplebucket",
  Key: "SampleFile.txt",
  Range: "bytes=0-9"
 };
 s3.getObject(params, function(err, data) {...

So your Fastify server should proxy at latest those 2 services to let the client download
simultaneously many pieces of the file and then merge them.


text:
Q: Can't install mysql gem on OS X 10.6 Snow Leopard Server Having trouble installing mysql ruby gem on OS X Server 10.6.
This is the error I'm getting:
macserver:~ admin$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-       config=/usr/bin/mysql_config

Building native extensions. This could take a while…

ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/Users/admin/.rvm/rubies/ruby-1.8.7-p371/bin/ruby extconf.rb --with-mysql-config=/usr/bin/mysql_config

checking for mysql_ssl_set()… yes
checking for rb_str_set_len()… yes
checking for rb_thread_start_timer()… yes
checking for mysql.h… no
checking for mysql/mysql.h… no

*** extconf.rb failed ***

Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/admin/.rvm/rubies/ruby-1.8.7-p371/bin/ruby
--with-mysql-config

Gem files will remain installed in /Users/admin/.rvm/gems/ruby-1.8.7-p371/gems/mysql-2.9.1 for inspection.
Results logged to /Users/admin/.rvm/gems/ruby-1.8.7-p371/gems/mysql-2.9.1/ext/mysql_api/gem_make.out

Any help is appreciated.

A: You need to have the development headers for MySQL installed. The default binary package from Oracle does not include these.
If you're using either Homebrew or MacPorts, both of these will be able to provide the required files.


text:
Q: Can't get PHP's openssl_encrypt to match output from aes_encrypt in C I'm not a programmer by trade, so please bear with me...
I have an application I am using that unfortunately stores passwords in plaintext in MySQL, which is something I do not want.  As the program does makes use of the OpenSSL library, I have access to the aes functions.
Below I've cobbled together demo code that uses these functions to encrypt a test string and uses MD5 to hash it (since the encrypted text is binary):
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/aes.h>
#include <openssl/md5.h>

char *str2md5(const char *str, int length) {
    int n;
    MD5_CTX c;
    unsigned char digest[16];
    char *out = (char*)malloc(33);

    MD5_Init(&c);

    while (length > 0) {
        if (length > 512) {
            MD5_Update(&c, str, 512);
        } else {
            MD5_Update(&c, str, length);
        }
        length -= 512;
        str += 512;
    }

    MD5_Final(digest, &c);

    for (n = 0; n < 16; ++n) {
        snprintf(&(out[n*2]), 16*2, "%02x", (unsigned int)digest[n]);
    }

    return out;
}

int main(int argc, char* argv[]) {
        AES_KEY aesKey_;
        unsigned char userKey_[16];
        unsigned char in_[16];
        unsigned char out_[16];

        strcpy(userKey_,"1234567890abcdef");
        strcpy(in_,"texttoencrypt");

        fprintf(stdout,"Original message: %s\n", in_);
        AES_set_encrypt_key(userKey_, 128, &aesKey_);
        AES_encrypt(in_, out_, &aesKey_);

        char *output = str2md5(out_, strlen(out_));
        fprintf(stdout,"MD5 of Encrypted message: %s\n", output);

        AES_set_decrypt_key(userKey_, 128, &aesKey_);
        AES_decrypt(out_, in_,&aesKey_);
        fprintf(stdout,"Recovered Original message: %s\n", in_);
        return 0;
}

This outputs:
Original message: texttoencrypt
MD5 of Encrypted message: 3675b450ae0415e5a8521b9bb7ee01ba
Recovered Original message: texttoencrypt

Now in PHP I am using this code to generate the various AES-128 encrypted strings and similarly, MD5ing the result:
<?php

$methods = openssl_get_cipher_methods();

$plain = "texttoencrypt";
$password = "1234567890abcdef";

foreach ($methods as $method) {

        if (preg_match('/AES-128/', $method)) {
                $encrypted = openssl_encrypt($plain, $method, $password);
                $decrypted = openssl_decrypt($encrypted, $method, $password);
                echo $method . ' : ' . md5($encrypted) . ' ; ' . $decrypted . "\r\n";
        }
}
?>

Output:
AES-128-CBC : 08d6f8e2ae21a7a506fabf91adcc3b63 ; texttoencrypt
AES-128-CFB : ce10ea28d7607bd6514e478e025e47c6 ; texttoencrypt
AES-128-CFB1 : 6adde484b8bee26f9b1ca7856634586d ; texttoencrypt
AES-128-CFB8 : aea100f1473c0a3d6380dd0f28585e19 ; texttoencrypt
AES-128-ECB : 08d6f8e2ae21a7a506fabf91adcc3b63 ; texttoencrypt
AES-128-OFB : ce10ea28d7607bd6514e478e025e47c6 ; texttoencrypt

Unfortunately, I am not getting a match to the 3675b450ae0415e5a8521b9bb7ee01ba generated by the C code.  I've tried just about every comment I've seen on the PHP manual pages and here on SE, but can't get a match.
I can't modify the C code, just the PHP... so any pointers on how to get PHP to match the C output is certainly appreciated!

A:  AES_encrypt(in_, out_, &aesKey_);

 char *output = str2md5(out_, strlen(out_));

Who is taking care of null terminating out so strlen works as expected? Certainly not AES_encrypt.
Moreover in strcpy(userKey_,"1234567890abcdef"); you are copying 17 bytes of data (you have to count the null terminator) to an array 16 of char.


text:
Q: Convergence of $\int_1^\infty \! \sin^\alpha(1/x) \, \mathrm{d}x$ for $\alpha > 1$ How do I show that for $\alpha > 1$ the integral $\displaystyle  \int_1^\infty \! \sin^\alpha(1/x) \, \mathrm{d}x$ converges?
I am given the hint:

Compare with the integral $\displaystyle \int_1^\infty \! x^{-\alpha} \, \mathrm{d}x$.

A: What basically your hint means that if $f$ and $g$ are two non-negative functions such that $f \leq g$ and $\int g$ converges then $\int f$ converges. This is basically the comparison test.
Just evaluate your integral:
\begin{align*}
\lim_{t \to \infty} \int\limits_{1}^{t} \frac{1}{x^{\alpha} } \ \textrm{dx} &=\lim_{t \to \infty} \Biggl[\frac{x^{-\alpha +1}}{-\alpha+1}\Biggr]_{1}^{t}
\end{align*}

A: The integral
\begin{equation} \int _{1}^{\infty} \frac{1}{x^\alpha}  \ \textrm{dx} \end{equation}
converges, as show @Chandru1. Moreover,
$$ \lim_{x\to \infty} \left( \frac{\sin\left( \frac{1}{x} \right)}{\frac{1}{x}} \right)^\alpha = 1, $$
therefore your integral and $\int _{1}^{\infty} \frac{1}{x^\alpha}  \ \textrm{dx}$ have the same behavior, i.e., your integral converges.


text:
Q: Why is racket macro's lambda not returning anything? I'm trying to make a basic journal entry language in racket for a class on DSLs (specifically beautiful racket, the training version).  I have a correct parser and reader, but I am having difficulty with my macros.  Below is my expander code.  I am trying to have my DSL be functional rather than imperative (I know I could have a global ledger value that I update, but it is not in the spirit of this project).
I have included the code for the important functions in this module.  A lot of them are based off of this tutorial: https://beautifulracket.com/bf/a-functional-expander.html
Right now, when I run my code on this text:
[1920-02-19<equipment-20000><cash-10000,stock-10000>]
[2020-12-20<insurance-500><cash-500>]

I get this output from my display calls:
(#<date 1920-02-19> debits credits)()(#<date 2020-12-20> debits credits)#<void>#<void>

It looks like my lambda is not returning the updated ledger in my journal-entry macro.  My knowledge isn't great when it comes to Racket, so I'm not sure what I'm doing wrong here.  Any tips?

(define (fold-funcs apl ac-funcs)
  (for/fold ([current-apl apl])
            ([ac-func (in-list ac-funcs)])
    (ac-func current-apl)
    (display current-apl)))

(define-macro (ac-line ENTRIES ...)
  #'(begin
      (define ledger empty)
      (set! ledger (fold-funcs ledger (list ENTRIES ...)))
      (display ledger)))
(provide ac-line)

(define-macro (journal-entry "[" INFO ... "]")
  #'(lambda (ledger)
      (define entry (list INFO ...))
      (define dt (first entry))
      (set! entry (rest entry))
      (define d (first entry))
      (set! entry (rest entry))
      (define c (first entry))
      (define e (list dt d c))
      (display e)
      (set! ledger (cons e ledger))
      ledger
      ))
(provide journal-entry)


text:
Q: How does spontaneous symmetry breaking happen? To be specific, let us consider the double-well potential. If we study quantum mechanics, i.e. a particle in such a potential, then we know that there is no spontaneous symmetry breaking but a energy-level splitting. The ground state is presumably a superposition of the local minima. Now if we consider a quantum field in a box with finite volume $V$, still there is no SSB and the ground state is also a superposition of the local minima. If we now take $V\rightarrow \infty$, then we know that there must be SSB. I was wondering how the superposition state of the two minima reduces to one of them as we take the limit?

A:
how the superposition state of the two minima reduces to one of them as we take the limit?

We can retain the symmetric vacuum state when taking the limit, and the result is mathematically well-defined (if the symmetry is discrete). The problem is that the result violates a physical principle, namely the cluster property.
Roughly, the cluster property says that the vacuum expectation value of a product of fields, like $\langle 0|\phi(x)\phi(y)|0\rangle$, should factorize into a product of vacuum expectation values, like $\langle 0|\phi(x)|0\rangle\,\langle 0|\phi(y)|0\rangle$, as the points $x,y$ become sufficiently separated from each other. The SSB vacuum states have this property, but the symmetric vacuum state does not. Both are well-defined (for discrete SSB), and both have the same minimum energy, but only the SSB vacua satisfy the cluster property.
To enforce this property when taking the infinite-volume limit, we can add a small explicit symmetry-breaking term to the action, then take the infinite-volume limit, and then remove the explicit symmetry-breaking term.
These references explain how the cluster property selects an SSB vacuum state:

*

*In the context of spin systems (like the Ising model): Section 23.3, "Order Parameter and Cluster Properties", of Zinn-Justin's book Quantum Field Theory and Critical Phenomena.

*In the context of QFT: Section 19.1 in Weinberg, The Quantum Theory of Fields, Volume II.
Weinberg's argument is reviewed below.
 Why the symmetric vacuum violates the cluster property
Suppose that the symmetry in question is a $\mathbb{Z}_2$ symmetry (double-well potential).
Let $|{v}\rangle$ be a candidate for a vacuum state. In particular, $|{v}\rangle$ must have zero momentum, which implies
$$
\newcommand{\la}{\langle}
\newcommand{\ra}{\rangle}
 \la\psi|\phi(x)|{v}\ra =
 \la\psi|\phi(0)|{v}\ra.
\tag{1}
$$
Now consider the correlation function $\la{v}|\phi(x)\phi(y)|{v}\ra$. We can write this as
$$
 \la{v}|\phi(x)\phi(y)|{v}\ra
 =
 \la{v}|\phi(x)I\phi(y)|{v}\ra
\tag{2}
$$
where the identity operator $I$ can be written
$$
 I
 = \sum_{k=1,2}|{v}_k\ra\,\la{v}_k|
 +\sum_n \int dp\ |n,p\ra\,\la n,p|
\tag{3}
$$
where $|{v}_{1,2}\ra$ is any orthonormal basis for the set of lowest-energy states and where sum/integral term accounts for all other states orthogonal to these. The argument $p$ is momentum, and $n$ is all other degrees of freedom. Insert (3) into the right-hand side of (2) and use translation symmetry to get
\begin{align}
 \la{v}|\phi(x)\phi(y)|{v}\ra
 &=
 \sum_{k=1,2}\la{v}|\phi(0)|{v}_k\ra
  \,\la{v}_k|\phi(0)|{v}\ra
\\
 &+\sum_n \int dp\ e^{ip(x-y)}
 \la{v}|\phi(0)|n,p\ra\,\la n,p|\phi(0)|{v}\ra.
\tag{4}
\end{align}
Now assume that the quantities in the integrand are smooth enough so that the integral goes to zero as $|x-y|\to\infty$, leaving
\begin{align}
 \lim_{|x-y|\to\infty}\la{v}|\phi(x)\phi(y)|{v}\ra
 &=
 \sum_{k=1,2}\la{v}|\phi(0)|{v}_k\ra
  \,\la{v}_k|\phi(0)|{v}\ra.
\tag{5}
\end{align}
The $2\times 2$ matrix with components
$$
 M_{jk} := \la{v}_j|\phi(0)|{v}_k\ra
\tag{6}
$$
is not necessarily diagonal, but it is hermitian and therefore can be diagonalized by choosing a new basis $|{v}_{1,2}\ra$ if needed. Equation (5) shows that the cluster property is satisfied if and only if $|{v}\ra$ is one of the basis states in a basis that diagonalizes $M$. The "only if" part assumes that the eigenvalues of $M$ are distinct and non-zero, which requires that $\phi$ is not invariant under the symmetry in question (it must be an "order paraemter").
Altogether, this shows that the cluster property holds only for states that diagonalize the matrix (6), which in turn must be SSB states if the eigenvalues of $M$ are distinct and non-zero.


text:
Q: What is the purpose of having two folders in Azure Data-lake Analytics I am a newbie to Azure Data lake.
The below screenshot has 2 folders (Storage Account and Catalog), one for Datalake analytics and other data lake store.
My Question is why is the purpose of each folder and why are we using U-SQL for transformations when this can be done in the data factory.
Please explain the data flow process from the data store to the data lake.
enter image description here
Thanks you,
Addy

A: I have addressed your query on MSDN thread:
https://social.msdn.microsoft.com/Forums/en-US/f8405bdb-0c85-4d37-8f2e-0dab983c7f94/what-is-the-purpose-of-having-two-folders-in-azure-datalake-analytics?forum=AzureDataLake
Hope this helps.


text:
Q: How to keep the colors of text printed before the color comand in batch was executed I want to change the colors for the rest of the text promted by CMD and keep the colors for the text printed before color command was executed.
example:
@echo off
echo hello world
color 0A

The problem with this code is that it will turn the hello world text to green as well as all the other text in the command promt.

A: This code can did the trick :
When you call something like this : Call :Color 0B "Hello world !" 0
The second argument equal to 0 means you stay in the same line
If you choose the second argument equal to 1 like this one :
Call :Color 0e "Not in same line !" 1
@echo off
Title Example with multicolors
Call :Color 0A "Hello world !" 0
Call :Color 0D "Hello world in the same line !" 0
echo(
Call :Color 0C "Hello world !" 1
Call :Color 0E "Not in same line !" 1
Pause
::***********************************
:Color
for /F "delims=." %%a in ('"prompt $H. & for %%b in (1) do rem"') do set "BS=%%a"
set nL=%3
if not defined nL echo Requires third argument & Pause > nul & goto :Eof
if %3 == 0 (
    <nul set /p ".=%BS%">%2 & Findstr /V /A:%1 /R "^$" %2 nul & Del %2 2>&1
    goto :Eof
) else if %3 == 1 (
    echo %BS%>%2 & Findstr /V /A:%1 /R "^$" %2 nul & Del %2 2>&1
    goto :Eof
)
::***********************************

A: You may "change the colors for the rest of the text promted by CMD" (that is not the same of "show text in a given color") with the aid of PowerShell, but the method is s-l-o-w...
@echo off

echo Standard color
call :SetColor Yellow/Blue
set /P "=Hello" < NUL
call :SetColor Magenta/DarkGreen
echo  World!
goto :EOF

:SetColor fore/back
for /F "tokens=1,2 delims=/" %%a in ("%~1") do (
   PowerShell $host.UI.RawUI.BackgroundColor = '%%b'; $host.UI.RawUI.ForegroundColor = '%%a'
)
exit /B

The colors set via this method are used in all posterior text displayed in the cmd.exe window!
Available color names:
Black           DarkGray
DarkBlue        Blue
DarkGreen       Green
DarkCyan        Cyan
DarkRed         Red
DarkMagenta     Magenta
DarkYellow      Yellow
Gray            White


text:
Q: Grpc.Net vs Grpc.Core: What are the server side differences? It seems like Grpc.Net requires ASP.NET Core in order to host a service whereas Grpc.Core doesn't? What are the differences? Which one is preferred?
Grpc.Net
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }

    app.UseRouting();

    app.UseEndpoints(endpoints =>
    {
        // Communication with gRPC endpoints must be made through a gRPC client.
        // To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909
        endpoints.MapGrpcService<GreeterService>();
    });
}

Grpc.Core
Server server = new Server
{
    Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
    Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
};
server.Start();

A: Grpc.Core is a library that is based on the native implementation of gRPC. It is basically a binding to the native library that makes it possible to use "the original" gRPC directly for both client and server purposes.
Grpc.AspNetCore is a managed reimplementation for gRPC that is built on top of the Kestrel server stack. This makes Grpc.AspNetCore in general a lot more efficient compared to the native implementation. Being built for ASP.NET Core itself, it also integrates a lot more nicely into ASP.NET Core applications which also allows you to host gRPC services side-by-side with other ASP.NET Core endpoints. In contrast, it may not support all gRPC features and is also limited to the server-side aspect.


text:
Q: npm run build gatsby: "Page data from page-data.json for the failed page "/404/"..." When npm building my gatsby project, I get the following:
Page data from page-data.json for the failed page "/404/": {
  "componentChunkName": "component---src-pages-404-js",
  "path": "/404/",
  "result": {
    "pageContext": {}
  },
  "staticQueryHashes": []
}

failed Building static HTML for pages - 3.357s

 ERROR #95313

Building static HTML failed for path "/404/"

See our docs page for more info on this error: https://gatsby.dev/debug-html

  21 |     };
  22 |     this.defaultAttributeTypes = {
> 23 |       position: 'Float32Array',
     | ^
  24 |       normal: 'Float32Array',
  25 |       color: 'Float32Array',
  26 |       uv: 'Float32Array'

I don't know what it means, by searching the internet, I found this question Page data from page-data.json for the failed page "/", I learned that this error could be caused by using the window object, so  I tried to check for the window use in my code, the problem was that I use react three fiber, and it may be using this document object,
Then, the same answer showed that one could bypass this error by adding a code to the gatsby-node.js (it doesn't say by I guess), basically exporting onCreateWebpackConfig (in this file I'm exporting sourceNodes and onCreateWebpackConfig, hope this doesn't cause any error)
The problem persists.
I also have a 404 page
import React from "react";

const NotFoundPage = () => {
    return
Sorry, the page you requested was not found
;
};

export default NotFoundPage;

Any hints please, I really don't know how to fix it
****** EDIT ******
Ferran asked me for my onCreateWebpackConfig, here it is:
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
    if (stage === "build-html" || stage === "develop-html") {
        actions.setWebpackConfig({
            module: {
                rules: [
                    {
                        test: /react-three-fiber/,
                        use: loaders.null(),
                    },
                ],
            },
        });
    }
};

I typed "test: /react-three-fiber/,", but I'm not sure of it, I'm supposed to type the "bad module", I don't know, I only know my components

A: As you pointed out when you deal with third-party modules that use window or other global objects you need to add a null loader to webpack configuration to bypass the server-side compilation using onCreateWebpackConfig. In your case, since the package name is @react-three/fiber, try something like:
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
  actions.setWebpackConfig({
    module: {
      rules: [
        {
          test: /@react-three\/fiber/,
          use: loaders.null(),
        },
      ],
    },
  });
};

Keep in mind that test is a regular expression (that's why is between slashes, /) and it matches the folder name under node_modules. Be sure that the folder name matches the regular expression.
Answering the duplicity of configuring gatsby webpack to don't check base objects like window when compiling a component

But I also use canvas, window.innerWidth, and whatnot, in a component
How do I set another rule to indicate webpack to not throw that error
when checking a component?

For third-party dependencies you just need to keep adding libraries to the previous null-loader configuration:
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
  actions.setWebpackConfig({
    module: {
      rules: [
        {
          test: /@react-three\/fiber/,
          use: loaders.null(),
        },
        {
          test: /other-library/,
          use: loaders.null(),
        },
      ],
    },
  });
};

Keeping in mind what I said, /other-library/ stands for a folder name inside node_modules.
For the internal use of window object, you just need to add the following condition in before using it:
if(typeof window !== "undefined"){
  //your window calculation
}

Depending on when and how you are using window, you may not need to wrap it in this condition (i.e: if you use window in a useEffect that is not triggered until the DOM is loaded where window will be always set).
All these approaches can be found at Gatsby docs: https://www.gatsbyjs.com/docs/debugging-html-builds/

By the way, I'm having two exports in gatsby-node.js:
exports.sourceNodes = async ({... for a data that I use with a
graphql, and exports.onCreateWebpackConfig =... described here,
is there any problem with that?

Of course not, is just a file exporting functions. It's how it is supposed to work and that's the reason why you have a bunch of APIs available.


text:
Q: не возвращаются данные отправленные на сервер В чате отправляя текст на сервер,оттуда отправляю в базу данных,и хочу вернуть его сразу на клиентскую страницу,но данные выводятся только после перезагрузки сервера, как исправить ситуацию?
сервер app.js
   io.on('connection', async function (socket) {
   var name = 'U' + (socket.id).toString().substr(1, 4);
   socket.emit('allMessage', await con.then(function (res) {

     return res;
    })); // При соеденении я на клиенте получаю все сообщения.

   socket.broadcast.emit('newUser', name);

   socket.emit('userName', name);

   socket.on('message', async function (msg) {
    InData.insert(msg, name, "Sex"); // Добовляю в базу данных
    socket.emit('messageToclient',await con.newSelect.then(function (res) {
        return res; // После добовления в базу данных, снова делаю запрос
    //что-бы язьять все данные  отправляю на клиента. Если посмотреть в
    //бд,информация появилась. Если поставить вывод на самом сервере через
    //console.log,то информация так же не обновляется.
    }));

});
});

main.js
var SelectChat = angular.module('SelectChat',
['ngRoute']).config(['$routeProvider',function($routeProvider){
$routeProvider.when("/",{
templateUrl: 'index.html',
controller: 'NameInfo'
});
}]).factory('socket',['$rootScope',function ($rootScope) {
var port = 8080;
var socket = io.connect('http://localhost:' + port);

 return {
on: function(eventName, callback) {
    socket.on(eventName,function(data){
        $rootScope.$apply(function(){callback(data)});
    });
},
emit: function(eventName,data){
    socket.emit(eventName,data);
    console.log(data);
 }
 }
}]);
SelectChat.controller('NameInfo',function($scope,socket){

socket.on('userName',function(userName){
$scope.name = userName;
});

socket.on('newUser',function(newUser){
//$scope.newUsername = newUser;
});

socket.on('allMessage',function(date){
$scope.text = date.rows;
});

socket.on('messageToclient',function(date){

 $scope.text = date.rows;
console.log(date.rows);

});

$(document).on('click','button',function(){

var message = $('input').val();
socket.emit('message',message);
$('input').val(null);
 });

});

index.html

<meta charset="utf-8">
<title>chat</title>

<link href="stylesheets/main.css" rel="stylesheet">

Chat

{{texts.text}}/

<input type="text" name="text" size="100">
<button type="button" name="button" id="sendMsg">Отправить</button>


text:
Q: Unable to add a core in Solr 3.6 I'm trying to add multiple cores in solr 3.6 but i'm unable to do it. I wrote the following in solr.xml file
<solr persistent="true" sharedLib="lib">
    <cores adminPath="/admin/cores" defaultCoreName="collection1">
         <core name="collection1" instanceDir="." />
    </cores>
    <core name="core1" instanceDir="./core1">
         <property name="dataDir" value="./core1/data" />
    </core>
</solr>

core1 is the new core i want to create, I copied the config folder of the default core into core1, when I try to access localhost:8983/solr/core1/admin I get 404 error.

A: New core should be defined within the cores tag :-
<solr persistent="true" sharedLib="lib">
    <cores adminPath="/admin/cores" defaultCoreName="collection1">
         <core name="collection1" instanceDir="." />
         <core name="core1" instanceDir="./core1">
              <property name="dataDir" value="./core1/data" />
         </core>
    </cores>
</solr>


text:
Q: How do I stop iteration in Java using Apache POI I am reading a particular excel template in Java using Apache POI. There are some unwanted fields at the bottom (like a small guide) which I need to skip. So I want to stop the iteration whenever POI finds that a row is completely blank and hence the fields at the bottom will be skipped automatically.
I found many ways to handle a blank CELL but my requirement is for a complete row.

A: Following code will iterate through the cells of a row. it will keep a count for each cell it encounters(cellCount). another couont(nullCount), is incremented only if the cell is blank. if both these counts are equal, row is empty.
boolean isEmptyRow = false;
            int cellCount = 0;
            int nullCount = 0;

                Iterator<Cell> cellIterator = row.iterator();
                while (cellIterator.hasNext()) {
                    cellCount++;
                    Cell cell = (Cell) cellIterator.next();
                    if ((cell == null)
                            || ((cell != null) && (cell.getCellType() == Cell.CELL_TYPE_BLANK))) {
                        nullCount++;
                    }
                }

            if ((cellCount != 0) && (nullCount != 0)
                    && (cellCount == nullCount)) {        //If nullCount & cellCouont are same, Row is empty
                isEmptyRow = true;
            }


text:
Q: What is the value of ConfigurationPropertyAttribute.DefaultValue when a default value has not been specified? The default value of the following configuration property is obvious. It is "Arial":
  [ConfigurationProperty("name", DefaultValue = "Arial", IsRequired = true)]
  public string Name
  {
     get { return (string)this["name"]; }
     set { this["name"] = value; }
  }

But, what if I remove the "DefaultValue" part, as follows?
  [ConfigurationProperty("name", IsRequired = true)]
  public string Name
  {
     get { return (string)this["name"]; }
     set { this["name"] = value; }
  }

In Visual Studio, the value of the DefaultValue property on the attribute is listed as {object}, and if I call .ToString() on it, I get "System.Object".
How do I check whether or not a default value has actually been specified on the attribute?

A: According to the reference source, it looks like an object is created privately, meaning it cannot be accessed:
private object _DefaultValue = ConfigurationElement.s_nullPropertyValue;

(source: http://referencesource.microsoft.com/#System.Configuration/System/Configuration/ConfigurationPropertyAttribute.cs,31)
However, I was able to fix the problem as follows:
var isDefaultSpecified = propertyAttribute.DefaultValue != null && propertyAttribute.DefaultValue.GetType() != typeof(object);


text:
Q: Crystal Reports: Is it possible to sum for more than one column? I work on an accounting project in .NET.
I want to sum all transaction and its opening balances.
I use summary but it Allows only one column..

A: You can summarize within formulas, so long as the formula field is present in the report footer.  When using Sum() CR knows to evaluate the expression for all records returned.
So you would create a formula for the report footer, and the formula code would be something like:
Sum({@TransactionAmt1}) + Sum({Transactions.Amount}) + Sum({@AnotherFormula});


text:
Q: TWGL Camera rotation not expected I'm so confused,
I am trying to use mouse and keyboard controls (With WebGL2), and I'm trying to rotate and move the camera with these four functions:
m4.rotateX(m, angleInRadians, dst);
m4.rotateY(m, angleInRadians, dst);
m4.rotateX(m, angleInRadians, dst);
m4.translate(m, v, dst);

(Provided by twgl)
And it works fine with X, and Y (When seperate), but when added it provides weird output (As of a gyroscope)
Heres what I use to rotate the camera and create the scene:
(() => {
    class Camera {
        static setPosRot(x, y, z, cx, cy, cz, camera) {
/*
x,y,z = Players X,Y,Z Position
cx,cy,cz = Players X,Y,Z Rotation
*/
            m4.identity(camera);
            m4.translate(camera, [
                x,
                y,
                z
            ], camera);
            m4.rotateX(camera, ((cx - 90) * Math.PI) / 180, camera);
            m4.rotateY(camera, (cy * Math.PI) / 180, camera);
            m4.rotateZ(camera, (cz * Math.PI) / 180, camera);
            return camera;
        }
    }

    class Block {
        #texture;
        #x;
        #y;
        #z;

        set texture(texture) {
            this.#texture = texture;
        }

        get getTexture() {
            return texture;
        }

        set x(x = 0) {
            x = parseInt(x);
            if (isNaN(x)) {
                console.warn(`Invalid X pos, exiting`);
                return;
            }
            this.#x = x;
            return;
        }

        set y(y = 0) {
            y = parseInt(y);
            if (isNaN(y)) {
                console.warn(`Invalid Y pos, exiting`);
                return;
            }
            this.#y = y;
            return;
        }

        set z(z = 0) {
            z = parseInt(z);
            if (isNaN(z)) {
                console.warn(`Invalid Z pos, exiting`);
                return;
            }
            this.#z = z;
            return;
        }

        get getX() {
            return this.#x;
        }

        get getY() {
            return this.#y;
        }

        get getZ() {
            return this.#z;
        }

        set pos(pos = [
            0,
            0,
            0
        ]) {
            var x = parseInt(pos[0]);
            var y = parseInt(pos[1]);
            var z = parseInt(pos[2]);
            if (isNaN(x)) {
                console.warn(`Invalid X pos, setting to default.`);
                x = 0;
            }
            if (isNaN(y)) {
                console.warn(`Invalid Y pos, setting to default.`);
                y = 0;
            }
            if (isNaN(z)) {
                console.warn(`Invalid Z pos, setting to default.`);
                z = 0;
            }
            this.#x = x;
            this.#y = y;
            this.#z = z;
            return;
        }

        get getPos() {
            return [
                this.#x,
                this.#y,
                this.#z
            ]
        }

        render() {
            m4.identity(Render.world);
            m4.translate(Render.world, [
                this.#x * 3,
                this.#y * 3,
                this.#z * 3
            ], Render.world);

            m4.multiply(Render.viewProjection, Render.world, Render.worldViewProjection);
            m4.inverse(Render.world, Render.worldInverse);
            m4.transpose(Render.worldInverse, Render.worldInverseTranspose);

            twgl.setBuffersAndAttributes(Render.gl, Render.pinfo, Render.binfo);
            twgl.setUniforms(Render.pinfo, {
                u_worldViewProjection: Render.worldViewProjection,
                u_worldInverseTranspose: Render.worldInverseTranspose,
                u_color: [
                    (this.#x + 2) / 3,
                    (this.#y + 2) / 3,
                    (this.#z + 2) / 3,
                    1
                ],
                u_lightDir: Render.lightDir,
            });
            twgl.drawBufferInfo(Render.gl, Render.binfo);
        }

        constructor(x = 0, y = 0, z = 0) {
            var x = parseInt(x);
            var y = parseInt(y);
            var z = parseInt(z);
            if (isNaN(x)) {
                console.warn(`Invalid X pos, setting to default.`);
                x = 0;
            }
            if (isNaN(y)) {
                console.warn(`Invalid Y pos, setting to default.`);
                y = 0;
            }
            if (isNaN(z)) {
                console.warn(`Invalid Z pos, setting to default.`);
                z = 0;
            }
            this.#x = x;
            this.#y = y;
            this.#z = z;
            return;
        }
    }

    class Render {
        static vertexShader = [
`precision highp float;`,
`uniform mat4 u_worldViewProjection;`,
`uniform mat4 u_worldInverseTranspose;`,
`attribute vec4 position;`,
`attribute vec3 normal;`,
`varying vec3 v_normal;`,
`void main() {`,
    `gl_Position = u_worldViewProjection * position;`,
    `v_normal = (u_worldInverseTranspose * vec4(normal, 0)).xyz;`,
`}`
        ].join(`\n`);

        static fragmentShader = [
`precision highp float;`,
`varying vec3 v_normal;`,
`uniform vec3 u_lightDir;`,
`uniform vec4 u_color;`,
`void main() {`,
`vec3 norm = normalize(v_normal);`,
    `float light = dot(u_lightDir, norm) * .5 + .5;`,
    `gl_FragColor = vec4(u_color.rgb * light, u_color.a);`,
`}`
        ].join(`\n`);

        static canvas;
        static gl;
        static gl2d;
        static program;

        static width = 1920;
        static height = 1080;

        static pinfo;
        static binfo;

        static #cx = 90;
        static #cy = 0;
        static #cz = 0;

        static #x = 0.0;
        static #y = 0.0;
        static #z = 0.0;

        static webgloptions = {
            powerPreference: `default`,
            antialias: true,
            depth: true
        };

        static load() {
this.width = document.documentElement.clientWidth;
            this.height = document.documentElement.clientHeight;
            this.canvas = document.createElement(`canvas`);
            this.canvas.id = `root`;
            this.canvas.width = this.width;
            this.canvas.height = this.height;
            this.canvas.style.width = this.width;
            this.canvas.style.height = this.height;
            document.body.appendChild(this.canvas);
            this.canvas = document.getElementById(`root`);
            this.canvas.addEventListener(`contextmenu`, event => event.preventDefault());
            this.gl = this.canvas.getContext(`webgl2`, this.webgloptions);
            this.gl2d = this.canvas.getContext(`2d`, this.webgloptions); // Rendering UI
            if (this.gl == null || this.gl == undefined || !this.gl) {
                console.warn(`WebGL2 not supported, attempting to use WebGL, expect bugs.`);
                this.gl = this.canvas.getContext(`webgl`, this.webgloptions) || this.canvas.getContext(`experimental-webgl`, this.webgloptions);
                if (this.gl == null || this.gl == undefined || !this.gl) {
                    console.error(`Neither WebGL nor WebGL2 is supported, exiting`);
                    return true;
                }
            }
            this.pinfo = twgl.createProgramInfo(this.gl, [
                this.vertexShader,
                this.fragmentShader
            ]);
            this.binfo = twgl.primitives.createCubeBufferInfo(this.gl, 1);
            this.gl.clearColor(0.0, 0.0, 0.0, 1.0);
            this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
            return false;
        }

        static projection = m4.identity();
        static camera = m4.identity();
        static view = m4.identity();
        static viewProjection = m4.identity();
        static world = m4.identity();
        static worldViewProjection = m4.identity();
        static worldInverse = m4.identity();
        static worldInverseTranspose = m4.identity();
        static lightDir = v3.normalize([1, 2, 3]);

        static render() {
            requestAnimationFrame(this.render.bind(this));
            var now = Date.now() * 0.001;
            this.#deltaTime = now - this.#then;
            this.#then = now;
            this.gl.clearColor(0.0, 0.0, 0.0, 1.0);
            this.gl.clearDepth(1.0);
            this.gl.viewport(0, 0, this.width, this.height);
            this.gl.enable(this.gl.DEPTH_TEST);
            this.gl.enable(this.gl.CULL_FACE);
            this.gl.depthFunc(this.gl.LEQUAL);
            this.gl.useProgram(this.pinfo.program);
            this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
            const fov = (this.#fov * Math.PI) / 180;
            const aspect = this.gl.canvas.clientWidth / this.gl.canvas.clientHeight;
            m4.perspective(fov, aspect, 0.0, 100.0, this.projection);
            /*
            m4.axisRotate(this.camera, m4.getAxis(this.camera, 0), (this.#cx - 90) * Math.PI / 180, this.camera);
            m4.axisRotate(this.camera, m4.getAxis(this.camera, 1), this.#cy * Math.PI / 180, this.camera);
            m4.axisRotate(this.camera, m4.getAxis(this.camera, 2), this.#cz * Math.PI / 180, this.camera);
            */
            /*
            m4.rotateX(this.camera, ((this.#cx - 90) * Math.PI) / 180, this.camera);
            m4.rotateY(this.camera, (this.#cy * Math.PI) / 180, this.camera);
            m4.rotateZ(this.camera, (this.#cz * Math.PI) / 180, this.camera);
            */

            this.camera = Camera.setPosRot(this.#x, this.#y, this.#z, this.#cx, this.#cy, this.#cz, this.camera);

            m4.inverse(this.camera, this.view);

            m4.multiply(this.projection, this.view, this.viewProjection);

            for (let z = -1; z <= 1; ++z) {
                for (let y = -1; y <= 1; ++y) {
                    for (let x = -1; x <= 1; ++x) {
                        if (x === 0 && y === 0 && z === 0) {
                            continue;
                        }

                        const block = new Block();
                        block.pos = [
                            x,
                            y,
                            z
                        ];
                        Render.addObj(block);
                    }
                }
            }
        }
    }
})();

(Taken from this website (Runnable))

A: Twgl does not rotate stuff like mat4 example:
Twgl:
function rotateX(m, angleInRadians, dst) {
  dst = dst || new MatType(16);
  const m10 = m[4];
  const m11 = m[5];
  const m12 = m[6];
  const m13 = m[7];
  const m20 = m[8];
  const m21 = m[9];
  const m22 = m[10];
  const m23 = m[11];
  const c = Math.cos(angleInRadians);
  const s = Math.sin(angleInRadians);
  dst[4] = c * m10 + s * m20;
  dst[5] = c * m11 + s * m21;
  dst[6] = c * m12 + s * m22;
  dst[7] = c * m13 + s * m23;
  dst[8] = c * m20 - s * m10;
  dst[9] = c * m21 - s * m11;
  dst[10] = c * m22 - s * m12;
  dst[11] = c * m23 - s * m13;
  if (m !== dst) {
    dst[0] = m[0];
    dst[1] = m[1];
    dst[2] = m[2];
    dst[3] = m[3];
    dst[12] = m[12];
    dst[13] = m[13];
    dst[14] = m[14];
    dst[15] = m[15];
  }
  return dst;
}

function rotateY(m, angleInRadians, dst) {
  dst = dst || new MatType(16);
  const m00 = m[0 * 4 + 0];
  const m01 = m[0 * 4 + 1];
  const m02 = m[0 * 4 + 2];
  const m03 = m[0 * 4 + 3];
  const m20 = m[2 * 4 + 0];
  const m21 = m[2 * 4 + 1];
  const m22 = m[2 * 4 + 2];
  const m23 = m[2 * 4 + 3];
  const c = Math.cos(angleInRadians);
  const s = Math.sin(angleInRadians);
  dst[0] = c * m00 - s * m20;
  dst[1] = c * m01 - s * m21;
  dst[2] = c * m02 - s * m22;
  dst[3] = c * m03 - s * m23;
  dst[8] = c * m20 + s * m00;
  dst[9] = c * m21 + s * m01;
  dst[10] = c * m22 + s * m02;
  dst[11] = c * m23 + s * m03;
  if (m !== dst) {
    dst[4] = m[4];
    dst[5] = m[5];
    dst[6] = m[6];
    dst[7] = m[7];
    dst[12] = m[12];
    dst[13] = m[13];
    dst[14] = m[14];
    dst[15] = m[15];
  }
  return dst;
}

function rotateZ(m, angleInRadians, dst) {
  dst = dst || new MatType(16);
  const m00 = m[0 * 4 + 0];
  const m01 = m[0 * 4 + 1];
  const m02 = m[0 * 4 + 2];
  const m03 = m[0 * 4 + 3];
  const m10 = m[1 * 4 + 0];
  const m11 = m[1 * 4 + 1];
  const m12 = m[1 * 4 + 2];
  const m13 = m[1 * 4 + 3];
  const c = Math.cos(angleInRadians);
  const s = Math.sin(angleInRadians);
  dst[0] = c * m00 + s * m10;
  dst[1] = c * m01 + s * m11;
  dst[2] = c * m02 + s * m12;
  dst[3] = c * m03 + s * m13;
  dst[4] = c * m10 - s * m00;
  dst[5] = c * m11 - s * m01;
  dst[6] = c * m12 - s * m02;
  dst[7] = c * m13 - s * m03;
  if (m !== dst) {
    dst[8] = m[8];
    dst[9] = m[9];
    dst[10] = m[10];
    dst[11] = m[11];
    dst[12] = m[12];
    dst[13] = m[13];
    dst[14] = m[14];
    dst[15] = m[15];
  }
  return dst;
}

Mat4 (What im looking for):
function rotateX(out, a, rad) {
  let s = Math.sin(rad);
  let c = Math.cos(rad);
  let a10 = a[4];
  let a11 = a[5];
  let a12 = a[6];
  let a13 = a[7];
  let a20 = a[8];
  let a21 = a[9];
  let a22 = a[10];
  let a23 = a[11];
  if (a !== out) {
    out[0] = a[0];
    out[1] = a[1];
    out[2] = a[2];
    out[3] = a[3];
    out[12] = a[12];
    out[13] = a[13];
    out[14] = a[14];
    out[15] = a[15];
  }
  out[4] = a10 * c + a20 * s;
  out[5] = a11 * c + a21 * s;
  out[6] = a12 * c + a22 * s;
  out[7] = a13 * c + a23 * s;
  out[8] = a20 * c - a10 * s;
  out[9] = a21 * c - a11 * s;
  out[10] = a22 * c - a12 * s;
  out[11] = a23 * c - a13 * s;
  return out;
}

function rotateY(out, a, rad) {
  let s = Math.sin(rad);
  let c = Math.cos(rad);
  let a00 = a[0];
  let a01 = a[1];
  let a02 = a[2];
  let a03 = a[3];
  let a20 = a[8];
  let a21 = a[9];
  let a22 = a[10];
  let a23 = a[11];
  if (a !== out) {
    out[4] = a[4];
    out[5] = a[5];
    out[6] = a[6];
    out[7] = a[7];
    out[12] = a[12];
    out[13] = a[13];
    out[14] = a[14];
    out[15] = a[15];
  }
  out[0] = a00 * c - a20 * s;
  out[1] = a01 * c - a21 * s;
  out[2] = a02 * c - a22 * s;
  out[3] = a03 * c - a23 * s;
  out[8] = a00 * s + a20 * c;
  out[9] = a01 * s + a21 * c;
  out[10] = a02 * s + a22 * c;
  out[11] = a03 * s + a23 * c;
  return out;
}

function rotateZ(out, a, rad) {
  let s = Math.sin(rad);
  let c = Math.cos(rad);
  let a00 = a[0];
  let a01 = a[1];
  let a02 = a[2];
  let a03 = a[3];
  let a10 = a[4];
  let a11 = a[5];
  let a12 = a[6];
  let a13 = a[7];
  if (a !== out) {
    out[8] = a[8];
    out[9] = a[9];
    out[10] = a[10];
    out[11] = a[11];
    out[12] = a[12];
    out[13] = a[13];
    out[14] = a[14];
    out[15] = a[15];
  }
  out[0] = a00 * c + a10 * s;
  out[1] = a01 * c + a11 * s;
  out[2] = a02 * c + a12 * s;
  out[3] = a03 * c + a13 * s;
  out[4] = a10 * c - a00 * s;
  out[5] = a11 * c - a01 * s;
  out[6] = a12 * c - a02 * s;
  out[7] = a13 * c - a03 * s;
  return out;
}


text:
Q: need help formulating my question I want to find a concise way of asking the following, so that I can re-post it.
I have a limited set of data from which I would like to find a function that approximates the data.  That is, if you plot the following [x:y]:
1:0, 2:1, 3:7, 6:8, 7:16, 9:19, 18:20, 25:23, 27:111, 54:112, 73:115, 97:118, 129:121, 171:124, 231:127, 313:130, 327:143, 649:144, 703:170, 871:178, 1161:181,
2223:182, 2463:208, 2919:216, 3711:237, 6171:261, 10971:267, 13255:275, 17647:278, 23529:281, 26623:307, 34239:310
the resulting graph appears to be roughly logarithmic.  Is there a way to generate a function such that for each x from the data it will produce a y "close" to the expected y value from the data.

A: Perhaps you'll want to consider Logarithmic Regression.
EDIT: This very easy to use page allows you to work out logarithmic regressions.


text:
Q: Exception in thread "main" java.util.NoSuchElementException (how to fix error) This error is getting on my nerves.
Exception in thread "main" java.util.NoSuchElementException
    at java.util.Scanner.throwFor(Scanner.java:862)
    at java.util.Scanner.next(Scanner.java:1485)
    at java.util.Scanner.nextInt(Scanner.java:2117)
    at java.util.Scanner.nextInt(Scanner.java:2076)
    at Main.main(Main.java:266)
    at Ideone.test(Main.java:72)
    at Ideone.test(Main.java:32)
    at Ideone.main(Main.java:23)

My code:
import java.util.Scanner;
import java.lang.Math;

class Main {
  public static void main(String[] args){

      Scanner scan = new Scanner(System.in);

      System.out.println("Welcome. What is your name?");
      String x;
      x = scan.nextLine();

      System.out.println("Hello " + x + ". Try your best to crack the code!");
      System.out.println(" ");

//Phase 1
      System.out.println("PHASE 1");

      System.out.println("Enter a number:");
      int y = scan.nextInt();
      if (y == 3){
        System.out.println("Correct!");
        System.out.println(" ");
//Phase 2
        System.out.println("PHASE 2");
        System.out.println("Enter a number:");
      }
      int z = scan.nextInt();
      if (z == 1 || (z >= 33 && z <= 100)){
        System.out.println("Correct!");
        System.out.println(" ");
//Phase 3
        System.out.println("PHASE 3");
        System.out.println("Enter a number:");}
      int c = scan.nextInt();
      if (c % 3 == 0 || c % 7 == 0){
        System.out.println("Correct!");
        System.out.println("You have cracked the code!");}
      else{
        System.out.println("Sorry, that was incorrect!");
        System.out.println("Better luck next time!");}

    }
}

Want to end the whole program if the input is incorrect.
Not sure what is exactly wrong.
Been stuck on this for awhile now.
How do you find out what is wrong with the scanner and the inputs?

A: Your errors are purely logic errors. You have }'s everywhere they shouldnt be.
You also are not consuming the /n  " New line" that pressing enter generates on nextInt().
To avoid confusing your self use opening and closing comments on nested if's
It is a good practice to create your frame work when creating if's and spacing everything out using whitespace.
if( conditon)
{
      if_statement(s);
}
else
{
      else_statement(s);
}

Here is your corrected code
import java.util.Scanner;
import java.lang.Math;

class BrockTaylor
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        System.out.println("Welcome. What is your name?");
        String x;
        x = scan.nextLine();
        System.out.println("Hello " + x + ". Try your best to crack the code!");
        System.out.println(" ");
        System.out.println("PHASE 1");
        System.out.println("Enter a number:");
        int y = scan.nextInt();
        // consume the /n
        scan.nextLine();
        //Phase 1
        if (y == 3)
        {
            System.out.println("Correct!");
            System.out.println(" ");
            System.out.println("PHASE 2");
            System.out.println("Enter a number:");
            int z = scan.nextInt();
            // consume the /n
            scan.nextLine();
            //Phase 2
            if (z == 1 || z >= 33 && z <= 100)
            {
                System.out.println("Correct!");
                System.out.println(" ");
                System.out.println("PHASE 3");
                System.out.println("Enter a number:");
                int c = scan.nextInt();
                // consume the /n
                scan.nextLine();
                //Phase 3
                if (c % 3 == 0 || c % 7 == 0)
                {
                    System.out.println("Correct!");
                    System.out.println("You have cracked the code!");
                }
                else // phase 3
                {
                    System.out.println("Sorry, that was incorrect!");
                    System.out.println("Better luck next time!");
                }
            }
            else // phase 2
            {
                System.out.println("Sorry, that was incorrect!");
                System.out.println("Better luck next time!");
            }
        }
        else// phase 1
        {
        System.out.println("Sorry, that was incorrect!");
        System.out.println("Better luck next time!");
        }
    }
}


text:
Q: WPF grid layout and how to deal with too narow window I'd like to have a WPF panel with two columns, where the 2nd one is fixed width and is to the right of the first column. The first columns is auto-sized. I want the second column to always be right after the first one, but also not to get lost when window (or parent element) gets too narrow and only first column or a part of the first column fits.
When I use DockPanel like this:
<DockPanel DockPanel.Dock="Top">
  <Label Content="I am autosize" DockPanel.Dock="Left" />
  <Label Content="I come right after the first column" />
</DockPanel>

The first column is visible, the second is right after it and when I start to resize the window to make it more narrow, firstly, the second column gets cropped until it disappers, the the first one is cropped.
When I use this:
<DockPanel DockPanel.Dock="Top">
  <Label Content="I come right after the first column" DockPanel.Dock="Right" />
  <Label Content="I am autosize" />
</DockPanel>

The second column start to be cropped second, but when window is wide enough, it is not right after fill-docked first one, it is docked to the right. The first column is not auto-sized.
When I tried to use the Grid, result were basically the same. When I set column widths to *, 20, *, it doesn't work, *, 20, Auto also doesn't make it behave exactly the way I want.
Is it even possible to use some Panel (DockPanel, prefferably) and layouting properties combination to make my second column appear always immediately to the right of the first one, but also make the first one crop first when both of their widths combined are larger than parent element width, so the second column in this case appears to be right-docked and the first one full-docked?
Thanks!

A: You can try to use the Grid control.
<Window x:Class="WpfApplication6.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525"
    MinWidth="200">
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition  MinWidth="200"/>
    </Grid.ColumnDefinitions>
    <TextBlock Text="I am autosize"
                   Background="Red" />
    <TextBlock Text="I come right after the first column"
                   Grid.Column="1"
                   Background="AliceBlue"
                   Width="200"
                   HorizontalAlignment="Left" />
</Grid>

The only problem is that you have to set also the parent control MinWidth to a fix size, in this example case, the window.
I hope this can help you.


text:
Q: Is the Galois group of a given polynomial always a subgroup of the Klein-$4$ group? Let $f(x) = (x^2-ax+b)(x^2-cx+d)$ be a separable polynomial with rational coefficients.
Is it true, that its Galois group over the rationals is always a subgroup of the Klein four group $C_2 \times C_2$?

A: Let $K_1,K_2$ be Galois extension of given factors of $f(x)$ over $\mathbb{Q}$. They are at most degree $2$. (See what happens if one of them is of degree $1$; i.t. $\mathbb{Q}$).
If both are degree $2$ extensions, consider their join in some algebraic closure (it is degree $\leq 4$ extension). Thus the Galois extension of $f(x)$ is inside this extension $K_1K_2$.
If $K_1=K_2$ then $K_1K_2=K_1$ is the Galois extension of $f(x)$ of degree $2$.
If $K_1\neq K_2$, then the Galois extension $K_1K_2$ of $f(x)$ has (at least) two subfields; correspondingly, Galois group (of order $4$) should contain two (at least) subgroups; what it should be?


text:
Q: Set Content for UIScrollview in UITableViewCell I have a tableview where I want to display uiscroll view in its row. I have set height of the tableview as following:
 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat{
    let deviceFrame = UIScreen.main.bounds.size
    print((1.21*deviceFrame.width))
    return (1.21*deviceFrame.width)
}

Now I have a custom table view cell, Inside that tableview cell I am trying to add pages for uiscrollview as following:
func loadContent(){
    var xaxis = 0
    var numOfPages = 0
    let screenSize = UIScreen.main.bounds.size
    for index in 1...3 {
        let pagevw = CustomPageView(frame: CGRect(x: xaxis, y: 0, width: Int(scrlvw.frame.size.width), height: Int(scrlvw.frame.size.height-10)))
        pagevw.translatesAutoresizingMaskIntoConstraints = true
        scrlvw.addSubview(pagevw)
        xaxis = xaxis + Int(screenSize.width)
        numOfPages += 1
    }
    let content = CGSize(width: numOfPages * (Int(scrlvw.frame.height)), height: Int(scrlvw.frame.height-30))
    print("content")
    print(content)
    scrlvw.contentSize = CGSize(width: numOfPages * (Int(scrlvw.frame.height)), height: Int(scrlvw.frame.height-30))
    pagecontrol.numberOfPages = numOfPages
}

Now although cell is coming up correct but content size of table is not updated correctly. Probably autolayout is creating some trouble here. Although I want autolayout to remain as I have many components inside my page.

A: When you dynamically add auto-layout content to a UIScrollView, you want to add the proper constraints to the subviews, rather than using the old style of setting each subview's x,y,w,h and then calculating the scrollview's ContentSize.
When doing so, you use constraints not only to position the "pages" (the embedded subviews), but also to "push out" the sides of the scrollview's content size.
I put together a sample of adding subviews to a horizontally scrolling UIScrollView embedded in a vertically scrolling UIScrollView. It's in Swift 2.2, but it auto-updates to 3.0 without issues.
https://github.com/DonMag/SWAutoLayoutScrollView
I played around with several different ways to assign constraints, all of which accomplished the same thing. The "working" methods are still in the main view controller class.
You should be able to replicate those techniques to solve your scrolling needs.


text:
Q: Zapier.com zipcode autofill city and state We are using zapier.com to connect many programs, but one function that I need is to autofill the city and state from a zip code. This is available in zapier.com as setup Code by Zapier Run Javascript.  I can't seem to figure this out and any help is much appreciated.
<script type="text/javascript">//<![CDATA[
    $(function() {
    // IMPORTANT: Fill in your client key
    var clientKey; // Deleted for Stack Overflow

    var cache = {};
    var container = $("#example1");
    var errorDiv = container.find("div.text-error");

    /** Handle successful response */
    function handleResp(data)
    {
      // Check for error
      if (data.error_msg)
        errorDiv.text(data.error_msg);
      else if ("city" in data)
      {
        // Set city and state
        container.find("input[name='city']").val(data.city);
        container.find("input[name='state']").val(data.state);
      }
    }

    // Set up event handlers
    container.find("input[name='zipcode']").on("keyup change", function() {
      // Get zip code
      var zipcode = $(this).val().substring(0, 5);
      if (zipcode.length == 5 && /^[0-9]+$/.test(zipcode))
      {
        // Clear error
        errorDiv.empty();

        // Check cache
        if (zipcode in cache)
        {
          handleResp(cache[zipcode]);
        }
        else
        {
          // Build url
          var url = "https://www.zipcodeapi.com/rest/"+clientKey+"/info.json/" +    zipcode + "/radians";

          // Make AJAX request
          $.ajax({
            "url": url,
            "dataType": "json"
          }).done(function(data) {
            handleResp(data);

            // Store in cache
            cache[zipcode] = data;
          }).fail(function(data) {
            if (data.responseText && (json = $.parseJSON(data.responseText)))
            {
              // Store in cache
              cache[zipcode] = json;

              // Check for error
              if (json.error_msg)
                errorDiv.text(json.error_msg);
            }
            else
              errorDiv.text('Request failed.');
          });
        }
      }
    }).trigger("change");
      });
//]]></script>

A: It looks like you're trying to use client-side JavaScript here. This won't work in a Zapier code step because it's meant to be used in a browser (on a webpage). To make an HTTP request in a Zapier code step, you'll want to use fetch (here's some documentation on that).
Alternatively, the simplest way to get the data you need from that API is with a Webhook step:

*

*Add a step to your Zap

*Choose Webhooks by Zapier and select the GET action

*Set up that step like this. The step will return city/state data which you can use in subsequent steps

A: There are a couple points of confusion here, the main one being:

Code by Zapier is not run "in the browser" (there is no <script> tags or Jquery) - it is run in something called Node.js.

You'll need to approach the problem completely differently as a result - definitely take a look at the samples found in https://zapier.com/help/code/ and at the Node docs https://nodejs.org/docs/v4.3.2/api/.


text:
Q: solr 7.5 suggester multi word search special character and number shows top I am using solr 7.5 suggeter.
Actual result of suggest
acetic acid
acetic acid 1-[1-{4-[5-(4-{[(z)-1-acetoxy-ethoxycarbonylimino]-amino-methyl}-phenyl)-furan-2-yl]-phenyl}-1-amino-meth-(z)-ylidenecarbamoyloxy]-ethyl ester
acetic acid [1-[1-(4-fluoro-phenyl)-7-naphthalen-1-ylmethyl-4,5,6,7-tetrahydro-1h-indazol-3-yl]-meth-(e)-ylidene]-hydrazide
acetic acid (10r,13s)-17-(2-acetyl-2,3-dihydro-1h-imidazol-4-yl)
.
.
acetic acid amide
acetic acid oxime

Expected result
acetic acid
acetic acid amide
acetic acid basc
acetic acid casd
cetic acid 1-[1-{4-[5-(4-{[(z)-1-acetoxy-ethoxycarbonylimino]-amino-methyl}-phenyl)-furan-2-yl]-phenyl}-1-amino-meth-(z)-ylidenecarbamoyloxy]-ethyl ester
acetic acid [1-[1-(4-fluoro-phenyl)-7-naphthalen-1-ylmethyl-4,5,6,7-tetrahydro-1h-indazol-3-yl]-meth-(e)-ylidene]-hydrazide
acetic acid (10r,13s)-17-(2-acetyl-2,3-dihydro-1h-imidazol-4-yl)
<fieldType class="solr.TextField" name="textSuggest" positionIncrementGap="100">`enter code here`<tokenizer class="solr.StandardTokenizerFactory"/> <filter class="solr.LowerCaseFilterFactory"/></fieldType>

I am using AnalyzingLookupFactory lookupImpl. Is there any way to improve suggest.


text:
Q: Segmentation Fault, c program Why does these code returning a segmentation fault? I searched online but can't find the problem. Could you please help?
Is it because of pointer malloc fault?
void multiply(int **a, int n, int m, int **b, int m2, int p, int **c)
{
    int i, j, k;
    for (i = 0; i < n; i++){
        for (j = 0; j < p; j++){
            for (k = 0; k < m; k++){
                c[i][j] += a[i][k] * b[k][j];
                }
            printf("%d", c);}}
}
main()
{
    int **a, **b, **c;
    int n, m, p;
    int i, j;
    scanf("%d", &n); scanf("%d", &m); scanf("%d", &p);
    a = (int **)malloc(n*sizeof(int*));
    for (i = 0; i < n; i++){
        a[i] = (int*)malloc(m*sizeof(int));}
    for (i = 0; i < n; i++){
        for (j = 0; j < m; j++){
            scanf("%d", &a[i][j]);}
    }
    b = (int **)malloc(m*sizeof(int*));
    for (i = 0; i < m; i++){
        b[i] = (int *)malloc(p*sizeof(int));}
    for (i = 0; i < m; i++){
        for (j = 0; j < p; j++){
            scanf("%d", &b[i][j]);}
    }
    c = (int **)malloc(n, sizeof(int));
    for (i = 0; i<n; i++)
        c[i] = (int *)malloc(p, sizeof(int));
    multiply(a, n, m, b, m, p, c);
    free(a);
    free(b);
    free(c);
}

Thanks^^
I edit some code and it is now correct. Thank you guys so much.
Cheers!

A: If you're on an LP64 architecture (int is 32 bits and int* is 64 bits), c is too small, you should use
c = (int **)calloc(n, sizeof(int*));

A: You have a typo here:
        for (k = 0; k < m; j++){
                           ^

This should be:
        for (k = 0; k < m; k++){
                           ^

Also:
multiply(**a, n, m, **b, m, p, **c);

should be:
multiply(a, n, m, b, m, p, c);

Note that if you had turned on compiler warnings then the compiler would have helpfully pointed out this mistake to you.
Note also that you should not cast the result of malloc in C.


text:
Q: Javascript common function for multiple input type=text & input type=color In my body tag i have two input types(text & color). It works like this,

*

*If you give the  hex value of color in the inputText, inputColor
will automatically change to that color.

*If you select the color via colorPicker, inputText will
automatically change to the colorHex value you have chosen.

Below code works

<input type="text" id="txtColor">
<input type="color" id="colColor" >

What i am trying to do is, i have a table with multiple rows of above pair(inputText & inputColor). It should function similarly to above. I am trying with getElementsByClassName having a common classname for inputText and inputColor, so that it would update the sibling with hexColor value or color.
This is my current code, its not working. Currently getting error "Uncaught TypeError: txtColorClass.addEventListener is not a function"

            <input type="text" id="txtColor0" class="txtColorClass">
            <input type="color" id="colColor0" >

            <input type="text" id="txtColor1" class="txtColorClass">
            <input type="color" id="colColor1" >

            <input type="text" id="txtColor2" class="txtColorClass">
            <input type="color" id="colColor2" >

A: Check below snippet
There are many possible way you can do this. Below is one of the possible way. And you can easily do this using jquery also.

var txtColorClass = document.getElementsByClassName("txtColorClass");

for(var i = 0; i < txtColorClass.length; i++)
{
   txtColorClass.item(i).addEventListener("blur", function( event ) {
  //event.target.style.background = "pink";
  var txtColor = event.target.value;
  event.target.nextElementSibling.value = txtColor;

}, true);

}

var colColorClass = document.getElementsByClassName("colColor");

function myFunction1() {
    //alert("Input field lost focus.");
    var txtColor = document.getElementById("txtColor").value;

    document.getElementById("txtColor").nextElementSibling.value = txtColor;

//    document.getElementById("colColor").value = txtColor;
}

function myFunction2(colColorBox) {
    //alert("Input field lost focus.");
    var colColor = colColorBox.value;
    colColorBox.previousElementSibling.value = colColor;

    //document.getElementById("txtColor").value = colColor;
}

            <input type="text" id="txtColor0" class="txtColorClass">
            <input type="color" id="colColor0" class="colColor" onchange="myFunction2(this)">

            <input type="text" id="txtColor1" class="txtColorClass">
            <input type="color" id="colColor1" class="colColor" onchange="myFunction2(this)">

            <input type="text" id="txtColor2" class="txtColorClass">
            <input type="color" id="colColor2" class="colColor" onchange="myFunction2(this)">

A: Thank You Very Much NewToJS with your hint i was able to resolve this.

            <input type="text" id="txtColor0" class="txtColorClass">
            <input type="color" id="colColor0" class="colColorClass">

            <input type="text" id="txtColor1" class="txtColorClass">
            <input type="color" id="colColor1" class="colColorClass">

            <input type="text" id="txtColor2" class="txtColorClass">
            <input type="color" id="colColor2" class="colColorClass">


text:
Q: css - Make stackexchange like tags I've been trying to create a textbox, that has spans inside it, similar to the ones here, but I'm stuck - I have no idea what to do. The code itself doesn't work. My code:
$(".writetags").each(function(){
        var elem = $(this);
        elem.bind("keyup", function() {
            elem.data("oldVal", $(this).data("newVal") || "");
            elem.data("newVal", $(this).val());
            var oldVal = elem.data("oldVal");
            var newVal = $(this).val();
            var newChar = newVal.charAt(newVal.length-1);
            var oldChar = oldVal.charAt(oldVal.length-1);
            if(newChar!=oldChar){
                if(newChar==","){
                    var at = 0;
                    if(newVal.lastIndexOf("")>=0){
                        at = newVal.lastIndexOf("");
                    }
                    var toSpan = newVal.substring(at, newVal.length-1);
                    var newTxt = newVal.substring(0, at)+""+toSpan+"";
                    elem.val(newTxt);
                }
            }
        });
    });

HTML:
<input type="text" class="writetags" id="tags" style="width: 95%;direction:rtl;font-size: 18px;"/>

$(".writetags").each(function() {
  var elem = $(this);
  elem.bind("keyup", function() {
    elem.data("oldVal", $(this).data("newVal") || "");
    elem.data("newVal", $(this).val());
    var oldVal = elem.data("oldVal");
    var newVal = $(this).val();
    var newChar = newVal.charAt(newVal.length - 1);
    var oldChar = oldVal.charAt(oldVal.length - 1);
    if (newChar != oldChar) {
      if (newChar == ",") {
        var at = 0;
        if (newVal.lastIndexOf("") >= 0) {
          at = newVal.lastIndexOf("");
        }
        var toSpan = newVal.substring(at, newVal.length - 1);
        var newTxt = newVal.substring(0, at) + "" + toSpan + "";
        elem.val(newTxt); //change to HTML
      }
    }
  });
});

<input type="text" class="writetags" id="tags" style="width: 95%;font-size: 18px;" placeholder="Seperate tags using commas." />

This doesn't work properly as you can see in the snippet above. Not only it doesn't show the spans, if you type tag1, tag2, instead of making it tag1tag2 it writes tag1tag2
I had an idea of making it work with a div with spans and shorten the input by the new span's length but I have no idea of how to do that and I'd rather keep it simple.
Thanks in advance, NonameSL

A: You cannot append anything to an input element, as it's a self-closing element. So are the  or
 elements. This means they only use one tag, to be created, and they cannot have children. The solution would be to create an input and position the tags above it.

A: If you can add external libraries then Selectize will be very useful for you. Check the API documentation. It is as simple as
// initialize the selectize control
var $select = $('select').selectize(options);

See the JS Fiddle for an example, http://jsfiddle.net/MuEh5/


text:
Q: Running an OS off an external drive I'm looking to do away with my Boot Camp partition. Now I've bought a 2 TB external drive, and I was wondering if it's possible to either install a Boot Camp partition onto the external drive, or failing that, how much of a performance drop I'll see if I install a VM via Parallels Desktop onto the external drive.
It's a USB 3 external drive.
My Mac is a MacBook Pro late '13, 2.4 GHz Intel i5, 8 GB of DDR3 RAM

A: It seems to be possible to install Windows 7/8 to an external drive but a lot of work is necessary to overcome Boot Camp/Windows 7/8 restrictions.
The following guide is shamelessly stolen at bleeptobleep.blogspot.de.
All credits go to the the respective  persons/groups of persons.
To keep the formatting and improve readability i didn't choose the quote tags.
Mac: Install Windows 7 or 8 on an external USB3 or Thunderbolt drive without using bootcamp
Introduction
After I received my new iMac with a 3 TB Fusion Drive, I was disappointed when I realized that Bootcamp was not running on this model and prevented me from installing Windows on it. I wanted to take advantage of the powerful iMac hardware to play games but I couldn't.
There are a few ways of working around this limitation, but I found most of them quite complex and most of the time they required formatting the internal hard drive or repartitioning it and go for a brand new installation of Mac OS X. I was not comfortable with that.
But there is another way, and that is to install Windows on an external hard drive, using either USB or Thunderbolt. Personally I used a Lacie Rugged 1 TB drive that has both USB3 and Thunderbolt connectors. Both work very well.
This guide may interest you if:

*

*You have an internal hard drive of more than 2TB and you can't run bootcamp at all (like late 2012 iMacs with a 3TB drive)

*You have limited space or you don't want to dedicate disk space on your internal hard disk drive to a Windows installation

What this guide will make you do:

*

*It will make you erase all your data from your external USB3/Thunderbolt hard drive

*It will make you install Windows on your external USB3/Thunderbolt hard drive

*It will make you install bootcamp drivers

What this will not make you do:

*

*It will not make you modify anything on your internal Mac hard drive

*It will not make you use or install the bootcamp assistant

*It will not activate the Preference Pane for the default boot drive. You have to boot by pressing the ALT key to manually select your boot drive each time you want to boot Windows.

What you'll need

*

*An external hard drive with a USB3 and/or Thunderbolt connector. This drive will be formatted so ensure you saved your files before going further. You can use either an SSD drive or a classic hard drive.

*A Windows 7 or 8 install DVD or ISO (check whether to install 32 or 64 bits versions based on your Bootcamp drivers) and the corresponding Windows serial number.

*One of the following:

*

*Mac OS X with a Windows 7 or 8 Virtual Machine (use VMWare Fusion or Parallels Desktop for example. Note: VMWare Fusion seems to have some issues with Thunderbolt and USB3. Plug your drive to a USB2 enclosure or hub to work around this -it worked for me-, or use another VM software) → Read the important note below

*A PC running Windows 7 or 8 → Read the important note below

*Windows AIK (free) running on your Virtual Machine or on your PC, or just the imagex.exe file (the rest of the Windows AIK package is not needed)

*

*Download imagex.exe

*Download Windows AIK 7 or Windows AIK 8 (this download and installation is not required if you have already downloaded imagex.exe)

*Bootcamp drivers for your Mac. You can get these either by running bootcamp from your Mac (Applications > Utilities > Bootcamp) or, if like me you have a 3TB drive and can't run bootcamp at all, use the direct download links here.

*A USB stick to store your bootcamp drivers

IMPORTANT: If your Mac has a 64 bits processor, your Windows Virtual Machine on OSX, your Windows installation on your PC and your Windows DVD/ISO must also be in 64 bits!
Step by Step guide
Step 1: Get the install.wim file

*

*If you have a Windows ISO file:

*

*Mount the ISO

*

*If you're on OS X: double click on the ISO file

*If you're on on Windows 7: Use a software like Virtual Clone Drive (free)

*If you're on Windows 8: double click on the ISO file

*Open the mounted drive, then go to the "sources" folder and locate the "install.wim" file. Save this file to C:\wim\ on your Windows installation or virtual machine.

*If you have a Windows DVD: open the "sources" folder on the DVD and locate the "install.wim" file. Save this file to C:\wim\ on your Windows installation or virtual machine.
IMPORTANT: If instead of a "install.wim" file, you have "install.esd", you can not continue this step by step guide. And an ESD file can not be converted into a WIM file. So you must get a version of the Windows installation DVD/ISO that has an install.wim file.
Step 2: Clean, partition and format your external hard drive

*

*On your Windows installation or virtual machine, plug in your external hard drive (can be plugged using USB2, USB3 or Thunderbolt at this stage)

*Open the command prompt in administrator mode (cmd.exe). To run it in administrator mode, right click on cmd.exe > Run as admin.

*Type the following and hit enter to open the disk partitioner utility:
diskpart

*Type the following and hit enter to list your drives:
list disk
This will display a list of disks mounted on your computer or virtual machine. Make sure your drive is listed here before you continue.

*Identify the disk ID of your external hard drive. Replace # by your real external disk ID in the command below:
select disk #

*Clean all partitions by typing the following (warning: this will erase all data from your external drive!):
clean

*Type the following to use MBR as partitioning format:
convert mbr

*Create the boot partition by typing the following followed by the enter key:
create partition primary size=350
This will create a 350MB partition on your external drive

*Format the partition in FAT32 by typing the following:
format fs=fat32 quick

*Set this partition to active by typing:
active

*Assign a letter to mount this partition. We will use letter B in our example. If B is already used on your PC, replace B by any other available letter:
assign letter=b
Windows will detect a new drive and probably display a pop-up. Ignore that.

*Create the Windows installation partition using all the remaining space available on the external drive by typing the following:
create partition primary

*Format the new partition in NTFS:
format fs=ntfs quick

*Assign a letter to mount this partition. We will use letter O in our example. If O is already used on your PC, replace O by any other available letter:
assign letter=o
Windows will detect a new drive and probably display a pop-up. Ignore that.

*Exit the disk partitioner utility by typing:
exit
Step 3: Deploy the Windows installation image

*

*Still using the command prompt in admin mode (you didn't close it, did you? ;) ), locate the imagex.exe file mentioned in the "What you'll need" section and access its folder. In our example, we have put this file in C:\imagex\imagex.exe

*Your Windows installation ISO has probably several installation options in it. So in order to identify the right one, type in the following:
imagex.exe /info C:\wim\install.wim

*Now identify the INDEX number of the installation that you wish to deploy. You will use it in the next step.

*Type the following and hit enter. Replace 1 with the INDEX you identified in the previous step. Also remember to replace o: with the letter you have chosen in the previous step:
imagex.exe /apply C:\wim\install.wim 1 o:
This will take some time. The Windows installation image is being deployed to your external drive

*Once done, type the following to create the boot section (remember to replace o: and b: with the letters you've chosen in the previous step):
o:\windows\system32\bcdboot o:\windows /f ALL /s b:

*

*If you get an error message saying that you can't run this program on your PC, then most probably you are running on a 32 bits installation of windows and you're trying to deploy a 64 bits install. This means you did not read the important notes in the beginning of this guide ;)

*If you get an error message on the options that can be used with the BCDBOOT command, then it's because you're installing Windows 7, and the /f option is not supported. If that is the case, remove /f ALL from the command and retry.

Step 4: Boot from your external drive and install Windows

*

*Plug in your external drive:

*

*If you've done all the previous steps from a Windows PC, unplug your external drive from your PC and plug it to your Mac, either on a USB3 or a Thunderbolt port.

*If you've done all the previous steps from your Mac using a Virtual Machine, ensure the external drive is plugged in to a USB3 or Thunderbolt port. Using USB2 should also work but you'll get very poor performance so I don't recommend doing that.

*Reboot your Mac and once the bootup sound is over, immediately press the ALT (option) key and release it only when the boot drives selection screen appears. If you did not get the boot drives selection screen, reboot and try again. The timing to press the ALT (option) key is quite short. It must not be too early or too late.

*On the boot selection screen, choose "Windows" using the arrow keys on your keyboard, then press enter.

*The Windows installation starts. Follow the on-screen instructions as normal. The installation program will restart your computer one or 2 times. Don't forget to press ALT (option) right after the bootup sound, and boot on Windows again each time to continue the installation.

Step 5: Install bootcamp drivers

*

*Once the Windows installation is complete, plug in the USB stick where you stored the bootcamp drivers (see "what you'll need" section), open it and right click on "setup.exe" and select "Run as admin". Follow the on-screen instructions.

*

*If you have an error saying that you can't run this program on this PC, obviously you have installed a 32 bits version of Windows and the bootcamp drivers for your Mac are made for a 64 bits version. You have to restart the whole guide and make sure to get a 64 bits version of Windows this time!

*Once the bootcamp drivers are all installed, reboot and press ALT (option) after the bootup sound to boot on Windows again. And Voilà, you have Windows installed on your USB3/Thunderbolt drive running on your Mac.

*Now each time you want to boot on Windows, press and hold the ALT (option) key after the startup sound and select "Windows", then press Enter.

Credits, sources and big thank you to:
tweaks.com where I got the info on how to install Windows to go on a USB external drive
Chris F Caroll where I finally found where to download the bootcamp drivers without running bootcamp
Macrumors forums for the very helpful forum members
To answer your second question about performance drop:
I don't have a Boot Camp partition so i can't compare Windows Boot Camp to a Windows VM.
But i may give you a Mac <-> Mac VM comparison and single Windows 7/8 VM benchmarks:
Geekbench 3 Benchmark:

*

*iMac14,2 3.5 GHz i7 4 cores 8 threads 32 GB 10.9.5: single-core score: 4009 multi-core score: 14951

*iMac14,2 3.5 GHz i7 2 (virtual) cores 4 GB 10.9.5 Parallels VM single-core score: 3870 multi-core score: 7127

Windows Experience Index:
Windows 7 Parallels VM, 2 (virtual) cores, 4 GB (WEI: 1.0-7.9):

*

*Processor:        7.3

*RAM:              7.9

*Graphics:         7.8

*Gaming Graphics:  7.8

*Prim. Hard Disk:  6.0

Windows 8.1 Parallels VM, 2 (virtual) cores, 8 GB (WEI: 1.0-9.9):

*

*Processor:        7.5

*RAM:              7.9

*Graphics:         8.2

*Gaming Graphics:  8.2

*Prim. Hard Disk:  7.5


text:
Q: Basic Bayesian Linear Regression prediction with PyMC3 I would like to use my PyMC3 LR model to get an 80% HPD range for the value of the predicted variable y as new data becomes available.
Thus, extrapolate a credible distribution of values for y for a new value of x not in my original dataset.
Model:
with pm.Model() as model_tlr:
    alpha = pm.Normal('alpha', mu=0, sd=10)
    beta = pm.Normal('beta', mu=0, sd=10)
    epsilon = pm.Uniform('epsilon', 0, 25)

    nu = pm.Deterministic('nu', pm.Exponential('nu_', 1/29) + 1)
    mu = pm.Deterministic('mu', alpha + beta * x)

    yl = pm.StudentT('yl', mu=mu, sd=epsilon, nu=nu, observed=y)

    trace_tlr = pm.sample(50000, njobs=3)

After burnin I sample from the posterior and get an HPD
ppc_tlr = pm.sample_ppc(btrace_tlr, samples=10000, model=model_tlr)
ys = ppc_tlr['yl']
y_hpd = pm.stats.hpd(ys, alpha=0.2)

Which is great for visualizing the HPD around the central tendency (using fill_between)

But I would like to now use the model to get an HPD for y when x=126.2 (for example) and the initial dataset didn't contain an observed x=126.2
The way I understand sampling from the posterior is that there are 10k samples for each of the available x values in the dataset and hence there isn't a corresponding sampling in ys for x=126.2 as it wasn't observed.
Basically, is there a way to use my model to obtain a distribution of credible  values (based on the model) from a predictor value x=126.2 which only became available after the model was built?
If so, how?
Thank you
EDIT:
Found SO Post which mentions

Function under development (will likely eventually get added to pymc3) that will allow to predict posteriors for new data.

Does this exist?

A: OK, so it's possible, more or less as described in the above SO post.
However, there has since been a sample_ppc function added to PyMC3 which makes the author's run_ppc redundant.
First, setup a Theano shared variable for x.
from theano import shared
x_shared = shared(x)

Then use x_shared when building the model.
After the model is built, add the new datum and update the shared variable
x_updated = np.append(x, 126.2)
x_shared.set_value(x_updated)

Re-run the PPC sample generator with the original trace and model objects
new_ppc = pm.sample_ppc(btrace_tlr, samples=10000, model=model_tlr)

The sampling of the posterior for the new datum is found with
sample = new_ppc['yl'][:,-1]

I can then get the HPD with
pm.stats.hpd(sample)

array([ 124.56126638,  128.63795388])

Sklearn has spoiled me into thinking there should be a simple predict interface...