text:
Q: Dojo 1.6 dialog widget losing content attachpoints We've recently upgraded a project from Dojo 1.5 to 1.6 [for the basic IE9 support] and its broken one of our widgets. We have a dialog widget [dijit.Dialog] with another widget within it [any widget here will produce the same behavior], the expected behavior is for the inner widget to be placed within the dialog widget's contentNode, and each of their attachpoints to be available through the main widget.
This isn't happening, instead we only find the dialog's attachpoint. More details below:
We're doing something like this in our main widget's template:

This provides us a parent widget [main_widget] with two attach points: dia_widget and val_widget, which could be accessed within the main widget [after the buildRendering() function] by calling this.dia_widget and this.val_widget respectively.
After upgrading to 1.6.0 things go awry.
My guess is that when a dialog widget gets parsed it removes the domNode of its content into its new containerNode. When the rootnode is having attachpoints assigned, since the domNode is no longer available, it wont get added.
I've been debugging and from what I can see buildRendering() calls _attachTemplateNodes() in dijit/_Templated.js. This loops over the nodes in the widget, looking for their dojoattachpoint attribute and pushing them in the widget's _attachpoints attribute.
The first loop has two nodes [our dia_widget and val_widget] nodes. At this point it then begins parsing each node individually, beginning by calling buildRendering() on dia_widget and finding the attachpoints of all its children.
At some point here the main_widget's dom is modified to include the parsed/rendered dia_widget. The loop then returns to the main node _attachTemplateNodes() call, where it only sees dia_widget as a child node, having lost the val_widget entry. Since the node isn't found, it never gets added as an attachpoint in main_widget, and we can't access it down the line.
I hope this isn't too convoluted to follow, I'm new to Dojo and chasing through the code in firebug wasn't the most fun experience in the world, so I've written things up as they make sense to me.
I'm left wondering why the behavior varies from 1.5 to 1.6, is this simply a feature/parameter I should be passing to the dialog to behave as it did before? Is this a bug in the way I'm creating the nested widget? Is this a [known?] bug in dojo itself?
Thanks,
vic

A: There are some changes in 1.6.0 that potentially adds a "lang" attribute to dynamically-loaded content.  Sometimes this "lang" attribute value is undefined and causes problems.
See if you are having problems with a "lang" attribute -- if so, this is likely to go away with 1.6.1.


text:
Q: Error in importing "asammdf" in Robotframework i have written a custom Library in python, which imports a package named "asammdf". But, when i import my custom Library in Robot code, it shows error in importing "asammdf" in python. It says: "Error in File *.robot. Importing test Library *.py failed. Import Error: DLL load failed: the specified module could not be found."
"asammdf" package is available in one of the PYTHONPATH it mentions during executions.
Can someone please help me doing this and let me know, what have i done wrong?
My python File (trialRobot.py):
import asammdf
...
...
...

My robot file (TC1.robot):
*** Settings ***
Library trialRobot.py

*** Test Cases ***
TC1
   DO THIS
   DO THAT

The error it shows is:
[ ERROR ] Error in file 'G:\AutomationRobotFramework\RobotAutomationFramework\TC1.robot': Im
porting test library 'G:\AutomationRobotFramework\RobotAutomationFramework\trialRobot.py' fa
iled: ImportError: DLL load failed: The specified module could not be found.
Traceback (most recent call last):
  File "G:\AutomationRobotFramework\RobotAutomationFramework\trialRobot.py", line 1, in <mod
ule>
    import asammdf
  File "g:\automationrobotframework\venv\lib\site-packages\asammdf\__init__.py", line 15, in
 <module>
    from .blocks.mdf_v2 import MDF2
  File "g:\automationrobotframework\venv\lib\site-packages\asammdf\blocks\mdf_v2.py", line 4
, in <module>
    from .mdf_v3 import MDF3
  File "g:\automationrobotframework\venv\lib\site-packages\asammdf\blocks\mdf_v3.py", line 4
4, in <module>
    from ..signal import Signal
  File "g:\automationrobotframework\venv\lib\site-packages\asammdf\signal.py", line 9, in <m
odule>
    from .blocks.utils import MdfException, extract_cncomment_xml, SignalSource
  File "g:\automationrobotframework\venv\lib\site-packages\asammdf\blocks\utils.py", line 27
, in <module>
    from cchardet import detect
  File "g:\automationrobotframework\venv\lib\site-packages\cchardet\__init__.py", line 1, in
 <module>
    from cchardet import _cchardet

PYTHONPATH:
  G:\AutomationRobotFramework\venv\Scripts\robot.exe
  C:\Program Files\Python37\python37.zip
  C:\Program Files\Python37\DLLs
  C:\Program Files\Python37\lib
  C:\Program Files\Python37
  g:\automationrobotframework\venv
  g:\automationrobotframework\venv\lib\site-packages
  g:\automationrobotframework\venv\lib\site-packages\pip-19.0.3-py3.7.egg

But, the asammdf package is installed in python using pip without any name or location conflict. It is installed only once and in the folder, where pip installs by default.
Thanks in advance.

A: You need to provide the absolute path or relative path to the example.py file.
so like,
*** Settings ***
Library C:/SomeFolder/example.py

or
*** Settings ***
Library ../folder/example.py

A: You need to install cchardet 2.1.5

redpajama_set_name: RedPajamaStackExchange


text:
Q: null pointer exception when adding an onclicklistener to a button outside the main view I want to have access to objects in views from views other than the main content view in the app. How can I go about doing this?
I am trying to add an onclicklistener, but it fails every time because the program can't seem to find the button.
02-12 15:26:29.034: E/AndroidRuntime(11788): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.evolutionsystems.kiroco/com.evolutionsystems.kiroco.OverviewActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference

Or am I going about this the wrong way? Should I include all the buttons in the main view and have them set to hidden and then change them dynamically as the user interacts with the program?
EDIT - This is the type of code that throws the error.
final Button receiver = (Button) findViewById(R.id.receiver);
         receiver.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 aboutKirocoClicked(v);
             }
         });

The receiver button is part of a different view to the content view so the program can't find it and it returns null.

A: When you call findViewById( int ) you are asking for a view within the context of the object you called.
So if this is an activity then the object must be part of the xml resource from setContent.
You can also find resources from other inflated layouts ( menu, fragement ), but you must call the findViewById on that object inorder to find the view.
Not to complicate your life, but once you are more comfortable with Android you may want to check out a dependency injection framework like Roboguice or Dagger.

A: In your Activity, where you would like your button to appear, you add the following code:
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //In activity_main.xml, you have a button.
    setContentView(R.layout.activity_main);
    //You get this button with the referencing ID
    Button myBtn = (Button) findViewById(R.id.my_btn_id);
    //Now, you can set your onClickListner
    myBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Handle your button click
        }
    });
}


text:
Q: postfix smtp_get: EOF I'm using postfix (incomming port 25) + SpamPD (127.0.0.1:10025 relayhost:127.0.0.1:10026) for filtering incoming email, which are coming from internet for my remote MTA. MTA which holds virtual domains is running on a seperate machine. So for users authentication I'm using SpamPD proxy with postfix.
I'm facing problem with smtp authentication on Microsoft Outlook 2007. However smtp authentication is working with Outlook Express.
postfix debug:
May 31 16:55:19 filter postfix/smtpd[17149]: connect from unknown[192.168.0.33]
May 31 16:55:19 filter postfix/smtpd[17149]: match_hostname: unknown ~? 127.0.0.0/8
May 31 16:55:19 filter postfix/smtpd[17149]: match_hostaddr: 192.168.0.33 ~? 127.0.0.0/8
May 31 16:55:19 filter postfix/smtpd[17149]: match_hostname: unknown ~? 192.168.0.0/24
May 31 16:55:19 filter postfix/smtpd[17149]: match_hostaddr: 192.168.0.33 ~? 192.168.0.0/24
May 31 16:55:19 filter postfix/smtpd[17149]: match_hostname: unknown ~? 192.168.0.0/24
May 31 16:55:19 filter postfix/smtpd[17149]: match_hostaddr: 192.168.0.33 ~? 192.168.0.0/24
May 31 16:55:19 filter postfix/smtpd[17149]: > unknown[192.168.0.33]: 220 filter.mydomain.local ESMTP Postfix
May 31 16:55:19 filter postfix/smtpd[17149]: watchdog_pat: 0x9883ba0
May 31 16:55:19 filter postfix/smtpd[17149]: < unknown[192.168.0.33]: EHLO mypc
May 31 16:55:19 filter postfix/smtpd[17149]: > unknown[192.168.0.33]: 250-filter.mydomain.local
May 31 16:55:19 filter postfix/smtpd[17149]: > unknown[192.168.0.33]: 250-PIPELINING
May 31 16:55:19 filter postfix/smtpd[17149]: > unknown[192.168.0.33]: 250-SIZE 10240000
May 31 16:55:19 filter postfix/smtpd[17149]: > unknown[192.168.0.33]: 250-VRFY
May 31 16:55:19 filter postfix/smtpd[17149]: match_list_match: unknown: no match
May 31 16:55:19 filter postfix/smtpd[17149]: match_list_match: 192.168.0.33: no match
May 31 16:55:19 filter postfix/smtpd[17149]: > unknown[192.168.0.33]: 250-ETRN
May 31 16:55:19 filter postfix/smtpd[17149]: > unknown[192.168.0.33]: 250-ENHANCEDSTATUSCODES
May 31 16:55:19 filter postfix/smtpd[17149]: > unknown[192.168.0.33]: 250-8BITMIME
May 31 16:55:19 filter postfix/smtpd[17149]: > unknown[192.168.0.33]: 250 DSN
May 31 16:55:19 filter postfix/smtpd[17149]: watchdog_pat: 0x9883ba0
May 31 16:55:19 filter postfix/smtpd[17149]: smtp_get: EOF
May 31 16:55:19 filter postfix/smtpd[17149]: match_hostname: unknown ~? 127.0.0.0/8
May 31 16:55:19 filter postfix/smtpd[17149]: match_hostaddr: 192.168.0.33 ~? 127.0.0.0/8
May 31 16:55:19 filter postfix/smtpd[17149]: match_hostname: unknown ~? 192.168.0.0/24
May 31 16:55:19 filter postfix/smtpd[17149]: match_hostaddr: 192.168.0.33 ~? 192.168.0.0/24
May 31 16:55:19 filter postfix/smtpd[17149]: match_hostname: unknown ~? 192.168.0.0/24
May 31 16:55:19 filter postfix/smtpd[17149]: match_hostaddr: 192.168.0.33 ~? 192.168.0.0/24

Postfix master.cf
smtp      inet  n       -       -       -       20      smtpd -v
    -o smtpd_proxy_filter=127.0.0.1:10025
    -o smtpd_client_connection_count_limit=10
# After-filter SMTP server. Receive mail from the content filter
# on localhost port 10026.
#
127.0.0.1:10026 inet n  -       n       -        -      smtpd
    -o smtpd_authorized_xforward_hosts=127.0.0.0/8
    -o smtpd_client_restrictions=
    -o smtpd_helo_restrictions=
    -o smtpd_sender_restrictions=
    -o smtpd_recipient_restrictions=permit_mynetworks,reject
    -o smtpd_data_restrictions=
    -o mynetworks=127.0.0.0/8
    -o receive_override_options=no_unknown_recipient_checks

Please help in this regard.
I've further diagnose it. Below are the diagnose with Outlook Express.
created thread for connection
processing 4 on thread b7f66b90
accepted connection from 192.168.0.50
SERVER connected to 192.168.0.51
SERVER < 220-mydomain.com ESMTP
CLIENT > 220-mydomain.com ESMTP
CLIENT < EHLO mypc
SERVER > EHLO mypc
SERVER < 250-mydomain.com Hello virata [192.168.0.151], pleased to meet you.
intercepting host response
CLIENT > 250-smtp.passthru
SERVER < 250-ENHANCEDSTATUSCODES
CLIENT > 250-ENHANCEDSTATUSCODES
SERVER < 250-SIZE
CLIENT > 250-SIZE
SERVER < 250-EXPN
CLIENT > 250-EXPN
SERVER < 250-ETRN
CLIENT > 250-ETRN
SERVER < 250-ATRN
CLIENT > 250-ATRN
SERVER < 250-DSN
CLIENT > 250-DSN
SERVER < 250-CHECKPOINT
filtered ESMTP feature CHECKPOINT
SERVER < 250-8BITMIME
CLIENT > 250-8BITMIME
SERVER < 250-AUTH CRAM-MD5 DIGEST-MD5 LOGIN PLAIN
CLIENT > 250-AUTH CRAM-MD5 DIGEST-MD5 LOGIN PLAIN
SERVER < 250-AUTH=LOGIN
CLIENT > 250-AUTH=LOGIN
SERVER < 250-STARTTLS
filtered ESMTP feature STARTTLS
SERVER < 250 HELP
CLIENT > 250 HELP
CLIENT < AUTH LOGIN
SERVER > AUTH LOGIN
SERVER < 334 VXNlcm5hbWU6
CLIENT > 334 VXNlcm5hbWU6
CLIENT < YXNpbUBnYWxpbGVvLm5leGxpbngubmV0LnBr
SERVER > YXNpbUBnYWxpbGVvLm5leGxpbngubmV0LnBr
SERVER < 334 UGFzc3dvcmQ6
CLIENT > 334 UGFzc3dvcmQ6
CLIENT < MTIzNDU2
SERVER > MTIzNDU2
SERVER < 235 2.0.0 Authentication successful
Client authenticated successfully
CLIENT > 235 2.0.0 Authentication successful
CLIENT < MAIL FROM <asim@mydomain.com>
SERVER > MAIL FROM <asim@mydomain.com>
SERVER < 250 2.1.0 <asim@mydomain.com>... Sender ok
CLIENT > 250 2.1.0 <asim@mydomain.com>... Sender ok
CLIENT < RCPT TO <asim.mcp@gmail.com>
SERVER > RCPT TO <asim.mcp@gmail.com>
SERVER < 250 2.1.5 <asim.mcp@gmail.com>... Recipient ok; will forward
CLIENT > 250 2.1.5 <asim.mcp@gmail.com>... Recipient ok; will forward
CLIENT < DATA
CLIENT > 354 Start mail input; end with <CRLF>.<CRLF>
executed filter command /usr/local/bin/spamassassin.sh (pid 22927)
created cache file /tmp/.Os81QA

Below are the diagnose with Microsoft Outlook 2007.
created thread for connection
processing 4 on thread b7f92b90
accepted connection from: 192.168.0.33
SERVER connected to: 192.168.0.82
SERVER < 220-mydomain.com ESMTP
CLIENT > 220-mydomain.com ESMTP
CLIENT < EHLO mypc
SERVER > EHLO mypc
SERVER < 250-mydomain.com Hello mypc [192.168.0.151], pleased to meet you.
intercepting host response
CLIENT > 250-smtp.passthru
SERVER < 250-ENHANCEDSTATUSCODES
CLIENT > 250-ENHANCEDSTATUSCODES
SERVER < 250-SIZE
CLIENT > 250-SIZE
SERVER < 250-EXPN
CLIENT > 250-EXPN
SERVER < 250-ETRN
CLIENT > 250-ETRN
SERVER < 250-ATRN
CLIENT > 250-ATRN
SERVER < 250-DSN
CLIENT > 250-DSN
SERVER < 250-CHECKPOINT
filtered ESMTP feature: CHECKPOINT
SERVER < 250-8BITMIME
CLIENT > 250-8BITMIME
SERVER < 250-AUTH CRAM-MD5 DIGEST-MD5 LOGIN PLAIN
CLIENT > 250-AUTH CRAM-MD5 DIGEST-MD5 LOGIN PLAIN
SERVER < 250-AUTH=LOGIN
CLIENT > 250-AUTH=LOGIN
SERVER < 250-STARTTLS
filtered ESMTP feature: STARTTLS
SERVER < 250 HELP
CLIENT > 250 HELP
CLIENT < AUTH DIGEST-MD5
SERVER > AUTH DIGEST-MD5
SERVER < 334 mVhbG09ImdhbGlsZW8ubmV4bGlueC5uZXQucGsiLG5vbmNlPSJPVGMxTkdaaFlXWmlZalE0Iix
CLIENT > 334 mVhbG09ImdhbGlsZW8ubmV4bGlueC5uZXQucGsiLG5vbmNlPSJPVGMxTkdaaFlXWmlZalE0Iix
CLIENT < XNlcm5hbWU9ImFzaW0iLHJlYWxtPSJnYWxpbGVvLm5leGxpbngubmV0LnBrIixub25jZT0iT1RjMU5
SERVER > XNlcm5hbWU9ImFzaW0iLHJlYWxtPSJnYWxpbGVvLm5leGxpbngubmV0LnBrIixub25jZT0iT1RjMU5
SERVER < 501 5.7.0 Authentication failed
CLIENT > 501 5.7.0 Authentication failed
CLIENT < AUTH LOGIN
SERVER > AUTH LOGIN
SERVER < 334 VXNlcm5hbWU6
CLIENT > 334 VXNlcm5hbWU6
CLIENT < YXNpbUBnYWxpbGVvLm5leGxpbngubmV0LnBr
SERVER > YXNpbUBnYWxpbGVvLm5leGxpbngubmV0LnBr
SERVER < 334 UGFzc3dvcmQ6
CLIENT > 334 UGFzc3dvcmQ6
CLIENT < MTIzNDU2
SERVER > MTIzNDU2
SERVER < 235 2.0.0 Authentication successful
Client authenticated successfully
CLIENT > 235 2.0.0 Authentication successful
CLIENT < MAIL FROM: <asim@mydomain.com>
SERVER > MAIL FROM: <asim@mydomain.com>
SERVER < 250 2.1.0 <asim@mydomain.com>... Sender ok
CLIENT > 250 2.1.0 <asim@mydomain.com>... Sender ok
CLIENT < RCPT TO: <asim.mcp@gmail.com>
SERVER > RCPT TO: <asim.mcp@gmail.com>
SERVER < 250 2.1.5 <asim.mcp@gmail.com>... Recipient ok; will forward
CLIENT > 250 2.1.5 <asim.mcp@gmail.com>... Recipient ok; will forward
CLIENT < DATA
CLIENT > 354 Start mail input; end with <CRLF>.<CRLF>
created cache file: /tmp/bixHC8
wrote 2440 bytes to filter, read 0 bytes
filter exit code: 127
CLIENT > 550 Content Rejected; sh: From:: command not found
SERVER > RSET
SERVER < 250 2.0.0 Reset state
client=192.168.0.33, from=asim@mydomain.com, to=asim.mcp@gmail.com, status=sh: From:: command not found
CLIENT < RSET
SERVER > RSET
SERVER < 250 2.0.0 Reset state
CLIENT > 250 2.0.0 Reset state
CLIENT < MAIL FROM: <asim@mydomain.com>
SERVER > MAIL FROM: <asim@mydomain.com>
SERVER < 250 2.1.0 <asim@mydomain.com>... Sender ok
CLIENT > 250 2.1.0 <asim@mydomain.com>... Sender ok
CLIENT < RCPT TO: <asim.mcp@gmail.com>
SERVER > RCPT TO: <asim.mcp@gmail.com>
SERVER < 250 2.1.5 <asim.mcp@gmail.com>... Recipient ok; will forward
CLIENT > 250 2.1.5 <asim.mcp@gmail.com>... Recipient ok; will forward
CLIENT < DATA
CLIENT > 354 Start mail input; end with <CRLF>.<CRLF>
created cache file: /tmp/Jh3Ic7
wrote 2437 bytes to filter, read 0 bytes
filter exit code: 127
CLIENT > 550 Content Rejected; sh: From:: command not found
SERVER > RSET
SERVER < 250 2.0.0 Reset state
client=192.168.0.33, from=asim@mydomain.com, to=asim.mcp@gmail.com, status=sh: From:: command not found
CLIENT < QUIT
SERVER > QUIT
CLIENT connection closed
SERVER connection closed
waiting for threads to quit
cleaning up completed thread

The difference between both of the diagnose is as following.
CLIENT < AUTH DIGEST-MD5
SERVER > AUTH DIGEST-MD5
SERVER < 334 cmVhbG09ImdhbGlsZW8ubmV4bGlueC5uZXQucGsiLG5vbmNlPSJPVGMxTkdaaFlXWmlZalE0Iix
CLIENT > 334 cmVhbG09ImdhbGlsZW8ubmV4bGlueC5uZXQucGsiLG5vbmNlPSJPVGMxTkdaaFlXWmlZalE0Iix
CLIENT < dXNlcm5hbWU9ImFzaW0iLHJlYWxtPSJnYWxpbGVvLm5leGxpbngubmV0LnBrIixub25jZT0iT1RjMU5
SERVER > dXNlcm5hbWU9ImFzaW0iLHJlYWxtPSJnYWxpbGVvLm5leGxpbngubmV0LnBrIixub25jZT0iT1RjMU5
SERVER < 501 5.7.0 Authentication failed
CLIENT > 501 5.7.0 Authentication failed
Which means Microsoft Outlook First try Authentication method "DIGEST-MD5" which is causing the problem. Any help please...

A: I can't see your problem. Your server (whatever it is, but it is not Postfix) announces 250-AUTH CRAM-MD5 DIGEST-MD5 LOGIN PLAIN. Allowing all the given authentication methods. And when Outlook tries to send the password as DIGEST-MD5 encrypted, your authentication server rejects this (password or method). So Outlook tries the next possibility to send it as AUTH LOGIN which succeeds. Outlook Express directly uses AUTH LOGIN because of the 250-AUTH=LOGIN. This is a workaround for the buggy Outlook Express.
Then your filter rejects the mail because it is misconfigured as it can't find the program(s) or files needed to scan the mail (550 Content Rejected; sh: From:: command not found)
This is not a Postfix problem at all. Nor is it a problem of Outlook or Outlook Express.


text:
Q: Replace WooCommerce attribute labels by a custom image for each I am working on project and I need some group help.
I am using woocommerce product system and on shop archive page product I am showing attribute-label: attribute-value (just like text).
attribute-label:attribute-value (ex. Transmission: Manual)
Is there a way to show attribute-label as image? I can't add html code like  and styling with CSS doesn't help too.
I have searched for plugins and more.. But nothing on web.
To show attributes on product shop page i have used this function:
function isa_woocommerce_all_pa(){

    global $product;
    $attributes = $product->get_attributes();

    if ( ! $attributes ) {
        return;
    }

    $out = '
';

    foreach ( $attributes as $attribute ) {

        // skip variations
        if ( $attribute->get_variation() ) {
        continue;
        }
        $name = $attribute->get_name();
        if ( $attribute->is_taxonomy() ) {

            $terms = wp_get_post_terms( $product->get_id(), $name, 'all' );
            // get the taxonomy
            $tax = $terms[0]->taxonomy;
            // get the tax object
            $tax_object = get_taxonomy($tax);
            // get tax label
            if ( isset ( $tax_object->labels->singular_name ) ) {
                $tax_label = $tax_object->labels->singular_name;
            } elseif ( isset( $tax_object->label ) ) {
                $tax_label = $tax_object->label;
                // Trim label prefix since WC 3.0
                if ( 0 === strpos( $tax_label, 'Product ' ) ) {
                   $tax_label = substr( $tax_label, 8 );
                }
            }

            $out .= '
';
            $out .= '' . esc_html( $tax_label ) . ':  ';
            $out .= '';
            $tax_terms = array();
            foreach ( $terms as $term ) {
                $single_term = esc_html( $term->name );
                // Insert extra code here if you want to show terms as links.
                array_push( $tax_terms, $single_term );
            }
            $out .= implode(', ', $tax_terms);
            $out .= '
';

        } else {
            $value_string = implode( ', ', $attribute->get_options() );
            $out .= '
';
            $out .= '' . $name . ':  ';
            $out .= '' . esc_html( $value_string ) . '
';
        }
    }

    $out .= '
';

    echo $out;
}
add_action('woocommerce_single_product_summary', 'isa_woocommerce_all_pa', 25);

Can someone help me with this? How to change attribute-label with image?

A:
Updated since WC 3.2+

As Product attributes dont have images, you should create a in your active theme a folder images (if it doesn't exist) and inside a subfolder attributes.
For each product attribute, you will have to add an image inside this subfolder attributes, which name will be the name of your attribute (the slug). For example for "Color" attribute you will have to add an image named color.jpg.
Then I have make some changes in your code, to get this working. Only the terms set in the product for each attribute will be displayed. For each attribute you will get an image.
Here is the code:
add_action('woocommerce_single_product_summary', 'isa_woocommerce_all_pa', 25);
function isa_woocommerce_all_pa(){
    global $product;

    $attributes = $product->get_attributes();

    if ( ! $attributes ) return;

    $out = '
';

    foreach ( $attributes as $attribute ) {

        if ( $attribute->get_variation() ) continue; // skip variations

        if ( $attribute->is_taxonomy() ) {
            $taxonomy = $attribute->get_name();
            $taxo_obj = $attribute->get_taxonomy_object();
            $name = $taxo_obj->attribute_name; // <== Corrected
            $label = $taxo_obj->attribute_label; // <== Corrected

            $out .= '
';

            ## ATTRIBUTE IMAGE ##
            // For a child theme use get_stylesheet_directory_uri() instead.
            $out .= ' ';
            $out .= '';

            $terms = wp_get_post_terms( $product->get_id(), $taxonomy, array('fields' => 'names') );

            foreach ( $terms as $term_name )
                $term_names['name'] = $term_name;

            $out .= implode(', ', $term_names);
            $out .= '
';

        } else {
            $value_string = implode( ', ', $attribute->get_options() );
            $out .= '
';
            $out .= '' . $taxonomy . ':  ';
            $out .= '' . esc_html( $value_string ) . '
';
        }
    }
    $out .= '
';

    echo $out;
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This code is tested and work.


text:
Q: Dynamic transform style property while scrolling I'm in a blind spot with my small jQuery script.
The point is that I'm trying to make an element to rotate, and to apply the rotation value dynamically as the user is scrolling through the page.
It works here on stackoverflow but I can't get this to work on my website...
The only external library I'm using is JQuery.
Can you please tell me where is the problem?

var $animObject = $('.animateObject');
var $window = $(window);

$window.on('scroll', function() {
  var fromTop = $window.scrollTop() / -4;
  $animObject.css('transform', 'rotate(' + fromTop + 'deg)')
});
.header {
  width: 100%;
  height: 100vh;
  background-image: url('https://simply-design.ml/dev/img/start1.jpg');
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-content {
  padding: 30px;
  max-width: 470px;
}

.header-wrapper {
  padding: 50px;
  border: solid 3px #fff;
}

.header h1 {
  font-size: 30px;
  color: #fff;
  text-align: center;
}

.header p {
  font-size: 20px;
  color: #fff;
  text-align: center;
}

.p-title {
  font-size: 14px;
  color: #fff;
}

.head-button {
  padding: 10px 25px;
  background-color: #3b88df;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  font-family: 'Source Sans Pro', sans-serif;
}

.head-button:hover {
  background-color: #2c78ce;
}

title

subtitle

A: Check this example I've made without jQuery, which shows how to rotate an element based on the scroll position of the window, but only once the element is in view.
I've decided to do this without jQuery because it's better for performance, working directly with the DOM instead of passing through jQuery, and also because it's relatively simple code, understandable.

*

*Find out how much was scrolled

*Get the target's element absolute position

*Calculate if the element is within the viewport (if not, break)

*If it's in, save the scroll value at that point

*Subtract that value from the current scroll value to get the value from that point on

*Use the new value as baseline for the transformation

var elm = document.querySelector('b');

var onScroll = (function(){
  var startPos;

  function run(){
    var fromTop = window.pageYOffset,
        rect = elm.getBoundingClientRect(),
        scrollDelta;

    // check if element is in viewport
    if( (rect.top - window.innerHeight) <= 0 && rect.bottom > 0 )
       startPos = startPos === undefined ? fromTop : startPos;
    else{
      startPos = 0;
      return;
    }

    scrollDelta = (fromTop - startPos) * 1; // "speed" per scrolled frame
    elm.style.transform = `translateX(${scrollDelta}px) rotate(${scrollDelta}deg)`;

    console.clear();
    console.log(scrollDelta);
  }

  run();

  return run;
})()

window.addEventListener('scroll', onScroll);
html, body{ height:100%; }
body{ height:1500px; }

b{
  position:fixed;
  top: 20px;
  left:20px;

  width:100px;
  height:100px;

  background:red;
}

inspect the  element while scrolling and see that it only gets transform when it is in view.


text:
Q: Rundeck 2.10: howto remote logging to syslog on premise we got a Rundeck 2.10 and it's configured logging to local file. I would like to configure it for logging on a remote syslog-ng.
I've managed to search infos on web but I've only found this page: https://docs.rundeck.com/docs/administration/maintenance/logs.html#streaming-log-plugins that talks about the "availability" of a Streaming Log Writers but I cannot find this plugin anywhere.
Someone got a guide to achieve this result?
Thanks in advance for your help

A: You have a good example written in Groovy here. And here a good explanation about Rundeck groovy plugins.
You can create a groovy file and put on the libext directory as any Rundeck plugin.


text:
Q: How can i get `String` date from calendar? How can i get String date from calendar?
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_MOUNTH, -5); //set now and 5 days to back

I want get String like this(date on interval -5 days to TODAY):
11.03.2015
10.03.2015
.
.
.
07.03.2015

It's possible? How?

A: you can use for loop and reduce one day from calendar instance and print it
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");

for (int index = 1; index <= 5; index++) {
    calendar.add(Calendar.DATE, -1);
    System.out.println(dateFormat.format(calendar.getTime()));
}

output:
10.03.2015
09.03.2015
08.03.2015
07.03.2015
06.03.2015

A: You should use the SimpleDateFormat class, as follows.
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_MOUNTH -5);
SimpleDateFormat myDateFormat = new SimpleDateFormat("MM.dd.yyyy"); //or ("dd.MM.yyyy"), If you want days before months.
String formattedDate = myDateFormat.format(cal.getTime());

A: SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
String strdate = sdf.format(calendardate.getTime());

A: Calendar cal = Calendar.getInstance();
Date date = cal.getTime();
Long beforeTime = date - (5*24*60*60*1000);
Date beforeDate = new Date(beforeTime);
SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
String s = format.format(beforeDate);

s returns the date in your required format.


text:
Q: Vue price range filter I am looking for a good example for filtering price range in Vue app, something you would see in most ecommerce site: https://www.theiconic.com.au/all/?campaign=lp-m-long-weekend-wear&page=1&sort=popularity&price%5B%5D=*-50&price%5B%5D=100-200.
What I have got so far isn't working when you choose multiple price range. Any help would be appreciated.
new Vue({
    el: "#app",
    data: {
        url: '',
    products: [],
        filterApplied: [10],
        search: '',
        prices: [
            'Under $25', '$25 to $50', '$51 to $100', 'Over $100'
        ],

    },
    created() {
        axios.get(this.url)
            .then((response) => {
                this.products = response.data;
            })
            .catch((error) => {
                this.products = null;
            });
    },
    computed: {
        filteredProducts() {
            return this.products.filter(product => {
                return this.filterApplied.every(filterApplied => {
                        switch (filterApplied) {
                            case 'Under $25':
                                return product.Price < 25;
                                break;
                            case '$25 to $50':
                                return product.Price >= 25 && product.Price <= 50;
                                break;
                            case '$51 to $100':
                                return product.Price >= 51 && product.Price <= 100;
                                break;
                            case 'Over $100':
                                return product.Price > 100;
                                break;
                        }
                    return product;
                })
            })
        }
    },
    methods: {
        setFilter(filter) {
            if (this.filterApplied.indexOf(filter) > -1) {
                this.filterApplied.pop(filter);
            } else {
                this.filterApplied.push(filter);
            }
            console.log(this.filterApplied);
        }
    }
});

Price Range

        {{ price }}

{{ product.Name }}

${{ product.Price }}

{{ product.Details }}

A:

new Vue({
    el: "#app",
    data: {
        url: '',
    products: [{Details: 'Cheap', Price: 1, Name: 'Candy'}, {Details: 'Thrifty', Price: 26, Name: 'Burger'}, {Details: 'Spendy', Price: 51, Name: 'Steak'}, {Details: 'Fancy', Price: 101, Name: 'Lobster'}],
        filterApplied: [],
        search: '',
        prices: [
            'Under $25', '$25 to $50', '$51 to $100', 'Over $100'
        ],
        filtersAsNumbers: {
          'Under $25': [0, 25], '$25 to $50': [25, 50], '$51 to $100': [51, 100], 'Over $100': [100, 1000000]
        }
    },
    created() {
       /* axios.get(this.url)
            .then((response) => {
                this.products = response.data;
            })
            .catch((error) => {
                this.products = null;
            }); */
    },
    computed: {
        filteredProducts() {
         return this.products.filter(product => {
            if (this.filterApplied.length < 1) {
              return product
            } else {
              var productReturn
              Object.keys(this.filtersAsNumbers)
                .filter(priceRange=>
                  this.filterApplied.includes(priceRange)
                )
                .filter(priceRangeFiltered=>{
                  let low = this.filtersAsNumbers[priceRangeFiltered][0]
                  let high = this.filtersAsNumbers[priceRangeFiltered][1]
                  if (product.Price >= low && product.Price <= high) {
                    productReturn = product
                  }
                })
              return productReturn
            }
          })
      }

    },
    methods: {
        setFilter(filter) {
            if (this.filterApplied.indexOf(filter) > -1) {
                this.filterApplied.pop(filter);
            } else {
                this.filterApplied.push(filter);
            }
            console.log(this.filterApplied);
        },
        clearFilter(){
          this.filterApplied = []
        }
    }
});
.filters, .product-tile {
  margin: 20px;
}

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>

Price Range

         {{ price }}
        Clear

                {{ product.Name }}
                ${{ product.Price }}
                {{ product.Details }}

This is not the most elegant solution ever, but it does work for what you need.


text:
Q: mod_xsendfile alternatives for a shared hosting service without it I'm trying to log download statistics for .pdfs and .zips (5-25MB) in a rails app that I'm currently developing and I just hit a brick wall; I found out our shared hosting provider doesn't support mod_xsendfile. The sources I've read state that without this, multiple downloads could potentially cause a DoS issue—something I'm definitely trying to avoid. I'm wondering if there are any alternatives to this method of serving files through rails?

A: Well, how sensitive are the files you're storing?
If you hosted these files somewhere under your app's /public directory, you could just do a meta tag or javascript redirect to the public-facing URL of these files after your users hit some sort of controller action that will update your download statistics.
In this case, your users would probably need to get one of those "Your download should commence in a few moments" pages before the browser would start the file download.
Under this scenario, your Rails application won't be streaming the file out, your web server will, which will give you the same effect as xsendfile.  On the other hand, this won't work very well if you need to control access to those downloadable files.


text:
Q: Extension of diffeomorphism up to boundary Suppose that I have two bounded open sets with $C^2$ boundary in $\mathbb{R}^n$ and I have a differmorphism $f:D_1\to D_2$ between them. I'm looking for some examples where the map $f$ can not be extend $C^2$ (I guess not even homeomorphism) up to boundary. Namely, their boundary, as embedded $C^2$ submanifold in $\mathbb{R}^n$ are not diffeomorphic under the extension.Any help will be appreciated!

A: Let $D_1 = D_2 = \{ x^2 + y^2 <1\}$ and let
$$ f : D_1 \to D_2, \ \ f(r, \theta) = (r, g(r) + \theta)$$
where $g : [0,1)\to \mathbb R$ is a smooth function so that $g(x) = 0$ on $[0,\epsilon)$ and $g(r) \to \infty$ as $r\to 1$. This $f$ cannot be extended continuously to the boundary.


text:
Q: TypeError when attempting to render static HTML page I am trying to render a static HTML page when a GET request is made to the root directory (/).
However, I receive the following error when accessing the root directory (http://localhost:3000/):
TypeError: Cannot read property '_locals' of undefined

Project Structure
index.js
node_modules
public
|-- html
|   |--index.html

index.js
var express = require('express');
var app = express();
var port = 3000;

app.use(express.static(__dirname + '/public'));

app.listen(port);
console.log('Server running on port ' + port + '.');

app.get('/', function(req, res) {
    app.render(__dirname + '/html/index.html');
})

I can access my static HTML page by going to http://localhost:3000/html/index.html. However, calls to app.render() fail. I suspect it has something to do with the directory I am passing into app.render().

A: *

*You shouldn't use app.render, it should be res.render

*res.render is supposed to render content with template engine, for example, mustache, ejs, jade, etc. You shouldn't use it to render pure html files.

*if you want to send *.html content, try to use res.sendFile

app.get('/', function(req, res) {
    res.sendFile(__dirname + '/html/index.html');
});

A: Just remove this
app.get('/', function(req, res) {
    app.render(__dirname + '/html/index.html');
});

Try using it again.

A: app.get('/', function(req, res) {
    res.render(__dirname + '/html/index.html');
})

res rather than app in the function


text:
Q: Valgrind output Understanding ==20420==
==20420== HEAP SUMMARY:
==20420==     in use at exit: 0 bytes in 1 blocks
==20420==   total heap usage: 1 allocs, 0 frees, 0 bytes allocated
==20420==
==20420== Searching for pointers to 1 not-freed blocks
==20420== Checked 48,492 bytes
==20420==
==20420== 0 bytes in 1 blocks are still reachable in loss record 1 of 1
==20420==    at 0x400677E: malloc (vg_replace_malloc.c:195)
==20420==    by 0x80483D8: main (jig.c:10)
==20420==
==20420== LEAK SUMMARY:
==20420==    definitely lost: 0 bytes in 0 blocks
==20420==    indirectly lost: 0 bytes in 0 blocks
==20420==      possibly lost: 0 bytes in 0 blocks
==20420==    still reachable: 0 bytes in 1 blocks
==20420==         suppressed: 0 bytes in 0 blocks

See in my project I use malloc like this:
malloc(sizeof(some_structure) * some_expression);

at one point some_expression gives value 0 so indirectly i am doing
   malloc(0)

So when I am not going to malloc a single byte so I am not making free it but in that case valgrind shows memory leackage. Why?
Edit :
If I use like this:
char *a = malloc(0);

Then a is not NULL. So question is why not NULL? & Which address it stores?

A: From my malloc(3) manpage (Linux):

If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be successfully passed to free().

So there's no guarantee that malloc is not allocating any space when you pass it 0, and you have to free the pointer that it gives you if it isn't NULL.
If malloc does not return NULL, you get a buffer that you can't use for anything, but since it has a unique address, malloc must have allocated at least one byte.
Maybe you'd want to replace the malloc call with one to
// like malloc, but guarantees NULL return value if n==0
void *malloc0(size_t n)
{
    return n ? malloc(n) : NULL;
}


text:
Q: How can a tag exist as both an ordinary tag, and as a synonym? For example, on the Physics SE, the [biology] tag exists as both.
Here is the SEDE query to the tag, and to the synonym.

A: A tag could be set on a post (or many posts) well before it becomes a synonym.
Once a such tag does become a synonym, we do not go and edit all posts with it in order to change it to its synonym - if someone happens to edit it, that will automatically happen, but if no one does, it will not.
The result will be that some tags that are synonyms will exist on the posts they were put on before they became synonyms.


text:
Q: Why is this .sh script run on CentOS but not on Ubuntu? I'm trying to run this simple script that succesfully run on CentOS but not on Ubuntu.
The script start succesfully but fails to get into the if condition and straight moving to the else.
Is there any syntax error with the if loop?
The idea is to get the content of filename output2.txt into a variable named value (is that command OK?) and check if subtext 512.00GB include in the text (in value)...
sudo msecli -L > output2.txt
value=`cat output2.txt`
check="512.00GB"
#echo "$value"
if [[ "$value" == *"$check"* ]]; then
  echo "The SSD is 512GB"
sudo msecli -L >> output.txt
sudo nvme delete-ns -n 1 /dev/nvme0
sudo nvme delete-ns -n 1 /dev/nvme1
sleep 1
sudo msecli -N -q 100 -n /dev/nvme0 -r
sleep 1
sudo msecli -N -q 100 -n /dev/nvme1 -r
sleep 2
sudo reboot
else
sudo msecli -L >> output.txt
echo "***** The SSD is READY!!! *****"
fi

The error we get is in line 5 [[, which seems the if command is not working.
I used the following example I found on the web for searching subtext in a text:
#example
#STR='GNU/Linux is an operating system'
#SUB='Linux'
#if [[ "$STR" == *"$SUB"* ]]; then
#  echo "It's there."
#fi

A: If your script doesn't start with a shebang line like
#!/bin/bash

it may be run by /bin/sh (see "Which shell interpreter runs a script with no shebang?" for details).
Ubuntu uses dash for /bin/sh and dash doesn't support Bash-specific syntax like [[...]] so you get an error.
CentOS may use Bash for /bin/sh so this works there.
Add
#!/bin/bash

as the first line of your script to make sure it is run by Bash.


text:
Q: Prevent page jumping in Chrome when tabbing to offscreen elements Run the following in Chrome, and press Tab until the window scrolls:

<input type="text" autofocus>

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

Note how the focused element jumps up to the middle of its window.  This makes data entry annoying, so I'd rather the page scroll up smoothly, keeping the newly focused element at the bottom.  This seems to occur in Chrome only.
I can prevent this behavior with JavaScript:

$(document).on('focus', 'input', function() {
  let top = $(this).parent().position().top,
      scroll = $(window).scrollTop(),
      inputHeight = $('input').height(),
      windowHeight = $(window).height();

  if (top < scroll + inputHeight) {
    window.scrollBy(0, -inputHeight);
  } else if (top > scroll + windowHeight - inputHeight * 2) {
    window.scrollBy(0, inputHeight);
  }
});

<input type="text" autofocus>

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

But I'm wondering if there is an HTML or CSS solution.  (I would also settle for a more elegant JavaScript solution.)

Edit
I've come up with a much simpler solution, but it has the side-effect of the page scrolling one pixel for each Tab (or Shift+Tab) press:

$('input').keydown(function(evt) {
  if(evt.key == 'Tab') {
    window.scrollTo(0, window.scrollY + (evt.shiftKey ? -1 : 1));
  }
});

<input type="text" autofocus>

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

A: You don't need JS here, as Chrome supports scroll-behavior property:

html {
  scroll-behavior: smooth;
}

<input type="text" autofocus>

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

A: HTML/CSS cannot help in this matter, you have to take care of it with JavaScript. The simplest one I can think of is using Element.scrollIntoView() method.

Element.scrollIntoView()
The Element.scrollIntoView() method scrolls the element on which it's called into the visible area of the browser window. It is experimental API as of today, but supported by most of modern browsers including chrome. (See Browser Support)

(function ($) {
    var shouldScroll = false;
    $(document).on('focus', 'input', function () {
        if (shouldScroll) {
            this.scrollIntoView(false);
            shouldScroll = false;
        }
    });
    $(document).on('keydown', 'input', function (e) {
        if (e.keyCode == 9) shouldScroll = true;
    });
})(jQuery);

<input type="text" autofocus>

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

Note: View the snippet in Full-Page/Expand-Snippet mode.

A: This is smooth for tabbing forward (tab) or backwards (shift+tab).
At first it is calculated which 'pixel' or 'index' is the first and the last visible one.
Then a comparison is made if the desired pixel/index fits within that range.
If not -> an adjustment is done.
$('input').focusin(function(e) {
  let height = $(window).height();
  let scroll = $(window).scrollTop();

  let position = $(this).position().top;
  let elementHeight = $(this).height();

  let firstVisibleIndex = scroll;
  let lastVisibleIndex = scroll + height;
  let additionalSpace = 5 * elementHeight;

  let newScrollTop;

  if(position + additionalSpace > lastVisibleIndex) {
    newScrollTop = position - height + additionalSpace;
  }

  if(position - additionalSpace < firstVisibleIndex) {
    newScrollTop = position - additionalSpace;
  }

  $(window).scrollTop(newScrollTop);
});

https://jsfiddle.net/yo12fgLj/115/

A: I've come up with a pure CSS solution.
Simply changing the height of the input on focus, even slightly, solves the problem:

input:focus {
  background: yellow;
  transform: scaleY(1.00001);
}

<input type="text" autofocus>

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

<input type="text">

Here's why it works:
When focusing a partially-offscreen element, Chrome scrolls only as much as is needed.  When focusing a completely-offscreen element, Chrome scrolls it to the center of the screen.
By increasing the height on focus, the window scrolls if needed to accommodate the newly-focused element.
When you Tab to the next element, the previous element reverts to its previous height.  But the window has already scrolled enough so that the next element is already partially in view.
That's enough to prevent Chrome from scrolling it to the center of the screen.
This works for both Tab and Shift+Tab.


text:
Q: How to embed xsl into xml to view in web browser I have been given the following code and need to make some changes to it, but first I'd like to be able to view the result in the browser.
I'm new at this and don't yet understand the structure of embedding the xsl.
I did try the solutions from a couple of the other "how to embed xsl"-questions, but to no avail.
Can someone show me what needs to be changed in order for this to be valid so it can be seen in the browser:
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="statementTitle"/>
    <xsl:param name="customLogoURL"/>
    <xsl:param name="companyLogoURLParam"/>
    <xsl:param name="companyName"/>
    <xsl:param name="DEPARTMENT"/>
    <xsl:param name="moneyFormat"/>
    <xsl:param name="amountFormat"/>
    <xsl:param name="percentFormat"/>
    <xsl:param name="userLocaleSpecificMoneyFormat"/>
    <xsl:param name="userLocaleSpecificAmountFormat"/>
    <xsl:param name="userLocaleSpecificPercentFormat"/>
    <xsl:param name="userLocaleSpecificBonusPercentFormat"/>
    <xsl:param name="userLocaleSpecificDecimalFormatter"/>
    <xsl:param name="EMPID"/>
    <xsl:param name="FIRSTNAME"/>
    <xsl:param name="LASTNAME"/>
    <xsl:param name="DIVISION"/>
    <xsl:param name="LOCATION"/>
    <xsl:param name="TITLE"/>
    <xsl:decimal-format name="defaultDecimalFormatter" grouping-separator="," decimal-separator="."/>
    <xsl:decimal-format name="decimalFormatterDotComma" grouping-separator="." decimal-separator=","/>
    <xsl:decimal-format name="decimalFormatterSpaceComma" grouping-separator=" " decimal-separator=","/>
    <xsl:variable name="companyLogoURL" select="$companyLogoURLParam"/>
    <xsl:template match="/sf-compensation">

        <xsl:variable name="empFirstName" select="./comp-plan-entry/comp-plan-entry-firstname"/>
        <xsl:variable name="empLastName" select="./comp-plan-entry/comp-plan-entry-lastname"/>
        <xsl:variable name="userId" select="./comp-plan-entry/comp-plan-entry-userid"/>
        <xsl:variable name="salaryEligible" select="./comp-plan-entry/comp-salary/comp-salary-ineligible"/>
        <xsl:variable name="promoEligible" select="./comp-plan-entry/comp-salary/comp-salary-ineligible/@promo-ineligible"/>
        <xsl:variable name="meritEligible" select="./comp-plan-entry/comp-salary/comp-salary-ineligible/@merit-ineligible"/>
        <xsl:variable name="extraEligible" select="./comp-plan-entry/comp-salary/comp-salary-ineligible/@extra-ineligible"/>
        <xsl:variable name="extra2Eligible" select="./comp-plan-entry/comp-salary/comp-salary-ineligible/@extra2-ineligible"/>
        <xsl:variable name="lumpsumEligible" select="./comp-plan-entry/comp-salary/comp-salary-ineligible/@lumpsum-ineligible"/>
        <xsl:variable name="lumpsum2Eligible" select="./comp-plan-entry/comp-salary/comp-salary-ineligible/@lumpsum2-ineligible"/>
        <xsl:variable name="bonusEligible" select="./comp-plan-entry/comp-bonus/comp-bonus-ineligible"/>
        <xsl:variable name="stockEligible" select="./comp-plan-entry/comp-stock/comp-stock-ineligible"/>
        <xsl:variable name="stockUnitsEligible" select="./comp-plan-entry/comp-stock/comp-stock-ineligible/@units-ineligible"/>
        <xsl:variable name="stockOptionEligible" select="./comp-plan-entry/comp-stock/comp-stock-ineligible/@option-ineligible"/>
        <xsl:variable name="stockStockEligible" select="./comp-plan-entry/comp-stock/comp-stock-ineligible/@stock-ineligible"/>
        <xsl:variable name="stockOther1Eligible" select="./comp-plan-entry/comp-stock/comp-stock-ineligible/@other1-ineligible"/>
        <xsl:variable name="stockOther2Eligible" select="./comp-plan-entry/comp-stock/comp-stock-ineligible/@other2-ineligible"/>
        <xsl:variable name="stockOther3Eligible" select="./comp-plan-entry/comp-stock/comp-stock-ineligible/@other3-ineligible"/>
        <xsl:variable name="cust_current_annual_actual_salary" select="./comp-plan-entry/comp-custom-data/comp-custom-field[@id='cust_current_annual_actual_salary']"/>
        <xsl:variable name="merit" select="./comp-plan-entry/comp-salary/comp-salary-merit"/>
        <xsl:variable name="cust_total_pct_increase" select="./comp-plan-entry/comp-custom-data/comp-custom-field[@id='cust_total_pct_increase']"/>
        <xsl:variable name="cust_final_annual_actual_salary" select="./comp-plan-entry/comp-custom-data/comp-custom-field[@id='cust_final_annual_actual_salary']"/>

                <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"/>
                <title>Letter</title>
                <link href="/css/profed/styles.css" media="screen" type="text/css" rel="stylesheet"/>
                <link href="/css/profed/print.css" media="print" type="text/css" rel="stylesheet"/>

                                <xsl:text disable-output-escaping="yes">
                                    <![CDATA[Private and Confidential
[First Name] [[Last Name]

[Email Address]

]]>
                                </xsl:text>

                                    <xsl:text disable-output-escaping="yes">
                                        <![CDATA[Dear ]]>
                                    </xsl:text>
                                    <xsl:value-of select="$empFirstName"/>
                                    <xsl:text disable-output-escaping="yes">
                                        <![CDATA[,

I am writing to confirm that, with effect from 1 June 2020, your gross annual salary will increase to the amount shown.  All other terms and conditions of employment remain unchanged.

I would like to take this opportunity to thank you for your hard work and commitment to SomeCompany and I look forward to working with you over the coming year.

Yours sincerely

SomeCompany
]]>
                                    </xsl:text>

                                <xsl:if test="$salaryEligible = 'false'">

                                                <![CDATA[Salary Review 2020]]>

                                                <![CDATA[Current Gross Annual Salary]]>

                                                <xsl:value-of select="format-number($cust_current_annual_actual_salary, $userLocaleSpecificMoneyFormat, $userLocaleSpecificDecimalFormatter)"/>

                                        <xsl:if test="$merit > 0">

                                                    <![CDATA[Salary Review Amount]]>

                                                    <xsl:value-of select="format-number($merit, $userLocaleSpecificMoneyFormat, $userLocaleSpecificDecimalFormatter)"/>

                                        </xsl:if>

                                                <![CDATA[Salary Review %]]>

                                                <xsl:value-of select="format-number($cust_total_pct_increase, $userLocaleSpecificPercentFormat, $userLocaleSpecificDecimalFormatter)"/>

                                                <![CDATA[Final Gross Annual Salary]]>

                                                <xsl:value-of select="format-number($cust_final_annual_actual_salary, $userLocaleSpecificMoneyFormat, $userLocaleSpecificDecimalFormatter)"/>

                                </xsl:if>

                                    <xsl:text disable-output-escaping="yes">
                                        <![CDATA[
[Signature Image]

John Doe
Manager

johndoe@somecompany.it

Tel. 123456789

[Footer in Blue]

Some Company

Registered address: some address

]]>
                                    </xsl:text>

    </xsl:template>
</xsl:stylesheet>


text:
Q: Are VSTS upgrades applied to inherited processes? We want to add/change states and reasons for our work items in VSTS.  I believe that I will need to inherit a process first and make changes to the inherited process.  Are future upgrades to VSTS applied to inherited processes?

A: Yes, you need to custom work item fields in an inherited process. And you can refer the document Add a custom field.
After updating the inherited process template, the projects which use the inherited process will be updated automatically.


text:
Q: Spring rollback issue for JDBC Template I have 2 insert / update statements that i want to wrap in a Spring transaction.  If either statement fails i want to have the statements rolled back.  I tried to test this with the following scenario:
I have an application which has a DB constraint that it's CODE can only be 25 characters max.  I'm forcing a constraint violation while saving a second application by supplying a CODE that is too large.
I would expect that the first insertion / update on application A would have been rolled back.  However my test indicates that this is not the case.
I am not quite sure what I am missing ...
My Transation test:
public class SpringTransactionTest {

private static final Logger LOGGER =  LoggerFactory.getLogger(SpringTransactionTest.class.getName());

private ApplicationDAO applicationDAO = SpringUtils4Test.getBean(ApplicationDAO.class);

@Transactional
public void doStuff() {
    Application a = new Application();
    a.setCode("A");
    Application b = new Application();
    b.setCode("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB");
    a = applicationDAO.insertOrUpdate(a);
    LOGGER.debug("a: "+a.getIdentifier());

    b = applicationDAO.insertOrUpdate(b);
    LOGGER.debug("b: "+b.getIdentifier());
}

@Before
public void cleanIt() {
    Application a = applicationDAO.getApplicationByCode("A");
    if(a != null && a.getIdentifier() > 0) {
        applicationDAO.deleteById(a.getIdentifier());
        LOGGER.debug("removed A");
    }
    Application b = applicationDAO.getApplicationByCode("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB");
    if(b != null && b.getIdentifier() > 0) {
        applicationDAO.deleteById(b.getIdentifier());
        LOGGER.debug("removed B");
    }
}

@Test
public void runTransactionTest() {
    try {
        doStuff();
    } catch (org.springframework.jdbc.UncategorizedSQLException e) {
        e.printStackTrace();
    }

    Assert.assertNull("A should be null, but instead A was found", applicationDAO.getApplicationByCode("A"));
    Assert.assertNull("B should be null, but instead B was found", applicationDAO.getApplicationByCode("B"));
}
}

Console output:
16:42:38.272 [main] DEBUG bla.dao.AbstractDAO - getApplicationDetails for : A
16:42:38.779 [main] DEBUG bla.dao.AbstractDAO - application found with id: 1008
16:42:39.062 [main] DEBUG bla.view.SpringTransactionTest - removed A
16:42:39.062 [main] DEBUG bla.dao.AbstractDAO - getApplicationDetails for : BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
16:42:39.358 [main] DEBUG bla.dao.AbstractDAO - no application found
16:42:39.676 [main] DEBUG bla.dao.AbstractDAO - new application id: 1009
16:42:39.677 [main] DEBUG bla.view.SpringTransactionTest - a: 1009
02-Sep-2014 16:42:40 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
02-Sep-2014 16:42:40 org.springframework.jdbc.support.SQLErrorCodesFactory <init>
INFO: SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL []; SQL state [72000]; error code [12899]; ORA-12899: value too large for column "BLA"."APPLICATION"."CODE" (actual: 36, maximum: 25)
; nested exception is java.sql.SQLException: ORA-12899: value too large for column "BLA"."APPLICATION"."CODE" (actual: 36, maximum: 25)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:658)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:941)
at bla.dao.ApplicationDAO.insert(ApplicationDAO.java:98)
at bla.dao.ApplicationDAO.insertOrUpdate(ApplicationDAO.java:90)
at bla.view.SpringTransactionTest.doStuff(SpringTransactionTest.java:35)
at bla.view.SpringTransactionTest.runTransactionTest(SpringTransactionTest.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.sql.SQLException: ORA-12899: value too large for column "BLA"."APPLICATION"."CODE" (actual: 36, maximum: 25)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:966)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1170)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3339)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3423)
at org.springframework.jdbc.core.JdbcTemplate$3.doInPreparedStatement(JdbcTemplate.java:944)
at org.springframework.jdbc.core.JdbcTemplate$3.doInPreparedStatement(JdbcTemplate.java:941)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:642)
... 31 more
16:42:40.411 [main] DEBUG bla.dao.AbstractDAO - getApplicationDetails for : A
16:42:40.717 [main] DEBUG bla.dao.AbstractDAO - application found with id: 1009
java.lang.AssertionError: A should be null, but instead A was found expected null, but was:<bla.domain.Application@12a66ea>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotNull(Assert.java:664)
at org.junit.Assert.assertNull(Assert.java:646)
at bla.view.SpringTransactionTest.runTransactionTest(SpringTransactionTest.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Process finished with exit code -1

Maven Dependency properties:
<java.version>1.6</java.version>
<spring.version>4.0.0.RELEASE</spring.version>
<jsf.version>2.2.5</jsf.version>
<servlet.version>3.0.1</servlet.version>
<ojdbc14.version>10.2.0.3.0</ojdbc14.version>

SpringUtils4Test:
public class SpringUtils4Test {

    private static final ClassPathXmlApplicationContext CTX = new ClassPathXmlApplicationContext("applicationContext.xml");

    public static <T> T getBean(Class<T> clazz) {
        return CTX.getBean(clazz);
    }
}

ApplicationDAO:
public Application insertOrUpdate(final Application application) {
    if (application.getIdentifier() == null) {
        return insert(application);
    } else {
        return update(application);
    }
}

private Application insert(final Application application) {
    KeyHolder keyHolder = new GeneratedKeyHolder();
    jdbcTemplate.update(
            new PreparedStatementCreator() {
                public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
                    PreparedStatement ps = connection.prepareStatement(
                        "insert into application (CODE) values (?)",
                        new String[]{"id"});
                    JdbcUtil.setValues(ps, application.getCode());
                    return ps;
                }
            },
            keyHolder);

    final Long applicationId = keyHolder.getKey().longValue();
    LOGGER.debug("new application id: " + applicationId);
    application.setIdentifier(applicationId);
    return application;
}

private Application update(final Application app) {
    jdbcTemplate.update("update APPLICATION set CODE = ? where id = ?",
            app.getCode(), app.getIdentifier());
    return app;
}

My ApplicationContext:
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
   ">

<context:component-scan base-package="bla"/>
<aop:aspectj-autoproxy proxy-target-class="true"/>

<bean id="transactionManager"
      class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
</bean>

<!-- Enable Annotation based Declarative Transaction Management -->
<tx:annotation-driven proxy-target-class="true" transaction-manager="transactionManager" />

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="url" value="jdbc:oracle:thin:@bla:1540:bla"/>
    <property name="username" value="bla"/>
    <property name="password" value="blabla"/>
</bean>

</beans>

A: I think @Transactional in junit test is too late
you need to move it to dao (or create business object layer)
when spring creates ctx.getBean, it needs to proxy that class to apply transaction
see if these help
Does Spring @Transactional attribute work on a private method?
http://www.intertech.com/Blog/secrets-of-the-spring-aop-proxy/


text:
Q: workaround for mysqlnd missing driver My hosting provider has PHP 5.3 without mysqlnd installed, and thus it returns an error when I call mysqli_stmt_get_result()
is there any workaround to achieve the same functionality without having to install mysqlnd?
I don't want to change 100's of functions, if there's an easier method, any help will be appreciated :)

A: I went through a lot of trouble on a server where mysqlnd wasn't available, and had a lot of headaches.
If you don't have mysqlnd installed/loaded whatever, you will get an undefined reference when trying to call mysqli_stmt_get_result().
I wrote my own mysqli_stmt_get_result() and a mysqli_result_fetch_array() to go with it.
<?php
class iimysqli_result
{
    public $stmt, $nCols;
}

function iimysqli_stmt_get_result($stmt)
{
    /**    EXPLANATION:
     * We are creating a fake "result" structure to enable us to have
     * source-level equivalent syntax to a query executed via
     * mysqli_query().
     *
     *    $stmt = mysqli_prepare($conn, "");
     *    mysqli_bind_param($stmt, "types", ...);
     *
     *    $param1 = 0;
     *    $param2 = 'foo';
     *    $param3 = 'bar';
     *    mysqli_execute($stmt);
     *    $result _mysqli_stmt_get_result($stmt);
     *        [ $arr = _mysqli_result_fetch_array($result);
     *            || $assoc = _mysqli_result_fetch_assoc($result); ]
     *    mysqli_stmt_close($stmt);
     *    mysqli_close($conn);
     *
     * At the source level, there is no difference between this and mysqlnd.
     **/
    $metadata = mysqli_stmt_result_metadata($stmt);
    $ret = new iimysqli_result;
    if (!$ret) return NULL;

    $ret->nCols = mysqli_num_fields($metadata);
    $ret->stmt = $stmt;

    mysqli_free_result($metadata);
    return $ret;
}

function iimysqli_result_fetch_array(&$result)
{
    $ret = array();
    $code = "return mysqli_stmt_bind_result(\$result->stmt ";

    for ($i=0; $i<$result->nCols; $i++)
    {
        $ret[$i] = NULL;
        $code .= ", \$ret['" .$i ."']";
    };

    $code .= ");";
    if (!eval($code)) { return NULL; };

    // This should advance the "$stmt" cursor.
    if (!mysqli_stmt_fetch($result->stmt)) { return NULL; };

    // Return the array we built.
    return $ret;
}
?>

A: This related question has another workaround to get data without installing mysqlnd. It puts the data into an associative array.
Mysqli - Bind results to an Array

A: The solution from Daan is very nice! For this, i have to say thank you!
The point is, that i had, based on this, developed a class which works with mysqlnd, when it's there and Daan's alternative when it's missing.
I have built in fetchAssoc, fetchAllAssoc/Array, num_rows as methods. It's still in development and part of youphptube. This maybe also helps Ehab (whish for fetchAssoc).
https://github.com/DanielnetoDotCom/YouPHPTube/blob/master/objects/mysql_dal.php
Usage:
    $sql = "SELECT * FROM users WHERE id = ?";
    $res = sqlDAL::readSql($sql,"i",array($users_id));
    $fullData = sqlDAL::fetchAllAssoc($res);
    // $data = sqlDAL::fetchAssoc($res); $data2 = sqlDAL::fetchAssoc($res); // or like this
    // $countedRows = sqlDAL::num_rows($res); // or like this
    sqlDAL::close($res);

I would made this as a sub-post to Daan's answer, but my reputation is too small.


text:
Q: Example of cone of numerically effective curves which is not polyhedral I think I have seen more than one reference in which the cone of numerically effective curves can be 'not polyhedral', i.e. with an infinite number of extremal rays
I cannot remember where I read that the usual example is the blow-up of the plane in the $9$ points of intersection of $2$ general cubics. This should give an infinite number of $-1$-curves, but I don't manage to see why it should be infinite! As far as I see the strict transform $C$ of any curve in the pencil would give me $C^2=\pi*(C)+  \sum E_i^2=9-9=0$ where $E_i$ are the exceptional divisors.
What am I missing?

A: Yes, this is the standard example of a variety whose cone of curves has infinitely many extremal rays. (A reference is Koll\'ar--Mori, p.22).
To see why there are infinitely many (-1)-curves: each of the 9 points you blow up gives a (-1)-curve E_i, as you know. But the E_i are also sections of the elliptic fibration determined by the pencil. So one can use the group structure of the generic fibre (which is an elliptic curve over the function field k(P^1)) to translate any of the  E_i to any other section of the fibration; since the action is by automorphisms of the surface, the other sections must be (-1)-curves also. As long as there are infinitely many sections (which is guaranteed by the assumption that the cubics are general) one gets infinitely many (-1)-curves this way.
Edit: It's worth mentioning that there are other examples of surfaces with non-finitely generated cone of curves, which differ from the example above in an interesting way. For example, suppose X is a K3 surface which has Picard rank at least 3 and no (-2) curves. Then the (closed) cone of curves of X consists of all classes in N^1(X) satisfying x^2 ≥ 0 and x.H ≥ 0 for any fixed ample class H. This is the standard "round cone" in N^1, with uncountably many extremal rays. (A similar example is obtained by taking X to be an abelian surface with Picard rank at least 3.)
As mentioned in the comments, Volume 1 of Lazarsfeld's great book Positivity in Algebraic Geometry is the best reference for these kinds of questions.


text:
Q: How to add a constraint to check if the date entered (column) is today's date I was having this "database" exam and I bumped into the following question.
Alter table "x" to add a constraint that only lets you enter today's date in "x.datecolumb".
I clearly have no idea how to do so, so ...?

A: In all MySQL versions

The CHECK clause is parsed but ignored by all storage engines.

MySQL Reference Manual, CREATE TABLE Syntax
The only way to solve Your problem seems to be a trigger pack checked constraint You need and discarded wrong data insertion. But this solution is not complete - there is a lot of situations when inserting/altering data do not fire the trigger action.


text:
Q: Append all files in a given directory to one file I have a directory full of small text files.
I want to create a new text file which has contents of all the small files (first have to convert the contents to lower case). Once, I have appended the small text files to get the larger one, I just want to sort it and only save unique elements.

A: cat directoryname/*|tr [:upper:] [:lower:] >filename.txt
sort -u filename.txt

or just:
cat directoryname/*|tr [:upper:] [:lower:]|sort -u > unique_elements.txt

A: Edit: i missed the part about the lowercase, see Kimvais' answer for the case transforming.

First, to append all the contents of files in /path/to/dir to 1 file:
find /path/to/dir -type f -maxdepth 1 -exec cat {} >> /var/tmp/large_file \;

Or:
cat /path/to/dir/*.log >> /var/tmp/fie_with_all_files_contents

Then to sort and only keep unique items:
sort -u /var/tmp/large_file -o /var/tmp/large_file

Or, with redirection:
sort -u /var/tmp/large_file > /var/tmp/sorted_file

man sort
man find


text:
Q: why netbeans doesn't show persian characters correctly when I read from a .csv file in java
it does its work correctly,
but for not english(persian) chars it show "?"
I add -J-Dfile.encoding=UTF-8 to my netbeans_default_options in netbeans.conf
but it is incorrect yet
what should I do?

A: You probably want to try UTF-16 instead of UTF-8 to display Persian characters.
Here's Joel Spolsky's excellent blog post on the difference.

A: Use the programmers editor JEdit to check the encoding (can be started from the web).
Read with
BufferedReader in = new BufferedReader(
        new InputStreamReader(new FileInputStream(file), "UTF-8"));

This explicitly sets the character encoding, which is better than the global system property file.encoding.
Or try "ISO-639-3" instead of "UTF-8".


text:
Q: How to use new-bind with addeventListeners in ES6 - Javascript? I am trying to add addEventlistener to DOM element which has #addButton id.I am using new binding method in ES6 but this does not work. How to call add function?
class ToDoApp {
constructor (settings) {
    if (!settings) {
        throw 'Todo App requires settings object';
    }
    this.addButtonHandler = document.querySelector(settings.addButtonSelector);
    this.addButtonHandler.addEventListener('click', this.add);

}
add = () => {
    console.log('heello');
 }
}

 const myTodo = new ToDoApp({
inputSelector: '#input',
addButtonSelector: '#addButton',
deleteButtonSelector: '#delete',
listContainerSelector: '#list'
});

HTML

        <form action="index.html" method="POST">
            <input type="text" id="input" />
            <input type="button" id="addButton" value="Add" />
        </form>

                <input type="checkbox" />

Task 1

                <input type="button" id="delete" value="X" />

A: I guess you are getting this error due to the fact that element would not exist when you create an instance of newTodo. you might want to put null check for the button you are trying to add event listener to.
class ToDoApp {
    constructor(settings) {
        if (!settings) {
            throw 'Todo App requires settings object';
        }
        this.addButtonHandler = document.querySelector(settings.addButtonSelector);
        if (this.addButtonHandler) {
            this.addButtonHandler.addEventListener('click', this.add);
        } else {
            throw "Element you want to add event listener to doesn't exist";
        }

    }
    add = () => {
        console.log('heello');
    }
}

const myTodo = new ToDoApp({
    inputSelector: '#input',
    addButtonSelector: '#addButton',
    deleteButtonSelector: '#delete',
    listContainerSelector: '#list'
});


text:
Q: Java Hashtable class - Does this thing work the way I think it does? Specific questions included I have a class called Node that I've written. I overrode the hashCode() function of it to take into account two fields of the Node (there is also a third field which doesn't affect the my hashCode() function). I also wrote an equals() function which takes all three fields into account.
I'm trying to use the Hashtable class to store Nodes so that I can easily check later on when I make new nodes whether the new nodes are duplicates of ones in the hashtable or not. So far I have this
 Hashtable<Node,Node> hashTbl = new Hashtable<Node,Node>();
 ...
 Node node1 = // some new node
 hashTbl.put(node1,node1);
 ...

So now, say I make a new node called node2 which has the exact same hash value as node1, but is not equal to node1 as defined by the equals() method. I want to check whether node2 is a duplicate of anything in the hash table (it's not), but if I use constainsKey(), won't that give me a false positive? It seems like using containsValue() wouldn't be utilizing the efficiency of the hash table. So how can I do this efficiently?
Also, my assumption is that when I call hashTbl.put(arg1,arg2), it calls the hashCode() function of arg1 and uses that value to find an index in an "array" to place arg2 in. Is this right?
Sorry for being kind of confusing. Thanks anyone.

A: First, you probably want a HashSet (or something similar), not a Hashtable - all you are trying to do is check for membership, and a HashSet will allow you to do that without needing to provide a value for every key.
To answer your question, the determines which slot in the array that the value gets put in, but every slot is actually a linked list.  If the new key is not .equal to any other key in the linked list, the new key and value are put in their own node in the linked list.  Simply returning 1 for all objects is a perfectly legal and correct .hashcode implementation.  The only issue with that implementation is that it turns Hashtables and similar data structures into linked lists (which obviously causes you to lose all the performance benefits of the Hashtable).
In short, your .hashcode method will work fine.  If you put a large number of objects that aren't .equal but have the same hashcode, performance will decrease, but the code will still function correctly.

A: You're essentially right: the hashtable (btw, HashMap is the newer, more recommended class) uses hashCode() to find a bucket to put your object in. If there's a collision (another object in the same bucket), it uses a list within each bucket, using equals(Object) to find out if this new object is already equal to one of the objects in the hash (or, in a lookup, to see whether the lookup key matches one of the key-value pairs). So in the worst case of all collisions, your hash turns into a list with O(N) operations. As you point out, this is inefficient.
As long as your equals(Object) is correct, there won't be a functional problem -- just an efficiency issue if your hashCode produces too many conflicts. Basically, if two objects are equal, they must have the same hashCode for correctness; if two objects are not equal, they should have different hashCodes for hashing efficiency.

A: A HashTable (or HashMap) contains N bins, where a bin can hold more than one Object.  (Each bin is effectively a linked list of Map.Entry).  The hashCode() of the key is used to determine the bin.  However, after determining the bin, equals() is then used on the key to see if the key is already there.  So, if you put node1 and node2 into the HashTable, and both have the same hashCode() but are not equal, they will go into the same bin, but that bin will be a linked list of length two, with two keys, node1 and node2, and corresponding values.
containsKey() will NOT give you a false positive, as it will use the hashCode() to find the bin, but then will do an equals on all the keys for that bin.  Having the same hashCode for a bunch of keys makes the HashTable slow and inefficient (if all the values have the same hashCode, in effect, you are storing in a linked list) but will not break the contract.


text:
Q: how to speed up styling pages I've just started developing and I'm working in a company that there is no senior developer to guide me ,How can I make sure that I'm in a right path I always doubt that my codes aren't good enough or I'm wasting time on styling pages using css ,if there is someone who can consult me I would appreciate.

A: Don't judge yourself, A good programmer understands that he have to continue to learn and grow so just keep going. strive to do your best at every effort, admit to failures and learn from them. A good programmer loves to program, and would do so in their spare time even if they already spend 80+ hours a week programming.


text:
Q: How to set up local network with Tenda routers to extend wireless coverage I bought two Tenda F3 routers in hope to extend wireless network coverage. Although I have some knowledge of networks from university I'm not sure how to set up the network properly.
Current state:

*

*I have a router provided by my ISP which is running a DHCP server and serves as the modem (I'm not trying to replace this router). It also runs WiFi network.

*To this router there are also several devices connected via ethernet cable such as a printer.

*The DHCP is configured to use addresses starting from 192.168.0.10, the fixed connected devices are therefore below this boundary.

Desired state:

*

*The first Tenda router is connected to the modem via ethernet cable and emits its own WiFi network (its own name, password etc.) Its administration is accesible on its given fixed IP address.

*The second Tenda router is connected to the first Tenda router and again emits its own WiFi network. Its administration is accesible on its given fixed IP address.

*Only the modem/ISP router acts as a DHCP server.

*The two Tenda routers have fixed IP addresses.

Issues:

*

*The ISP modem's local network IP address is 192.168.0.1 (I also don't seem to be able to change that)

*The default Tenda router IP address is also 192.168.0.1

*If I disconnect Tenda router from the modem and just connect it to the computer via thernet cable I can see a quick-setup page at 192.168.0.1 with selection between PPPoE, Static IP or Dynamic IP connection types. It also urges me to connect the source of the internet to the WAN port and doesn't let me acces any more setting without that. I also wouldn't know which one of the three connection type to select.

*If I connect the Tenda router to the modem it gets a dynamic IP address and I am connected to the network and internet through the Tenda router, can access modem administration at 192.168.0.1. but cannot access Tenda settings at the IP address that has been given to it.

*I tried to specify a reserved IP address in the modem administration based on the Tenda's MAC address, it then gave Tenda that address but the address still isn't accessible in the web browser.

*So basically right now I didn't get past setting up the first Tenda router.

There is certainly some basic mistake I'm making because of the lack of practice. I suppose the Tenda router should be capable of the desired scenario.

A: The solution was simple - although it seemed that the quick setup page required WAN port to be connected to a source of internet, the Okay button worked just fine without it. And then all the needed options became available and it was a matter of selecting the AP mode. I had to determine the router's IP address via DHCP address reservation though since in AP mode there is no way of setting a static IP address in that router (reservation feels like the better way anyway).


text:
Q: How to replace only specific 20 characters using sed file.dat
No      Name                       Title               Publisher           Edition

1001 Programming in Java By BPB    Balaguruswamy       BPB                 Second
1002 Computer Networks             Tanenbaum           Pearson             Fifth
1003 Operating Systems             Chaudhari           Jaico               First

*

*No: Numeric (4) – uniquely identifies each book

*Title: Alphanumeric(30)

*Author: Character(20)

*Publisher: Character(20)

*Edition: Character(9)

I want to replace all publishers with name BPB to -> THM under publisher column only. Using sed, it not only replaces under Publisher column, but also under Name column. I want sed to work only between 55th character to 74th character
I have extracted 55th-74th character using
while IFS= read -r line; do
    echo ${line:55:20}
done < $file

What should I do to replace only specific 20 characters?
Thanks in advance

A: Something like:
To replace the publisher column in its entirety (BPB followed by 17 spaces:
sed 's/^\(.\{55\}\)BPB\( \{17\}\)/\1THM\2/'

To replace the BPB string with THM wherever it appears in the publisher column:
sed '
  :1
    s/^\(.\{55,72\}\)BPB/\1THM/
  t1'