text:
Q: How to populate a whole form after ajax GET request? I am working on ASP.NET MVC project and have an empty form rendered by MVC controller. Right after it's been rendered, I make an AJAX GET request, and receive JSON data to populate the form.
Everything works fine when I populate each individual field (please see code below), but I have a feeling that there is a better/righter way of how to populate the entire form in one shot. Please help.
In my $.get request, I tried:
$("#content").html(data);

It simply empties my form (all fields disappear).
Then I tried:
$("#content").val(data);

Here, all fields stay blank.
Anyways, here is the code that I have (please see below).
Here is my view (.cshtml file):

@model ViewModels.ProductDetailsViewModel

<form asp-controller="ApiProduct" asp-action="Post" id="content">

        Name
        <input asp-for="Name" type="text" class="form-control" id="js-name" />

        Description
        <textarea asp-for="Description" rows="5" cols="40" class="form-control" id="js-description"></textarea>

        <input type="submit" value="Save" class="btn btn-default" />

</form>

@section Scripts {

}

Here is my API controller:
[HttpGet("{id}")]
    public IActionResult Get(int id)
    {
        var product = _repository.GetProductById(id);

        return Ok(product);
    }

Here is my MVC controller:
  public IActionResult Details(int id)
    {
        var vm = new ProductDetailsViewModel()
        {
            Id = id;
        };
        return View(vm);
    }

A: Apri478 ...Your API is giving you JSon result of your product and not html.
Above this line write console.log(data)
$("#content").html(data);
and see your response of API.
If you bind this json to form there are plenty of way.. writing custom js binding or using MVVM like angular or knockout.
try to explain more if this is not what you were expecting.


text:
Q: \xdef and \fnsymbol problem under TeX Live 2015/MacPorts 2015_6 I'm writing a paper using a cls file provided by the journal (which I cannot modify). They are using some tricky code for creating table notes under tables. Problem is that this code crashes under my MacPorts version of TeX Live (while working fine on a colleague's linux machine) with the following message:
! TeX capacity exceeded, sorry [input stack size=5000].
\font@name ->
             \OMS/cmr/m/n/12

I've tried modifying texmf.cnf by increasing stack size, that doesn't fix the problem.
I'm not quite good in understanding the original code, but after some reverse engineering I was able to compose a MWE:
\documentclass[a4paper,12pt]{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[pdftex,unicode]{hyperref}
\makeatletter

\newcounter{mycount}

\newcommand\thecounter{\fnsymbol{mycount}}%
\gdef\MyPrint{}

\def\MyAdd#1#2{%
  \g@addto@macro\MyPrint{
    \refstepcounter{mycount}%
    \xdef\@currentlabel{\thecounter}%
    \label{#1}%
    \thecounter #2
    }%
}

\begin{document}
\MyAdd{l1}{Hello}
\MyAdd{l2}{World}

My\ref{l1} print\ref{l2}:
\MyPrint
\end{document}

If I replace
\xdef\@currentlabel{\thecounter}%

with
\def\@currentlabel{\thecounter}%

everything works fine and I even get the correct result:

Another thing that fixes the problem is replacing
\newcommand\thecounter{\fnsymbol{mycount}}%

with
\newcommand\thecounter{\arabic{mycount}}%

(or with \roman or \Roman)
Here's the full output of pdflatex -version:
pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015/MacPorts 2015_6)
kpathsea version 6.2.1
Copyright 2015 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.6.18; using libpng 1.6.18
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with poppler version 0.37.0

Is this a bug or is something missing from my TeX Live installation?
UPD1.
Output from \listfiles:
 *File List*
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size12.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
 fontenc.sty
  t2aenc.def    2005/09/27 v1.0i Cyrillic encoding definition file
  t2acmr.fd    2001/08/11 v1.0a Computer Modern Cyrillic font definitions
inputenc.sty    2015/03/17 v1.2c Input encoding file
    utf8.def    2014/09/29 v1.1m UTF-8 support for inputenc
   t1enc.dfu    2014/09/29 v1.1m UTF-8 support for inputenc
  ot1enc.dfu    2014/09/29 v1.1m UTF-8 support for inputenc
  omsenc.dfu    2014/09/29 v1.1m UTF-8 support for inputenc
  t2aenc.dfu    2014/09/29 v1.1m UTF-8 support for inputenc
hyperref.sty    2012/11/06 v6.83m Hypertext links for LaTeX
hobsub-hyperref.sty    2012/05/28 v1.13 Bundle oberdiek, subset hyperref (HO)
hobsub-generic.sty    2012/05/28 v1.13 Bundle oberdiek, subset generic (HO)
  hobsub.sty    2012/05/28 v1.13 Construct package bundles (HO)
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
  ifvtex.sty    2010/03/01 v1.5 Detect VTeX and its facilities (HO)
 intcalc.sty    2007/09/27 v1.1 Expandable calculations with integers (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
pdfescape.sty    2011/11/25 v1.13 Implements pdfTeX's escape features (HO)
bigintcalc.sty    2012/04/08 v1.3 Expandable calculations on big integers (HO)
  bitset.sty    2011/01/30 v1.1 Handle bit-vector datatype (HO)
uniquecounter.sty    2011/01/30 v1.2 Provide unlimited unique counter (HO)
letltxmacro.sty    2010/09/02 v1.4 Let assignment for LaTeX macros (HO)
 hopatch.sty    2012/05/28 v1.2 Wrapper for package hooks (HO)
xcolor-patch.sty    2011/01/30 xcolor patch
atveryend.sty    2011/06/30 v1.8 Hooks at the very end of document (HO)
atbegshi.sty    2011/10/05 v1.16 At begin shipout hook (HO)
refcount.sty    2011/10/16 v3.4 Data extraction from label references (HO)
 hycolor.sty    2011/01/30 v1.7 Color options for hyperref/bookmark (HO)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
 auxhook.sty    2011/03/04 v1.3 Hooks for auxiliary files (HO)
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
  pd1enc.def    2012/11/06 v6.83m Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg    2002/06/06 v1.2 hyperref configuration of TeXLive
   puenc.def    2012/11/06 v6.83m Hyperref: PDF Unicode definition (HO)
     url.sty    2013/09/16  ver 3.4  Verb mode for urls, etc.
 hpdftex.def    2012/11/06 v6.83m Hyperref driver for pdfTeX
rerunfilecheck.sty    2011/04/15 v1.7 Rerun checks for auxiliary files (HO)
 nameref.sty    2012/10/27 v2.43 Cross-referencing by name of section
gettitlestring.sty    2010/12/03 v1.4 Cleanup title references (HO)
    test.out
    test.out
  omscmr.fd    2014/09/29 v2.5h Standard LaTeX font definitions
 ***********

A: The LaTeX team recently (start of 2015) integrated the fixltx2e package into the kernel. There are a small number of places where this may cause issues, primarily where people have relied on problematic behaviour. Here, the class is relying on the expansion safety of \thecounter (or rather of the code to make footnote symbols), which it should not do. The code should be
\def\MyAdd#1#2{%
  \g@addto@macro\MyPrint{
    \refstepcounter{mycount}%
    \protected@xdef\@currentlabel{\thecounter}% Change here
    \label{#1}%
    \thecounter #2
    }%
}

Of course, for a fixed class you can't alter that. What you can do is back out the kernel changes by adding
\RequirePackage[2014/12/31]{latexrelease}

right at the start of you document (before \documentclass). This will undo all changes to LaTeX since the end of 2014 and so will allow you to compile.

redpajama_set_name: RedPajamaStackExchange


text:
Q: IntelliJ show "always true" hint but not "always false" for instanceof So, I use IntelliJ IDEA to program in Java, and I was experimenting with the keyword instanceof and my code looked eventually like this:
public class Main {

    public static void main(String args[])
    {
        One one = new One();
        One two = new Two();

        if (one instanceof Two)
        {
            System.out.println(one);
        }

        if (two instanceof Two)
        {
            System.out.println(one);
        }

    }
}

class One { }

class Two extends One { }

IntelliJ gives me at the two instanceof Two line a hint "[...] is allways true", but for one instanceof Two IntelliJ doesn't give me a "[...] is always false" hint. Does anyone know why?

A: Updated: fixed in IDEA 2018.3.

(Disclaimer: IntelliJ IDEA developer is here, who is responsible for this feature).
Short answer: because it's not implemented.
When we track an actual type of variable within the data flow analysis, we use a model described by TypeConstraint class. It allows us to track the facts of two kinds: 1) if variable actual type is instanceof something and 2) if variable actual type is not instanceof something. Having these facts we can infer always true/always false instanceof in many cases E.g.:
void test(Object foo) {
  if (foo instanceof String) {
    if (foo instanceof Integer) {
      // always false: "instanceof String" fact is not compatible
      // with "instanceof Integer"
    }
  }
}

Or
void test(Object foo) {
  if (!(foo instanceof Number)) {
    if (foo instanceof Integer) {
      // always false: "not instanceof Number" fact is not compatible
      // with "instanceof Integer"
    }
  }
}

However for your case this model is not enough. We need to extend it to track the exact type of variable. In your code we track that one is instanceof One (which is compatible with instanceof Two fact), despite from the new expression we could know more precise type information that one is exactly One. This is not often usable, because in most of the cases (variable is method parameter, variable is returned from method, variable is assigned from field, array element, cast expression etc.) we cannot know whether the type is exact or subtype, so the current model is completely satisfactory. I can imagine only two cases where exactly One fact tracking is useful: the new expression (like in your case) and after comparison like obj.getClass() == Xyz.class.
I think, it's a reasonable feature to implement. I already thought about this, but as somebody else besides me also cares, I filed an issue, so you can track it.


text:
Q: t test alternative when participants can belong to multiple groups? Newbie here, so please excuse any faux pas.
I have participants who belong to different groups: A & B. However, a participant can also belong to both groups or to neither. Possibilities are A, B, A+B, or 0.
I would like to test for differences between the groups in a dependent variable. However, I do not know how to treat the A+B participants.
An extra point is that the dependent variable is a ratio, which I suspect might complicate matters. So it would also be useful to know whether there are methods that would or would not work for different types of DV.
Sorry if this is really obvious, but I have never had data like these before and haven't had any luck searching using keywords.

A: There are a few possibilities.
You could make it a two way ANOVA:

*

*A or notA

*B or notB

That would also allow you to look at interaction effects. You would need to put some thought into how many and which post-hoc tests you will need.
You could also go for a flat design and look at 4 distinct groups:

*

*A but not B

*B but not A

*neither

*both

If you also need to control for some other variables, which may be continuous, then a regression is the way to go.


text:
Q: How to get the _visible height_ of a TextFlow inside a ScrollPane, not its text's height? Extract from the FXML (note: JavaFX 8):
<Tab text="Parse tree" closable="false">
    <SplitPane dividerPositions="0.5">
        <SplitPane dividerPositions="0.5" orientation="VERTICAL">
            <TreeView fx:id="parseTree" editable="false"/>
            <!-- TODO: replace with something else -->
            <TextArea fx:id="parseNodeDetails" editable="false"
                style="-fx-font-family: monospace"/>
        </SplitPane>
        <BorderPane>
            <top>
                <ToolBar>
                    <Label fx:id="textInfo"/>
                </ToolBar>
            </top>
            <center>
                <ScrollPane fx:id="inputTextScroll">
                    <TextFlow fx:id="inputText">
                        <padding>
                            <Insets fx:id="inputTextPadding" bottom="5.0"
                                left="5.0" right="5.0" top="5.0"/>
                        </padding>
                    </TextFlow>
                </ScrollPane>
            </center>
        </BorderPane>
    </SplitPane>
</Tab>

Now, I have a lot of text in it. Both the horizontal and the vertical scroll bars show.
What I need to do is to make a certain line visible by setting the ScrollPane's vvalue (yes, two vs) so that this highlighted line appear as close as possible to the middle of the visible portion of the TextFlow.
But I cannot find a property on the TextFlow which tells me that. Its .getHeight() returns the total height of the embedded text, and this if of course not what I want...
The problem with the simple formula which is to divide the line number to display by the total number of lines is that it is messed up due to the horizontal scroll bar.
I'm at a loss. How do I obtain the visible height from the TextFlow, and only that?

A: Well, answer to self...
I asked the same question elsewhere and got the response:
// inputTextScroll is the ScrollPane
final long visibleHeight = inputTextScroll.getViewportBounds().getHeight();

The beauty is that it does NOT include the scrollbars! Perfect.


text:
Q: Magento1 - REST API based add to cart missing catalog rule We have a custom APIs for quote creation for guest and adding the products to cart.
Everything is working fine except catalog rule based price is not coming in cart.
First API, which returns the quote id.
          $quote = Mage::getModel('sales/quote');
          $quote->setStoreId(1)
                ->setIsActive(true)
                ->setIsMultiShipping(false)
                ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID)
                ->setCustomerIsGuest(true)
                ->save();

Product adding API with quote.
         $request = new Varien_Object();
         $request->setData($options);
         $quote->addProduct($product, $request);

Updated all catalog pricing rules and applied all rules.
When adding the product from magento UI and admin panel, its working fine.
We have only one store.
So whats is missing here ?
Also we cannot getting the price after rule when taking the product final price with below
code.
$product->getFinalPrice();

But its getting if we taking the price by below method.
$final_price = Mage::getModel('catalogrule/rule')->calcProductPriceRule($product->setStoreId('1')->setCustomerGroupId('0'),$product->getPrice());

Whats the issue here ?


text:
Q: jsonarray from string returning as null This single line of snippet of converting string to JSONArray is returning as null, any ideas?
JSONArray("""[{"id":1,"first":"John","last":"Doe"}]""")

Here are my dependencies
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'

    implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
    implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"
    androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"

    testImplementation 'junit:junit:4.13'
    testImplementation 'org.mockito:mockito-inline:2.13.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    implementation 'androidx.test.espresso:espresso-idling-resource:3.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
    androidTestImplementation 'androidx.test:rules:1.3.0-alpha05'
    implementation 'com.google.android.material:material:1.1.0'
}

Subsequent issues. Calling localhost from SUT using JUnit.

A: I'm assuming you must be running unitTests which are present under module/tests in Android project.
If you try to use or access the Android related code in JUnit tests then it is not expected to work until and unless you've not added the following line of code in your build.gradle file of the module.
testOptions {
    unitTests.returnDefaultValues = true
    unitTests.includeAndroidResources = true
}

And once you add the above configuration, any access to Android methods is expected to return their default value, no matter what you're passing to them.
Anything related to android tests needs to be written under androidTest
For more info.
http://tools.android.com/tech-docs/unit-testing-support#TOC-Method-...-not-mocked.-


text:
Q: Unbiased + Variance Vanishes = Convergence in Probability? I am reading a proof of the consistency of sample variance estimator.
http://webpages.cs.luc.edu/~jdg/w3teaching/stat_305/sp11/consistentsamplevariance.pdf
On page two, it argues that, since $A=\frac{1}{n}\sum_{i=1}^nX_i^2$ is an unbiased estimator of $\Bbb E(X^2)$ and since $Var(A)\to 0$ as $n\to\infty$, the estimator converges in probability to $\Bbb E(X^2)$, or $A\overset{\Bbb P}{\to}\Bbb E(X^2)$.
I am new to these convergence concepts, so how does this follow? Is it true that $$Unbiased + Vanishing\text{ }Variance \implies Convergence\text{ }in\text{ } Probability$$ holds in general?

A: Unbiasedness + vanishing variance implies convergence in mean-square; convergence in mean-square implies convergence in probability.
If $A$ is an unbiased estimator of some parameter $\alpha$ then (by definition) we have $\mathbb{E}(A) = \alpha$.  Then, using Chebyshev's inequality we have:
$$\mathbb{P}(|A - \alpha| > \epsilon) = \mathbb{P}(|A - \mathbb{E}(A)| > \epsilon) \leqslant \frac{\mathbb{V}(A)}{\epsilon^2}.$$
If $\lim_{n \rightarrow \infty} \mathbb{V}(A) = 0$ then $\lim_{n \rightarrow \infty} \mathbb{P}(|A - \alpha| > \epsilon) = 0$ for all $\epsilon > 0$, which means $A \xrightarrow{P} \alpha$.
In your particular question, you have $\alpha = \mathbb{E}(X^2)$, so the result you give is correct.  It is a specific case of a more general rule that unbiasedness and vanishing variance implies convergence in mean-square, which then implies convergence in probability.


text:
Q: Template Class Error I have to create a template class. The class creates a set in which you can enter and display numbers. I keep getting a Undefined symbols for architecture x86_64 compiling error though. I can't really find my error. Could someone bring it to my attention?
Set.h
#ifndef SET_H
#define SET_H
#include <iostream>

using namespace std;

template <class T>
class Set
{
    public:

        Set(T n = DEFAULT_SIZE);
        Set(T a[], T n);
        void populate ();
        bool isMember (T n);
        void insertEl (T n);
        void display()const;
        void expandSet(T n);
        ~Set();

    private:
        T * set;
        T pSize;
        T numElements;
        static const T DEFAULT_SIZE;
};

#endif // SET_H

Set.cpp
#include "Set.h"
#include <iostream>

using namespace std;

//***************************************************
// Default constructor to initialize the set to     *
// the empty set. In other words, a set that        *
// contains no elements.                            *
//***************************************************

template <class T>
Set<T>::Set(T n)
{
    cout << "Default constructor[Set(int n)] was called: " << endl;
    numElements = 0;
    set = new T[n];
    cout << "New set was created of size " << n << endl << endl;
    pSize = n;
}

//***************************************************
// Constructor to initialize the set from the array *
// of integers passed to the constructor. The       *
// arguments to this constructor are the array of   *
// integers, size of the passed array.              *
//***************************************************

template <class T>
Set<T>::Set(T a[], T n)
{
    cout << "Constructor [Set(int a[], int n)] was called: " << endl;
    numElements = 0;
    set = new T[n];
    for (int i = 0; i < n; i++)
    {
        set[i] = a[i];
        numElements++;
    }
    pSize = n;
    cout << "New set was created of size " << n << endl << endl;
}

//***************************************************
// A method to populate the set of integers from    *
// user input                                       *
//***************************************************

template <class T>
void Set<T>::populate ()
{
    T n;
    cout << "Enter the number of elements: ";
    cin >> n;
    if (n + numElements > pSize)
    {
        expandSet(n);
    }
    T num;

    cout << "Enter the elements, separating each by a space: ";
    for (int i = 0; i < n; i++)
    {
        cin >> num;
        if (!isMember(num))
        {
            set[numElements]= num;
            numElements++;
        }
    }

}
//****************************************************
// A method to expand the set by a value n           *
//****************************************************

template <class T>
void Set<T>::expandSet(T n)
{
    if (n + numElements > pSize)
    {
        pSize += n+pSize;
        cout<<"Expanding, pSize is now "<<pSize<<endl;
        int *temp = new T[pSize];
        for (int i=0; i< numElements ; i++)
            temp[i]=set[i];
        delete [] set;
        set = temp;
    }
}

//****************************************************
// A method to check if element n is already in the  *
// set. Returns true or false if not.
//****************************************************

template <class T>
bool Set<T>::isMember (T n)
{
    for (int i = 0; i < numElements; i++)
    {
        if (set[i] == n)
            return true;
    }
    return false;
}

template <class T>
void Set<T>::insertEl (T n)
{
    if (!isMember(n))
    {
        if (numElements >= pSize)
        {
            expandSet(pSize);
        }
        set[numElements] = n;
        numElements++;
    }
}

//****************************************************
// A method to display the set. Note that the set    *
// should be displayed using proper set notation     *
//****************************************************

template <class T>
void Set<T>::display()const
{
    for (int i = 0; i < numElements; i++)
    {
        if (i == 0)
            cout << "{";
        cout << set[i];
        if (i == numElements - 1)
            cout << "}";
        else
            cout << ", ";
    }
    cout << endl;
}

template <class T>
Set<T>::~Set()
{
    delete [] set;
}

template <class T>
const T Set<T>::DEFAULT_SIZE = 5;

main.cpp
#include <iostream>
#include "Set.h"

using namespace std;

int main()
{
    Set<int>set1;
    return 0;
}

My compiling error:
Undefined symbols for architecture x86_64:
  "Set<int>::DEFAULT_SIZE", referenced from:
      _main in main.o
  "Set<int>::populate()", referenced from:
      _main in main.o
  "Set<int>::Set(int)", referenced from:
      _main in main.o
  "Set<int>::~Set()", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


text:
Q: Why the ring finger is called the third finger? I've long puzzled about why the ring finger is called third finger in spite of it being the forth finger from the thumb (counting the thumb as the first, the pointing finger the second, the middle finger as the third) and the second from the little finger.
Wikipedia describes it as;

the fourth proximal digit of the human hand, and the second most ulnar
  finger, located between the middle finger and the little finger. It is
  also called digitus medicinalis, the fourth finger, digitus annularis,
  digitus quartus, or digitus IV in anatomy. In Chinese it's called 无名指
  - unnamed finger.

Nothing is related with "the third."
We Japanese also call the ring finger "薬指- kusuri-yubi" meaning the finger (only) used for tasting and examining medicine.
How did the ring finger come to be called the third finger?
For your refference;
Cambridge online English Dictionary defines finger as "One of the five long parts at the end of your hand."
Oxford online English Dictionary defines finger as "Each of the four slender jointed parts attached to either hand, or five, if the thumb is included.
Merriam-Webster English Dictionary defines finger as "One of the five long parts of the hand that are used for holding things; especially: one of the four that are not the thumb."

A: The obvious answer is that the thumb is not a finger. Otherwise it would not be called thumb but first finger.
In German a germanic language just like English we have:

*

*Thumb --> Daumen

*Index finger --> Zeigefinger

*Middle finger (the finger) --> Mittelfinger

*Fourth finger / Ring finger --> Ringfinger

*Pinky --> Kleiner Finger (small finger)

As you can see the thumb is not called finger. So the first finger would be the index finger.
Why is this the first? Because it is the most used.


text:
Q: NodeJS / PassportJS [local] - Is there a way to update req.user automatically? Good morning,
I am currently studying beginner courses online using NodeJS, Passport, MongoDB (+Mongoose) and implementing sign up, login, changing details etc.
While implementing edit profile page which allows users to change their name, email address and profile picture, I have noticed that my req.user does not get updated while the course I am watching says that Passport should handle it automatically and his video evidently does so.
The changes I enter is successfully reflected in MongoDB, which I can see from typing db.users.find({}) in mongo but my req.user object doesn't get updated so my pages still render the old name, email and profile picture until I logout and log back in.
I have worked around it by manually updating req.user as per the code below but I was wondering why my codes behave differently to the videos I am watching. Any guidance will be very appreciated.
//from the controller
export const postEditProfile = async (req, res) => {
  const {
    body: { name, email },
    file,
  } = req;
  try {
    await User.findByIdAndUpdate(req.user._id, {
      name,
      email,
      avatarUrl: file ? file.path : req.user.avatarUrl,
    });
    console.log(req.user);  //shows old db information
    req.user.name = name;
    req.user.email = email;
    req.user.avatarUrl = file ? file.path : req.user.avatarUrl;
    res.redirect(routes.me);
    console.log(req.user); //shows new db information
  } catch (error) {
    res.render("editProfile", { pageTitle: "Edit Profile" });
  }
};

//serializing and deserialzing
passport.serializeUser((user, done) => {
  done(null, user);
});

passport.deserializeUser((obj, done) => {
  done(null, obj);
});

Thank you!

A: The req.user object is created after done in deserializeUser is called. It's a common practice to have deserializeUser make a database query which will in turn update the req.user if changes are made after the initial login.
Here's an example that uses sequelize. You may need to modify the code to work with your database query system. The general idea though is that deserializeUser is called on each request so by querying the database you maintain up to date data.
passport.deserializeUser((obj, done) => {
  try {
    const { userId } = obj;
    const { dataValues: user } = await User.findOne({ where: { userId } }) || {};
    if (!user) done(null, false); // no user found
    done(null, user);
  } catch (err) {
    done(err);
  });


text:
Q: Why isn't my AJAX code working? I believe this should be pretty trivial, but I cannot figure it out at all. I am doing a small test with sending an AJAX request, and echoing a variable extracted from a drop-down menu.
However, it doesn't seem to be executing whatsoever. I was wondering if someone could help me point out what's wrong?
Here are the relevant snippets from index.php:

    <?php

    //create a drop down of available accounts
                echo 'Available Accounts: ';

                echo '<select name=dropAccounts class=dropAccounts>';
                //if there is at least one account available
                if (count($accsAvailable) > 0) {
                    echo '<option value=0>---Select an account---</option>'; //default option
                    foreach ($accsAvailable as $account) {
                        //populate from API
                        echo '<option value=' . $account->getId() . '>' . $account->getName() . '</option>';
                    }
                } else {
                echo '<option value=0>---No accounts---</option>'; //else if no accounts exist
            }
            echo '</select>';

            //for available webproperties
            echo '
 Available Webproperties: ';
            echo '<select name=dropProperties class=dropProperties>';
            echo '<option selected=selected>---Select a webproperty---</option>';
            echo '</select>';

    ?>

The important thing to take away from the snippet is that the first drop-down menu is called 'dropAccounts'.
here is my JS script for handling an onchange event on 'dropAccounts':

I eventually intend to populate the second drop-down menu 'dropProperties' using the value grabbed from 'dropAccounts' but it's not even echoing in my PHP script.
propertyID.php:
<?php

if($_POST['id'])
{
    $accountID = $_POST['id'];
    echo $accountID;
}

?>

I was following the tutorial found here: http://www.9lessons.info/2010/08/dynamic-dependent-select-box-using.html

A: According to what I see the problem is the following:
var dataString = 'id='+ id;
data: dataString

You need to send the data in the following way;
data : {
         'id' : id
       }

And it should send you the data in the correct format.
EDIT: I'm adding this to clarify how your code would look.

A: your generated html is not valid. every class and name should be inside quotes.
Change your index.php
like this:

    <?php

    //create a drop down of available accounts
    echo 'Available Accounts: ';

    echo '<select name="dropAccounts" class="dropAccounts">';
    //if there is at least one account available
    if (count($accsAvailable) > 0) {
        echo '<option value="0">---Select an account---</option>'; //default option
        foreach ($accsAvailable as $account) {
            //populate from API
            echo '<option value="' . $account->getId() . '">' . $account->getName() . '</option>';
        }
    } else {
        echo '<option value="0">---No accounts---</option>'; //else if no accounts exist
    }
    echo '</select>';

    //for available webproperties
    echo '
 Available Webproperties: ';
    echo '<select name="dropProperties" class="dropProperties">';
    echo '<option selected=selected>---Select a webproperty---</option>';
    echo '</select>';

    ?>

you should append in the ajax success callback:
$(".dropProperties").append(html);

A: There are a couple of issues here!
For the sake of legibility and syntax highlighting (not to mention that it will draw awareness to your mistakes) you should use direct html output instead of echoing it with php.
Instead of
echo '<select name=dropAccounts class=dropAccounts>';

try
//End php parsing with a closing php tag
?>
<select name=dropAccounts class=dropAccounts>
<?php
//Resume php parsing

This draws attention to the fact that you're not surrounding your attribute values with quotes
Instead of
<select name=dropAccounts class=dropAccounts>

It's important that you quote the attribute:
<select name="dropAccounts" class="dropAccounts">

The next thing is that you're trying to insert the server's output (a raw STRING) into a select element with this code:
success: function(html) {
    $(".dropProperties").html(html);
}

I believe this is what you want instead:
success: function(html) {
    var newOption = $('<option value="' + html + '">' + html + '</option>');
    $(".dropProperties").append(newOption);
}

According to html specification, only option elements should be the children of select elements. In order to add a string into the select element, my code is creating a new option element, making its text the "html" string, and inserting that option element into the select element.
Hope this helps!


text:
Q: Who sells alchemy recipes? Alchemy can be pretty powerful in the game, and there is a huge difference between the simple versions of potions, oils and bombs and the enhanced or superior versions. The superior versions are often much better than the first ones you can craft.
My main problem is that I'm still missing many recipies, especially annoying is missing the first one and being unable to craft the enhanced and superior versions due to that. I've been trying to buy all recipies I could find, but I'm certain that I haven't found everyone that sells alchemy recipies.
Who are the merchants that sell alchemy recipies, and where can I find them?

A: A few vendors (to be firmed up when I get to my PC):

*

*The Halfling Herbalist, south Novigrad (mid-high tier)

*Herbalist, Hierarch Square (low tier)

A: There are many vendors that sell alchemy recipes. Maybe this alchemy guide will help.


text:
Q: Merging and Sorting struct array in c I am trying to make a c99 program that reports the number of bytes downloaded by devices using WiFi.
It takes in a packet file as input, and each packet is sorted into an array of structs that contain the mac id and size of packet.
Now I am trying to sort out the array of structs in ascending order, and add the bytes of the same mac address and delete the added record.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define PACKETS "sample-packets"
#define MAXMACADD 500

struct packetStruct {
    char mac[17];
    int size;
} packetStruct[MAXMACADD];

struct output {
    char mac[17];
    int size;
} output[MAXMACADD];

void sortSize(struct packetStruct* macadd, int n) {
  int j, i;

  for (i = 1; i < n; i++) {
    for (j = 0; j < n - i; j++) {
      if (macadd[j].size < macadd[j + 1].size) {
        struct packetStruct temp = macadd[j];
        macadd[j] = macadd[j + 1];
        macadd[j + 1] = temp;
      }
    }
  }
}

void mergeMac2(struct packetStruct* macadd, struct output* output, int n) {
  int i, j, k=0;

  for (i = 0; i < n; i++) {
    if (strcmp(macadd[i].mac, "\0") != 0) {
      for (j = 0; j < n; j++) {
        if (strcmp(macadd[j].mac, "\0") != 0) {
          if (strcmp(macadd[i].mac, macadd[j].mac) == 0){
            strcpy(output[k].mac, macadd[i].mac);
            output[k].size += macadd[i].size;
            macadd[i].size = 0;
          }
        } else j++;
      }
    } else i++;
    k++;
  }
}

int readpacket() {
  char *token;
  char buf[60];
  int size;
  FILE *packet = fopen(PACKETS, "r"); //open packet file in read mode

  int i = 0;
  int j = 0; //loop control variables
  int k = 0;

  while (fgets(buf, sizeof (buf), packet) != '\0') {
    token = strtok(buf, "\t"); //tokenize buf and point to time
    token = strtok(NULL, "\t"); //point to sender mac add

    token = strtok(NULL, "\t"); //point to dest mac add
    strcpy(packetStruct[i].mac, token);

    token = strtok(NULL, "\t"); //point to byte size
    packetStruct[i].size += atoi(token);

    //printf("%i. %s\t%d\n", i, packetStruct[i].mac, packetStruct[i].size);
    i++;
  }
  fclose(packet); //close packet file

  sortSize(packetStruct, i);
  mergeMac2(packetStruct, output, i);

  for (i = 0; i < 20; i++) {
    printf("%i. %s\t%d\n", i, packetStruct[i].mac, packetStruct[i].size);
  }

  for (i=0; i < 20; i++){
    printf("%i. %s\t%d\n", i+1, output[i].mac, output[i].size);
  }
  return 0;
}

void main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("%s: program needs 1 argument, but there was %d\n", argv[0], argc - 1);
    exit(EXIT_FAILURE);
  } else {
    if (strcmp(argv[1], "packets") != 0) {
      printf("%s: program expected command 'packets', but you wrote %s\n", argv[0], argv[1]);
    } else {
      if (readpacket() != 0) {
        exit(EXIT_FAILURE);
      }
    }
  }
}

You can compile in command line using:
$: gcc main.c

run using:
$: ./a.out packets

It is sorting it fine but the merging is the issue. Should i use another struct called output and store the values in there or should i just merge up the current array? time-efficiency is not necessary.
I can provide the sample input file if it would be useful.

A: If I have understood you correctly you want to add all sizes from the same mac address. Then mergeMac2() should be like that (edit: now it's a version that completely preserves the original macadd array):
  // return number of elements in output
  int mergeMac2(struct packetStruct* macadd, struct output* output, int n) {

      int i, j, k=0;

      for (i = 0; i < n; i++) {
          // '"\0" makes no difference to "" here
          //if (strcmp(macadd[i].mac, "\0") != 0) {
          if (strcmp(macadd[i].mac, "") != 0) {
              // search in putput;
              for( j=0; j<k && strcmp( macadd[i].mac, output[j].mac ) != 0; j++ ) ;
              if( j == k ) {
                  // not yet created in output
                  strcpy( output[k].mac, macadd[i].mac );
                  output[k].size = macadd[i].size;
                  k++;
              } else {
                  output[j].size += macadd[i].size;
              }
          }

      }
      return k;
  }

Now you have added all sizes for each mac address to the first struct element that originally contained that address. Your second printf() loop should now be:
int j, n;
...
n = mergeMac2( packetStruct, output, i );
for( j=0; j<n; j++ ) {
    ...
}

At least I think you should first merge and then sort but that depends on what you want to achieve, of course.

A: void mergeMac2(struct packetStruct* macadd, struct output* output, int n)
{
    int i, j, k = 0;

    for (i = 0; i < n; i++) {
        /*
         * If size is 0, the packet has already been processed.
         */
        if (macadd[i].size == 0)
           continue;

        memcpy(&output[k], &macadd[i], sizeof(struct packetStruct));

        for (j = i+1; j < n; j++) {
            /*
             * If size is 0, the packet has already been processed.
             */
            if (macadd[j].size == 0)
               continue;

            if (strcmp(macadd[i].mac, macadd[j].mac) == 0) {
                output[k].size += macadd[j].size;

                /*
                 * Set size to 0 so that these packets won't be
                 * processed in the next pass.
                 */
                macadd[j].size = 0;
            }
        }
        k++;
    }
}


text:
Q: adding/removing days from date code fix needed I have this code here:
public static String AddRemoveDays(String date, int days) throws ParseException
    {
        SimpleDateFormat k = new SimpleDateFormat("yyyyMMdd");
        Date d = k.parse(date);
        d = new Date(d.getTime() + days*86400000);
        String time = k.format(d);

        return time;
    }

It take String formed "yyyyMMdd", and adds int days to it. It should work then the days is negative - then he would substract the days from the date. When it does it's math, it returns String formated "yyyyMMdd".
At least that is what it should do. It works for small numbers, but if I try to add (or remove), for example, a year (365 or -365), it returns wierd dates.
What's the problem?
Should I do it a completley another way?

A:     d = new Date(d.getTime() + days*86400000);

If you multiply 86400000 by 365 integer cant hold it. Change 86400000 to Long
    d = new Date(d.getTime() + days*86400000L);

and it will be fine.

A: Hard to say what's going on without specific dates.
If you're committed to doing this with the raw Java classes, you might want to look at using Calendar -e.g.
Calendar calendar = Calendar.getInstance();
calendar.setTime(d);
calendar.add(Calendar.DATE, days); // this supports negative values for days;
d = calendar.getTime();

That said, I would recommend steering clear of the java Date classes, and look to use jodaTime or jsr310 instead.
e.g. in jsr310, you could use a DateTimeFormatter and LocalDate:
DateTimeFormatter format = DateTimeFormatters.pattern("yyyyMMdd");
LocalDate orig = format.parse(dateString, LocalDate.rule());
LocalDate inc = orig.plusDays(days); // again, days can be negative;
return format.print(inc);


text:
Q: Intermittent problems trying to get the correct question search results for just my tags on the Math site A few minutes ago, when I refreshed my screen to see the latest set of questions with just my selected tags on the Math site, I got this:

I checked to find I could see all of the questions on this site, as well as Math and MathOverflow. However, trying a refresh again with searching just my tags took a long time, but I got the same result as above. However, the third time I tried this, it then finally worked, with over 59,000 results showing, but I seem to recall there being around 80,000, so it might still not be working properly.
Also, as I'm writing this, I tried a fourth time, and got the error occurring one more time. Thus, it seems to be an intermittent problem. Since the list of all questions for the Math site appears to be working properly, it appears the issue is related to just the search operation. Note I haven't tried it on any other sites, so I don't know how widespread the problem is.
Trying a fifth time, I now got the following error occurring instead:

However, the list of all questions for the Math site is still working, including showing new questions coming in.

Update: It now appears to be working properly, with 78,977 questions showing, which seems to be the correct number based on my recollection of the past values.

Update #2: When I've tried refreshing since then, it's often slow, but apparently works properly. However, just several minutes ago (about 4 hours after I originally posted this), I got this result:

The "newest" question it shows is from around the time when the earlier troubles were occurring when I originally posted this question, but there have been quite a few additional questions since then. Note, though, when I did another refresh shortly afterwards, I got the following:

As the light-blue link highlights show, I've already looked at these recent questions, with no more recent ones I saw which aren't showing now. Thus, the system seems to be behaving properly again, at least for now.

Update #3: Just over a week later, this problem is occurring again now, on Oct. 28/20 at about 8:30 p.m. UTC. In particular, trying to search for tagged questions on the Math side, I first got a screen saying there's no results, like the first image in this question, and then a notice the site is offline for maintenance. However, I can still get the list of recent questions on this site, and the ones for just one specific tag on MathOverflow.
Note when I just tried to get the list of my tagged questions on this site, it took a long time, but I did eventually get a list back. However, trying this with MathOverflow, I also got the same offline message, so the issue is not with just the Math site but, I suspect, it's a problem network wide.
I just checked on the Math site to see it has now come back with a list, but it's once again short of what is the correct amount. It shows

but the correct number is just under 80,000, so it's missing about 20,000 questions.
I would appreciate somebody checking into this to see what can be possibly done to fully fix the issue so it doesn't keep coming up.


text:
Q: Does dial-up support HTTPS connections? We have some customers still using dial-up in remote locations. After disabling HTTP and forcing them to use HTTPS, some of those offices have indicated they cannot connect.
I have searched online and only confirmed my prior knowledge so far - dial-up uses PSTN to connect to the internet and should be able to support HTTP/HTTPS. The only possible causes I can think of are platform supportability for our current TLS cipher suite. However, the customer is using a recent version of our software and working on Windows 7. LMK

A: In theory, there is no reason why dial-up cannot do https. It is Level 7 protocol and dialup is on levels 1-3, so it even doesn't know there is any https (it is just pack of data).
Therefore there might be some limitation on the ISP side, like some proxy, protocol filtering etc. This must be communicated with ISP itself, but I personally don't even believe some provider will shut down HTTPS. Is there any other HTTPS-enabled site accessible? Facebook, twitter for example.

A: As explained by @Ondra Sniper Fildr, dial-up is simply one of several transport options one can use to join an IP network.
However, I think the situation might warrant some consideration when looking at your TLS setup.
Notably, I would highly recommend you look into the High Performance Browser Networking book's TLS chapter, which includes some rationale for, and recommendations to, try and optimise your TLS stack for low latency and (particularly relevant in your case) to reduce the number of round-trips added by TLS (typically 3, can be 1).
You might also want to consider enabling HTTP/2 if you can, to further optimise the connection.
The combination of both a tuned TLS setup and more efficient HTTP handling should yield a performance improvement for all your users, and should make the experience of using dial-up a little less painful for those that do so.

A: In addition to the first answer of @Ondra Sniper Flindr
Most https sites has heavy weight content now. PSTN dialup speed can't be more 64Kbps or 128Kbps for ISDN connections. It takes more time to download this content but https protocol is very
sensitivity of timeout and errors.
These connections often have many transmission errors, which can break https connection and all encrypted content must be reloaded.
Also Windows 7 often downloads it's updates which has usually 300MB per a week. The computer will take more one day for it with such speed.
When you use https connection at this moment the connection timeout may occur.
It's important to have synchronized date and time for https encryption.


text:
Q: Active Directory + whenChanged attribute Can someone explain what the 'whenChanged ' attribute is for in AD. We have recently been running a report on this attribute because I believe this attribute will will tell what accounts have changed in Active Directory but we are getting loads of reported updates on user accounts that I cannot explain
thanks

A: The whenChanged attribute is updated anytime a local write occurs. It's not a replicated attribute (e.g. maintained locally on each domain controller).
If you want to see what changed specifically,
Look at repadmin /showobjmeta:"DN of object goes here".
Thanks,
Brian Desmond
Active Directory MVP

A: I can't find any information on a "whatschanged" attribute. The closest is the whenChanged attribute which is merely a timestamp which is updated when any other object property changes.
Where do you see "whatschanged" and how are you generating a report?


text:
Q: PHP array_intersect() - how does it handle different types? If I've got an array of values that are basically zerofilled string representations of various numbers and another array of integers, will array_intersect() still match elements of different types?
For example, would this work:
$arrayOne = array('0003', '0004', '0005');
$arrayTwo = array(4, 5, 6);

$intersect = array_intersect($arrayOne, $arrayTwo);

// $intersect would then be = "array(4, 5)"

And if not, what would be the most efficient way to accomplish this? Just loop through and compare, or loop through and convert everything to integers and run array_intersect() after?

A: From http://it2.php.net/manual/en/function.array-intersect.php:

Note:  Two elements are considered equal if and only if
(string) $elem1 === (string) $elem2.
In words: when the string representation is the same.

In your example, $intersect will be an empty array because 5 !== "005" and 4 !== "004"

A: $ cat > test.php
<?php
$arrayOne = array('0003', '0004', '0005');
$arrayTwo = array(4, 5, 6);

$intersect = array_intersect($arrayOne, $arrayTwo);

print_r($intersect );

?>

$ php test.php
Array
(
)
$
So no, it will not.   But if you add
foreach($arrayOne as $key => $value)
{
   $arrayOne[$key] = intval($value);
}

you will get
$ php test.php
Array
(
    [1] => 4
    [2] => 5
)


text:
Q: Redirect a dynamic URL with Apache I need to make a Apache rule to redirect an specific URL
http://www.domain.cl/section.do?one.second=8  --> http://www.newdomain.cl/
I was reading about using mod rewrite but all the examples i found use regular expressions and i don't want to other URL (like www.domain.cl/section.do?one.second=9) was affected for the rule that i want to create.
Any ideas?
Thanks.

A: The query string isn't part of the URI as far as mod_rewrite is concerned, so you need to specifically check its contents.  If you want to redirect for just that one specific URI and one specific exact query string, then you'll want..
RewriteCond %{QUERY_STRING} ^one\.second=8$
RewriteRule ^/section\.do$ http://www.newdomain.cl/ [R=301,L]


text:
Q: Flask JWT Token/ Payload - Return User Json I understand that Flask JWT gives us the /auth endpoint. Once a user successfully logs in, an access token is assigned and the logged in user can be stored in Flask JWT's current_identity. What I'm wondering is can I also return the User Json back to my client in the same /auth endpoint? Or does it have to be a separate request?
This is for a mobile rest-api, using Flask-Restful. Right now, I have a user log in. The login route (/auth) returns the access token to the client, and then I use the token to get the User Json in a separate request, but I feel like I should be able to condense this into the same request.
Any tips are appreciated :)
IDEA:
Can I create an auth resource via flask-restful and specify exactly what I want it to return? (the token for the server and the user json to the client?)

A: Flask-JWT has been abandoned for quiet a while now. I would suggest checking out Flask-JWT-Extended instead as an alternative that is still actively maintained (full disclosure, I'm the author of that extension).
In Flask-JWT-Extended you create your own endpoint instead of having the extension create one for you, so you can return whatever data you want there. Here is an example of this in action: http://flask-jwt-extended.readthedocs.io/en/latest/basic_usage.html


text:
Q: PHP/MYSQL: Why is my database all of the sudden case-sensitive for table names on my Linux server (and not on my XP server)? how can i make it so that the tables are case insensitive?

A: Table names are case-sensitive based on the OS's filesystem.  On windows, filenames are not case-sensitive, so you can specify either.  However, on Linux, filenames are case-sensitive.  Hence the difference.
Best practice is to make your SQL conform exactly to the table name.
MySQL Documentation on identifier case sensitivity

A: Tables in MySQL are files (named the same as the table) behind the scenes.  If those files are stored on a case-sensitive filesystem (like, say, just about every FS Linux supports), then MySQL will care about the case of table names.  On the other hand, Windows filesystems tend to ignore case when looking up files, so any case could work.
You may be able to use a different engine for the database (InnoDB may be case insensitive, as it stores its tables differently), but really, you ought to be using consistent case all the time -- that'd make case sensitivity irrelevant.

A: MySQL metadata is case sensitive by default on Linux.
To avoid that go to /etc/my.cnf and put the following line:
lower_case_table_names = 1


text:
Q: Custom menu with JS in WordPress theme I have my custom menu in HTML theme and I want to create same menu but in wordpress.
On my page u can see how it works...
In this menu I use jQuery and Bootstrap dropdown. How to create this menu using wp_nav_menu ?
This is my code (HTML, JS, CSS).

/*!
 * Start Bootstrap - Simple Sidebar HTML Template (http://startbootstrap.com)
 * Code licensed under the Apache License v2.0.
 * For details, see http://www.apache.org/licenses/LICENSE-2.0.
 */

/* Toggle Styles */
/* FB, wersja jezykowa */
.fb-language {
  position: fixed;
  bottom: 20px;
  left: 65px;
  list-style: none;
}

/* Ikonka jezyka */
.lang-item {
    display: inline;
}

/* ikonka fb */
.fb-language img {
  display: inline-block;
  width: 20px;
  height: auto;
}

.fb-language p {
  display: inline-block;
  color: #999999;
  font-size: 12px;
  margin-left: 5px;
}

.fb-language a {
  text-decoration: none;
  color: #999999;
}

.fb-language a:hover {
  color: #656565;
  text-decoration: underline;
}

/* Kolor linku w menu jezeli jestes na podstronie */
.current_page_item a {
  color: black !important;
}

.page_item {
  list-style: none !important;
}

.dropdown-toggle .icon-bar {
  margin-bottom:4px;
  margin-top: 4px;
  display: block;
  width: 22px;
  height: 2px;
  background-color: #ffffff;
  border-radius: 1px;
}

/* kolor button'a dla mobilnego menu */
button {
  background-color: rgb(230, 225, 225) !important;
  text-align: left !important;
  left: 8px !important;
  position: absolute;
}

.navbar-header {
  position: fixed !important;
  width: 100% !important;
  height: 45px !important;
  background-color: rgb(255, 255, 255) !important;
  border-radius: 0 !important;
  margin: 0 auto !important;
  text-align: center !important;
}

.navbar-header img {
  width: 13% !important;
  height: auto !important;
  margin: 0 auto !important;
  text-align: center !important;
}

#wrapper {
    padding-top: 50px;
    padding-left: 0;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}

#wrapper.toggled {
    padding-left: 250px;
}

#sidebar-wrapper {
    z-index: 1000;
    position: fixed;
    left: 250px;
    width: 0;
    height: 100%;
    margin-left: -250px;
    overflow-y: auto;
    background-color: rgb(255, 255, 255);
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}

#wrapper.toggled #sidebar-wrapper {
    width: 250px;
}

#page-content-wrapper {
    width: 100%;
    background-color: rgb(214, 214, 214);
    position: absolute;
    padding: 15px;
}

#wrapper.toggled #page-content-wrapper {
    position: absolute;
    margin-right: -250px;
}

/* Sidebar Styles */
.sidebar-nav {
    position: block;
    top: 0;
    width: 250px;
    margin: 0;
    padding-top: 9px;
    padding-left: 50px;
    list-style: none;
    text-align: left;
}

.sidebar-nav li {
    list-style: none;
    text-indent: 20px;
    line-height: 40px;
}

.sidebar-nav li a.bez:before {
  content: " " !important;
}

.sidebar-nav li a {
    display: block;
    line-height: 18px;
    text-decoration: none;
    color: #999999;
}

.sidebar-nav li a:hover {
    text-decoration: none;
    color: #000;
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
    text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
    font-size: 14px;
    line-height: 30px;
}

.sidebar-nav > .sidebar-brand a {
    color: #999999;
}

.sidebar-nav > .sidebar-brand a:hover {
    color: #000;
    background: none;
}

.sidebar-nav > .sidebar-links {
    padding-left: 43px;
}

.sidebar-nav2 {
    position: block;
    top: 0;
    width: 250px;
    margin: 0;
    padding-top: 60px;
    padding-left: 80px;
    list-style: none;
    text-align: left;
    list-style: none;
    text-transform: lowercase;
}

.sidebar-nav2 li {
    text-indent: 20px;
    line-height: 24px;
}

.sidebar-nav2 li a {
    display: block;
    text-decoration: none;
    color: #999999;
}

.sidebar-nav2 li a:hover {
    text-decoration: none;
    color: #000;
}

.sidebar-nav2 li a:active,
.sidebar-nav2 li a:focus {
    text-decoration: none;
}

@media(max-width: 769px) {
  #wrapper {
    padding-top: 70px !important;
  }

  .sidebar-nav {
    padding-top: 5px !important;
    margin-top: 0;
  }

  .fb-language {
    position: absolute;
    bottom: 20px;
    left: 65px;
    z-index: 10;
  }
}

@media(min-width:769px) {
    #wrapper {
        padding-left: 250px;
    }

    #wrapper.toggled {
        padding-left: 0;
    }

    #sidebar-wrapper {
        width: 250px;
    }

    #wrapper.toggled #sidebar-wrapper {
        width: 0;
    }

    #page-content-wrapper {
        padding: 20px;
        position: relative;
        background-color: rgb(214, 214, 214);
    }

    #wrapper.toggled #page-content-wrapper {
        position: relative;
        margin-right: 0;
    }
}

  <button href="#menu-toggle" class="btn btn-xs btn-default dropdown-toggle" id="menu-toggle">
    Toggle navigation

  </button>

 ARCHITEKTURA

jednorodzinne

dom opolski

dom 2

dom 3

wielorodzinne

dom 1

dom 2

dom 3

usługowe

przedszkole w Chróścicach

obiekt 2

obiekt 3

PORT DESIGN

meble

stół 1

stół 2

krzesło 1

ceramika

ceramika 1

ceramika 2

ceramika 3

grafika

grafika 1

grafika 2

grafika 3

inne

inne 1

inne 2

inne 3

PORT MIEJSCE

kawiarnia

kawa

śniadanie

wydarzenia

coworking

coworking 1

coworking 2

coworking 3

warsztat

warsztat 1

warsztat 2

warsztat 3

cennik

A: In WordPress, the menus are usually done by using the admin dashboard UI. Using appearance -> Menus.
The drop-down ability is done by indenting sub-menu items to the parent menu item. Then it's either you add you own JavaScript to manipulate how  the current menu behave, or your current theme could be doing it exactly how you want it.
I'd look into using the right theme as well.

A: I'm using the wordpress bootstrap navwalker for using the bootstrap menu. You can easily edit the walker.
Try https://github.com/twittem/wp-bootstrap-navwalker
~ Neme


text:
Q: Proving that $\frac{2xy}{x^2+y^2}$ is discontinuous? I'm reading Courant's: Calculus, Vol 2.
When he speaks about continuity, he gives the following example:
$$
f(x,y) = \left\{
        \begin{array}{ll}
            \cfrac{2xy}{x^2+y^2} & \quad (x,y)\neq (0,0)\\
            \quad\,\,\, 0 & \quad (x,y)= (0,0)
        \end{array}
    \right.
$$
And argues why this function is not continuous, however, I'd like to test it's continuous using the definition. I can understand Courant's argument: He takes $f(x,0)=0, f(0,y)=0$ and show that along the line $y=x$, we have: $f(x,x)=1$ and with this, we could choose any value $c$ for $f(0,0)=c$ and we would always have one path for which the function is discontinuous.
My question is different of this question because I don't want to find some paths and show it is discontinuous (I already know how to do this in the last paragraph), I'm actually using Courant's example to ask about something more subtle: Suppose I have a function $f(x,y)$ and want to test It's continuity at some point, I know I can test all paths along a line, I know I could use polar coordinates but given what I've seen in my lectures, the positivity of such tests is not a proof of continuity - It seems that even when these two tests are positive, there are still infinite paths in which the function could be discontinuous.
I've set up the expressions according to the text:

What do I do now? I tried to write:
$$|f(h,k)-f(0,0)|\leq \epsilon$$
$$\left|\cfrac{2hk}{h^2+k^2}\right|\leq \epsilon$$
And it should hold for all the pairs given in the text but I'm not sure about what I should do now. I guess that it would be counter productive to search for a pair that acts as a counterexample because in more complicated functions, it may not be so easy to find one. I'm completely lost at what I should do now.
EDIT: I have tried to put some thought on it and also tried to read the definition of continuity in Zorich's book:

So this seems almost like a sort of script which seems a little easier to grasp. I take one neighborhood $N(f(a))$, then I need to find a neighborhood $N(a)$ such that $f(N(a))\subset N(f(a))$, then if it's impossible to find a neighborhood $N(a)$ for some neighborhood $N(f(a))$, the function is discontinuous.
Now I guess I can suppose $N(f(a))$ has length $\epsilon$ (in $\Bbb{R}^1$) , I guess I need to pick a reasonable radius for $N(a)$, that is: $x^2+y^2\leq \delta$. For operational simplicity, I have decided to use: $x^2+y^2 = \delta$ but I'm totally unaware of how catastrophic that could be (supposing it could be catastrophic). Now:
$$x=\pm\sqrt{\delta - y^2}\quad \quad \quad\quad  \quad y=\pm\sqrt{\delta - x^2} $$
$$f(\sqrt{\delta - y^2}, \sqrt{\delta - x^2} )=f(-\sqrt{\delta - y^2},- \sqrt{\delta - x^2} )= \frac{2\sqrt{\delta - y^2}\sqrt{\delta - x^2}}{\delta}$$
$$f(-\sqrt{\delta - y^2}, \sqrt{\delta - x^2} )=f(\sqrt{\delta - y^2},- \sqrt{\delta - x^2} )=\frac{-2\sqrt{\delta - y^2}\sqrt{\delta - x^2}}{\delta}$$
This is the operational simplicity I mentioned: If I used $x^2+y^2\leq \delta$, I guess I couldn't make that substitution which - at least for first sight, seems to be a little helpful and harmless. Now I guess I need to check if:
$$-\epsilon \leq \frac{2\sqrt{\delta - y^2}\sqrt{\delta - x^2}}{\delta}\leq \epsilon \quad \quad \quad -\epsilon \leq \frac{-2\sqrt{\delta - y^2}\sqrt{\delta - x^2}}{\delta}\leq \epsilon $$
In which I guess that solving just one of the cases, would prove the other one. So I'll pick the first one:
$$-\epsilon \leq \frac{2\sqrt{\delta - y^2}\sqrt{\delta - x^2}}{\delta}\leq \epsilon $$
And here, I suppose I picked one small $\epsilon>0$, I guess I need to find a $\delta$ in terms of $\epsilon$ which I'm not completely sure but seems to ammount to the same as solving for $\delta$? So:
$$-\epsilon\delta \leq 2\sqrt{\delta - y^2}\sqrt{\delta - x^2}\leq \epsilon\delta $$
Now I need to square all the sides:
$$\epsilon^2\delta^2 \leq 2(\delta - y^2)(\delta - x^2)\leq \epsilon^2\delta^2 $$
If this is a valid move, then:
$$2 \delta ^2-2 \delta  x^2+2 x^2 y^2-2 \delta  y^2=\epsilon^2\delta^2 $$
Solving for $\delta$ gives me:
$$\delta=\frac{-x^2-y^2\pm\sqrt{x^4+2 x^2 y^2 \epsilon ^2-2 x^2 y^2+y^4}}{\epsilon ^2-2}$$
Now if $\epsilon \to 0$, then:
$$\delta=\frac{1}{2} \left(x^2+y^2\pm\sqrt{\left(x^2-y^2\right)^2}\right)$$
But I'm not sure if this would imply something useful or if everything I did was a complete nonsense.

A: Let $\epsilon = 0.9$ and suppose a $\delta$ with the desired property exists. Then, for instance, $(h,k) = \left(\dfrac{1}{2}\delta, \dfrac{1}{2}\delta\right)$ is in the ball of radius delta centered at the origin.
However
$$|f(h,k)| = \dfrac{2\cdot h^2}{h^2+h^2}=1 > \epsilon$$


text:
Q: Are there any weapons in FO4 that are natively chambered in .50 caliber? Are there any weapons in FO4 that are natively chambered in .50 caliber?
By natively chambered, I mean a gun that doesn't need a ".50 caliber receiver" mod to fire .50 caliber rounds, so that it can potentially take other receiver mods and still shoot .50 caliber bullets.
I was really looking forward to finding my first anti-materiel rifle and modding it up with a Calibrated Powerful Receiver and the other top tier sniper mods to relive the fun I had in FO:NV, sneaking around with my silenced anti-materiel rifle and one-shot-killing all the Mojave's toughest creatures with a headshot.
Sadly, I haven't been able to find any common weapons that are natively chambered in .50 caliber, preventing me from reliving that fun in FO:4.  (And no, slapping a .50 caliber receiver into something isn't even close to the same experience.)
So, while I'm pretty sure there are no common guns that are natively .50 caliber, I'm still holding out a faint hope that maybe there's a unique or rare weapon that is.  Does anyone know, one way or the other?

A: If the Fallout Wikia's Fallout 4 Weapons wiki page and table is accurate and contains all information, then no, there are no base weapons that use .50 ammo.
Their ammunition page has the following weapons listed as using .50 ammo:

*

*Hunting rifle

*Pipe bolt-action pistol

*Reba II (unique weapon)


text:
Q: Show that $x$ is commutative and $+$ is associative for these binary operations on $\mathbb{R}^2$ \begin{align*}
+ : \mathbb{R}^2\times\mathbb{R}^2 &\rightarrow \mathbb{R}^2\\
((a,b),(c,d))&\mapsto(ad+bc,bd)\\[1cm]
\times: \mathbb{R}^2\times \mathbb{R}^2 &\rightarrow  \mathbb{R}^2\\
((a,b),(c,d))&\mapsto(ac,bd)
\end{align*}
Questions:
a) Show that $\times$ is commutative.
b) Show that $+$ is associative.
c) Show that $\times$ is not distributive over $+$.
d) Show that there is a neutral element for $+$.

A: a. Assuming that we commute in $\mathbb{R}$, $(a,b) \times (c,d) = (ac,bd) = (ca,db) = (c,d)\times(a,b)$
b. $$((a,b) + (c,d)) + (e,f) $$$$= (ad+bc,bd) + (e,f) $$$$= ((ad+bc)f+bde, bdf)$$
and we also have
       $$(a,b) + ((c,d) + (e,f)) $$$$= (a,b) + (cf+de,df) $$ $$= (adf + b(cf+de), bdf)$$ $$=((ad+bc)f+bde, bdf)$$
So we have associativity.
c. Here is a good counter example. We are going to go step by step on this first one now: $(1,2) \times ((3,4) + (1,1)) =(1,2) \times(3\cdot 1+4\cdot 1, 4 \cdot 1) =(1,2) \times (7,4) = (1\cdot 7, 2\cdot 4)$ $$ = (7,8)$$
$(1,2) \times (3,4) +(1,2) \times (1,1) = (3,8) + (1,2) $ $$= (14, 16)$$
So we have shown that distributive law does not work.
d. (0,1) is neutral. Notice that $(a,b) + (0,1) = (a\cdot1+ b\cdot 0 , b\cdot 1) = (a,b)$ for any $(a,b)$


text:
Q: Tabulator library and undo function I am trying to add row menu and header menu to my table.Both functions works fine , but function undo does not working and function userTable.getHistoryUndoSize() allways returns 0. Undo works fine when I editing data in table manually only.
Can someone help what I am doing wrong?
I am using latest tabulator 4.8.3
Thank you
var rowMenu = [{
    label:"Enable All Floors",
    action:function(e, row){
        userTable.blockRedraw();
        row.update({f1:true});row.update({f2:true});row.update({f3:true});row.update({f4:true});row.update({f5:true});row.update({f6:true});
        row.update({f7:true});row.update({f8:true});row.update({f9:true});row.update({f10:true});row.update({f11:true});row.update({f12:true});
        row.update({f13:true});row.update({f14:true});row.update({f15:true});row.update({f16:true});
        userTable.restoreRedraw();
    }
},
{
    label:"Disable All Floors",
    action:function(e, row){
        userTable.blockRedraw();                                                                            row.update({f1:false});row.update({f2:false});row.update({f3:false});row.update({f4:false});row.update({f5:false});row.update({f6:false});
        row.update({f7:false});row.update({f8:false});row.update({f9:false});row.update({f10:false});row.update({f11:false});row.update({f12:false});
        row.update({f13:false});row.update({f14:false});row.update({f15:false});row.update({f16:false});
        userTable.restoreRedraw();
    }
}
]

var headerMenu = [{
    label:"Set All in column to ON",
    action:function(e, column){
        userTable.blockRedraw();
        rows.forEach(function(row){
            row.update({AL :true});
        });
        userTable.restoreRedraw();
    }
},
{
    label:"Set All in column to OFF",
    action:function(e, column){
        userTable.blockRedraw();
        rows.forEach(function(row){
            row.update({AL:false});
        });
        userTable.restoreRedraw();
    }
}]

dataChanged:function(data){
    console.log("data in table edited");
    document.getElementById( 'undoBadge' ).innerHTML = userTable.getHistoryUndoSize();
    document.getElementById('BTNundoData').removeAttribute("disabled");
    PreventLoseData = true;
},


text:
Q: MobileConnect Best Practices for Short Codes Are there any best practices around short codes? We are having an internal discussion around getting a single short code versus multiple short code. The line of thinking is a single short code for brand consistency versus multiple short codes for line of business branding or process.

A: I believe it is a matter of perspective in terms of the needs you phase -
 and potentially keyword availability. If you insist on "Subscribe" as a keyword for two brands - if it's available - two shortcodes is required. There could also be a matter of having a permission / opt out strategy, e.g. having one shortcode for transactional and one for commercial (so lot of thoughts around it)
Generally speaking though, I believe that the fewer shortcodes the better. Ideally one. The reason is that opt-ins are handled at a Shortcode+Keyword level. Imagine you have a Subscription and Event list. That is 2 which needs to be maintained. If you add an additional shortcode, it would double the amount of lists, assuming you want the same.
However, answer could vary depending on the primary purpose of your SMS usage?


text:
Q: ClipToBounds with no border colour issue - Xamarin.iOS, C# Program:

*

*I have a UIImageView. The image view has an image, a border and a
corner radius (rounded).

*The image view property "ClipsToBounds" is set to true so the image
matches the rounded corners.
Code:
UIImageView imageView = new UIImageView();
imageView.Layer.BorderWidth = 5f; //set border thickness
imageView.Layer.CornerRadius = 25; //make corner's rounded
imageView.Layer.BorderColor = UIColor.Red.CGColor; //set border color red
imageView.Image = new UIImage(imgPath); //set img
imageView.ClipsToBounds = true; //required - so image is rounded

Problem:
If I change the border colour to white (transparent) you can see small black lines at every corner. How can I get rid of these?

A: I looked at the core animation layers that being rendered via Revel on the border radius and those are rendering artifacts on the composite (I assume those are rounding errors in the mini-map/anti-aliasing in the radius calculations of the original image color, but that is just a wild guess...)

So if you create a CAShapeLayer with the same radius you are using and apply it as the layer's mask, the artifact becomes smaller. (The Core Animation bezier path is more accurate but not perfect?)

If you create a CAShapeLayer that is one pixel larger on the corner's radius as a "hack", the artifacts are totally masked:

CAShapeLayer/Mask Fix-up Example:
UIImageView imageView = new UIImageView
{
    Image = UIImage.FromBundle("foo.jpg"),
    ClipsToBounds = true,
    Bounds = View.Bounds
};
imageView.Layer.BorderWidth = 5f; //set border thickness
imageView.Layer.CornerRadius = 25; //make corner's rounded
imageView.Layer.BorderColor = UIColor.White.CGColor; //set border color red
var maskingShapeLayer = new CAShapeLayer()
{
    Path = UIBezierPath.FromRoundedRect(imageView.Bounds, UIRectCorner.AllCorners, new CGSize(26, 26)).CGPath
};
imageView.Layer.Mask = maskingShapeLayer;

Note: Maybe someone that is a "hard-core" Core Animation expert can explain way the rendering artifacts exist on these border curves in the first place as I still use CAShapeLayers to do my corner masking which do not have the rendering artifacts even though in iOS 11+ you can just set your UIView's Layer.CornerRadius like the question does.


text:
Q: Showing a div if all inputs are filled in I am stuck trying to figure out how to show a div after checking to see if all inputs have been filled in. I am only wanting the inputs within the #intro-info section to be checked. I am not sure what to write in the else statement to make the button #intro-button display if all of the inputs have been filled in.
Here is a fiddle if it helps

$(function () {
    var intro = $('.intro');

    intro.on('keypress', function() {
        if ($(this).val().length > 1) {
            $(this).next('.intro').addClass('block');
        }
       /* else {
            $('.intro').hide();
        }*/
    });
    var allEmpty = true;

    $('#intro-info :input').each(function() {
        if ($(this).val() !== '') {
            allEmpty = false;
            return false; // we've found a non-empty one, so stop iterating
        } else
    });
     return allEmpty;
});
.intro {
  opacity: 0;
  padding: 10px 15px;
  margin: 20px auto;
}

.intro:first-child {
  display: block;
  opacity: 1;
}
.block {
  display: block;
  opacity: 1;
   -webkit-animation: fadein 1s ease-in;
   -moz-animation: fadein 1s ease-in;
    animation: fadein 1s ease-in;
}
.next {
  display: none;
}
#intro-button {
 display: none;
}

  <input id="name" type="text" class="intro">
  <input id="email" type="email" class="intro">
  <input id="title" type="text" class="intro">
  <button id="intro-button">Proceed</button>

show div

A: You can use jQuery's toggle() method to set the visibility of the element.  So you can grab the input from the text fields, check their lengths, and then pass the result to this function.
For example:
$('.next').toggle($('#name').val().length > 0);

will set the visibility of the next div depending on whether or not something has been entered in the name field.

A: *

*Use input event instead of keypress

*Use jQuery.filter and test all the values in form except button
Also note that selector for next button has to be .next, not #next

$(function() {
  var intro = $('.intro');
  var testFunction = function() {
    return $('#intro-info :input:not(button)').filter(function() {
      return this.value == '';
    })
  };
  intro.on('input', function() {
    $('.next').toggle(!testFunction().length);
  });
});
.intro {
  //opacity: 0;
  padding: 10px 15px;
  margin: 20px auto;
}
.intro:first-child {
  display: block;
  opacity: 1;
}
.block {
  display: block;
  opacity: 1;
  -webkit-animation: fadein 1s ease-in;
  -moz-animation: fadein 1s ease-in;
  animation: fadein 1s ease-in;
}
.next {
  display: none;
}
#intro-button {
  display: none;
}

  <input id="name" type="text" class="intro">
  <input id="email" type="email" class="intro">
  <input id="title" type="text" class="intro">
  <button id="intro-button">Proceed</button>

show div

A: *

*Change your keypress to input.

*CSS id selector is prior to class selector, the  #intro-button{ display:none} is prior to .block{display:block}. So even though class block is added, but display is still none.
The simplest solution is add !important in .block property display :
.block {
  display: block !important;
}

*JS part : Add class when all inputed.
if (intro.filter(function(){
  return $(this).val().length > 1
}).length === intro.length){
  $("#intro-button").addClass('block');
}else {
  $("#intro-button").removeClass('block');
}


text:
Q: How to split an interger in a list where the indexes have only one number in them? I mean something like this;
        input:    x = 12345
        code:     y = magic(x)
              print(y)
        output:   (1, 2, 3, 4, 5)

I want to split the long interger in to many 1 length integers and put them in a list. Hopefully you guys can help

A:
Quoted from https://www.geeksforgeeks.org/python-split-string-into-list-of-characters/

Solution #1: Using For loop
This approach uses for loop to convert each character into a list. Just enclosing the For loop within square brackets [] will split the characters of word into list.
def split(word):
    return [char for char in word]

word = 'geeks'
print(split(word))

Output:
['g', 'e', 'e', 'k', 's']

Solution #2: Typecasting to list
Python provides direct typecasting of string into list using list()
def split(word):
    return list(word)

word = 'geeks'
print(split(word))

Output:
['g', 'e', 'e', 'k', 's']


text:
Q: How can I access the main component's functions from a page navigated to in Ionic 2? I've created an Ionic v2 application using the following command:
ionic start my-app sidemenu --v2 --ts.
Inside the app.ts file, I have some logic (functions) to do some things (like opening a modal and maintaining state for what the side menu should show). When a certain page (e.g. pages/getting-started/getting-started.ts) is shown, I'd like to reuse the same functions in app.ts. How do I access functions of app.ts from a page navigated to?
My app.ts looks like the following.
class MyApp {
 @ViewChild(Nav) nav:Nav;
 private rootPage:any = GettingStartedPage;
 private pages:any;

 constructor(platform:Platform) {
  this.initializeApp();
  this.pages = {
   'GettingStartedPage': GettingStartedPage,
   'AnotherPage': AnotherPage //more pages and modals
  };
 }

 initializeApp() {
  this.platform.ready().then(() => {
   StatusBar.styleDefault();
  });
 }

 openPage(page:string) {
  //when a user clicks on the left menu items, a new page is navigated to
  let component this.pages[page];
  this.nav.setRoot(component);
 }

 openModal(page:string) {
  //modals are opened here, there's more complicated logic
  //but this serves to demonstrate my problem
  let component = this.pages[page];
  Modal.create(component);
 }
}

ionicBootstrap(MyApp);

My getting-started.ts looks like the following.
export class GettingStartedPage {
 constructor(
  platform:Platform,
  viewController:ViewController,
  navController:NavController,
  navParams:NavParams) {
 }

 buttonClicked() {
  //i need to access app.ts openModal here
  //how do i call a method on app.ts?
  //like MyApp.openModal('SomeModal');
 }
}

A: With a shared service, you can communicate across the whole application.
Create a service class like
@Injectable()
class SharedService {
  // use any kind of observable to actively notify about new messages
  someEvent:Subject = new Subject();
}

Provide it on your app
@App({
  ...
  providers: [SharedService]
})

Inject it to the App component and any component, directive, or service you want to communicate to the App component from
constructor(private sharedService:SharedService) {}

someEventHandler() {
  this.sharedService.someEvent.next('some new value');
}

In the App component subscribe to notifications
constructor(sharedService:SharedService) {
  sharedService.someEvent.subscribe(event => {
    if(event == ...) {
      this.doSomething();
    }
  });
}

For details see https://angular.io/docs/ts/latest/cookbook/component-communication.html

A: With Ionic 2 you could use Events for the communication between components.  For example, in your function buttonClicked() you could fire an event
buttonClicked() {
  this.events.publish('functionCall:buttonClicked', thisPage);
}

and listen to it e.g. in the constructor of your main class to open the modal:
this.events.subscribe('functionCall:buttonClicked', userEventData => {
  openModal(userEventData[0]);
});

You can even send data with the event (here: thisPage).

A: in the page component TS file:
import { MyApp } from '../../app/app.component';

constructor(public AppComponent: MyApp) {
  }

then inside the page wherever you want to access that function:
this.AppComponent.functionName();

A: Alternatively, you can go for either
Events

Events is a publish-subscribe style event system for sending and
  responding to application-level events across your app.

or EventEmitter

EventEmitter is an angular2 abstraction and its only purpose is to
  emit events in components.


text:
Q: Magento 2 form validation - accessing mage/validation/validation.js return values? This is my first go at a Magento 2, so please bear with me. I want to add functionality that scrolls the page to an error message if a form does not pass validation. Currently, I am listening for a submit event on the #product_addtocart_form and running a checkError function that runs a copy of the grouped product validation code found in mage/validation/validation.js:
function checkError() {
    /* grouped qty validation code taken from mage/validation.js */
    var result = false;
    var total = 0;
    $('#product_addtocart_form').find('input[data-validate*="validate-grouped-qty"]').each(function (i, e) {
        var val = $(e).val();
        if (val && val.length > 0) {
            result = true;
            var valInt = parseInt(val, 10) || 0;
            if (valInt >= 0) {
                total += valInt;
            } else {
                result = false;
                return result;
            }
        }
    });
    if(!(result && total > 0)) {
        $('html, body').animate({
            scrollTop: $('#product_addtocart_form').offset().top
        }, 1000);
    }
}

Obviously, this is not optimal because the validation code is being run twice for every form submit, once in validation.js and once in my code. And because code duplication, etc.
What I would like to know is, is there a way to access the return value of the 'validate-grouped-qty' function in mage/validation/validation.js?
In Magento 1, this could by accomplished by something like the following:
productAddToCartForm.validator.options.onFormValidate = function(result, form) {
    if(!result) {
        $('html, body').animate({
            scrollTop: $('#product_addtocart_form').offset().top
        }, 1000);
    }
}

A: While I did not find exactly what I was looking for (an analog of onFormValidate), I did find out that you can get an 'isValid' boolean return by simply doing:
var isValid = $('#product_addtocart_form').validation('isValid');

If you do not specify 'isValid' as a parameter, validation() will not return a value but instead only validate the form.
For my purposes, this works very well as it accounts for all possible form invalidations - not just the grouped product qty that I specified above.


text:
Q: Подобрать вормулу в гугл документах для расчета итога конверсии,CR, % а также eCPA,
Помогите подобрать формулу для расчета итога конверсии,CR, % а также eCPA, руб. В интернете много инфы не могу понять как именно я должна прописать формулы для этих столбцов.


text:
Q: Can't mount disk before nfs server starts I have an NFS server with the following /etc/exports line(the only one): /data/Nextcloud devserver.emcci(rw,sync,all_squash,anonuid=33,anongid=33)
But the problem is that data is on another disk than the root filesystem. And nfs-server status says that can't find the /data/Nextcloud folder. So I think that nfs-server.service is running before the disk can be mounted. Here you have the status output:

I have tried some solutions I have found on internet. Like adding x-system.d.before=nfs-server.service in fstab file: UUID=0618335b-3595-4428-aab5-5da1a1d3f450 /data           auto    nosuid,nodev,nofail,x-gvfs-show,x-system.d.before=nfs-server.service 0 0. I have tried also with x-system.d.before=nfs-kernel-server.service.
I have tried also to add After=data.mount to the system.d unit, but had no effect:

What I'm doing wrong? If I start the services manually it works, but not at boot time.
Thanks for your time,
Héctor
EDIT: I have found that adding Before=nfs-server.service on data.mount it works! Even deleting all the other modifications. So, telling the system to mount the disk before sharing it works perfectly, telling it to share it after being mounted does nothing... Does anyone know why?
Haven't post it as an answer because for me isn't a complete answer without knowing why.


text:
Q: Merge multiple spreadsheets with pd.merge I am trying to merge multiple spreadsheets together on Python. I have the same header titles for each column in the same order with the same data types. The only differences between the four are the actual data points in the cell. Here's what I mean
df1:

Header 1
Header 2
Header 3
Header 4

X
A
M
1

Y
B
T
2

df2:

Header 1
Header 2
Header 3
Header 4

G
J
H
5

B
Q
L
8

df3:

Header 1
Header 2
Header 3
Header 4

E
U
D
6

Z
P
S
3

The dtypes for the dfs are as follows:

*

*Header 1: object

*Header 2: object

*Header 3: object

*Header 4: float

I basically just want to stack the data from all of the data frames on top of one another, like this:

Header 1
Header 2

X
A

Y
B

G
J

B
Q

E
U

Z
P

...and so on for header 3 & 4. Any way I can do this with pd.merge?

A: Try df4=df1.merge(df2,on="outer")
followed by

`df4.merge(df3,on="outer")


text:
Q: Groovy: parsing file for mysql database changes i have a text file with content:
ACTION = NEW        // (NEW, CHANGE)
NEW_NUMBER = '123456'
NUMBER_FOR_CHANGE = '789456'
TEXT_NAME1 = 'TEST1'
TEXT_NAME2 = 'TEST2'
TEXT_NAME3 = 'TEST3'

and i want make a code on Groovy script for parsing this file and making next changes:
if action = new:
`sql.executeInsert "INSERT INTO TABLE.DB (NUMBER, NAME1, NAME2, NAME3) VALUES ($NEW_NUMBER, $TEXT_NAME1, $TEXT_NAME2, $TEXT_NAME3)" `

if action = change:
    sql.executeUpdate "UPDATE TABLE.DB SET NAME1 = $TEXT_NAME1, NAME2 = $TEXT_NAME2, NAME3 = $TEXT_NAME3 WHERE NUMBER LIKE $NUMBER_FOR_CHANGE"

if action = delete:
    sql.execute "DELETE FROM TABLE.DB WHERE NUMBER = $NUMBER_FOR_CHANGE"

I will be grateful for any help
Thanks

A: Something like this should do it?
def sqlstr = new Properties().with { props ->
  new File( '/path/to/file' ).withReader { r ->
    load( r )
    switch( props.ACTION ) {
      case 'NEW':
        "INSERT INTO TABLE.DB (NUMBER, NAME1, NAME2, NAME3) VALUES ($NEW_NUMBER, $TEXT_NAME1, $TEXT_NAME2, $TEXT_NAME3)"
        break
      case 'CHANGE':
        "UPDATE TABLE.DB SET NAME1=$TEXT_NAME1, NAME2=$TEXT_NAME2, NAME3=$TEXT_NAME3 WHERE NUMBER = $NUMBER_FOR_CHANGE"
        break
      case 'DELETE':
        "DELETE FROM TABLE.DB WHERE NUMBER = $NUMBER_FOR_CHANGE"
        break
      default:
        throw new RuntimeException( "Unknown ACTION $props.ACTION" )
    }
  }
}

// Assuming sql is set up right:
sql.execute sqlstr


text:
Q: Airflow unable to import the airflow.providers Im wants to import Airflow Google providers. So I installed it.
pip3 install apache-airflow-backport-providers-google

Im able to see all the hooks and everything under the packages directory.
/usr/local/lib/python3.7/dist-packages/airflow/providers/google/cloud/transfer

But when I run the import command its failing.
from airflow.providers.google.cloud.transfers.sql_to_gcs import BaseSQLToGCSOperator

Error:
Traceback (most recent call last):
  File "test1.py", line 8, in <module>
    from custom.custom_PostgresToGCSOperator import custom_PostgresToGCSOperator
  File "/root/airflow/dags/custom/custom_PostgresToGCSOperator.py", line 8, in <module>
    from airflow.providers.google.cloud.transfers.sql_to_gcs import BaseSQLToGCSOperator
ModuleNotFoundError: No module named 'airflow.providers'

A: I had the same issue when upgrading to 2.0.0a1, what I did:

*

*install providers package

*Download the upgrade version:

*

*wget
https://dist.apache.org/repos/dist/dev/airflow/2.0.0a1/apache-airflow-2.0.0a1-bin.tar.gz

*pip install apache-airflow-2.0.0a1-bin.tar.gz

*airflow db upgrade

*airflow scheduler -D; airflow webserver -D

Also refer to this https://cwiki.apache.org/confluence/display/AIRFLOW/AIP-8+Split+Providers+into+Separate+Packages+for+Airflow+2.0


text:
Q: Migrating Azure Mobile Service to AppService and swapping apns certificate Our team has migrated from Azure Mobile Service to AppService and all works fine, except now we need to swap the APNS cert as it's reaching its expiry date.
According to this article: https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-migrating-from-mobile-services it has to be done manually in the file system.
Can someone explain how to do it, using the legacy push? Is it the FTP that I need to use? or maybe something else?

A:
Can someone explain how to do it, using the legacy push?

Currently, the Mobile Apps feature of Azure App Service uses Azure Notification Hubs to send pushes,so we need to configurate the notification for the Appservice. The following is the detail steps:
1.In the azure portal,go to your app service and click [push]
2.Click connect to connect or add a notification hub source to the app
3.Click [Configure push notification services] to configurate push notification
services.

4.Upload the certificate

We also could get more info from the azure tutorials.

A: After some investigation I happily found an answer to this question and I thought it'd be good for others who don;t want to upgrade to NH to share it.
It's enough to go to App Service Editor -> App_Data and swap the certificate there. And this is really it. No need to go to Notification Hubs.
This isn't a Microsoft's recommened approach but it's safe for applications that are already in production state.


text:
Q: Excel VBA Copy Paste I'm trying to copy and paste a certain range from one worksheet to two other worksheets. This is a snippet of code where it seems to go wrong:
row = ActiveWorkbook.Sheets("SheetX").Cells(Rows.Count, 3).End(xlUp).Row

ws.Range("A1", "J1").Copy
ActiveWorkbook.Sheets("Sheet1").Range("B2", "K2").PasteSpecial xlPasteValues
ActiveWorkbook.Sheets("SheetX").Range(Cells(row, 3),  Cells(row,12)).PasteSpecial xlPasteValues

Since the amount of rows is dynamic "row" holds the row number I want to paste it to.
The problem is that I get a "Application-defined or Object-defined"-error on the last line, where I try to past it to the second worksheet.

A: When you run Cells(row,3) you are actually calling Cells(row,3) on the ActiveSheet and not on Sheets("SheetX"). Instead you should do this:
row = ActiveWorkbook.Sheets("SheetX").Cells(Rows.Count, 3).End(xlUp).Row

ws.Range("A1", "J1").Copy
ActiveWorkbook.Sheets("Sheet1").Range("B2", "K2").PasteSpecial xlPasteValues
Range(ActiveWorkbook.Sheets("SheetX").Cells(row, 3),  ActiveWorkbook.Sheets("SheetX").Cells(row,12)).PasteSpecial xlPasteValues


text:
Q: GDB on Solaris: /proc/168: Value too large for defined data type I have a C application running on Solaris SPARC 8 that processes message off Websphere MQ and send them onto a target application.
The application runs unchanged on Solaris 10 and Linux 100%....no issues....
On this specific box it seems to run in say 4000 messages or more and on an AD HOC basis it just "hangs"...
So we installed GDB as I had the hope of attaching to the running process, so when I run something like:
gdb ./idoclink_inbound --pid=168 -tui I get the following output:
exec No process In:                                          Line: ??   PC: 0x0
and "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.8"...
Attaching to program `/opt/smq/idoclink/bin/idoclink_inbound', process 168
/proc/168: Value too large for defined data type.
do_attach: couldn't save traced faults.
(gdb) backtrace
No stack.
(gdb)

I really need to try find out what the process is doing, do you have any ideas what this issue could be?
It almost seems like a GDB bug?
Any advise or help would be greatly appreciated ;-)
Lynton

A:
GDB is possibly compiled in 32 bit mode

Your GDB is definitely built in 32-bit mode. If it was built in 64-bit mode, it would say spacv9-sun-solaris....
Rebuilding in 64-bit mode is likely to solve the problem.


text:
Q: Doing basic exercise from learncpp.com, output for "the least number" in Pancake Glutton isn't right I'm learning C++ currently and wanted to do the following exercise:
Requires:
variables, data types, and numerical operators
basic input/output
logic (if statements, switch statements)
loops (for, while, do-while)
arrays
Write a program that asks the user to enter the number of pancakes eaten for breakfast by 10 different people (Person 1, Person 2, ..., Person 10)
Once the data has been entered the program must analyze the data and output which person ate the most pancakes for breakfast.
★ Modify the program so that it also outputs which person ate the least number of pancakes for breakfast.
★★★★ Modify the program so that it outputs a list in order of number of pancakes eaten of all 10 people.
i.e.
Person 4: ate 10 pancakes
Person 3: ate 7 pancakes
Person 8: ate 4 pancakes
...
Person 5: ate 0 pancakes
Sofar I've gotten the "ate most" and "second most", but I get a problem with the "least" part...
Here is my code:
#include <iostream>
using namespace std;
int arrayPersonsPancakes[]={};
int arrayPersonsNr;

int createArrayforPersons();
void pancakesPerPerson(int);
void whoAteTheMost();

int main(){
int arrayPersonsNr = createArrayforPersons();
pancakesPerPerson(arrayPersonsNr);
whoAteTheMost();

/*for(int i=0; i < arrayPersonsNr; i++){
   cout << arrayPersonsPancakes[i] << endl;
}*/

}

int createArrayforPersons(){
cout << "Please enter the Nr. Of Persons who ate breakfast: " << endl;
int nrOfPersons;
cin >> nrOfPersons;
arrayPersonsPancakes[nrOfPersons];
return nrOfPersons;
}

void pancakesPerPerson(int nrOfPersons){
for (int i=0; i < nrOfPersons; i++){
    cout << "Please enter how many pancakes person Nr." << i+1 << " ate: " << endl;
    cin >> arrayPersonsPancakes[i];
    }

}
void whoAteTheMost(){
    int theMost= arrayPersonsPancakes[0];
    int theSecondMost;
    int theLeast;
for(int i = 0; i < arrayPersonsNr; i++){
    if (arrayPersonsPancakes[i] > theMost){
        theSecondMost = theMost;
        theMost = arrayPersonsPancakes[i];
                }
    }

theLeast = theMost;

 cout << theLeast << endl; //Here I get the normal output

for(int y = 0; y < arrayPersonsNr; y++){
    if (theLeast >  arrayPersonsPancakes[y]) {
        theLeast = arrayPersonsPancakes[y];
    }
}

cout << "after for " << theLeast << endl;  //I always get a zero here after the loop and have no idea why.
}

for(int j = 0; j < arrayPersonsNr; j++){
    if (arrayPersonsPancakes[j] == theMost){
        cout << "Person Nr." << j+1 << " ate the most Pancakes: " << theMost << endl;}
    else if (arrayPersonsPancakes[j] == theSecondMost){
        cout << "Person Nr." << j+1 << " ate the second most Pancakes: " << theSecondMost << endl;}
   else if (arrayPersonsPancakes[j] == theLeast){
        cout << "Person Nr." << j+1 << " ate the least Pancakes: " << theLeast << endl;}

    }
}

After the Loop for "theLeast" I always get a zero no matter what I do.
I'd appreciate any comments to how I code and how I can improve that (regardless of missing comments currently, sorry about that)
Thank you!

A: You are creating local variable arrayPersonsNr in main function
int main(){
        int arrayPersonsNr = createArrayforPersons(); // This is local variable
        pancakesPerPerson(arrayPersonsNr);
        whoAteTheMost();
    }

Modify your code to
int main(){
    arrayPersonsNr = createArrayforPersons(); // This is global variable
    pancakesPerPerson(arrayPersonsNr);
    whoAteTheMost();
}


text:
Q: Redirect on Error - ASP.NET I understand that I can redirect a user on an exception by setting the customErrors element in the Web.config
<customErrors mode="On" defaultRedirect="/WebTest/ErrorPages/AppError.html">
</customErrors>

I could also do a Response.Redirect in the Application_Error event in the Global.asax file.
What are the differences between these 2 approaches and which one is preferred?

A: If you don't want to do anything with the error (such as logging), you'd better simply use the configuration file. It's simpler and easier to reconfigure. Moreover, using the configuration file has the advantage of supporting RemoteOnly type, where you can easily see the exception on the server for diagnostics purposes but others won't be able to see it.
In general, there's no point in writing code for something that's perfectly configurable and is built in the system. Code is more prone to errors than configuration options.

A: I am not sure of anything official, but I find using the config file easier for local testing versus production behaviour.