text:
Q: Pass a array from one function to another I have this code which grab data from a xml file. I need to feed these data to a google chart which is currently in an array. I need to pass my xml values to the google chart. Can anyone help me to figure this out. The below is my code.
<!DOCTYPE html>

<title>My Read</title>

Xml File
<?xml version="1.0" encoding="utf-8" ?>
    <Chart>
      <Pie>
         <Title>Task</Title>
         <Value>Hours per Day</Value>
      </Pie>
      <Pie>
         <Title>Work</Title>
         <Value>11</Value>
      </Pie>
      <Pie>
         <Title>Eat</Title>
         <Value>2</Value>
      </Pie>
      <Pie>
         <Title>Commute</Title>
         <Value>2</Value>
      </Pie>
      <Pie>
         <Title>Watch TV</Title>
         <Value>2</Value>
      </Pie>
      <Pie>
         <Title>Sleep</Title>
         <Value>7</Value>
      </Pie>
    </Chart>

A: Change this
var data = google.visualization.arrayToDataTable([
            ['Task', 'Hours per Day'],
            ['Work',     11],
            ['Eat',      2],
            ['Commute',  2],
            ['Watch TV', 2],
            ['Sleep',    7]
        ]);

to
var data = google.visualization.arrayToDataTable((Array.isArray(val) && val.length) ? val : [
    ['Task', 'Hours per Day'],
    ['Work',     11],
    ['Eat',      2],
    ['Commute',  2],
    ['Watch TV', 2],
    ['Sleep',    7]
]);

if value array and is not empty - pass val to function, else pass default options.
Also you need convert sValue from string to number, like this
$(xml).find('Pie').each(function() {
    var sTitle = $(this).find('Title').text();
    var sValue = $(this).find('Value').text();

    if (!isNaN(+sValue)) {
        sValue = +sValue;
    }

    values.push([sTitle, sValue]);
});

A: You have passed that array to drawChart() function as,
drawChart(values);

Hope that it will work fine.

A: Maybe you are just confusing yourself by calling drawChart twice: once in google.setOnLoadCallback(drawChart) and once in the success function. Remove the one in setOnLoadCallback (or create a function that keeps an eye on load-status for both, and calls drawChart when both are loaded).
And implement Alexanders suggestions.


text:
Q: Validating input to an array I am trying to validate the input of the array to only allow an input of only one single digit integer (either 2 or 3) at each index of the array. For example a = [2,3,2,3,2,2,2,2,2,3]. My attempt is below.
int main()
{
        int a[10];
        int b;
        bool c= false;
        printf( "Please the 10 values: \n");
        while(c)
        {
            for(b=0;b<10;b++)
            {

                scanf("%d", &a[b]);//enter each value individually
                if(&a[b]==2 || &a[b]==3)
                {
                    c= true;
                }
                else
                {
                    printf("please the value");
                    scanf("%d", &a[b]);
                    c= false;
                }
            }

        }
}

A: If you want to check the value, you have to change your code
if(&a[b]==2 || &a[b]==3)

to
if((a[b]==2) || (a[b]==3))   //no need for address of (&) operator

However, for an array like int a[10];, using
 for(b=0;b<32;b++)

will overrun the allocated memory and you'll run into undefined behavior.
That said, the else part is not checking the validity of the repeated input. You need to take care of that, too.
Also, the recommended signature of main() is int main(void).

A: Increment the counter b when there is a correct value.
scanf will return the number of items successfully scanned. In this case one.
If scanf does not return one, the else will read a character and then scanf can try again.
int main()
{
    int a[10];
    int b = 0;
    printf( "Please the 10 values: \n");
    while(b < 10)
    {
        printf( "enter value for a[%d]\n", b);
        if ( ( scanf("%d", &a[b])) == 1) {//enter each value individually
            if(a[b]==2 || a[b]==3)
            {
                b++;//correct value increment b
            }
        }
        else //scanf failed to read an int
        {
            getchar ( );//read a character and try again
        }
    }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why does scalac seem to expand implicits too far? I am trying to diagnose a compiler error which is caused by diverging implicit expansion errors.
Here is what I am seeing:
❯ scala
Welcome to Scala 2.13.1 (OpenJDK 64-Bit Server VM, Java 1.8.0_252).
Type in expressions for evaluation. Or try :help.

scala> :settings -Xlog-implicits

scala> :paste
// Entering paste mode (ctrl-D to finish)

trait Invariant[A]
trait Covariant[+A]
trait Foo

implicit def invariantTuple1[T1: Invariant]: Invariant[Tuple1[T1]] = ???

implicit def invariantFoo: Invariant[Foo] = ???

def a = implicitly[Invariant[Foo]]

implicit def covariant[A: Invariant]: Covariant[A] = ???

def b = implicitly[Covariant[Foo]]

// Exiting paste mode, now interpreting.

def b = implicitly[Covariant[Foo]]
                  ^
<pastie>:13: invariantTuple1 is not a valid implicit value for Invariant[T1] because:
hasMatchingSymbol reported error: diverging implicit expansion for type Invariant[T1]
starting with method invariantFoo

def b = implicitly[Covariant[Foo]]
                  ^
<pastie>:13: invariantFoo is not a valid implicit value for Invariant[T1] because:
diverging implicit expansion for type Invariant[T1]
starting with method invariantTuple1

def b = implicitly[Covariant[Foo]]
                  ^

(remaining output elided for clarity)
I want to know why specifically does this the compiler output these particular diverging implicit expansion messages?
Take this one first:
invariantTuple1 is not a valid implicit value for Invariant[T1] because:
hasMatchingSymbol reported error: diverging implicit expansion for type Invariant[T1]
starting with method invariantFoo

What does the "starting with method invariantFoo" mean here?
From what I can tell from the start of the message is that it is trying to find an implicit parameter for invariantTuple1 of type Invariant[T1]. Then what? It is trying to see if invariantFoo is a match? It's not a match but it certainly doesn't diverge. The "starting with" part sounds like that is where it starts but invariantFoo doesn't have any implicit parameters so why would that need to look any further?
The next one is also confusing:
invariantFoo is not a valid implicit value for Invariant[T1] because:
diverging implicit expansion for type Invariant[T1]
starting with method invariantTuple1

invariantFoo should be a valid implicit value for Invariant[T1] (assuming T1 is Foo). So how can invariantFoo diverge when it has not implicit parameters?


text:
Q: How to get media directory path in a phtml file in magento 2? Used the below method in order to get the media directory path, but it returns an error.
$om = \Magento\Core\Model\ObjectManager::getInstance();

$directoryList = $om->get(\Magento\App\Filesystem\DirectoryList::class);

$pubMediaDir = $directoryList->getPath(\Magento\App\Filesystem\DirectoryList::MEDIA);

Please help me to find a solution.

A: First you will need to inject DirectoryList class into your Magento 2 constructor:
public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\App\Filesystem\DirectoryList $directory_list, array $data = []) {
     parent::__construct($context, $data);
     $this->directory_list = $directory_list;
 }

After that you will have access to DirectoryList methods for retrieving various paths. For example, to get media folder you can use:
$this->directory_list->getPath('media');

Other possible uses are:
/* Get app folder */
$this->directory_list->getPath('app');

/* Get configuration folder */
$this->directory_list->getPath('etc');

/* Get libraries or third-party components folder */
$this->directory_list->getPath('lib_internal');

/* Get libraries/components that need to be accessible publicly through web-server folder */
$this->directory_list->getPath('lib_web');

/* Get public folder */
$this->directory_list->getPath('pub');

/* Get static folder */
$this->directory_list->getPath('static');

/* Get var folder */
$this->directory_list->getPath('var');

/* Get temporary files folder */
$this->directory_list->getPath('tmp');

/* Get file system caching directory (if file system caching is used) */
$this->directory_list->getPath('cache');

/* Get logs of system messages and errors */
$this->directory_list->getPath('log');

/* Get file system session directory (if file system session storage is used) */
$this->directory_list->getPath('session');

/* Get directory for Setup application*/
$this->directory_list->getPath('setup');

/* Get Dependency injection related file directory */
$this->directory_list->getPath('di');

/* Relative directory key for generated code*/
$this->directory_list->getPath('generation');

/* Temporary directory for uploading files by end-user */
$this->directory_list->getPath('upload');

/* Directory to store composer related files (config, cache etc.) in case if composer runs by Magento Application */
$this->directory_list->getPath('composer_home');

/* A suffix for temporary materialization directory where pre-processed files will be written (if necessary) */
$this->directory_list->getPath('view_preprocessed');

/* Get template minification dir */
$this->directory_list->getPath('html');

A: Try to get it by using StoreManagerInterface
use Magento\Store\Model\StoreManagerInterface;
protected $storeManager;

public function __construct(
    StoreManagerInterface $storeManager,
)
{
    $this->storeManager = $storeManager;
}

Now get media url using
 $mediaUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);

A: Use below code to get the media path on .phtml file.
$this->getUrl('pub/media');

By Objectmanager
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
echo $objectManager->get('Magento\Store\Model\StoreManagerInterface')
                    ->getStore()
                    ->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);

A: Instead of using direct object manager, use It like
use Magento\Framework\App\Filesystem\DirectoryList;

protected $_filesystem;

public function __construct(
    \Magento\Framework\Filesystem $filesystem
)
{
    $this->_filesystem = $filesystem;
}

Now you can media path by,
$mediapath = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath();

EDIT
If you want to use an Object Manager, then you can use this (not recommended)
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$fileSystem = $objectManager->create('\Magento\Framework\Filesystem');
$mediaPath = $fileSystem->getDirectoryRead(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA)->getAbsolutePath();
echo $mediaPath;
exit;

A: To get media path use below code
$this->fileSystem->getDirectoryRead(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA)->getAbsolutePath("folder_name")


text:
Q: How to Read data from dynamic Facebook C# SDK I am new to C# (learning it nowadays), and have choosen FB and C# Facebook SDK as a test project to learn things (maybe not a good idea). So here is the issue.
I am using VS 2010, ASP.NET MVC 3
I am using the following code to retreive some data from the FB
public ActionResult FBLandingPageFinal ( string accessToken )
        {
 var newfb = new FacebookClient ( accessToken );
 dynamic FQLResultSet = newfb.Get ( "fql", new { q = "select uid, name from user where is_app_user = 1 and uid in (SELECT uid2 FROM friend WHERE uid1 = me())" } );
 ViewBag.FQLResultSet = FQLResultSet;

         }

Now this return data in json format in the following format
{
  "data": [
    {
      "uid": XXXXX,
      "name": "User Name 1"
    },
    {
      "uid": XXXXX,
      "name": "User Name 2"
    },
    {
      "uid": XXXXX,
      "name": "User Name 3"
    }
  ]
}

Upto this point everything is working fine, now can anyone guide me how extract data from this viewbag object on my aspx page ( i am not using razor syntax)
Now on the aspx page this what i am trying to achieve

<%
 foreach (var item in ViewBag)
{
%>

<img src="https://graph.facebook.com/<%={uid from viewbag}%>/picture" alt="" /> <%{name from ViewBag} %>

<%
}

%>

Any advise will be a real help and i appreciate the time and effort you guys putting up in reading such a long question as i have tried to explain everything what i am doing.
Looking forward for guidance

A: You need to deserialize that JSON into an object before putting it into the ViewBag. You can use JavaScriptSerializer, like so
public ActionResult FBLandingPageFinal (string accessToken)
    {
     var newfb = new FacebookClient (accessToken);
     dynamic jsonResult= newfb.Get (
                             "fql",
                              new {
                               q = "select uid, name from user where is_app_user = 1 and uid in (SELECT uid2 FROM friend WHERE uid1 = me())"
                                  });
     var serializer = new JavaScriptSerializer();
     ViewBag.FQLResultSet = serializer.Deserialize<ImageSet>(jsonResult);
    }

// You have to define this class
public class FbImage
{
   public string string name {get; set;}
   public string string uid {get; set;}
}

// And this one
public class ImageSet
{
   public List<FbImage> images {get; set;}
}

And then, in your View, here's what you do:

<%foreach (var item in ViewBag.FQLResultSet.images ){%>

    <img src="https://graph.facebook.com/<%={item.uid}%>/picture" alt="" />
    <%{item.name} %>

<%}%>


text:
Q: login form asp.net my web app sign out every one minute, .aspxauth cookie set to (20 days) and asp.net_sessionid set to (session end), i want to make my site (remember me).
i am using the below code -but to no avail-:
<authentication mode="Forms">
    <forms
    loginUrl="~/Account/Login.aspx"
    protection="All"
    timeout="30160"
    name=".ASPXAUTH"
    path="/"
    requireSSL="false"
    slidingExpiration="false"
    defaultUrl="~/Default.aspx"
    cookieless="UseCookies"
    enableCrossAppRedirects="false" />
</authentication>

How do I prevent my app from signing out so often?

A: Look like everything is in default setting, so use the following setting.
<forms loginUrl="~/Account/Login.aspx"" timeout="30160" />

In web.config, make sure sessionState either doesn't exist at all or is set to something.
<sessionState timeout="20"/>

If you modified the default form authentication, see this post -
Forms Authentication Timeout


text:
Q: Input CNF for SAT4J solver I a totally new to sat4j solver..
it says some cnf file should be given as input
is there any possible way to give the rule as input and get whether it is satisfiable or not?
my rule will be of the kind :
Problem = (

     ( staff_1         <=>          staff_2 ) AND
     ( doctor_1        <=>      physician_2 )

) AND (

     ( staff_1         AND         doctor_1 )

)  AND (

    NOT( ward_2             AND physician_2 ) AND
    NOT( clinic_2           AND physician_2 ) AND
    NOT( admission_record_2 AND physician_2 )

) AND (

   NOT( hospital_2          AND physician_2 ) AND
   NOT( department_2        AND physician_2 ) AND
   NOT( staff_2             AND physician_2 )
)

Can someone help me how to solve this using sat4j solver?

A: If you want to use SAT4J, you need to transform your problem CNF format.
You first need to transform these text variables into integer.
1 = staff_1
2 = staff_2
3 = doctor_1
4 = physician_2
5 = ward_2
6 = clinic_2
7 = admission_record_2
8 = hospital_2
9 = department_2

Then, here are the rules and syntaxes that you need to know to transform your problem into CNF format.
Syntax:
    OR           = a space
    AND          = a newline
    NOT          = -

Rules from De Morgan's laws:
    A <=> B      = (A => B) AND (B => A)
    A  => B      = NOT(A) OR  B
    NOT(A AND B) = NOT(A) OR  NOT(B)
    NOT(A OR  B) = NOT(A) AND NOT(B)

And here is your example-problem, formatted as it should be to be read by SAT4J.
(see DIMACS to know more about this format).
 c you can put comment here.
 c Formatted by StackOverFlow.
 p cnf 9 12
 -1 2 0
 -2 1 0
 -3 4 0
 -4 3 0
  1 0
  3 0
 -5 -4 0
 -6 -4 0
 -7 -4 0
 -8 -4 0
 -9 -4 0
 -2 -4 0

I let you run SAT4J on this little example,
and it will give you the solution SATISFIABLE xor UNSATISFIABLE.
Little sum-up of what you have to do to use SAT4J :
 * Transform your `text_n` into a number.
 * Use the rule that I gave you to transform your problem into CNF.
 * Write the definition of your problem `p cnf nbVariables nbClauses`
 * Write everything in a FILE and run SAT4J on this file.

I hope this step-by-step example will help few people.

A: I was looking for an example of how using SAT4J and found this topic which is 6 years old.
I think the answer of Valentin Montmirail is not correct since the link provided
(DIMACS) says :

The definition of a clause is terminated by a final value of "0".

Therefore, I think the correct answer will be :
 c you can put comment here.
 c Formatted by StackOverFlow.
 p cnf 9 12
 -1 2 0
 -2 1 0
 -3 4 0
 -4 3 0
  1 0
  3 0
 -5 -4 0
 -6 -4 0
 -7 -4 0
 -8 -4 0
 -9 -4 0
 -2 -4 0

I lost 30min on this, I hope it will help future readers.

A: Did you review the SAT4J Howto on their website? It includes a link to a Postscript document detailing the semantics of the CNF format. The format seems to support all the operators you use in your example, except "<->", but that just might be an omission in this specific "unofficial" document.


text:
Q: Cutting polygons into mutually similar and non-congruent pieces It is well-known that a square can be cut into a finite number of squares all of mutually different sides (hence mutually non-congruent) - for example, see https://en.wikipedia.org/wiki/Squaring_the_square
Questions:

*

*Is there a non-rectangular, non-parallelogram polygon P that can be cut into a finite number of scaled down copies of P such that each copy is of a unique size (unique scale factor)?

*Is there a convex polygon P that can be cut into a finite number of (not necessarily convex) pieces all of which are mutually similar and of different sizes to one another but are not similar to P?
Remark: As has been pointed out by M Winter in comments below, one can cut a right triangle into 2 pieces similar to itself and non-congruent to each other with the altitude falling on the hypotenuse. This gives a simple answer to question 1 and naturally gives an equally simple answer to qn 2 - indeed, one can cut a rectangle into 3 right triangles, all mutually similar and non-congruent. Are there any other answers?
Bit added on 2nd August, 2021: Specific question: Is there any non-right triangle T that can be tiled by finitely many mutually non-congruent triangles all similar to T? Note: It was proved by Tutte (1948) that the equilateral triangle does not have this property.


text:
Q: QT - How to implement to resize Frameless Widget?
Possible Duplicate:
Implement Resize option to Qt Frameless widget

I make a frameless widget using
setWindowFlags(Qt::FramelessWindowHint);

And I want to implement resizing dialog such as Windows.
I found the solution that QSizeGrip is added.
but it makes resizing enabled on right-bottom.
On windows, for example, I can resize on all-sides border(top, bottom, right, left).
How can I implement to resize border like Windows?

A: You may take a look at the source code of QSizeGrip, see what's going on when right mouse button is clicked, and reimplement the function below. E.G. when left mouse button pressed... blah blah
virtual void    mousePressEvent ( QMouseEvent * event )

A: maybe try using QSizeGrip

Put this widget anywhere in a widget tree and the user can use it to resize the top-level window or any widget with the Qt::SubWindow flag set.


text:
Q: Onkeyup Events with Tapestry 5.2.6 I am tring to use the mixins zoneUpdater from Tapestry to trigger an event when I write in a textfield. However I keep getting the following error :
Failure creating embedded component 'myComponent' of com.mycompany.myapp.web.pages.tapestryTest.testEdit: Unable to resolve 'zoneUpdater' to a mixin class name.

Here is the code in the tml page :

    <t:label for="myComponent"/>
    <t:textfield t:id="myComponent"
    value="myValue" t:validate="maxlength=8" maxlength="8"
    style="width:70px;" t:mixins="zoneUpdater" t:clientEvent="keyup"
    t:event="updateMyValue"  t:zone="myZone"/>

</table

In the controller I defined the following method :
@OnEvent(component = "updateMyValue")
Object onupdateMyValue()
{
    if (this.value.length()==8){
        //does something
    }

    return myZone.getBody();
}

Any idea why I keep getting this problem? I am doing the same thing as on jumpstart but for some reason it doesn't recognise zoneUpdater. I am using Tapestry 5.2.3 so it should work without creating the classes from Jumpstart.
Thanks in advance,
Remi

A: Tapestry itself does not have a mixin called ZoneUpdater. The one described on Jumpstart pages (e.g., http://jumpstart.doublenegative.com.au/jumpstart7/examples/ajax/onevent) is a custom one. See that link for the source code. Just paste that code into your project.


text:
Q: How to sum data and join columns using Pandas I want to sum values in data
from this:

to this:

but the problem is, the data doesn't add up but they like 11, 1111
here is my code:
df_data.insert(loc=2, column='Jumlah', value='1')
df_data.pivot_table(index='Kecamatan', columns='Status', aggfunc='sum', fill_value=0)

And how I can make the columns only KECAMATAN NEGATIF ODP ODPSELESAI OTG PDP
Thank you guys.

A: Note that the value of the inserted column (Jumlah) is a string.
In the next instruction you attempt to generate a pivot_table summing
this column.
But if you attempt to sum text values, it actually means concatenation.
To put things right, change the first instruction to:
df_data.insert(loc=2, column='Jumlah', value=1)

i.e. remove apostrophes surrounding 1.
Then this column will be of int type and will be summed as you wish.


text:
Q: Как из предложения удалить гласные на чистом JS? Даны такие строчки:
("This website is for losers LOL!"),
 ( "Ths wbst s fr lsrs LL!")

Надо удалить все гласные из предложений, не используя никаких фрэймворков, кроме чистого JS. Как этого добиться?

A: Ну или при помощи методов массива:
let str = 'This website is for losers LOL!';
const res = str.split('').filter(letter => !['a','e','i','o','u','y'].includes(letter.toLowerCase())).join('');
console.log(res);


text:
Q: jquery dialog title undefined using global variable I have set a var in my code then made it global, but for some reason, dialog is showing it as 'undefined'. Can you not have var in title? Thanks
In .click event
box = $('#EB_custref').val();

Outside of function
var box;

In dialog options
title: 'Edit box' + ' ' + box,

A: The title: 'Edit box' + ' ' + box line gets run when you instantiate your dialog: I assume you're doing that on $(document).ready. At that point, your box variable is undefined.
When you set box on the click event it's too late - the title has already been set.
See this post for further info.

EDIT
Here's a demo of one solution for this:
HTML
<button data-title="Apple">OPEN 1</button>
<button data-title="Banana">OPEN 2</button>

<div id="MyDialog">
    Example Dialog Content
</div>

JQUERY
var globalTitle = ''; // Your global variable

// Startup operations
$(function () {

    $('#MyDialog').hide();
    $('button').click(function () {
                          openMyDialog($(this).data('title'))
                      });
});

// Open the dialog using the global myTitle variable
function openMyDialog(customTitle)
{
    globalTitle = customTitle;
    $('#MyDialog').dialog({title : globalTitle});
}

Note the use of HTML5-style data- attributes, which rock, and are accessible in jQuery through the .data() function. Also note that I've used a global variable to show you that it's possible to use one. However there's no need for it - the best approach would be to pass customTitle straight into the dialog() call, i.e. $('#MyDialog').dialog({title : customTitle});

A: alert($('#EB_custref').val())

Check that its returning value or not
and if possible post more code/


text:
Q: Instagram api: how to get photos containing like? in my application, i enter a user name and get his photo.
(To get photos, i use: https://api.instagram.com/v1/users/3/media/recent/?access_token = ...)
Request returns only 20 pictures, how to get all photos user?
I want to get photos of this user which contain his likes.
How can this be done?
I have an idea to get all the pictures that have user and check each pictures does it have his like ?!
But I get only the data for the four member who delivered Like, although photo has 50 likes. (See the screenshot below). Why so ? How to fix it ?
Thanks for the help.

A: It's a two step process:
1) Perform a GET request to /users/user-id/media/recent inorder to get the most recent media published by a user.
2) Then perform a second GET request to /media/media-id/likes in order to get a list of users who have liked this media.
At this point you can record all the media-id's which contain likes by the specific person you want.
Here is the API for instagram users:
http://instagram.com/developer/endpoints/users/
Here is the API for instagram likes:
http://instagram.com/developer/endpoints/likes/
As for getting the entire history, I apologize but I'm unclear as to how to go about doing more than what they provide.
Please let me know if you have any questions!


text:
Q: Linq using Aggregate() for List From the Data
OrderID     OrderAmt   OrderDate
----------- ---------- --------------------
1           10.50      2003-10-11 08:00:00
2           11.50      2003-10-11 10:00:00
3           1.25       2003-10-11 12:00:00
4           100.57     2003-10-12 09:00:00
5           19.99      2003-10-12 11:00:00
6           47.14      2003-10-13 10:00:00
7           10.08      2003-10-13 12:00:00
8           7.50       2003-10-13 19:00:00
9           9.50       2003-10-13 21:00:00

I want to display the following running total
OrderId     OrderDate            OrderAmt   Running Total
----------- -------------------- ---------- -------------
1           2003-10-11 08:00:00  10.50      10.50
2           2003-10-11 10:00:00  11.50      22.00
3           2003-10-11 12:00:00  1.25       23.25
4           2003-10-12 09:00:00  100.57     123.82
5           2003-10-12 11:00:00  19.99      143.81
6           2003-10-13 10:00:00  47.14      190.95
7           2003-10-13 12:00:00  10.08      201.03
8           2003-10-13 19:00:00  7.50       208.53
9           2003-10-13 21:00:00  9.50       218.03

From the following list
List<OrderData> ord = new List<OrderData>();

ord.Add(new OrderData() { OrderNumber=1, OrderAmount=10.50,
OrderDate=new DateTime(2003,10,11)});

ord.Add(new OrderData() { OrderNumber=2, OrderAmount=11.50,
OrderDate=new DateTime(2003,10,11)});

ord.Add(new OrderData() { OrderNumber=3, OrderAmount=1.25,
OrderDate=new DateTime(2003,10,11)});

ord.Add(new OrderData() { OrderNumber=4, OrderAmount=100.57,
OrderDate =new DateTime(2003,10,12)});

ord.Add(new OrderData() { OrderNumber=5, OrderAmount=19.99,
OrderDate=new DateTime(2003,10,12)});

ord.Add(new OrderData() { OrderNumber=6, OrderAmount=47.14,
OrderDate =new DateTime(2003,10,13)});

ord.Add(new OrderData() { OrderNumber=7, OrderAmount=10.08,
OrderDate=new DateTime(2003,10,13)});

ord.Add(new OrderData() { OrderNumber=8, OrderAmount=7.50,
OrderDate=new DateTime(2003,10,13)});

ord.Add(new OrderData() { OrderNumber=9, OrderAmount=9.50,
OrderDate=new DateTime(2003,10,13)});

How to reshape the following query
var query = from o in ord
            select new
            {
             OrdNumber=o.OrderNumber,
             OrdDate=o.OrderDate,
             Amount=o.OrderAmount,
            RunntingTotal =ord.Aggregate(0,(o a,o b)=>
           {a.OrderAmount+b.OrderAmount;})
            };

A: You can't do this using the built-in Aggregate method.
Darin's answer will give you what you need, but has side-effects (ie, the query updates the total variable as it enumerates).
If you want a "pure" query without side-effects then you'll need to create some sort of Accumulate extension method and use that instead of Aggregate:
var query = ord.Accumulate(
    new { Order = (OrderData)null, Total = 0.0 },
    (a, x) => new { Order = x, Total = a.Total + x.OrderAmount });

foreach (var x in query)
{
    Console.WriteLine("{0}\t{1}\t{2}\t{3}",
        x.Order.OrderNumber, x.Order.OrderDate, x.Order.OrderAmount, x.Total);
}

// ...

public static class EnumerableExtensions
{
    public static IEnumerable<TAccumulate> Accumulate<TSource, TAccumulate>(
        this IEnumerable<TSource> source,
        TAccumulate seed,
        Func<TAccumulate, TSource, TAccumulate> func)
    {
        if (source == null)
            throw new ArgumentNullException("source");

        if (func == null)
            throw new ArgumentNullException("func");

        TAccumulate accumulator = seed;
        foreach (TSource item in source)
        {
            accumulator = func(accumulator, item);
            yield return accumulator;
        }
    }
}

A: double total = 0;
var result =
    (from o in ord
     select new
     {
         OrdNumber = o.OrderNumber,
         OrdDate = o.OrderDate,
         Amount = o.OrderAmount,
         RunntingTotal = total += o.OrderAmount
     }).ToArray();


text:
Q: How do I rebind event after widget save I am writing a widget who's form elements have a click event attached to. I bind it using jQuery.
However, after clicking save, the bindings gets lost. That is, clicking those elements doesn't trigger the function anymore.
I tried using the on() jQuery method, as suggested here, but that doesn't help:
    var buttonsHolder=jQuery('#widgets-right .icon_buttons');
    // save the array of big icons, for later reference, and assign them the click event
    var  buttons=buttonsHolder.children('input');
    buttons.on("click",function(){
        openPanel(jQuery(this),jQuery(this).index());
    });

I could put my js code inside the widget form, as suggested here. That does solve the problem, but I really prefer to keep my js code separated.
What do I need to do in order to keep the click event of those elements working even after the save button is clicked?

A: Wordpress provides callbacks for widgets interactions. You're seems interested in two of them:
widget-added, widget-updated
Usage example:
jQuery(document).on('widget-updated', function(e, widget){
    // do your awesome stuff here
    // "widget" represents jQuery object of the affected widget's DOM element
});

A: Because the input box is getting rebuilt (or the entire form), I followed advice given me elsewhere, and instead of binding on() to an input box, I bind it higher up and use event delegation:
jQuery('#widgets-right').on('click','.icon_buttons input',function(){
     openPanel(jQuery(this),jQuery(this).index());
});

I still put some js variable declarations inside the widget form, but that's only for convenience, and it's only a few lines of code, so I don't mind it too much.


text:
Q: Filling an std::vector with raw data I need to fill a vector with raw data, sometimes 2 bytes, sometimes 8... I ended up with this template function:
template <typename T>
void fillVector(std::vector<uint8_t>& dest, T t)
{
    auto ptr = reinterpret_cast<uint8_t*>(&t);
    dest.insert(dest.end(),ptr,ptr+sizeof(t));
}

with this I can fill the vector like this:
fillVector<uint32_t>(dst,32bitdata);
fillVector<uint16_t>(dst,16bitdata);

I was wondering if something more similar already exist in the standard library?

A: No, there's nothing in the standard library to achieve what you are after. So your solution is pretty much what you can currently go with (assuming your goal is to do some form of serialization).
The only point of improvement is that you are assuming uint8_t is a type that may be used to alias an object and inspect its bytes. That need not be the case. The only such types in C++11 are char and unsigned char. While uint8_t usually aliases the later in most modern architectures, that's not a hard requirement, it could alias a platform specific 8 bit unsigned integer type (the merits of that are outside the scope of this question). So to be standard conforming, either guard against it:
static_assert(std::is_same<unsigned char, std::uint8_t>::value, "Oops!");

Or use your own alias for valid "byte" type
namespace myapp { using byte = unsigned char; }

and deal in std::vector<myapp::byte>.


text:
Q: The apply function is executed twice for the first 2 groups in a grouped pandas DataFrame I want to get the size of the every kind of animal that having max weight. The test code is here:
import numpy as np
import pandas as pd

print('numpy version =', np.__version__)
print('pandas version =', pd.__version__)
print()

def get_size_with_max_weight(subf):
    print(subf)
    return subf['size'][subf['weight'].idxmax()]

df = pd.DataFrame({'animal': 'cat dog cat fish dog cat cat'.split(),
                   'size': list('SSMMMLL'),
                   'weight': [8, 10, 11, 1, 20, 12, 12],
                   'adult': [False] * 5 + [True] * 2})

print(df)
print()

gf = df.groupby('animal').apply(get_size_with_max_weight)
print()
print(gf)

But When I tried to run apply function in DataFrame group, it was supposed each group should be just executed once. But when the function idxmax() is called as index with another column, I found that the apply function was executed twice for the first 2 groups. The below is the output:
numpy version = 1.18.5
pandas version = 1.0.5

  animal size  weight  adult
0    cat    S       8  False
1    dog    S      10  False
2    cat    M      11  False
3   fish    M       1  False
4    dog    M      20  False
5    cat    L      12   True
6    cat    L      12   True

  animal size  weight  adult
0    cat    S       8  False
2    cat    M      11  False
5    cat    L      12   True
6    cat    L      12   True
  animal size  weight  adult
1    dog    S      10  False
4    dog    M      20  False
  animal size  weight  adult
0    cat    S       8  False
2    cat    M      11  False
5    cat    L      12   True
6    cat    L      12   True
  animal size  weight  adult
1    dog    S      10  False
4    dog    M      20  False
  animal size  weight  adult
3   fish    M       1  False

animal
cat     L
dog     M
fish    M
dtype: object

As you can see, the group cat/dog was printed twice. If I don't use the idxmax() function, it won't happen. What's the problems?

A: This is not a bug. This is by design.
The apply function needs to know the shape of the groups. Since the first two groups have different shapes. It will print group them twice, first time for getting the shape and second time for running the code on it.
In pandas version 1.1.0 this has been fixed, as mentioned in the "What's New" page of the [documentation]

apply and applymap on DataFrame evaluates first row/column only once¶
Previous behavior:
df.apply(func, axis=1)
a    1
b    3
Name: 0, dtype: int64
a    1
b    3
Name: 0, dtype: int64
a    2
b    6
Name: 1, dtype: int64
Out[4]:
   a  b
0  1  3
1  2  6

New behavior:
df.apply(func, axis=1)
a    1
b    3
Name: 0, Length: 2, dtype: int64
a    2
b    6
Name: 1, Length: 2, dtype: int64
Out[79]:
   a  b
0  1  3
1  2  6

[2 rows x 2 columns]

Also mentioned here on GitHub.


text:
Q: How to find the entries in one table not like those in another I have a table called whitelist_email which looks like this
+----+---------------------+-------------+
| id | email_suffix        | create_date |
+----+---------------------+-------------+
|  1 | stackoverflow.com   | 2017-07-07  |
|  2 | example.com         | 2017-07-07  |

and a table called user_info with a field called verified_email. I would like to write a command to find all the rows in user_info whose verified_email field does not end with any entry in whitelist_email to give me a list of new users who need to be vetted. The best I can do with my limited knowledge is
SELECT verified_email
FROM user_info
WHERE verified_email IN (
    SELECT email_suffix
    FROM whitelist_email
);

A: One approach is to LEFT JOIN the user_info table to the whitelist_email table on the condition that the verified email address ends in a whitelisted suffix, and then retain only emails which did not match to any known whitelisted email suffix.
SELECT t1.*
FROM user_info t1
LEFT JOIN whitelist_email t2
    ON t1.verified_email LIKE CONCAT('%', t2.email_suffix)
WHERE t2.id IS NULL

A: SELECT verified_email
from user_info
where   SUBSTRING(verified_email,INSTR(reverse(verified_email),".")+1,length(verified_email))
    not in (select email_suffix from whitelist_email);

A: For example
Table user_info
id;verified_email
1;u1@tu.com
2;u2@example.com

Table whitelist_email
id;email_suffix
1;example.com
2;stackoverflow.com

Query
select *
from user_info u
where not exists(
  select *
  from whitelist_email
  where whitelist_email.email_suffix=substr(u.verified_email,locate('@',u.verified_email)+1)
)

Result
id,verified_email
1,u1@tu.com

It is more efficient to store mail account and mail domain in separate fields.


text:
Q: React-Native Add Fade in Animation I am trying to make this card fade in every time the component loads and fade out after it unmount's using hooks but I am failing to do so and desperately need someones help. Please can you show me how to animate this card every-time it's loaded and unmounted using hooks
This is my component:
import React, { useState } from "react";

const Home = (props) => {
  const renderCard = ({ item }) => {
    return (
      //I am trying to add a fadein to this everytime it loads and fadout when It unmounts
      <View>
        <Text style={styles.day}>{item}</Text>
        <MealCards
          item={state[item]}
          navigation={navigation}
          onChange={onChange}
        />
        <View style={styles.divider} />
      </View>
    );
  };
  return (
    <FlatList
      data={days}
      keyExtractor={(item) => item}
      showsHorizontalScrollIndicator={false}
      renderItem={renderCard}
    />
  );
};

A: Wrap your component in an Animated.View and give it the fade in animation using opacity: https://reactnative.dev/docs/animated.
Something like
  const [fadeAnim] = useState(new Animated.Value(0));

  React.useEffect(() => {
    Animated.timing(fadeAnim, {
      toValue: 1,
      duration: 1000,
    }).start();
  }, []);

  return (
    <Animated.View
      style={{
        opacity: fadeAnim,
      }}
    >
      {props.children}
    </Animated.View>
  );

Above code would be for fading in. Fading out would be done in the return function of the useEffect.

A: I think that the best way to do this is using Reanimated.
import Animated, { FadeIn, FadeOut } from    'react-native-reanimated';

<Animated.View
            key={'uniqueKey'}
            entering={FadeIn.duration(400)}
            exiting={FadeOut.duration(400)}
        />

Extra tip: If you want to retrigger the animation you could just change the component key prop ;)

A: Building off of @Benjamin Godlove's answer, here's a fully working fade in/out example.
I found that trying to fade out because of a useEffect return statement wouldn't work (I believe the component unmounts and unrenders before the animation has time to run), so instead I keep the component mounted and just effect opacity/visibility with a toggle.
type Props = {
  children: React.ReactNode;
  visible: boolean;
};

function FadePanel({children, visible}:Props){
  const fadeAnim = useRef(new Animated.Value(0)).current;
  React.useEffect(() => {
    if (visible) {
      Animated.timing(fadeAnim, {
        toValue: 1,
        duration: 1000,
        useNativeDriver: true,
      }).start();
    } else if (!visible) {
      Animated.timing(fadeAnim, {
        toValue: 0,
        duration: 1000,
        useNativeDriver: true,
      }).start();
    }
  }, [visible]);
  return (
    <Animated.View
      style={{
        opacity:fadeAnim
      }}
    >
      {children}
    </Animated.View>
  )
}

A: You can also use a library named react-native-fadeview-wrapper and you can easily cover all fade animations and it's also customizable.
<FadeView visible={isVisible}>
    {/** any components of yours */}
</FadeView>


text:
Q: AS3 collision dectection mouse movement I am making a game which uses collision detection with the mouse.
The player is a custom mouse cursor when the mouse collies with an object the mouse is moved to the coordinates X0,Y0. The code I have used to achieve this is below. However when the mouse is moved to X0,Y0 after a collision when the mouse is moved it starts back where the collision took place rather than moving from the top of the screen.
import flash.events.Event;

var cursor:MovieClip;

function initializeMovie ():void {

cursor = new Cursor();
addChild (cursor);
cursor.enabled = false;
Mouse.hide ();
stage.addEventListener (MouseEvent.MOUSE_MOVE, dragCursor);
}

function dragCursor (event:MouseEvent):void{

cursor.x = this.mouseX;
cursor.y = this.mouseY;
}

initializeMovie ();

this.addEventListener( Event.ENTER_FRAME, handleCollision)

function handleCollision( e:Event ):void{

if(cursor.hitTestObject( wall )){
cursor.x = 0
cursor.y = 0
     }

}

A: When you reset the position of cursor object you aren't moving the actual mouse position, I don't believe you can actual do what you're trying to (that is write to the mouse position to move the users cursor, I believe this would require system specific code, like C# or I believe Objective C and Cocoa or Carbon on the Mac side).
http://www.kirupa.com/forum/showthread.php?354641-Possible-to-set-mouse-position-in-flash
Here's a way you would do it on Mac apparently
https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html#//apple_ref/c/func/CGWarpMouseCursorPosition
And a way on Windows
Set Mouseposition in WPF
And a way on Linux (Although this only has AIR support up to 2.6)
How to set the mouse position under X11 (linux desktop)?
So if you implemented both of those solutions and are packaging as an AIR app you could make this work, but otherwise I'm pretty sure it's impossible.

A: Create a button at the 0, 0 coord that is required to click to continue again. Then your user will have to move the mouse to to that spot where you can continue to have the custom cursor track your mouse.


text:
Q: How many cyclic permutations can be shaped by two sets of 3 different points Let's say we have a set $M=\{v_{a}, v_{b}, v_{c}\}$ of three different points and another set $N=\{u_{x}, u_{y}, u_{z}\}$ of three different points. Let's also assume that a cyclic permutation $C_6$ (circle with 6 points) can be created by those points with the restriction that consecutive points must belong to different sets.
For example:$$C_6' = \{v_{a},u_{x},v_{c},u_{y},v_{b},u_{z}\}$$
In other words an $m$ point must be succeded by an $n$ point and vice versa. Of course every point of the two sets can be used only once.
How do we prove mathematically that there can only be created 6 circles by the sets above?
Note: A cyclic permutation $C_6$ is defined by the order of the elements. That is to say, all permutations will be consisted of the same 6 points but the points will be ordered in a different way for every permutation.

A: I'll just call the two sets of points $a,b,c$ and $x,y,z$ which must alternate around the circle. Given any valid arrangement, you can rotate it so that $a$ is at clock position 12:00 and then, by flipping if necessary, have $b$ at 4:00 and $c$ at 8:00 (I interpret the problem as meaning all $12$ rotations and reflections of the hexagon are to be considered the same arrangement).
Now having placed $a,b,c$ in those positions, you can assign $x,y,z$ to 2:00, 6:00, and 10:00 arbitrarily, which gives $3! = 6$ ways to do it -- and each of these $6$ is a unique arrangement, even with all the symmetries.
That's it, for an intuitive argument. You could do a full Burnside's Lemma thing on this, but is unnecessary here, in my opinion.


text:
Q: How do I generate a PDF417 Barcode with Java4Less? For our standard PDF & Barcode generation, we have the Java4Less library (java4less-1.0rel.jar) so that our customers can print tickets sold to/by them. We use this library to create CODE128(C), Aztec, QR barcodes and so on.
Right now we're looking into PDF417 Barcodes; and while this library supports this generation, something isn't going right. Have a look at the following code from a small Netbeans project:
BarCode bc= new BarCode();
bc.setSize(400 , 200);
bc.barType = BarCode.PDF417;
bc.resolution=1;
bc.leftMarginCM= 50;
bc.topMarginCM= 50;
bc.checkCharacter =true;
bc.code = "THISISJUSTATESTTEXT";
bc.barColor = Color.black;
bc.backColor= Color.red;
bc.fontColor = Color.blue;
bc.textFont = new Font("Arial",Font.BOLD,14);
bc.X = 1;
bc.N = 3;

bc.paint(region);

ImageIO.write(img, "PNG", new File("barcode.png"));

This piece of code generates a .png image with the requested barcode-type. All barcodes are generated, except for the PDF417.
Here's an image that shows a CODE128 and a PDF417 generation:

As you can see, the CODE128 generates its barcode, but the PDF417 doesn't. The only thing changed in the code is the following:
bc.barType = BarCode.CODE128; --> bc.barType = BarCode.PDF417;

I've looked up the documentation, examples; I even downloaded the demo from the official Java4Less website, and in a war/Java project, it generates a PDF417 normally.
So what is going wrong here? Is it a bug in the library that anyone knows of, or am I missing a step?

A: It would seem that our current library, despite claiming to support PDF417 creation, was outdated. When using the demo's library I managed to succesfully create a PDF417 barcode with the previousley mentioned code.


text:
Q: Efficient Access to Large Arrays in Documents I'm currently working on a web app using node.js, mongodb and mongoose. The logical structure of the model that I'm dealing with is a collection of documents where each document contains an array of subdocuments. Hence, the straightforward mongoose schema would look something like:
{
    "key": {type: String, index: {unique: true, dropDups: true}},
    // further document properties
    "subdocuments": [subschema]
}

However, I suspect that it is not a good idea to design the model this way, for the following reason: The arrays can grow potentially large. Also, the queries that I need to perform on a regular basis are of the following kind:

*

*Find all subdocuments in a specific range of a document A. (e.g., A.subdocuments.0 .. A.subdocuments.10).

*Find the document in the array with the highest index.

Does someone have a suggestion how to remodel this?


text:
Q: Head keeps getting the same value as tail pointer in singly linked list I'm trying to create a singly linked list with nodes containing two parameters.  Whenever I enqueue another node using the tail pointer, the head pointer takes the same value as the new node.
I'm sure the pointers are pointing to the same memory location or something similar, but I'm not sure how to fix this.
struct node
{
    struct process *p;
    struct node *next;
}

struct node* head;
struct node* tail;

void enqueue(struct process* newProcess)
{
    struct node *newNode = malloc(sizeof(struct node));
    newNode->p = malloc(sizeof(struct process));
    newNode->p = newProcess);

    if(tail==NULL)
    {
        head = tail = newNode;
        return;
    }

    tail = tail->next;
    tail = newNode;
}

I'd like to use this function to be able to create a singly linked list with the head node pointing to the first element in the list and the tail node pointing to the last element in the list.  The current code results in both variables representing the last element added.

A: Setting tail = tail->next is setting tail to null because it isn't set the first time around, and then both tail and head are immediately overwritten in the subsequent call.

A: There are some issues here. First, to fix your problem, replace the two last lines with:
tail = tail->next = newNode;

Also, consider this:
tail = tail->next;
tail = newNode;

What is the point of assigning a variable to a value if you reassign the same variable in the next statement? You have the same error earlier on too:
newNode->p = malloc(sizeof(struct process));
newNode->p = newProcess;

Because of the second line, the only thing you achieve with the first line is a memory leak. Remove the first line completely.


text:
Q: Can feature content be configured in lightning experience In SFDC Classic,I'm able to select content/files to "feature" and they appear in a featured section under libraries
I cannot find the same featured content files list in lightning experience.
Can any one of you please confirm , whether this can be configured in lightning experience or not .
FYR , I'm attaching the "featured content" list which is displayed in salesforce classic.

A: Based on what I have read from the release notes and online documentation, this feature does not seem available in lightning experience, as it falls under the category of Managing Libraries which the release notes state as Not Available in LEX:

Features Not Available in Lightning Experience

*

*Documents

*Salesforce CRM Content, including creating and managing libraries,    content deliveries, and sharing files with libraries

*File sharing with people and groups (except by posting to feeds)

*File syncing

*Freeze sharing (a new feature available only in Salesforce Classic in    the Winter '16 release)


text:
Q: Magento 2.4 Custom Filter on product collection, wrong collection size I created a custom filter to filter products on category pages and in search.
Filter itself seems to be correct (two products are visible from origin twelve) but pagination is wrong (total size is still 12 and link to 2nd page is rendered) (see 1st screenshot: ).
This filter is also not taken into account when list of other filters is rendered (see 2nd screeshot: there is still 12 products calculate instead of 2).
Filter itself is rather simple:
public function apply(\Magento\Framework\App\RequestInterface $request)
{
    $filter = $request->getParam($this->getRequestVar());
    if (!$filter) {
        return $this;
    }

    $collection = $this->getLayer()->getProductCollection();
    $customCollection = $this->collectionFactory->create();
    $customCollection->addFieldToFilter('value', $filter);
    $customIds = $customCollection->getColumnValues('entity_id');

    $collection->addAttributeToFilter([['attribute' => 'available_custom_ids',['in' => $customIds]],['attribute' =>'available_custom_ids',['null'=>true]]], null, 'left');
    $this->getLayer()->getState()->addFilter($this->_createItem($filter, $filter));
    return $this;
}

I injected this filter to the \Magento\Catalog\Model\Layer\FilterList with:
     public function aroundGetFilters(
    \Magento\Catalog\Model\Layer\FilterList $subject,
    \Closure $proceed,
    \Magento\Catalog\Model\Layer $layer
) {
    $result = $proceed($layer);
    $result[] = $this->_objectManager->create(
        \Vendor\Module\Model\Layer\Filter\ExampleFilter::class,
        ['layer' => $layer]
    );

    return $result;
  }

What I'm doing wrong? It seems Magento is using two different collections on the same page, but I'm totally lost which is which (and why).
Side note: I used custom filter instead of simple make "available_custom_ids" filterable because I wanted to include also products with available_custom_ids == NULL to the results. Is it correct approach?


text:
Q: How do I get rid of white dots appearing next to my Navbar links in a bootstrap template? I am currently using this template from ShareBootstrap. So far it is working perfectly fine, except for this one bug: White dots labeled as li.nav-tem::marker are appearing about an inch to the left of each Navbar link.
Information about my issue:

*

*I have checked the code for anything mentioning nav-item, marker, or any other combination of the terms.

*There is no mention of a marker in the HTML.

*It appears in every HTML page containing the navbar.
I have not edited the CSS.

*This appeared after adding a new navbar link, but I changed no other related code when I made the change.

*Other than the added link, the HTML navbar code looks identical.

*When I remove the new link I added, the problem persists.

Here is a github repository with my current code in it.
https://github.com/dritchkid/portfolio
Note: I am aware that I don't have the repository set up with pages. I'm currently just testing on my computer for now.
Image of the white dots in question.
Where are these dots coming from? Please help!

A: You can remove the dots by setting the list style on the navbar-nav class, which is on the ul.
.navbar-nav {
  list-style: none;
}


text:
Q: Can I have IIS and NodeJS on same windows 7 machine I want to experiment with NodeJS.   My windows 7 machine already have IIS ruuning for intranet purpose.    I simply want nodejs to run on own listening to a different port.   Is there an side effect to this setup that I need to know about?   All my search on the web seem to be about running nodejs from with iis.   I am simply looking for running nodejs on own; hoping there is a way to set a different port number when I install it.
Thank for the help
Mike

A: You don't set up a port number when installing Node.js. Node does not use a port at all, as long as you do not tell it to use one, e.g. for an HTTP or a TCP server. Which port is used then depends on what you do programmatically with Node.js, e.g.:
'use strict';

var http = require('http');

http.createServer(function (req, res) {
  // Do something with request and response
}).listen(3000);

The last call (the one to the listen function) tells Node.js to use port 3000, but you can use an arbitrary port here.
So, to cut a long story short: No, there won't be any problems, as long as you do not try to use a port within Node.js that is already being used by IIS.
Another option is to set up Node.js so that it runs in context of IIS, then of course you do not have any problems, too, but if I got your question correctly, you do not want to do that, but want to run Node.js separately.

A: *

*IIS is a HTTP server (as Apache)

*node.js is a language interpreter (as Python, Perl ...)

So you can have IIS and NodeJS on same machine.
node.js allow you to write WEB application without the need of a separate HTTP server. You don't choose a port when you install nodejs. Each node.js application include it's own HTTP server and can choose what port it want listen. You must just take care not having IIS and a node application listening at the same port.


text:
Q: Can I Remove Generic Kernel After Installing Ubuntu Studio Wrapper Over Kubuntu? I have seen posts online about removing the generic kernel and using only the low-latency one, but this question has a bit of a twist (I think). I'd like some input if anyone has any.
I recently installed the latest Ubuntu Studio LTS, which uses the low-latency kernel. I'm not sure I'm crazy about Ubuntu and might like to switch to what I was using before, which was Kubuntu with the Ubuntu Studio wrapper installed over it. However, with that setup, I end up with the generic kernel that Kubuntu comes with, as well as the low-latency one that the Ubuntu Studio wrapper adds.
I never boot into the generic kernel and not only does it take up space on my hard drive, it also adds clutter to the Grub menu. So my question is: After installing the Ubuntu Studio wrapper over Kubuntu, can I then delete the generic kernel it originally came with AND stop it being re-added/updated? If so, how would I best go about doing that?
(The version of Kubuntu I would be installing would be 22.04, if that helps with an answer. Ubuntu Studio installer I would be adding to it doesn't have a version number listed on the website, but it just adds the low-latency kernel, various software, and probably some dependencies.)

A: If you only use the realtime kernel, then it should be safe to remove other kernels, including the generic branch.
You can view installed kernels with this command:
dpkg --list *linux-image* | grep "ii"

By default, Ubuntu keep the 2 latest kernels of the active branch. You can remove the others, and install them at a later time should you need them again.


text:
Q: Get entry/node from LinkedList fastest From LinkedList.java I found this method for getting a an entry.
/**
 * Returns the indexed entry.
 */
private Entry<E> entry(int index) {
    if (index < 0 || index >= size)
        throw new IndexOutOfBoundsException("Index: "+index+
                                            ", Size: "+size);
    Entry<E> e = header;
    if (index < (size >> 1)) {
        for (int i = 0; i <= index; i++)
            e = e.next;
    } else {
        for (int i = size; i > index; i--)
            e = e.previous;
    }
    return e;
}

What bugs me is:
    if (index < (size >> 1))

Why do a bit shift operation here? Would not something like this be the optimal?
if (index < (size / 2)) {
    for (int i = 0; i <= index; i++)
        e = e.next;
} else {
    for (int i = size; i > index; i--)
        e = e.previous;
}

Since
if (index < (size / 2))

would promise our requested index are in the first half of the list.

A: There is no reason to do a bit shift right by one in the code example: dividing by two will have the same performance, and perhaps better readability than that of a bit shift. This micro-optimization was very common in the old days of C, but now every optimizer worth its salt would do this replacement for you.

A: Actually no. Shift operation if very fast at hardware level. It's like connecting wires (bits) and discarting the shifted ones. This only works for integer operations and "for base 2 divisions" so be aware.


text:
Q: In Jenkins TestNG Results, Fail test case link, opens with an error message TestNG: version 6.10,**Java:8,Test Cases Count:Total Tests: 743, Failed Tests: 19
Scenario:
1. API Test cases are written in Java + Rest assured + TestNG + Maven framework.
2. Running test cases with jenkin.
3.In Post-build action, have added, publish testng report.
Expecting Result: In testng failed test cases list, when I click on any fail test cases, it should navigate to failure exception page and show me the failure reason.
Note: I am not able to log this bug in jenkin site as I am not having the expected permission.
Actual Output: A problem occurred while processing the request.
Stack trace

org.apache.commons.jelly.JellyTagException: jar:file:/var/cache/jenkins/war/WEB-INF/lib/jenkins-core-2.89.4.jar!/lib/layout/layout.jelly:267:25:  org.apache.commons.jelly.JellyTagException: jar:file:/var/cache/jenkins/war/WEB-INF/lib/jenkins-core-2.89.4.jar!/lib/layout/main-panel.jelly:36:21:  org.apache.commons.jelly.JellyTagException: Cannot get property 'escapeTestDescp' on null object
      at org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:726)
      at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:281)
      at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
      at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
      at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
      at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
      at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
      at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:120)
      at org.kohsuke.stapler.jelly.groovy.JellyBuilder.doInvokeMethod(JellyBuilder.java:276)
      at org.kohsuke.stapler.jelly.groovy.Namespace$ProxyImpl.invoke(Namespace.java:92)
      at com.sun.proxy.$Proxy96.layout(Unknown Source)
      at lib.LayoutTagLib$layout$0.call(Unknown Source)
      at hudson.plugins.testng.results.MethodResult.index.run(index.groovy:8)
      at org.kohsuke.stapler.jelly.groovy.GroovierJellyScript.run(GroovierJellyScript.java:74)
      at org.kohsuke.stapler.jelly.groovy.GroovierJellyScript.run(GroovierJellyScript.java:62)
      at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:63)
      at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:53)
      at org.kohsuke.stapler.jelly.JellyClassTearOff.serveIndexJelly(JellyClassTearOff.java:112)
      at org.kohsuke.stapler.jelly.JellyFacet.handleIndexRequest(JellyFacet.java:140)
      at org.kohsuke.stapler.IndexViewDispatcher.dispatch(IndexViewDispatcher.java:30)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:248)
      at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
      at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
      at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
      at com.smartcodeltd.jenkinsci.plugin.assetbundler.filters.LessCSS.doFilter(LessCSS.java:47)
      at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
      at hudson.plugins.greenballs.GreenBallFilter.doFilter(GreenBallFilter.java:59)
      at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
      at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:237)
      at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:214)
      at net.bull.javamelody.PluginMonitoringFilter.doFilter(PluginMonitoringFilter.java:88)
      at org.jvnet.hudson.plugins.monitoring.HudsonMonitoringFilter.doFilter(HudsonMonitoringFilter.java:114)
      at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
      at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
      at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:64)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
      at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
      at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
      at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
      at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
      at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
      at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
      at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
      at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
      at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
      at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
      at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
      at org.eclipse.jetty.server.Server.handle(Server.java:564)
      at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
      at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
      at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
      at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
      at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:278)
      at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:148)
      at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
      at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
      at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
      at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
      at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
      at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
      at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: java.lang.RuntimeException: org.apache.commons.jelly.JellyTagException: jar:file:/var/cache/jenkins/war/WEB-INF/lib/jenkins-core-2.89.4.jar!/lib/layout/main-panel.jelly:36:21:  org.apache.commons.jelly.JellyTagException: Cannot get property 'escapeTestDescp' on null object
      at org.kohsuke.stapler.jelly.groovy.JellyBuilder.doInvokeMethod(JellyBuilder.java:280)
      at org.kohsuke.stapler.jelly.groovy.Namespace$ProxyImpl.invoke(Namespace.java:92)
      at com.sun.proxy.$Proxy96.main_panel(Unknown Source)
      at lib.LayoutTagLib$main_panel$1.call(Unknown Source)
      at hudson.plugins.testng.results.MethodResult.index$_run_closure1.doCall(index.groovy:10)
      at hudson.plugins.testng.results.MethodResult.index$_run_closure1.doCall(index.groovy)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at groovy.lang.Closure.call(Closure.java:414)
      at groovy.lang.Closure.call(Closure.java:408)
      at org.kohsuke.stapler.jelly.groovy.JellyBuilder$1.run(JellyBuilder.java:264)
      at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:99)
      at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
      at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
      ... 120 more
  Caused by: org.apache.commons.jelly.JellyTagException: jar:file:/var/cache/jenkins/war/WEB-INF/lib/jenkins-core-2.89.4.jar!/lib/layout/main-panel.jelly:36:21:  org.apache.commons.jelly.JellyTagException: Cannot get property 'escapeTestDescp' on null object
      at org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:726)
      at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:281)
      at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      at org.apache.commons.jelly.tags.core.CoreTagLibrary$1.run(CoreTagLibrary.java:98)
      at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
      at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:120)
      at org.kohsuke.stapler.jelly.groovy.JellyBuilder.doInvokeMethod(JellyBuilder.java:276)
      ... 139 more
  Caused by: java.lang.RuntimeException: org.apache.commons.jelly.JellyTagException: Cannot get property 'escapeTestDescp' on null object
      at org.kohsuke.stapler.jelly.groovy.JellyBuilder.doInvokeMethod(JellyBuilder.java:280)
      at org.kohsuke.stapler.jelly.groovy.Namespace.invokeMethod(Namespace.java:56)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      at hudson.plugins.testng.results.MethodResult.index$_run_closure1$_closure2.doCall(index.groovy:11)
      at hudson.plugins.testng.results.MethodResult.index$_run_closure1$_closure2.doCall(index.groovy)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at groovy.lang.Closure.call(Closure.java:414)
      at groovy.lang.Closure.call(Closure.java:408)
      at org.kohsuke.stapler.jelly.groovy.JellyBuilder$1.run(JellyBuilder.java:264)
      at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:99)
      at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
      at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
      ... 145 more
  Caused by: org.apache.commons.jelly.JellyTagException: Cannot get property 'escapeTestDescp' on null object
      at org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:726)
      at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:281)
      at org.kohsuke.stapler.jelly.groovy.JellyBuilder.doInvokeMethod(JellyBuilder.java:276)
      ... 164 more
  Caused by: java.lang.NullPointerException: Cannot get property 'escapeTestDescp' on null object
      at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60)
      at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174)
      at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:47)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296)
      at hudson.plugins.testng.results.MethodResult.reportDetail$_run_closure1$_closure4.doCall(reportDetail.groovy:30)
      at hudson.plugins.testng.results.MethodResult.reportDetail$_run_closure1$_closure4.doCall(reportDetail.groovy)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at groovy.lang.Closure.call(Closure.java:414)
      at groovy.lang.Closure.call(Closure.java:408)
      at org.kohsuke.stapler.jelly.groovy.JellyBuilder.doInvokeMethod(JellyBuilder.java:296)
      at org.kohsuke.stapler.jelly.groovy.JellyBuilder.methodMissing(JellyBuilder.java:173)
      at sun.reflect.GeneratedMethodAccessor31961.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:939)
      at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1262)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1215)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
      at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
      at org.kohsuke.stapler.jelly.groovy.GroovyClosureScript.invokeMethod(GroovyClosureScript.java:87)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:430)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:369)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
      at hudson.plugins.testng.results.MethodResult.reportDetail$_run_closure1.doCall(reportDetail.groovy:26)
      at hudson.plugins.testng.results.MethodResult.reportDetail$_run_closure1.doCall(reportDetail.groovy)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at groovy.lang.Closure.call(Closure.java:414)
      at groovy.lang.Closure.call(Closure.java:408)
      at org.kohsuke.stapler.jelly.groovy.JellyBuilder.doInvokeMethod(JellyBuilder.java:296)
      at org.kohsuke.stapler.jelly.groovy.JellyBuilder.methodMissing(JellyBuilder.java:173)
      at sun.reflect.GeneratedMethodAccessor31961.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:939)
      at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1262)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1215)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
      at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
      at org.kohsuke.stapler.jelly.groovy.GroovyClosureScript.invokeMethod(GroovyClosureScript.java:87)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:75)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
      at hudson.plugins.testng.results.MethodResult.reportDetail.run(reportDetail.groovy:14)
      at org.kohsuke.stapler.jelly.groovy.GroovierJellyScript.run(GroovierJellyScript.java:74)
      at org.kohsuke.stapler.jelly.groovy.GroovierJellyScript.run(GroovierJellyScript.java:62)
      at org.kohsuke.stapler.jelly.IncludeTag.doTag(IncludeTag.java:147)
      at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
      ... 165 more
  Caused: java.lang.RuntimeException
      at org.kohsuke.stapler.jelly.groovy.JellyBuilder.doInvokeMethod(JellyBuilder.java:280)
      at org.kohsuke.stapler.jelly.groovy.Namespace$ProxyImpl.invoke(Namespace.java:92)
      at com.sun.proxy.$Proxy96.layout(Unknown Source)
      at lib.LayoutTagLib$layout$0.call(Unknown Source)
      at hudson.plugins.testng.results.MethodResult.index.run(index.groovy:8)
      at org.kohsuke.stapler.jelly.groovy.GroovierJellyScript.run(GroovierJellyScript.java:74)
      at org.kohsuke.stapler.jelly.groovy.GroovierJellyScript.run(GroovierJellyScript.java:62)
      at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:63)
      at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:53)
      at org.kohsuke.stapler.jelly.JellyClassTearOff.serveIndexJelly(JellyClassTearOff.java:112)
      at org.kohsuke.stapler.jelly.JellyFacet.handleIndexRequest(JellyFacet.java:140)
      at org.kohsuke.stapler.IndexViewDispatcher.dispatch(IndexViewDispatcher.java:30)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:374)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:248)
      at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
      at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
      at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
      at com.smartcodeltd.jenkinsci.plugin.assetbundler.filters.LessCSS.doFilter(LessCSS.java:47)
      at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
      at hudson.plugins.greenballs.GreenBallFilter.doFilter(GreenBallFilter.java:59)
      at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
      at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:237)
      at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:214)
      at net.bull.javamelody.PluginMonitoringFilter.doFilter(PluginMonitoringFilter.java:88)
      at org.jvnet.hudson.plugins.monitoring.HudsonMonitoringFilter.doFilter(HudsonMonitoringFilter.java:114)
      at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
      at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
      at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:64)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
      at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
      at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
      at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
      at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
      at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
      at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
      at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
      at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
      at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
      at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
      at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
      at org.eclipse.jetty.server.Server.handle(Server.java:564)
      at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
      at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
      at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
      at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
      at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:278)
      at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:148)
      at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
      at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
      at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
      at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
      at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
      at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
      at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:748)

A:
org.apache.commons.jelly.JellyTagException: Cannot get property
  'escapeTestDescp' on null object

At some reason escapeTestDescp is null and that why the system fails while trying to get this property
It can be also a Jenkins bug. Here you can post your issue or search for similar issues.


text:
Q: onclick innerhtml does not work - not common issue What could be potentially wrong with the following simple code:

XXXXXX Show it!

The problem exists for few users, but I do not have physical access to the machines to debug it. When they click on it nothing happens.
I cannot replicate it, it works fine everywhere where I have physical access (even tried BrowserStack) and I'm running out of ideas.
Yes, they have JS up and running.
Different users, different browsers.
Asked them to try on JSFiddle as well - same issue.
Buggy version of web browser? Other software/addon blocks it?
Any ideas? Anybody had or have the same issue?
Thx in advance.


text:
Q: No changes in DropDownList Goal:
The user should not make any changes in the text field in Combobox.
Problem:
I don't want the user to make any changes in the text field. I want the user to make a selection in the DropDownList without any text changes. The same concept will be as ListBox.

A: Change the DropDownStyle property to ComboBoxStyle.DropDownList

A: Change your DropDownStyle property to "DropDownList" for your ComboBox.


text:
Q: Javascript covering both string true and boolean true I have the following
$scope.user.infowindow.enable = ($scope.user.infowindow.enable=="true") ? true : false;

This checks if $scope.user.infowindow.enable is "true" and if it is then turns it to true else false
Sometimes $scope.user.infowindow.enable can be true and not a string, what would be the best what to write that into this script so that in the end $scope.user.infowindow.enable will be set as either true or false checking to see if its a string or not.
Thanks

A: Use or '||' statement
 $scope.user.infowindow.enable = ($scope.user.infowindow.enable==="true" || $scope.user.infowindow.enable===true) ? true : false;

A: Or use "===", an explicitely treat different cases :
$scope.user.infowindow.enable =
   ($scope.user.infowindow.enable === "true" ||
    $scope.user.infowindow.enable === true) ? true : false;

Though I would rather understand why a single value can "sometimes" be a String, and "sometimes" be a boolean. That's probably your real issue here...

A: You may try this:
$scope.user.infowindow.enable = (true === $scope.user.infowindow.enable || 'true' === $scope.user.infowindow.enable);


text:
Q: Can`t load jQuery library I'm trying to load jQuery library following videos but it does not work. When I'm trying to load some jQuery function, it writes that jquery is not defined. I also tried CDN.
        <title>
            GRID
        </title>
        <link rel="stylesheet" href="grid.css">
        <link href="https://fonts.googleapis.com/css?
                family=Ubuntu&display=swap" rel="stylesheet">
        <script src="jquery-2.1.1.min.js"></script>
        <script src="script.js"></script>
    </head>```

A: You need to put jquery-2.1.1.min.js file into same location where your quoted file is if we are talking about local purposes.
If your prefer to download it each time, you can use for example Google Hosted Libraries in following way:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

A: Like so <script src="jquery-2.1.1.min.js"></script>, jquery have to be in the root of your domain, like your script.js.
If you want CDN, use:
<script rel="prefetch" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js></script>

Or official jQuery CDN:
<script
  rel="prefetch"
  src="https://code.jquery.com/jquery-2.1.1.min.js"
  integrity="sha256-h0cGsrExGgcZtSZ/fRz4AwV+Nn6Urh/3v3jFRQ0w9dQ="
  crossorigin="anonymous">
</script>


text:
Q: Matplotlib multiple colorbars I need four different color bars for a single plot. My plot consists of 5 subplots, but only the first one requires four different color bar plots. I would like to position them below a graph. I achieved it, but my color bars are of different sizes:

For your reference, my figure is split into 5 figures using the matplotlib subplot2grid method. A minimal working example (without subplot2grid) is shown below:
import matplotlib.pyplot as plt
import numpy as np

frame = np.zeros([512, 512])

fig = plt.figure(figsize=(16, 8))
ax = plt.imshow(frame)

for i in range(4):
    plt.colorbar(fraction=0.046, pad=0.04, location="bottom")

plt.show()

How do I position the color bar plots below the plot and them next to each other and of the same length (e.g. the same length as the first bar plot, or image size)?


text:
Q: Google Area Charts - Select all data sets for date - Combined Tooltip I'm trying to replicate the behaviour of Google Analytics Charts in my own app using the Google Charts Api.
In Google Analytics whenever i'm hovering over a date both data sets are selecting and i get a combined tooltip of both values for that date.
Can't find anything in the docs here: https://developers.google.com/chart/interactive/docs/gallery/linechart ... and nothing on Google also.
LE: as i figured out the GA charts are Area Charts and not line charts:
Checked: https://developers.google.com/chart/interactive/docs/gallery/areachart but still can't find a way to mimic the behavior of GA charts ...

A: For those who are looking for this, the answer is the focusTarget property:
focusTarget: 'category'


text:
Q: Shell Syntax: How to correctly use \ to break lines? I used to believe that  the appropriate way of breaking the lines in a list is
command1 && \
command2

It turned out that it isn't so , one doesn't need \
$ [  $(id -u) -eq 1000  ] &&
> echo yes
yes

The same works with pipes | the same way.
The bash man page sections on pipelining and lists didn't shed any light on this.  Thus , my question is : what is the proper usage of \ to break long lines ?

A: One of the scripting style guidelines I've encountered during my professional life at a huge IT company, obligated me to use no longer than 80 characters per line in a shellscript and indenting after breaking the line. Also, I had to break line before a pipe or && or ||. Like :
command1 \
  && command2 \
  || command3 \
  | command4

The goal was to have a clear readability.

A: If the statement would be correct without continuation, you need to use \. Therefore, the following works without a backslash, as you can't end a command with a &&:
echo 1 &&
echo 2

Here, you need the backslash:
echo 1 2 3 \
4

or
echo 1 \
&& echo 2

Otherwise, bash would execute the command right after processing the first line without waiting for the next one.


text:
Q: Nested components in re-frame not updating I'm building a single-page app using re-frame. Each "page" of the app calls a component base-page then supplies its page-specific children...
(defn base-page [& children]
  (into [:div
         ; banner goes here
        ] children))

(register-sub :count
  (fn [db _] (reaction (:count @db))))

(register-handler :inc
  (fn [db _] (update db :count inc)))

(defn test-page []
  (let [count (subscribe [:count])]
    (fn []
      [base-page
       [:h2 "Test Page"]
       [:p (str "Count: " @count)]])))

This renders the page correctly with the initial value for :count, and when I run (dispatch [:inc]) the page updates correctly.
Now I'd like base-page to be a form-2 component so it can have it's own subscriptions...
(defn base-page [& children]
  (let [user (subscribe [:current-user])]
    (fn []
    (into [:div
           ; banner goes here, including @user
          ] children))

However, when I do this, the count on test-page no longer updates when I run (dispatch [:inc]). I find this surprising, because I thought Reagent packages form-1 and form-2 components into form-3 components behind the scenes.
Is this expected behaviour? If so, is there a better way to implement my base page/concrete page model?

A: Isn't it a rule in the re-frame Reagent documentation (*) that for Form-2 components the outer function and the inner function must have the same arguments?
Check out the second 'rookie mistake' on this page
(*) re-frame depends on Reagent. The documentation about Form-1/2/3 components applies equally to using Reagent on its own or from one of the other frameworks/libraries that sit on top of Reagent.

A: As Chris Murphy pointed out, the problem was that I wasn't passing the outer arguments to my inner function. This definition of base-page works fine:
(defn base-page [& children]
  (let [user (subscribe [:current-user])]
    (fn [& children]
    (into [:div
           ; banner goes here, including @user
          ] children))


text:
Q: Should I turn my SQLite class into a singleton? I'm in the middle of creating an Android application with multiple tables inside of my database. The database is going to be constantly accessed, but with that said I've stumbled upon the idea of a singleton from http://www.javaworld.com/javaworld/jw-04-2003/jw-0425-designpatterns.html
Would it be advised to try to make a database a singleton so that I never have conflicts?
EDIT: In response to the first comment. I have an SQLiteOpenHelper class that I believe I can structure into a singleton.

A: It depends on your application and design. You can make a class singleton if it only creates a database.
But if you make singleton a class which executes query, you have to make sure that it doesn't gets called while the first query is executing. So a locking mechanism or queuing will be required then.