text:
Q: datarating system based on gridview data What I want to do is basically have a column that ranks the users so if there were 10 people it would rank the person with the highest sales 10 and the second highest 9 and so on. Theres not always going to be 10 employees
I am using a stored procedure along with a sqldatasource to connect to my stored procedure.
To get all the data for each agent, then I am using functions like
 Dim TotalSales As Decimal = 0.0
    Function GetTotalSales(ByVal Price As Decimal) As Decimal
        TotalSales += Price
        Return Price
    End Function
    Function GetTotal() As Decimal
        Return TotalSales
    End Function

    Dim TotalCalls As Decimal = 0.0
    Function GetCalls(ByVal calls As Decimal) As Decimal
        TotalCalls += calls
        Return calls
    End Function
    Function GetTotalCalls() As Decimal
        Return TotalCalls
    End Function

to get running totals
could i do something like
Dim salesrank As Decimal = 0.0
    Function Getsalesrank(ByVal salestorank As Decimal) As Decimal
        Dim rank As New ArrayList
        rank.Add(salestorank)

    End Function

and then some how sort the array list and print the index of the agents sales total?

A: Since you're using .Net 2.0 and apparently not adverse to using the built-in classes to accomplish data calls, I would recommend you switch from using the SQLDataSource to a strongly typed DataSet (.xsd file). You can create a typed DataTable and TableAdapter that will perform your initial queries and produce collection objects (tables) that can hold the data you need while you do other things to it. Once you have your dataset created you can call it simply by:
Dim connectionObject as System.Data.SqlClient.SqlConnection = _
    New System.Data.SqlClient.SqlConnection("Put your string here")

Dim myAdapter as MyStronglyTypedTableAdapter
Dim myTable as MyStronglyTypedTable

myAdapter.Connection = connectionObject
myTable = myAdapter.GetData()

If you create your DataTable so that it holds an empty column called TotalSales (I'm assuming the data table is holding data indexed by users), you can populate that column using your total sales method. Once you have the table organized by user you can use the table's DefaultView to sort and bind to your GridView:
Dim myView as DataView = myTable.DefaultView
myView.Sort = "TotalSales ASC"
myGridView.DataSource = myView
myGridView.DataBind()

When this is done you can manipulate one of the columns of your GridView to display the numeric ranking. This would be done in the RowDataBound event.


text:
Q: SEO in ReactJS when used with Django React uses Node server to handle server side rendering. So, when crawler requests a URL, Django server requests Node server which calls React.renderToString and generates HTML. The HTML is sent to Django which sends it to the crawler. Isn't there a performance issue in this as I'm calling Node and requesting for data and then sending it to the crawler?
Won't there be a performance penalty compared to rendering it directly in Django and sending?
SEO is critical in my application, but I also want to use client side rendering. What should be the best trade-off?

A: I'm not sure what the performance penalty would be and whether or not it would be worth building a public facing site as an SPA. I would keep that for admin and areas where users have to log in, not in public pages where I want Google and other crawlers to index the pages. Even if you did use React and Node to generate that page, the subsequent pages after would be all ajax and the html that was generated would never change, I find that to be useless IMO.
To summarize, keep your public site in Django and the admin site React, that would yield the best results and get you that SEO pages you want.
EDIT 2022
My answer was from many years ago and needs an update. If you're going the React route you should consider NextJS or Remix; both handle the SSR (server side rendering) to generate the HTML so that crawlers could index your content and so you can cover your SEO needs.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Latex table missing number error I am trying to make a table in the same format as above in Miktex yet I keep getting errors such as missing number treated as zero. The table should have some empty blocks I do not know if that is causing the problem.
\begin{align}
\begin{tabular}{ |p{3cm}||p{3cm}|p{3cm}|p{3cm}|p{3cm}|p{3cm}|p{3cm}|  }
 \hline
Test was&  &1 & 2 & 3 & ... & N\\
 \hline
 \multirow{2}{performed} & a_i & + & + $ -  & ... & +\\
 & b_i & +  & - & -  & ...$ + \\
\hline
 \multirow{2}{not performed} & a'_i & ? & ? & ? $ ... & ?\\
 & b'_i & ? & ? & ? $ ... & ?\\
 \hline
\end{tabular}
\end{align}

A: I guess the following is at least somewhat close to the expected output:

\documentclass{article}
\usepackage{multirow,array}
\begin{document}

\begin{tabular}{|l||>{$}c<{$}|c|c|c|c|c|} \hline
Test was                       &      & 1 & 2 & 3 & ... & N \\ \hline
\multirow{2}{*}{performed}     & a_i  & + & + & - & ... & + \\
                               & b_i  & + & - & - & ... & + \\ \hline
\multirow{2}{*}{not performed} & a'_i & ? & ? & ? & ... & ? \\
                               & b'_i & ? & ? & ? & ... & ? \\ \hline
\end{tabular}
\end{document}

A: With use of the array and w{c}{<width>} column type:
\documentclass{article}
\usepackage{array, multirow}

\begin{document}
    \[
\setlength\extrarowheight{2pt}
\begin{array}{ |p{7em}||*{6}{w{c}{2em}|} }
 \hline
Test was    &     & 1 & 2 & 3 & \dots & N   \\
 \hline
 \multirow{2}{=}{performed}
            & a_i & + & + & - & \dots & +   \\
            & b_i & + & - & - & \dots & +   \\
\hline
 \multirow{2}{=}{not performed}
            & a'_i & ? & ? & ? & \dots & ?  \\
            & b'_i & ? & ? & ? & \dots & ?  \\
 \hline
\end{array}
    \]
\end{document}


text:
Q: Is there a control to visualize mesh topology in c#? Does anyone know of a c# tool to visualize interconnected nodes (e.g. the call hierarchy in a class)? The sort of visualization I'm looking for is like that of the ANTS Memory Profiler when it's showing memory links if anyone is familiar with that tool?

A: Take a look at NDepend (http://www.ndepend.com/). In addition to computing various metrics for a code base, it can also visualize dependencies. A trial edition is available.
Here is a screenshot (on http://www.ndepend.com/Features.aspx#DependenciesView) that may be what you're looking for: http://www.ndepend.com/Res/DiagramBoxAndArrowGraphBig.jpg

A: To complete Matthew's answer on NDepend, have a look at these 2 articles concerning NDepend dependency graph and NDepend dependency matrix. Graph and Matrix work hands in hands.

*

*Dependency Graph : Graph is more intuitive but hard to understand when there are more than 30 nodes.

*Dependency Matrix : Matrix is less intuitive than Graph, but it scales, meaning, it can still be useful even with hundreds of nodes shown.

Here are 2 screenshots:

A: The tool that I've found is Graph# found at http://graphsharp.codeplex.com/. It seems to work brilliantly for plotting the kind of nodal interdependencies I'm after.
Apologies to those who I mislead with the ANTS reference. If it's any consolation, NDepend looks a seriously interesting tool.


text:
Q: How to repeat only one part of my sprites image as a background for div I need put one only one part of my sprites image as a div background but the result is this:

And I pretend this:

I need, use only one sprites image in my template (requirement from my boss). I need help for this.
My html:

My Css:
.background {width: 100%;
             height: 166px;
             background-size: 93px 166px;
             background: url('library/images/sprites.png') -150px 0px repeat-x;
            }

A: Unfortunately you're going to have to make a separate file if you want to repeat both x and y. If you wanted x or y, you could use the below to help guide you as answered here.

repeat-X: You would stack these vertically in your sprite sheet. You
  can only have one image per "row". All images must have the same
  width.
repeat-y: You would line the images horizontally and have only one
  image per "column". All images must have the same height.

It shouldn't hurt the load time too much!

A: You can only repeat the sprite in one direction.
To repeat the sprite horizontally you would need to edit the sprite so that the image you want to repeat is underneath the others with nothing else either side of it.
Then the code you provided should work (altering the position to suit).

A: http://cssspritegenerator.net is a good tool to help you with that, you choose either to repeat x or y and can do that for as many images you want.


text:
Q: Saving and using values tip calculator app I am creating a simple tip calculator to learn the basics of iOS development and I am having trouble saving values from one page and reusing it in another.
Currently, my root page(aka TipViewController.m):
#import "TipViewController.h"
#import "SettingsViewController.h"

@interface TipViewController ()

@property (weak, nonatomic) IBOutlet UITextField *billTextField;
@property (weak, nonatomic) IBOutlet UILabel *tipLabel;
@property (weak, nonatomic) IBOutlet UILabel *totalLabel;
@property (weak, nonatomic) IBOutlet UISegmentedControl *tipControl;

- (IBAction)onTap:(id)sender;
- (void)updateValues;
- (void)onSettingsButton;

@end

@implementation TipViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"Tip Calculator";
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self updateValues];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStylePlain target:self action:@selector(onSettingsButton)];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)onTap:(id)sender {
    [self.view endEditing:YES]; //keyboard goes away
    [self updateValues];
}

- (void)updateValues{
    float billAmount = [self.billTextField.text floatValue];

    // array to hold all tip values
    NSArray *tipValues = @[@(0.1), @(0.15), @(0.2)];
    float tipAmount = billAmount*[tipValues[self.tipControl.selectedSegmentIndex] floatValue];
    float totalAmount = tipAmount + billAmount;

    self.tipLabel.text = [NSString stringWithFormat:@"$%0.2f", tipAmount];
    self.totalLabel.text = [NSString stringWithFormat:@"$%0.2f", totalAmount];
}

- (void)onSettingsButton {
    [self.navigationController pushViewController:[[SettingsViewController alloc] init] animated:YES];
}

@end

When I tap the settings button on top right it will lead me to my settings page:
#import "SettingsViewController.h"

@interface SettingsViewController ()
@property (weak, nonatomic) IBOutlet UITextField *defaultTipPercentage;

- (IBAction)ontap:(id)sender;

@end

@implementation SettingsViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"Settings";
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)ontap:(id)sender {

    [self.view endEditing:YES];
}
@end

Right now I want the value placed inside the TextField to be the default tip percentage to be used when I go back to the root page.
I was thinking of putting this under ontap() to save the value(SettingsViewController.m):
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"some_string_to_save" forKey:@"some_key_that_you_choose"];
[defaults setInteger:123 forKey:@"another_key_that_you_choose"];
[defaults synchronize];

and create an if statement inside updateValues() in my TipViewController.m to load the default value.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *stringValue = [defaults objectForKey:@"some_key_that_you_choose"];
int intValue = [defaults integerForKey:@"another_key_that_you_choose"];

- (void)updateValues{
    float billAmount = [self.billTextField.text floatValue];

    if (intValue) {
        float tipAmount = .01 * intValue;
    }else {

    // array to hold all tip values
    NSArray *tipValues = @[@(0.1), @(0.15), @(0.2)];
    float tipAmount = billAmount*[tipValues[self.tipControl.selectedSegmentIndex] floatValue];
    float totalAmount = tipAmount + billAmount;
    }

    self.tipLabel.text = [NSString stringWithFormat:@"$%0.2f", tipAmount];
    self.totalLabel.text = [NSString stringWithFormat:@"$%0.2f", totalAmount];
}

Not really sure if I am doing this correctly but this is what I've tried so far.

A: rdelmar comment is correct unless you do want to persist the value between launches of the app.  (In this case, I would think so.)
Move the lines
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
int intValue = [defaults integerForKey:@"another_key_that_you_choose"];

inside of updateValues, so that value of intValue is current every time updateValues is called.


text:
Q: Parsing data from drag and drop view to controller I get a list of objects from the controller into my view using grails. In the view i have a jQuery ui with drag and drop.
Now i want to map the objects of list type A to list type B or C, by using drag and drop. By clicking on save button, i want to get them in the controller, to throw them into the database.
Here i have the gsp code for you:
<%@ page import="awp.Auftragsverwaltung.Auftrag" %>
<!DOCTYPE html>

<link rel="stylesheet"
    href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

<meta name="layout" content="main">
<link rel="stylesheet" href="${resource(dir: 'css', file: 'dispo.css')}"
    type="text/css">

<g:message
                        code="default.home.label" />

<g:link action="save">speichern</g:link>

Disposition

Absetzer

                <g:each in="${listeNurAbrollContainer}" status="i" var="auftrag">

<g:link action="show" id="${listeNurAbrollContainer.id}">${fieldValue(bean: auftrag, field:"kunde.kundeName")}</g:link>

Status: ${fieldValue(bean: auftrag, field:"auftragStatus")}

Art: ${fieldValue(bean: auftrag, field:"auftragArt")}

Bemerkung: ${auftrag.auftragBemerkungen}

                         </g:each>

Abroller

Spezial

.

KA-DC-100

KA-DC-200

KA-DC-300

KA-DC-400

And here the controller:
class DispoController {

    def index= {
        [listeNurAbrollContainer: dispoService.listeAbrollContainer(),
        listeNurAbsaetzContainer: dispoService.listeAbsaetzContainer(),
        listeNurSpezialContainer: dispoService.listeSpezialContainer()]
    }

    def save = {

    }

edit:
In:
<g:each in="${listeNurAbrollContainer}" status="i" var="auftrag">

                                    <g:link action="show" id="${listeNurAbrollContainer.id}">
                                        ${fieldValue(bean: auftrag, field:"kunde.kundeName")}
                                    </g:link>

                                        Status:
                                        ${fieldValue(bean: auftrag, field:"auftragStatus")}

                                        Art:
                                        ${fieldValue(bean: auftrag, field:"auftragArt")}

                                        Bemerkung:
                                        ${auftrag.auftragBemerkungen}

                        </g:each>

I get objects into the view out of the database.
I like to move the objects to different trucks like:

KA-DC-400

That is working so fare.
After the "save" button is used I need to get the information in the controller how the objects have moved, to throw that information into the service and later down into the database.
Here i`m not sure how to get this information into the controller so that I can get use of them.

A: Looking at you code I didn't saw any form. If you want to retrieve the information in the controller you need a form and fields to send the data.
If your visual representation is different from html fields, you can use hidden inputs to send the required data, probably adding a click handler in JavaScript to populate those hidden fields.


text:
Q: C++ lambda doesn't deduce function overloading I'm defining a class like this:
class foo {
public:
  // I define const and non-const versions of the 'visit' function
  // nb. the lambda is passed by reference
  virtual void visitWith(std::function<void(foo&)>&);
  virtual void visitWith(std::function<void(const foo&)>&) const;
};

foo can have children so the idea is to visit a foo and all it's children recursively.
When I try to use it, eg. like this:
foo f;
f.visitWith([&](const foo&) {
  // Do something here
});

I get compiler errors. The compiler can't figure out what to do.
I can make it work it by adding a typecast like this:
foo f;
f.visitWith( (std::function<void(const foo&)>) [&](const foo&) {
  // Do something here
});

But that's horrible.
How can I get it to work neatly?
Edit:
This may be a problem with Visual C++, it refuses to compile the code given here:
https://ideone.com/n9bySW
The VC++ output when I try to compile it is:

Edit2: Nope, Visual C++ is correct, the code is ambiguous. See my solution below...

A: A lambda is a compiler-generated type, it is not an instance of std::function, but it is assignable to one.
Your visitWith() method takes a std::function by non-const reference, which means it requires a pre-existing std::function object, eg:
std::function<void(const foo&)> func = [&](const foo&) {
    // Do something here
};
foo f;
f.visitWith(func);

Passing a lambda directly to visitWith() would require the compiler to create a temporary std::function object, but a non-const reference cannot bind to a temporary object. That is why your original code fails to compile.
For what you are attempting, you will have to pass the std::function either by value or by const-reference instead:
class foo {
public:
    void visitWith(std::function<void(foo&)>);
    void visitWith(std::function<void(const foo&)>) const;
};

Live Demo
class foo {
public:
    void visitWith(const std::function<void(foo&)> &);
    void visitWith(const std::function<void(const foo&)> &) const;
};

Live Demo

A: I reported this "bug" to Microsoft and got a reply, here:
https://developercommunity.visualstudio.com/content/problem/1201858/c-stdfunction-overloading-fails.html
Short version: Visual C++ is handling it correctly, ideone is wrong.
In the end I solved it by adding a third overload to foo which can add const-ness to an object, like this:
class foo {
public:
  // Use typedefs so that all the code that comes after these two functions is neater
  typedef std::function<void(Branch&)>visitor;
  typedef std::function<void(const Branch&)>const_visitor;

  virtual void visitWith(const visitor&);
  virtual void visitWith(const const_visitor&) const;

  // This is to thunk the third case that can happen when you start
  // a const visit from a non-const foo.
  void visitWith(const const_visitor& v) {
    static_cast<const foo*>(this)->visitWith(v);  // Add const-ness
  }

};

Now the code works, eg.:
foo f;
f.visitWith([](const foo& f) {
    std::cout << "visited a const foo!" << std::endl;
});


text:
Q: Showing servlet's list output in table using ajax asynchronously I'm new to ajax and don't know how to use it for displaying my data from sevlet on page asynchronously.Moreover I must not to use additional libraries like jquery. So I have to "reinvent a wheel" not knowing how it wheel looks like. So I have simple servlet which sends to my request List of plain beans, here is it's doGet:
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        List<Category> categoryList = dao.getCategoryList();

        request.setAttribute(PARAM_NAME_CATEGORY_LIST, categoryList);

        RequestDispatcher dispatcher = getServletContext()
            .getRequestDispatcher(PRODUCT_PAGE);
        dispatcher.forward(request, response);
}

And after forwarding to my page I need to represent data in table with help of ajax.

A: Loading data and displaying it in AJAX is made in several steps:

*

*The page sends an AJAX request to a URL of the wabapp. It registers a JavaScript callback function that will be called when the response to the request is received.

*The webapp generates a response to this request. The content of the response could be HTML, XML, JSON or anything else.

*The JavaScript callback function is called.

*The JavaScript callback function gets the data from the response, and updates the DOM tree of the page to display the received data.

Googling for "AJAX example" will lead you to plenty of tutorials explaining how to do that. If you have a more specific problem, come back.


text:
Q: FUndamentals of c -_- #include<stdio.h>

int main()
{
    int a=2;
    int j=++a  + ++a + ++a + ++a ;

    printf("%d",j);
}

//please tell me the execution of this fragment ...
//i am using GCC ubuntu (12.04) compiler. -_-

A: I generated the assembly code (gcc for windows on WIndows 7) [gcc -S test.c] and I get the following:
    .file   "increment.c"
    .def    ___main;    .scl    2;  .type   32; .endef
    .section .rdata,"dr"
LC0:
    .ascii "%d, %d\12\0"
    .text
    .globl  _main
    .def    _main;  .scl    2;  .type   32; .endef
_main:
LFB6:
    .cfi_startproc
    pushl   %ebp
    .cfi_def_cfa_offset 8
    .cfi_offset 5, -8
    movl    %esp, %ebp
    .cfi_def_cfa_register 5
    andl    $-16, %esp
    subl    $32, %esp
    call    ___main
    movl    $2, 28(%esp)   ;28(%esp) = 2 (a=2)
    incl    28(%esp)       ;28(%esp) = 3 (a++)
    incl    28(%esp)       ;28(%esp) = 4 (a++)
    movl    28(%esp), %eax ;%eax = 4 (eax = a = 4)
    leal    (%eax,%eax), %edx = %eax + %eax = 8 (edx = a + a)
    incl    28(%esp)       ;28(%esp) = 5 (a++)
    movl    28(%esp), %eax ;%eax = 5 (eax = a = 5)
    addl    %eax, %edx  ;%edx = %eax + %edx = 5 + 8 = 13 (edx = a + a + a)
    incl    28(%esp) ;28(%esp) = 6 (a++)
    movl    28(%esp), %eax ; %eax = 6 (eax = a = 6)
    addl    %edx, %eax    ;%eax = %edx + %eax = 13 + 6 = 19 (eax = a + a + a + a)
    movl    %eax, 24(%esp)
    movl    28(%esp), %eax
    movl    %eax, 8(%esp)
    movl    24(%esp), %eax
    movl    %eax, 4(%esp)
    movl    $LC0, (%esp)
    call    _printf
    leave
    .cfi_restore 5
    .cfi_def_cfa 4, 4
    ret
    .cfi_endproc
LFE6:
    .def    _printf;    .scl    2;  .type   32; .endef

After computing the result (see comments) the printf function is called with 19 as result.
Anyway different compilers can give different results. The final result depends on the way the compiler arranges instructions.


text:
Q: Keep scroll position with virtualized datagrid I've a little problem. I have a datagrid, which display lots of rows. So, for improve performance, I've decided to virtualize my datagrid.
Until this, no problem. Now, I would like to keep the scroll position after refresh.
In spite of some research, I don't find the solution.
This is my code now, but, it doesn't work :
 <DataGrid x:Name="Test" AutoGenerateColumns="False" ItemsSource="{Binding ItemCollection}" SelectionMode="Single"  IsReadOnly="True"
                         CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeColumns="False"
                         SelectedItem="{Binding SelectedItem, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                         VirtualizingPanel.IsVirtualizingWhenGrouping="True" VirtualizingPanel.IsContainerVirtualizable="True"
                         VirtualizingPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" Grid.Row="1"
                         ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Disabled">

In my ViewModel, I refresh my datagrid like this :
public ICollectionView ItemCollection
{
    get
    {
        return _itemCollection;
    }
    set
    {
        _itemCollection= value;
        OnPropertyChanged(() => ItemCollection);
    }
}

And this is my function that refesh the datagrid collection :
var orderCollection = Items.OrderByDescending(item => item.BeginDate);

var itemCollection = CollectionViewSource.GetDefaultView(orderCollection);
itemCollection.GroupDescriptions.Clear();

using (itemCollection.DeferRefresh())
{
    itemCollection.GroupDescriptions.Add(new PropertyGroupDescription("ShortStartDate"));
    itemCollection.Filter = ApplyFilter;
}

ItemCollection = itemCollection;

And this, my code behind. The GetScrollPosition is called just before the call of the method above. And the SetScrollPosition is call just after.
private void GetScrollPosition()
{
    if (DayBooks != null)
    {
        var scrollViewer = GetScrollViewer(DayBooks);
        if (scrollViewer != null)
            _currentScrollPosition = scrollViewer.VerticalOffset;
    }
}

public void SetScrollPosition()
{
    if (Test != null)
    {
        var scrollViewer = GetScrollViewer(Test);
        if (scrollViewer != null)
        {
            if (_currentScrollPosition != 0)
            {
                scrollViewer.InvalidateScrollInfo();
                scrollViewer.ScrollToVerticalOffset(_currentScrollPosition);
            }
        }
    }
}

private ScrollViewer GetScrollViewer(UIElement element)
{
    if (element == null) return null;

    ScrollViewer retour = null;
    for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element) && retour == null; i++)
    {
        if (VisualTreeHelper.GetChild(element, i) is ScrollViewer)
        {
            retour = (ScrollViewer)(VisualTreeHelper.GetChild(element, i));
        }
        else
        {
            retour = GetScrollViewer(VisualTreeHelper.GetChild(element, i) as UIElement);
        }
    }
    return retour;
}

So, when my datagrid is updated, I tried to set my scroll position (_currentScrollPosition), but the position stay to 0 and I lost my position.
Does it possible to solve my problem and keep my virtualization process ?

A: Your sort of problem is usally solved with a scroll into view behavior that reacts upon a selecteditem instead of a certain scoll position:
ScrollIntoView for WPF DataGrid (MVVM)
Did you consider using such a behavior to implement the behavior you are looking for?


text:
Q: Ajax request does not update database until page refresh I'm making a ToDo list for a dashboard system I'm creating.

So the idea is that a user can add new ToDo items, delete ToDo items and finish/unfinish ToDo items. I'm working in this project with codeIgniter.
The problem is when I'm adding a task it is added to the database but when I delete it after that or finish it, it has not been updated in the database. Only when I refresh the page and delete the task or finish the task after that it is  updated in the database. I have checked the data and that has been succesfuly sended to the controller and from the controller to the model. It just does not get updated in the Database for some reason.
I'm sending all data using AJAX post requests to the codeigniter controller.
$(document).ready(function () {
runBind();
function runBind() {

    /**
     * Deletes a task in the To Do list
     */
    $('.destroy').on('click', function (e) {
        var $currentListItem = $(this).closest('li');
        var $currentListItemLabel = $currentListItem.find('label');
        $('#main-content').trigger('heightChange');
        $.ajax({
            url: 'dashboard/deleteToDo',
            type: 'post',
            data: 'message=' + $currentListItemLabel.text()
        }).success(function (data) {
            $currentListItem.remove();
        }).error(function () {
            alert("Error deleting this item. This item was not deleted, please try again.");
        })
    });

    /**
     * Finish the to do task or unfinish it depending on the data attribute.
     */
    $('.toggle').on('ifClicked', function (e) {
        console.log("hallo");
        var $currentListItemLabel = $(this).closest('li').find('label');
        /*
         * Do this or add css and remove JS dynamic css.
         */
        if ($currentListItemLabel.attr('data') == 'done') {
            $.ajax({
                url: 'dashboard/finishToDo',
                type: 'post',
                data: 'message=' + $currentListItemLabel.text() + '&finish=' + false
            }).success(function (data) {
                console.log(data);
                $currentListItemLabel.attr('data', '');
                $currentListItemLabel.css('text-decoration', 'none');
            }).error(function () {
                alert("Error updating this item. This item was not updated, please try again.");
            })
        }
        else {
            $.ajax({
                url: 'dashboard/finishToDo',
                type: 'post',
                data: 'message=' + $currentListItemLabel.text() + '&finish=' + true
            }).success(function (data) {
                console.log(data);
                $currentListItemLabel.attr('data', 'done');
                $currentListItemLabel.css('text-decoration', 'line-through');
            }).error(function () {
                alert("Error updating this item. This item was not updated, please try again.");
            })
        }
    });
}

$todoList = $('#todo-list');

/**
 * Add a new To Do task.
 */
$("#frm_toDo").submit(function (e) {
    e.preventDefault();
    var url = $(this).attr('action');

    var method = $(this).attr('method');
    var data = $(this).serialize();
    $.ajax({
        url: url,
        type: method,
        data: data
    }).success(function (data) {
        addItemToHTMLList();
        $('#new-todo').val('');
    }).error(function () {
        alert("Error saving this task. This task has not been saved, please try again.");
    });
});

/**
 * Adds the task that has been created directly to the HTML page
 */
var addItemToHTMLList = function () {
    $('.destroy').off('click');
    $('.toggle').off('click');
    var todos = "";
    todos +=
        "
" +
        "
" +
            "
" +
                "
" +
                    "<input class='toggle' type='checkbox'>" +
                "
" +
                "
" +
                    "" + " " + $('#new-todo').val() + "" +
                "
" +
                "
" +
                    "" +
                "
" +
            "
" +
        "
" +
        "
" + $todoList.html();
    $todoList.html(todos);
    $todoList.find('input').iCheck({checkboxClass: 'icheckbox_flat-grey', radioClass: 'iradio_flat-grey'});
    runBind();
    $('#main').show();
}
});

It would be great if you can help me out because I have no clue. I have checked all the data but it just does not get updated in the database before the page refresh.

A: Have you compared the XHR requests using browser dev tools to ensure they are 100% equivalent (for a delete on an existing todo versus a delete on a newly added todo)?
Also, the typical pattern is to use some sort of id instead of using the whole message as the matcher -- have you considered having finish/delete operate on the id of the todo instead of sending the text of the todo? You can make a unique id if you do not want to expose your database ids.

A: The problem is that you are creating objects after the page has finished initializing and the events have already been attached. You need to instead assign the events to a parent element, so that this element delegates the event to any new items in the to-do. See the "Delegated Events" section in the jQuery docs: http://api.jquery.com/on/


text:
Q: Java - Vertx - Publish–Subscribe pattern : publishing message inside its own consumer. Is this a bad idea? I am new to Publish–subscribe pattern, and we are using Vertx in our application.
I am trying to do this for some usecase, where I am publishing inside its own consumer:
private void functionality() {
    EventBus eb = Vertx.currentContext().owner().eventBus();
    MessageConsumer<String> consumer = eb.consumer("myAddress");
    consumer.handler(message -> {
        if (condition1) {
            doOperationWhichMightChangeTheCondition();
            eb.publish("myAddress","Start Operation");
        }else {
            log.info("Operations on all assets completed");
        }
    });
    eb.publish("myAddress","Start Operation");
}

Is this a bad idea? Can this also lead to StackOverFlow error like recursive calls, or any other issues?

A: The EventBus.publish method is asynchronous; it does not block to wait for consumers to receive/process the published message. So it is perfectly safe to call publish inside a consumer that will then consume the published message. Internally, Vert.x has Netty schedule another call to the consumer, which will not run until the current invocation (and any other methods scheduled ahead of it on the Netty event loop) complete. You can easily prove this to yourself by writing a test that with a consumer that publishes to the address it is consuming from. You won't see a StackOverFlowError.


text:
Q: How to sort a 2D ArrayList by column value, and what if the values are equal? I want to sort two-dimensional ArrayList by their specific column values and if the column values of two arrays are equal then compare the two arrays using another column value.
For example:
array = [[2, 3, 4, 5][0, 2, 3, 4][0, 1, 2, 3][1, 2, 3, 4]]

I want to compare them first with their index [0], but since array[1][0] and array[2][0] have the same value 0 I want to compare these two arrays by their index [3].
So, the new array would be:
[[0, 1, 2, 3][0, 2, 3, 4][1, 2, 3, 4][2, 3, 4, 5]]

I have this code
public ArrayList<List<Integer>> sortArray(ArrayList<List<Integer>> spaces) {
    final Comparator<List<Integer>> comparator = new Comparator<List<Integer>>() {
        @Override
        public int compare(List<Integer> sList1, List<Integer> sList2) {
            return sList1.get(0).compareTo(sList2.get(0));
        }
    };

    Collections.sort(spaces, comparator);

    return spaces;
}

However, this only compares the value by the index [0], and no condition when the values are equal.

A: I think you can use the Java Collections.List's compareTo method (Let's abbreviate CT). Here are some example outputs of CT. 5.CT(7) -> -1 ; 7.CT(5) -> 1 ; 5.CT(5) -> 0 ;
compareTo returns 0 when they're the same, so you simply don't swap their positions. I'm not sure if I'm answering the question correctly though.

A: You need to compare all items in sub lists. For example:
public int compare(List<Integer> sList1, List<Integer> sList2) {
    for (int i = 0; i < 4; i++) {
        int c = sList1.get(i).compareTo(sList2.get(i));
        if (c != 0)
            return c;
    }
    return 0;
}

Not suggested if you are looking for a fast algorithm.

A: You need to modify your Comparator to handle that index check something like this:
public int compare(List<Integer> sList1, List<Integer> sList2) {
    if (sList1.get(0) != sList2.get(0)) {
        return sList1.get(0).compareTo(sList2.get(0));
    } else {
        return sList1.get(3).compareTo(sList2.get(3));
    }
}

But if you are running Java 8 and above you can directly do something like this to sort your collection:
Collections.sort(spaces, (sList1, sList2) -> {
    if (sList1.get(0) != sList2.get(0)) {
        return sList1.get(0).compareTo(sList2.get(0));
    } else {
        return sList1.get(3).compareTo(sList2.get(3));
    }
});

For pre-Java 8 you can do similar to what you are already doing:
Collections.sort(spaces, new Comparator<List<Integer>>() {
    @Override
    public int compare(List<Integer> sList1, List<Integer> sList2) {
        if (sList1.get(0) != sList2.get(0)) {
            return sList1.get(0).compareTo(sList2.get(0));
        } else {
            return sList1.get(3).compareTo(sList2.get(3));
        }
    }
});

In both cases, the output will be:
[[0, 1, 2, 3], [0, 2, 3, 4], [1, 2, 3, 4], [2, 3, 4, 5]]


text:
Q: Irrigation scheduling I'm trying to code an irrigation controller.  I have a preliminary tkinter UI that uses checkbuttons to get the days of the week when 4 valves will be turned on:

After I've checked the boxes, the data looks like this:
raw_data= [
    [1, 0, 0, 1, 0, 0, 0],
    [0, 1, 0, 0, 1, 0, 0],
    [0, 0, 1, 0, 0, 1, 0],
    [0, 0, 0, 1, 0, 0, 1]
]

Where '1's represent days that the valve will be turned on.  What I need to know (and don't know how to write the code for) is a way to calculate the number of days since the last irrigation.  It's easy for the second day of the week, I just subtract the weekday index for the second day from the first.  For Valve 1 in the present example that would be Thursday and Monday (3 days).  But...on the first day of the week, I need to know how many days since the valve was turned on the previous week.  Again, for Valve 1, on Monday I need to know how many days since the previous Thursday (4 days).  It's a trivial calculation for me, but I can't seem to get how to code it so a computer would understand.
What approach can I take (what logic can I use) to solve this problem?

A: I think you can do it in the following way.
Let's take as an example the valve 1 whose array would be: [1, 0, 0, 1, 0, 0, 0].
As you say, the easiest thing to do is to subtract the indexes, so we simply add the same array at the end to repeat the week with the same data.
a = [1, 0, 0, 1, 0, 0, 0]
b = a+a

aux = []

for i,v in enumerate(b):
    if v == 1:
        aux.append(i)

print(aux)

This code adds in aux index each time it finds a 1 in the array. Now we only need to subtract. In this case the last value does not interest us, so if you want you can remove it with aux.pop().
Output:
[0, 3, 7, 10]

Where 3-0=3 and 7-3=4

A: It appears that I now have two solutions to the problem I raised.  The one above and one that I came up with myself based on a answer to my previous question.  Unless I'm mistaken (which is possible, since I'm a beginner Python coder), the answer to the previous question didn't include today's date as a benchmark.  Once I put that into the code:
if today > day1:
    days_since_last_irrigation = day2 - day1
else:
    days_since_last_irrigation = ((day1 - day2) + 7)

I started to get results that made sense.  This exercise is an illustration that there's more than one way to solve most problems.

A: Easier way from @FG94.
a = [1, 0, 0, 1, 0, 0, 0]
b = a + a

aux = [i for i,v in enumerate(b) if v]
print(aux)


text:
Q: Get array/object value by referencing the object and key as string I'm trying to get the value of an array/object by passing KEY that is splitted from data attribute.
Please take a look of this whole scenario.
1st - passing the data-* to an element
 val

2nd - get the data attribute value
 var da = ele.data("action");
 var c = da.content;
 var c0 = c.split('.')[0];
 var c1 = c.split('.')[1];

4th - array/obj
 var content = {
    login : "..."
 };

3rd - trying to get the val of array
 console.log(c0[c1]);

result - undefined
Can someone give me the solution so that it logs the exact value of content.login by simply calling c0[c1]?

A: You can call the variable using the string by passing it to window: window[c0][c1]

var content = {
   login : "awesome"
};

var data = $('div').data('data');
var c = data.content;

var c0 = c.split('.')[0];
var c1 = c.split('.')[1];

console.log(c0, c1);

alert(window[c0][c1]);
   // translates to window['content']['login'] => calls content.login

NOTE: If you are in a function closure you can use this instead of window.

A: You're doing assignment of a single element rather than of array:
var c0 = c.split('.')[0]; //Take 1st element of array

So you can't try to access element of array like you have:
c0[c1]

Just print c0.


text:
Q: How to reduce the load in the memory RAM I have my Ubuntu 20.04 server with many cryptocurrencies daemons, I only have this kind of load in this server. Sometimes the server is running out of memory for these daemons, even if I have enough memory in swap partitions, this is an example:

I guess the server is running out the memory because the RAM is almost full, I would like to reduce the load in the memory RAM, changing something to the swap partition, is this possible? Or there is another best way to do something to help the server not run out of memory?
Thanks.
Edit:
free -h output:
              total        used        free      shared  buff/cache   available
Mem:           62Gi        60Gi       318Mi       0.0Ki       2.1Gi       1.7Gi
Swap:         381Gi       121Gi       260Gi

sudo sysctl vm.swappiness output:
vm.swappiness = 70

A: I'm not sure what utility this is a snapshot of, but analysing memory usage is tricky. For example, Linux will cache stuff in memory because... hey why not. So if I run:
find . -type f | xargs cat >/dev/null

When it's finished, you might find all the memory is "used" because it is caching your whole file system. However it isn't really used, because its caching stuff you'll never need again. So you tend to want to analyse not how much memory is used, but how hard your swap partition is getting hammered. If its not getting hit hard, then you may have plenty of memory. You could try disabling your swap. Does the server run fine without it? Maybe you have plenty of memory. I'd still enable swap though because it can get rid of rarely used things. As far as controlling swap, for the most part you can't control what's put there, the kernel does that for you. Which it generally does a good job of.


text:
Q: Cycle list items' positions I'm trying to cycle from users' roles in my system.
I have a list from users' ids:
users = [12, 13, 14, 15]

I'd like to make a function when every time I call it I can change the order of my list:
#function()
users = [13, 14, 15, 12]
#function()
users = [14, 15, 12, 13]
#function()
users = [15, 12, 13, 14]

I looked into Google but I didin't find a good way to do that. I'm thinking in pop the first value and remake the list every time that my function is created and put the poped item in last position.
Is there a more pythonic way to do it?

A: Try this:
def firsttolast():
    global users
    toappend = users.pop(0)
    users.append(toappend)

And you can use like this:
users = [12,13,14,15]
firsttolast()
print(users)

The whole code:
def firsttolast():
    global users
    toappend = users.pop(0)
    users.append(toappend)
users = [12,13,14,15]
firsttolast()
print(users)

A: You can use slicing to make it circular. I wrote the example function but you can modify it according to your needs.
#CLOCKWISE
def changeSeq(x): return x[-1:]+x[:-1]
#ANTICLOCKWISE
def changeSeq(x): return x[1:]+x[0:1]

def changeSeq(x): return x[-1:]+x[:-1]

u = [12, 13, 14, 15]
print(u)
u = changeSeq(u)
print(u)
u = changeSeq(u)
print(u)

#OUTPUT
[12, 13, 14, 15]
[15, 12, 13, 14]
[14, 15, 12, 13]


text:
Q: New project in TFS 2015 does not have XAML build definition We are trying to upgrade to TFS2015 and have done a test configuration for TFS 2015.
I have noticed that if we create a new project in TFS2015 the project is all empty, it does not even have the BuildProcessTemplates folder.
Can anyone guide me on how to get the Default build definition?

A: You are right that there is no BuildProcess Template folder created when you create a team project in TFS 2015.
If you have configure XAML build, you can download the build process template by creating a XAML build definition:

By the way, you can also check the new build system in TFS 2015, which is based on windows services, and doesn't need build process template. https://msdn.microsoft.com/en-us/library/vs/alm/build/feature-overview


text:
Q: BLDC and three phase inverter I want to run/control a BLDC motor from a DVD/CD-rom player and found a schematic how to do this, the so called three phase inverter (see right schematic on this page: http://en.wikipedia.org/wiki/Inverter_%28electrical%29#Three_phase_inverters).
I already made it with some some different types of transistors and an ATtiny2313 for the signal/timing and opening of the transistors, but I don't get the BLDC running. I can get LED's burning correctly, but not enough power for BLDC, I think. There are no 'anti-parallel diodes' in this set-up of my.
Now my question, do you think I can make the NPN's in the schematic with BC639 's? I can get 50 for 3,50 euro, so I can use them also for other stuff. What about the 'anti-parallel diodes' for back EMF, do I need those? The motor doesn't need to turn very fast, easy speed is enough. And what about timings, how long should the open/pulse take (how many ms)? Or do I need to use other stuff/different transistors/schematics?
Thanks for the help.

A: Microchip makes devices specifically for that sort of application:
Microchip BLDC control

A: uh oh... I should warn you that you have stepped into the wonderful and wild world of motor control. Getting a motor with an "easy" load like a fan or pump to turn is not too difficult, but you need to be aware of a couple of things, and unfortunately what you find on the Internet glosses over some important subtleties.
In order to control a BLDC motor (which is better to call a PMSM = permanent-magnet synchronous motor), you need to manage these aspects:

*

*power devices (the wikipedia page shows NPN transistors but nobody really uses those anymore, instead MOSFETs get used in sub-200V applications, IGBTs at higher voltages)

*gate drives (interfacing signals from your controller to the power devices)

*commutation (cycling current through different phases of the motor as it turns)

*current control (making sure you allow safe levels of current through the motor and transistors)

*motion control (making the motor turn at a desired speed or stay at a desired position)
I would highly recommend that you buy an integrated 3-phase bridge which takes in logic signals from a microcontroller, and turns on and off MOSFETs. ST is a decent manufacturer + has several of these, often including overcurrent protection. The L6234 is one that might suit your needs.
If you aren't going to use an integrated bridge, use MOSFETs but BE CAREFUL. The lower ones aren't too hard to control, but the upper ones can't be driven directly from a microcontroller output unless you use P-channel MOSFETs and the supply voltage is the same as the supply for the microcontroller. (In any case it's dangerous to drive directly from a micro; if you have a fault you can easily damage the microcontroller.)
(NPN transistors would be a real pain to drive; the lower ones may need more current than the micro can source, and the upper ones need some kind of circuitry to drive them correctly.)
The anti-parallel or "free-wheeling" diodes allow current to flow from the motor, which is an inductive load, to the power supply. If you don't have them and you turn off a transistor while current is flowing through the motor, you will probably damage the transistor due to the inductive voltage spike during turnoff.
Also you'll probably need to use PWM (pulse-width modulation) -- if you just use on/off control for each of the 6 transistor, you will probably get an overcurrent condition because you're putting the entire battery voltage across the motor, and when it's at a standstill, the back-emf is 0 so the current is only limited by the transistors and the motor's winding resistance.
Regarding commutation: if you don't have a position sensor on the motor, you will have to use a sensorless commutation technique, which can be interesting... the basic ones measure the motor terminal voltage and use that to measure the approximate back-emf. Nothing really works at zero speed; at low speed the algorithms are complicated, and at high speed it's not so bad. If your motor has an "easy" load (low load torque at low speeds, smoothly changing torque at higher speeds), then you can drive it open loop at low speeds like a stepper motor.
All this is just the tip of the iceberg for motor control.... fortunately you have a pretty small motor so it shouldn't be that difficult or dangerous to work with. Good luck!
edit: Allegro is another company that makes motor drive ICs.


text:
Q: Serializing multiple std::shared_ptr via boost::serialization and sending over boost::asio I'd like to transmit a shared_ptr object via boost asio from a client to a server. Here is my code:
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/asio.hpp>
#include <boost/serialization/export.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <chrono>
#include <iostream>
#include <sstream>
#include <string>
#include <thread>

using namespace std;

class Message {
public:
    Message() {
    }

    virtual ~Message() {
    }

    string text;

private:
    friend class boost::serialization::access;

    template <class Archive>
    void serialize(Archive &ar, const unsigned int version) {
        ar &text;
    }
};

BOOST_CLASS_EXPORT(Message)

void runClient() {
    // Give server time to startup
    this_thread::sleep_for(chrono::milliseconds(3000));

    boost::asio::ip::tcp::iostream stream("localhost", "3000");
    boost::archive::text_oarchive archive(stream);

    for (int i = 0; i < 10; i++) {
        std::shared_ptr<Message> dl = std::make_shared<Message>();
        stringstream ss;
        ss << "Hello " << i;
        dl->text = ss.str();
        archive << dl;
    }

    stream.close();
    cout << "Client shutdown" << endl;
}

void handleIncommingClientConnection(boost::asio::ip::tcp::acceptor &acceptor) {
    boost::asio::ip::tcp::iostream stream;

    acceptor.accept(*stream.rdbuf());

    boost::archive::text_iarchive archive(stream);

    while (true) {
        std::shared_ptr<Message> m;

        try {
            archive >> m;
            cout << m->text << endl;
        } catch (std::exception &ex) {
            cout << ex.what() << endl;

            if (stream.eof()) {
                cout << "eof" << endl;
                stream.close();
                cout << "Server: shutdown client handling..." << endl;
                break;
            } else
                throw ex;
        }
    }
}

void runServer() {
    boost::asio::io_service ios;
    boost::asio::ip::tcp::endpoint endpoint = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 3000);
    boost::asio::ip::tcp::acceptor acceptor(ios, endpoint);

    handleIncommingClientConnection(acceptor);
}

int main(int argc, char **argv) {
    thread clientThread(runClient);
    thread serverThread(runServer);

    clientThread.join();
    serverThread.join();

    return 0;
}

Here is the program output:
Hello 0
Hello 1
Hello 2
Hello 3
Hello 3
Hello 3
Hello 3
Hello 3
Client shutdown
Hello 3
Hello 3
input stream error
eof
Server: shutdown client handling...

I am expecting the following output:
Hello 0
Hello 1
Hello 2
Hello 3
Hello 4
Hello 5
Hello 6
Hello 7
Client shutdown
Hello 8
Hello 9
input stream error
eof
Server: shutdown client handling...

When changing the shared_ptr to a simple object (std::shared_ptr<Message> m; to Message m) everything works as expected. I want to stick to the shared_ptr. What do I need to change?
Serialization alone seems to work:
stringstream stream;

{
    boost::archive::text_oarchive archive(stream);
    std::shared_ptr<Message> dl = std::make_shared<Message>();
    stringstream ss;
    ss << "Hello World!";
    dl->text = ss.str();
    archive << dl;
}

{
    boost::archive::text_iarchive archive(stream);
    std::shared_ptr<Message> m;
    archive >> m;
    cout << m->text << endl;
}

Output: Hello World!

A: The issues you're encountering are due to object tracking done by Boost.Serialization.

Depending on how the class is used and other factors, serialized
  objects may be tracked by memory address. This prevents the same
  object from being written to or read from an archive multiple times.
  These stored addresses can also be used to delete objects created
  during a loading process that has been interrupted by throwing of an
  exception.

The documentation actually foreshadows this specific issue happening:

This could cause problems in progams[sic] where the copies of different
  objects are saved from the same address.

Furthermore, the Class Serialization Traits documentation on object tracking tells us that in this particular situation, object tracking is enabled:

Default tracking traits are:

*

*For primitive, track_never.

*For pointers, track_never. That is, addresses of addresses are not tracked by default.

*All current serialization wrappers such as boost::serialization::nvp, track_never.

*For all other types, track_selectively. That is addresses of serialized objects are tracked if and only if one or more of the
  following is true:

*

*an object of this type is anywhere in the program serialized through a pointer.

*the class is explicitly "exported" - see below.

*the class is explicitly "registered" in the archive

Going back to your situation -- in the client, due to how your loop body is written, the 5th (and following) Message instance were allocated at the same address as the 4th Message instance. You can verify this by inspecting the values of dl.get() in each iteration. (In my tests on coliru, all of the instances were allocated at the same address, so YMMV).
Due to how object tracking works, all those shared_ptr instances were considered to point to the same Message instance (even though you changed the value meanwhile -- the library does not expect this happening), so the additional occurrences were just serialized as additional references. Upon deserialization... to be honest this smells of memory leaks and/or dangling reference issues (opinion, haven't investigated this in detail).
Summed up, the main issue with the code as shown is that it breaks a prerequisite of the serialization library, which is that you're serializing some constant state, and on deserialization you recreate that same state.
One way to address this would be to have an initialized std::vector of shared_ptr<Message> containing all the messages to transmit in this particular transaction. Similarly, you'd deserialize the whole vector on the other side. If you expect to have some persistent connection, then add framing to the protocol, with each frame containing an archive that contains one sequence of messages.

Minimal code modifications to make this work -- add include
#include <boost/serialization/vector.hpp>

Change runClient() as such:
void runClient() {
    // Give server time to startup
    this_thread::sleep_for(chrono::milliseconds(3000));

    boost::asio::ip::tcp::iostream stream("127.0.0.1", "3000");

    std::vector<std::shared_ptr<Message>> messages;
    for (int i = 0; i < 10; i++) {
        std::shared_ptr<Message> dl = std::make_shared<Message>();
        stringstream ss;
        ss << "Hello " << i;
        dl->text = ss.str();
        messages.emplace_back(dl);
    }

    boost::archive::text_oarchive archive(stream);
    archive << messages;

    stream.close();
    cout << "Client shutdown" << endl;
}

And change handleIncommingClientConnection(...) as such:
void handleIncommingClientConnection(boost::asio::ip::tcp::acceptor &acceptor) {
    boost::asio::ip::tcp::iostream stream;

    acceptor.accept(*stream.rdbuf());

    boost::archive::text_iarchive archive(stream);

    while (true) {
        try {
            std::vector<std::shared_ptr<Message>> messages;
            archive >> messages;
            for (auto const& m : messages) {
                cout << m->text << endl;
            }
        } catch (std::exception &ex) {
            cout << ex.what() << endl;

            if (stream.eof()) {
                cout << "eof" << endl;
                stream.close();
                cout << "Server: shutdown client handling..." << endl;
                break;
            } else
                throw ex;
        }
    }
}

NB: This doesn't add any support for multiple frames -- the client is expected to close the connection after it sent one vector of messages, otherwise the behaviour is undefined.
Sample on Coliru

Further resources:

*

*boost serialization multiple objects


text:
Q: e000: Error 0x80070643: Failed to install MSI package Currently In my Solution it is containing .net Framework 4.8 , .net Standard and net 6 assemblies .
during installing the particular artifacts (.exe) of the solution, I can't  install it and getting the exception as
Error 1001. Unable to get installer types in the <file>\service.exe assembly.--> Unable to loadone or more request types.

for other .net framework and .net standard the wix setup are like this
<Component Id="__Device_dll" Guid="{9C75189F-BE83-4227-A798-F00C76F27CE6}">
   <File Id="__Device_dll" Name="Device.dll" KeyPath="yes"  Assembly=".net" AssemblyManifest="_Device_dll" AssemblyApplication="Device_dll" DiskId="1" Source="$(var.SourceDir)\Device.dll" />
</Component>

but for .net 6
<Component Id="Process_Executor_exe" Guid="{0D8D84F1-FFC5-28F6-F1D7-8620DA17313B}">
  <File Id="Process_Executor_exe" Name="SProcess.Executor.exe" Source="$(var.SimulationSourceDir)\Process.Executor.exe" />
</Component>

Is something I am missing in wix set up ,because the application rus fine in visual studio , during installation only Error 0x80070643: Failed to install MSI package these error logs are comming.


text:
Q: 'Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032"] While trying to access the Experience manager, I was getting following error.
There was a problem with your request: faultCode:Server.Error.Request faultString:'HTTP request error' faultDetail:'Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032"]. URL: http://10.11.33.111:8000/ifcr/wb//landing/LandingPagesGroups.action'
See the screenshot as well.

A: Maybe the error 2032 on endeca workbench happens if you open workbenches in two browser windows at the same time, and logout from one window and then try to login again while the workbench is open in another window. Close Workbench in other browsers and then logout and login.

A: This happens due to open Endeca experience manager in multiple tabs. Delete cookies and try.
However, you can use different browser to open experience manager using same id and password


text:
Q: Seconds is not showing in bootstrap datetimepicker I've read some opened issue about this, but it didn't help me. I have also read the moment.js documentation but I don't know why it still not working. I just want to add the seconds to show when picking a datetime. Please see my code below:

$(function(){

  $('#dateTimePicker').datetimepicker({
    format: "DD/MM/YYYY hh:mm:ss A"
  });

});
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/3.1.4/css/bootstrap-datetimepicker.min.css">

<input type="text" id="dateTimePicker" class="form-control">

A: Try passing useSeconds: true as shown below. That should help.
The datetimepicker FAQ says that it uses the format option to decide what components to show. But then I found useMinutes and useSeconds options here: http://eonasdan.github.io/bootstrap-datetimepicker/Changelog/#2120.
(I know its not a very good place to document a feature, but .... let it be ;) )

$(function(){

  $('#dateTimePicker').datetimepicker({
    format: "DD/MM/YYYY hh:mm:ss A",
    useSeconds: true
  });

});
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/3.1.4/css/bootstrap-datetimepicker.min.css">

<input type="text" id="dateTimePicker" class="form-control">

A: Please try this snippet,
Setting the format to the correct value from moment and sideBySide:

$('#datetimepicker1').datetimepicker({
    defaultDate: new Date(),
    format: 'DD/MM/YYYY hh:mm:ss A',
    sideBySide: true,
    tooltips: {
      pickSecond: 'Pick Second'
     }
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<link rel="stylesheet"
  href="https://rawgit.com/Eonasdan/bootstrap-datetimepicker/master/build/css/bootstrap-datetimepicker.min.css">

                    <input type='text' class="form-control"/>

For more info please visit this - How to add seconds to Bootstrap date time picker
Bootstrap3 DateTime picker - https://eonasdan.github.io/bootstrap-datetimepicker/Options/#viewdate

A:

<link rel="stylesheet" type="text/css" media="screen" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link href="//cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/build/css/bootstrap-datetimepicker.css" rel="stylesheet">

                    <input type='text' class="form-control" />


text:
Q: Use NSRegularExpression to find how "close" a phase is to another phrase I am trying to figure out how to use NSRegularExpression to see how "close" a string matches another string.  I know I can just create a set of substrings and use NSRange for each to see.  E.g.
"up", "to", "a", "point" match against "up two a point" I could match 3 out of 4
Similarly, "up too a point" matches 3, "Up to apoint" matches all 4.
I'm hoping that using regular expressions I could generalize the pattern matching so that I could just use "up to a point" and match it against what I find in another string, such as:
uptoapoint,
Up to  a point,
UP TO A POINT,
up too point,
etc and get a "percentage" match.
Not sure this is do-able, thus my question.  Thanks for any help/advice.

A: Regex is certainly not the right tool for this.
Do this instead:

*

*Unify strings either by running them thru [string uppercaseString] or [string lowercaseString].

*Compute Levenshtein Distance between unified strings.

*…

*Profit!

The Levenshtein Distance (or edit distance) is the absolute number of characters that need to be exchanged/removed/added in/from/to stringA in order to morph it into stringB.
Objective-C Implementation of the Levenshtein Distance.
Extended Note: It does not look like you are in danger here, but it's worth noting that while the Levenshtein distance is pretty handy for comparing short strings, it is not very useful for calculating distances between entire documents. Most implementations of the Levenshtein Distance require memory space of m*n (m and n being the lengths of your strings). And while some implementations are able to reduce this to m+n (afaik), their run time still requires O(n*n), which is basically equivalent to O(n^2) on average.

A: See http://en.wikipedia.org/wiki/Levenshtein_distance
Here is an implementation http://www.merriampark.com/ldobjc.htm


text:
Q: pgfplots colorbar does not render labels in fixed format when used with ymode=log Considering the MWE
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    point meta min=0.1,
    point meta max=0.48,
    colorbar,
    colorbar style={
        scaled y ticks=false,
        ymode=log,
        yticklabel style={
            /pgf/number format/fixed,
            /pgf/number format/fixed zerofill,
            /pgf/number format/precision=2
        },
    },
]
\end{axis}
\end{tikzpicture}
\end{document}

pgfplots really jumps through some hoops here to present an awkward result. Obviously, ymode=linear works as expected, but ymode=log renders 0.10 as 10^{-1.00} (unfortunately, TeX math input does not work here, but you get the idea).

A: As already stated in the comment below the question you can achieve this by adding log ticks with fixed point to the colorbar style options.
% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        point meta min=0.1,
        point meta max=0.48,
        colorbar,
        colorbar style={
            scaled y ticks=false,
            ymode=log,
            log ticks with fixed point,
        },
    ]
    \end{axis}
\end{tikzpicture}
\end{document}


text:
Q: Delete Repeating Calendar Events in iOS 7.0.4 I have an iPhone 4 and use the calendar feature often.  Deleting events used to be simple, but at the moment I've found that I cannot delete an existing repeating event.
I can tap on the event and view the details.  There used to be an "Edit" button for repeating events, where you could select to delete either one instance of the event, or all instances of the event.  That "Edit" button is no longer there though, and I cannot find any other way to delete the series.
Software version is iOS 7.0.4.  Does anyone know how I can get rid of this?
Thanks!

A: Tapping on an event should give you an edit button in the upper right. From there you scroll down to the very bottom and will see the option to delete the event(s).
delete event >


text:
Q: threading in titanium without alloy the following code is a loop which I have to run which will update my UI with the correct meta data title of a song currently played on the radio. I need the loop to run every 10 seconds-ish. I tried setting a timeout of ten seconds and calling my function every ten seconds and that caused my app to crash so I think I have to create a seperate thread. I saw a q & a answer detailing how to do this with alloy here:
http://developer.appcelerator.com/question/117199/how-to-create-multithreading-in-mobile-sdk

Is there any examples of doing this without alloy or what is the best practise for implementing multiple threads? Code below:
function FetchMetaData () {
//while (true)
alert("Am I being fired");
   if (isPlaying && Titanium.Network.online) {
        if  (TitleLabel.text !== streamer.getMetaTitle()) {
            TitleLabel.setText(streamer.getMetaTitle());
        }
        else {
                //Do nothing
        }
     }
     else {
           //Do nothing
     }
    //}
}

A: setInterval should do it:
function updateView() {
    //your update code
}
setInterval(function() {
    updateView();
}, 10000);

What is the titanium log error when your app crashes? It might be because of something other than the setInterval.


text:
Q: Looking for the impact of quantitative variables on one another via R For my project analysis, i am looking into how twitter data impacts the number of projects on Kickstarter in the field of video games
In order to do so, I am only using quantitative variables, by using a representative sample that shows how many tweets speaking of video games are published every day (i also have the number of retweets, replies, likes, etc ...) and how many new projects related to video games are  published on kickstarter every day (as well as how many backers and money these projects collected)
Would anyone have any advice on how to perform this analysis ?
I am using a regression model for the time being, and i also want to use some interaction variables in there to really capture the effect of Twitter on Kickstater
Sadly i am not rely good in stats, so i am ensure of what to do
Here is my data in case anyone is interested
[Workspace loaded from ~/.RData]

> dput(dataT)
structure(list(date = c("2021-01-01", "2021-01-02", "2021-01-03",
"2021-01-04", "2021-01-05", "2021-01-06", "2021-01-07", "2021-01-08",
"2021-01-09", "2021-01-10", "2021-01-11", "2021-01-12", "2021-01-13",
"2021-01-14", "2021-01-15", "2021-01-16", "2021-01-17", "2021-01-18",
"2021-01-19", "2021-01-20", "2021-01-21", "2021-01-22", "2021-01-23",
"2021-01-24", "2021-01-25", "2021-01-26", "2021-01-27", "2021-01-28",
"2021-01-29", "2021-01-30", "2021-01-31", "2021-02-01", "2021-02-02",
"2021-02-03", "2021-02-04", "2021-02-05", "2021-02-06", "2021-02-07",
"2021-02-08", "2021-02-09", "2021-02-10", "2021-02-11", "2021-02-12",
"2021-02-13", "2021-02-14", "2021-02-15", "2021-02-16", "2021-02-17",
"2021-02-18", "2021-02-19", "2021-02-20", "2021-02-21", "2021-02-22",
"2021-02-23", "2021-02-24", "2021-02-25", "2021-02-26", "2021-02-27",
"2021-02-28", "2021-03-01", "2021-03-02", "2021-03-03", "2021-03-04",
"2021-03-05", "2021-03-06", "2021-03-07", "2021-03-08", "2021-03-09",
"2021-03-10", "2021-03-11", "2021-03-12", "2021-03-13", "2021-03-14",
"2021-03-15", "2021-03-16", "2021-03-17", "2021-03-18", "2021-03-19",
"2021-03-20", "2021-03-21", "2021-03-22", "2021-03-23", "2021-03-24",
"2021-03-25", "2021-03-26", "2021-03-27", "2021-03-28", "2021-03-29",
"2021-03-30", "2021-03-31", "2021-04-01", "2021-04-02", "2021-04-03",
"2021-04-04", "2021-04-05", "2021-04-06", "2021-04-07", "2021-04-08",
"2021-04-09", "2021-04-10", "2021-04-11", "2021-04-12", "2021-04-13",
"2021-04-14", "2021-04-15", "2021-04-16", "2021-04-17", "2021-04-18",
"2021-04-19", "2021-04-20", "2021-04-21", "2021-04-22", "2021-04-23",
"2021-04-24", "2021-04-25", "2021-04-26", "2021-04-27", "2021-04-28",
"2021-04-29", "2021-04-30", "2021-05-01", "2021-05-02", "2021-05-03",
"2021-05-04", "2021-05-05", "2021-05-06", "2021-05-07", "2021-05-08",
"2021-05-09", "2021-05-10", "2021-05-11", "2021-05-12", "2021-05-13",
"2021-05-14", "2021-05-15", "2021-05-16", "2021-05-17", "2021-05-18",
"2021-05-19", "2021-05-20", "2021-05-21", "2021-05-22", "2021-05-23",
"2021-05-24", "2021-05-25", "2021-05-26", "2021-05-27", "2021-05-28",
"2021-05-29", "2021-05-30", "2021-05-31", "2021-06-01", "2021-06-02",
"2021-06-03", "2021-06-04", "2021-06-05", "2021-06-06", "2021-06-07",
"2021-06-08", "2021-06-09", "2021-06-10", "2021-06-11", "2021-06-12",
"2021-06-13", "2021-06-14", "2021-06-15", "2021-06-16", "2021-06-17"
), Kickstarter = c(4L, 0L, 0L, 0L, 8L, 4L, 4L, 0L, 0L, 0L, 4L,
12L, 0L, 8L, 8L, 0L, 0L, 4L, 4L, 4L, 4L, 4L, 4L, 0L, 0L, 4L,
4L, 4L, 4L, 0L, 8L, 9L, 25L, 0L, 10L, 0L, 0L, 0L, 5L, 10L, 5L,
20L, 5L, 0L, 0L, 5L, 19L, 0L, 10L, 20L, 0L, 0L, 5L, 5L, 5L, 2L,
0L, 12L, 0L, 22L, 14L, 0L, 2L, 4L, 6L, 9L, 5L, 37L, 0L, 5L, 0L,
0L, 4L, 10L, 12L, 21L, 4L, 4L, 6L, 6L, 9L, 16L, 9L, 6L, 13L,
0L, 2L, 19L, 24L, 20L, 8L, 25L, 16L, 5L, 24L, 27L, 24L, 6L, 9L,
15L, 8L, 25L, 35L, 26L, 8L, 2L, 5L, 14L, 12L, 20L, 19L, 7L, 9L,
5L, 0L, 4L, 17L, 13L, 15L, 8L, 10L, 7L, 5L, 16L, 11L, 16L, 10L,
6L, 0L, 3L, 22L, 10L, 10L, 3L, 1L, 0L, 0L, 7L, 4L, 6L, 4L, 5L,
3L, 0L, 6L, 3L, 3L, 0L, 1L, 0L, 3L, 9L, 6L, 4L, 2L, 1L, 1L, 3L,
5L, 2L, 4L, 2L, 2L, 1L, 5L, 5L, 6L, 3L), Money = c(50278.64,
0, 0, 0, 366279.590415302, 172073.0471292, 230.537553792, 0,
0, 0, 304353.5676352, 285277.861423738, 0, 931521.92, 62322.104033708,
0, 0, 292739.37663744, 97895.025306156, 20538.4758468, 5716,
69712, 15248.7519561728, 0, 0, 1257502.99126928, 102268, 32151.762183708,
70322.17520884, 0, 27549.00453216, 8371657.96195552, 1420782.4068818,
0, 137818.171860595, 0, 0, 0, 1175436.75496273, 1770825.83285245,
1070, 178761.8127624, 10016.918409372, 0, 0, 146129.2, 610608.234267955,
0, 676175.367448825, 1274147.86429578, 0, 0, 45595.6660422, 1776940,
4198.748196, 17.02446963, 0, 55272.18380506, 0, 490750.12364435,
571800.5, 0, 227.26420984, 619.23335154, 5942.151506976, 1098.48977709,
87300, 1879564.14902818, 0, 57100, 0, 0, 3.628861728, 715993,
228885.860968739, 1005412.33040269, 32978.39955816, 1956.52590528,
5789.84841572, 508.6539266268, 192238.643979976, 278988.70418106,
32470.60072344, 10653.5543364, 333900.00289616, 0, 2467.35065664,
698082.326436438, 581461.49769354, 170032.27513805, 24516.65281874,
11530.3738156855, 20060.6125168384, 154030.2061095, 215919.1704622,
1320696.42919177, 2000470.11990896, 1414.108082664, 12429.5108974052,
80676.567104964, 3211.42501648, 69994.39317561, 827188.797715076,
51349.427891072, 47925.216359587, 42, 28391.25545206, 6199141.75469484,
16078.9170341546, 724307.969231123, 238317.166592813, 243887.2812338,
3856.910710253, 5982.1359855268, 0, 1986.4520326, 180186.734055936,
25818.301703542, 284175.24917946, 27486.5134227176, 51837.3569258,
218101.634171675, 543.2343820104, 299634.97422679, 9200.1639420603,
112660.244016819, 27675.2965010449, 5203.03118806, 0, 75650.25,
327968.549088524, 1002.27102748, 37881.2795828444, 2896.1824198269,
596, 0, 0, 206880.064933601, 1688.14367074, 19176.1722666628,
48811.21823157, 4572.83962465, 375.36475346, 0, 126743.686979946,
489.0998, 4042.91231235, 0, 1343.0098244, 0, 2286.711086, 77485.7681307,
25272.4433349128, 11630.0007860946, 377.22065991, 199.9004139,
161, 2667.93172391, 69404.71338983, 23796.67811208, 17174.64072667,
9950.0416377665, 35443.95356773, 184.603426004, 85934.0997877056,
5603.88739935, 2306.02823117, 13.0064795336), Backers = c(2880L,
0L, 0L, 0L, 6588L, 3528L, 16L, 0L, 0L, 0L, 4204L, 6632L, 0L,
15404L, 1672L, 0L, 0L, 3588L, 416L, 464L, 364L, 1488L, 228L,
0L, 0L, 17124L, 2284L, 1348L, 2324L, 0L, 744L, 185822L, 35095L,
0L, 5980L, 0L, 0L, 0L, 24615L, 32525L, 40L, 4650L, 450L, 0L,
0L, 2640L, 15952L, 0L, 9275L, 16404L, 0L, 0L, 990L, 35075L, 79L,
6L, 0L, 1578L, 0L, 10705L, 9302L, 0L, 12L, 20L, 36L, 91L, 1505L,
40509L, 0L, 1890L, 0L, 0L, 4L, 9684L, 4196L, 16477L, 754L, 62L,
54L, 36L, 3787L, 3809L, 996L, 132L, 13216L, 0L, 50L, 12073L,
13826L, 4353L, 220L, 393L, 628L, 3607L, 6712L, 22403L, 30468L,
106L, 136L, 1854L, 102L, 1623L, 14638L, 1396L, 1923L, 6L, 426L,
161556L, 1020L, 6922L, 3575L, 1627L, 84L, 101L, 0L, 56L, 2291L,
450L, 2439L, 678L, 864L, 3195L, 17L, 6072L, 215L, 3119L, 1473L,
85L, 0L, 2306L, 7622L, 41L, 973L, 117L, 20L, 0L, 0L, 3127L, 45L,
424L, 819L, 84L, 12L, 0L, 3239L, 18L, 66L, 0L, 7L, 0L, 35L, 1651L,
651L, 242L, 25L, 13L, 6L, 59L, 1747L, 325L, 244L, 231L, 862L,
6L, 1819L, 74L, 66L, 4L), Twitter = c(1324L, 1548L, 1297L, 1585L,
1636L, 1583L, 1492L, 1676L, 1745L, 1389L, 1718L, 1781L, 1858L,
1798L, 1714L, 1808L, 1315L, 1644L, 1603L, 1820L, 1770L, 1843L,
1885L, 1390L, 1763L, 1875L, 1912L, 1812L, 1764L, 2117L, 1641L,
1914L, 1963L, 2092L, 1968L, 2021L, 2023L, 1331L, 1557L, 1555L,
1904L, 2034L, 1850L, 2067L, 1507L, 1738L, 1915L, 2057L, 1931L,
1859L, 2010L, 1525L, 1835L, 1850L, 1958L, 1848L, 1929L, 2015L,
1449L, 1823L, 1796L, 1902L, 1888L, 1875L, 2078L, 1442L, 1757L,
1877L, 2104L, 1926L, 1949L, 2175L, 1604L, 2030L, 1918L, 2011L,
1978L, 1959L, 2171L, 1528L, 1936L, 1889L, 2132L, 1907L, 2173L,
2233L, 1581L, 1793L, 1986L, 2128L, 2030L, 1805L, 1954L, 1459L,
1691L, 1967L, 2049L, 1835L, 1948L, 2246L, 1581L, 1950L, 1904L,
2245L, 2053L, 1877L, 1913L, 1571L, 1932L, 2004L, 2058L, 2087L,
1989L, 2180L, 1567L, 1865L, 1995L, 2144L, 2169L, 2148L, 2318L,
1606L, 1856L, 1948L, 2036L, 1887L, 2021L, 2132L, 1390L, 1717L,
1872L, 1919L, 1867L, 1994L, 2083L, 1509L, 1786L, 1808L, 1860L,
1854L, 1813L, 2102L, 1513L, 1890L, 1877L, 2063L, 1857L, 1827L,
2059L, 1413L, 1614L, 2153L, 1859L, 1920L, 1877L, 2106L, 1458L,
1822L, 1851L, 2005L, 1984L, 2097L, 2396L, 1607L, 2106L, 2256L,
2398L, 2245L), replies = c(882L, 1252L, 910L, 1018L, 810L, 1000L,
1050L, 1164L, 2062L, 640L, 1376L, 1387L, 1315L, 1278L, 1456L,
1484L, 733L, 1250L, 1216L, 1222L, 1083L, 2851L, 2331L, 760L,
1705L, 1157L, 1467L, 1231L, 1245L, 2068L, 907L, 1183L, 1241L,
1874L, 1396L, 2168L, 1527L, 966L, 1278L, 950L, 1407L, 1283L,
1327L, 1542L, 771L, 1060L, 1576L, 1569L, 1303L, 1149L, 2604L,
851L, 1310L, 1060L, 1454L, 1119L, 1381L, 1883L, 811L, 1177L,
1729L, 1135L, 1898L, 1052L, 2136L, 770L, 1082L, 1497L, 1809L,
1084L, 1733L, 1998L, 846L, 1319L, 1114L, 1526L, 1747L, 1658L,
2360L, 1871L, 1878L, 1174L, 2119L, 1204L, 1534L, 2001L, 1575L,
1090L, 1251L, 1890L, 1286L, 1447L, 1864L, 810L, 1147L, 1508L,
1946L, 1306L, 1209L, 3131L, 836L, 1289L, 1466L, 2141L, 1354L,
1323L, 2253L, 1211L, 1338L, 2261L, 1801L, 1374L, 1448L, 2171L,
930L, 1128L, 1553L, 1965L, 2010L, 1601L, 3066L, 964L, 1296L,
2044L, 1678L, 1297L, 1260L, 2630L, 815L, 1188L, 1991L, 1894L,
1324L, 1453L, 2961L, 757L, 1326L, 1357L, 1978L, 1023L, 1169L,
2532L, 1153L, 1038L, 1123L, 2391L, 1163L, 1326L, 2747L, 949L,
1146L, 3691L, 1485L, 1552L, 1118L, 2605L, 1035L, 1292L, 1171L,
2129L, 1880L, 1748L, 2920L, 666L, 1542L, 1496L, 3128L, 1641L),
    likes = c(22859L, 24375L, 17854L, 20341L, 19521L, 19401L,
    19875L, 18932L, 29993L, 16596L, 24307L, 28284L, 26521L, 28920L,
    24809L, 37702L, 14241L, 22099L, 32508L, 27823L, 20326L, 25664L,
    34146L, 17171L, 30035L, 23867L, 32392L, 24715L, 20302L, 39402L,
    19599L, 24293L, 25548L, 28174L, 28806L, 24824L, 29490L, 18462L,
    26055L, 22467L, 31811L, 25248L, 27877L, 32188L, 18357L, 21870L,
    45642L, 31962L, 24236L, 24418L, 36140L, 21271L, 24392L, 24503L,
    35133L, 23395L, 23260L, 40030L, 19736L, 27098L, 25462L, 24416L,
    28540L, 22627L, 39017L, 19760L, 26411L, 33813L, 34805L, 26390L,
    30583L, 41172L, 26137L, 30397L, 30079L, 31355L, 36543L, 31646L,
    38185L, 28978L, 36434L, 29245L, 54979L, 27145L, 27767L, 37101L,
    30858L, 28796L, 30398L, 35765L, 24545L, 30801L, 35000L, 18786L,
    24692L, 38665L, 39191L, 24083L, 27611L, 54171L, 22209L, 27587L,
    55352L, 38987L, 41536L, 31734L, 34210L, 23134L, 33761L, 63722L,
    30123L, 33743L, 28555L, 32825L, 20250L, 24637L, 30817L, 29721L,
    35042L, 32463L, 41842L, 21183L, 27702L, 36788L, 26537L, 24298L,
    24856L, 36523L, 23617L, 23998L, 30111L, 28374L, 32833L, 32429L,
    61207L, 22408L, 28370L, 26103L, 28198L, 26409L, 28253L, 36444L,
    33748L, 22794L, 26860L, 31895L, 27527L, 39273L, 32048L, 28277L,
    32493L, 64514L, 30865L, 34927L, 24095L, 34797L, 20978L, 28336L,
    26542L, 33005L, 41835L, 34136L, 33552L, 15492L, 33295L, 30017L,
    39526L, 29754L), retweets = c(8621L, 8239L, 6141L, 6728L,
    6938L, 6842L, 6875L, 7249L, 8819L, 6108L, 7807L, 10235L,
    9519L, 8793L, 8059L, 11179L, 5630L, 7688L, 9570L, 9107L,
    7798L, 8240L, 11139L, 6146L, 9507L, 8763L, 8831L, 8190L,
    7809L, 12824L, 7477L, 7741L, 8718L, 9407L, 8800L, 8934L,
    9631L, 6800L, 8060L, 7337L, 9138L, 8351L, 8983L, 10577L,
    7025L, 7411L, 12479L, 9642L, 8632L, 8349L, 12013L, 7152L,
    7976L, 8708L, 10597L, 8058L, 8433L, 12065L, 6274L, 8717L,
    8711L, 8232L, 8431L, 8279L, 11474L, 6693L, 8837L, 9476L,
    11279L, 9838L, 10989L, 12032L, 9009L, 9430L, 9493L, 9812L,
    10488L, 10279L, 12026L, 8188L, 18362L, 9620L, 13131L, 10242L,
    10095L, 11088L, 8278L, 11611L, 10139L, 11685L, 8554L, 8730L,
    10457L, 6767L, 9058L, 12049L, 12089L, 8539L, 9504L, 17077L,
    7959L, 9447L, 12574L, 11994L, 11046L, 10427L, 10220L, 7722L,
    10359L, 17003L, 10332L, 10557L, 10515L, 11407L, 7501L, 9243L,
    10535L, 10486L, 11430L, 10685L, 14098L, 8199L, 10602L, 12625L,
    10916L, 10504L, 10310L, 13443L, 9255L, 9787L, 11543L, 12336L,
    12867L, 11674L, 18969L, 8530L, 10492L, 10417L, 11170L, 10442L,
    8926L, 13209L, 11210L, 8826L, 9727L, 11406L, 9868L, 13170L,
    13176L, 9226L, 10508L, 18820L, 11594L, 13196L, 10729L, 13563L,
    8316L, 10406L, 10502L, 12760L, 15979L, 12610L, 14323L, 7876L,
    12819L, 11162L, 13549L, 11599L)), row.names = c(NA, -168L
), class = c("tbl_df", "tbl", "data.frame"))

To add to this, so far, linear regression seems to show that likes are more significant and have a stronger impact than other values


text:
Q: Replace user created blanks with 0's I made a binary calculator with bitwise functions (bitand, bitor, bitxor, ect.) in google sheets (yes I am aware that there are built in functions to do this, this seemed more fun). It is an 8 bit calculator, and I currently have addition and subtraction implemented. Multiplication is planned, but seems way too hard at the moment
One of the things I came across is once a calculation is done, the user has to manually 0 out the addends/minuend and subtrahend one digit at a time. I would like to optimize this process.
I can easily create a script that will input 0 into all the cells and hook that up to a button. I have a feeling that's the route I'm going to have to go. But I want to challenge myself in making cool stuff, so I want the coolest solution.
My question is: is there a way I can do this without a script attached? I've been experimenting with ARRAYFORMULA and VLOOKUP, but I don't have a clear answer yet.
Expected behavior:
User inputs their calculation. User records the answer. User selects both 8 bit binary numbers (currently residing in A1:H2) and presses backspace. Google Sheet automatically translates those blank cells to 0's.

A: take a look into custom internal formatting. any text can be converted to "0"

then see shifted arrays:
={"", "x"}

formula from G9 will print "0" into H9. also, you can anytime enter value in H9 to "overwrite" the zero and after you don't need the entered value you just clear it with backspace or delete key and it will be filled with "0" again.

also, note that after you enter value in H9, G9 will error out and such error cant be suppressed so see hidden cells:

not sure if it's cool enough but it works (with compromises)


text:
Q: Get values from complex Array of Dictionary in Swift2 I'm displaying a dictionary as UITableView. I did this very easily in Objective- c . But now in swift, I cannot get values from array of dictionary. When I try to get values in the tableView:cellForRowAtIndexPath the precompiler throw error like

Cannot convert value of type "AnyObject?!" to specified type 'Array'

or like in this example below

Cannot convert value of type "AnyObject?!" with an idnex of type 'int'

var cellArray = []

override func viewDidLoad() {
    cellArray = [
        [
            "section" : "Melody",
            "rows" :
                [
                    [
                        "title" : "Wi-Fi / Pairing",
                        "icon" : "",
                        "action" : "actionConnectSpeaker"
                    ],
                    [
                        "title" : "Sound",
                        "icon" : "",
                        "action" : "actionConnectSpeaker"
                    ]
                ]
        ],

        [
            "section" : "Music",
            "rows" :
                [
                    [
                        "title" : "Add a new account",
                        "icon" : "",
                        "action" : "actionAddAccount"
                    ]
                ]
        ]
    ]
}

...
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = UITableViewCell(style: UITableViewCellStyle.Value2, reuseIdentifier: nil)

    cell.textLabel?.text = cellArray[indexPath.section]["rows"][indexPath.row]["title"]

    return cell
}

I conclude we cannot do like this... I find any example. I probably not understand something about Types in Swift ...

A: In Swift you have to downcast AnyObject types if you want to call functions like objectAtIndex: or objectForKey: what subscripting actually does.
let section = cellArray[indexPath.section]
let rows = section["rows"] as! [[String:String]]
cell.textLabel?.text = rows[indexPath.row]["title"]

A: Simply doing this if you're sure there's no nil value:
cell.textLabel?.text = cellArray[indexPath.section]["rows"]![indexPath.row]["title"]

A: If you want to do it safely (if any object can be nil or the other type, you should use if let:
if let dict = cellArray[indexPath.section] as? [String : AnyObject],
    rows = dict["rows"] as? [AnyObject],
    result = rows[indexPath.row] as? [String : AnyObject],
    title = result["title"] {
    cell.textLabel?.text = title
}

A: You should generally avoid collections with elements of different types in Swift. Your section data is a dictionary, the value of "section" key is a string while the value of "rows" key is an array. Try to replace this dictionary with a tuple.
var cellArray = [(String, [[String: String]])]()

override func viewDidLoad() {
    cellArray = [
        (
            "Melody",
            [
                [
                    "title" : "Wi-Fi / Pairing",
                    "icon" : "",
                    "action" : "actionConnectSpeaker"
                ],
                [
                    "title" : "Sound",
                    "icon" : "",
                    "action" : "actionConnectSpeaker"
                ]
            ]
        ),

        (
            "Music",
            [
                [
                    "title" : "Add a new account",
                    "icon" : "",
                    "action" : "actionAddAccount"
                ]
            ]
        )
    ]
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = UITableViewCell(style: UITableViewCellStyle.Value2, reuseIdentifier: nil)

    cell.textLabel?.text = cellArray[indexPath.section].1[indexPath.row]["title"]

    return cell
}

This way Swift's type system can help you make sure you are using the right type, no force downcasting is needed.


text:
Q: JAXB - List? I made some classes using xjc.
    public class MyType {

    @XmlElementRefs({
        @XmlElementRef(name = "MyInnerType", type = JAXBElement.class, required = false),

    })
    @XmlMixed
    protected List<Serializable> content;

    public List<Serializable> getContent() {
        if (content == null) {
            content = new ArrayList<Serializable>();
        }
        return this.content;
    }
}

But i cant add inner elements using
getContent().add(newItem);

because MyInnerType is not Serializable.
Why its not a List of Objects? How do i add inner elements?

A: Please take a look here and here (one should for sure address your scenario).
From 2nd link:
<!-- schema fragment having  mixed content -->
<xs:complexType name="letterBody" mixed="true">
<xs:sequence>
    <xs:element name="name" type="xs:string"/>
    <xs:element name="quantity" type="xs:positiveInteger"/>
    <xs:element name="productName" type="xs:string"/>
    <!-- etc. -->
</xs:sequence>
</xs:complexType>
<xs:element name="letterBody" type="letterBody"/>

// Schema-derived Java code:
// (Only annotations relevant to mixed content are shown below,
//  others are ommitted.)
import java.math.BigInteger;
public class ObjectFactory {
    // element instance factories
    JAXBElement<LetterBody> createLetterBody(LetterBody value);
    JAXBElement<String>     createLetterBodyName(String value);
    JAXBElement<BigInteger> createLetterBodyQuantity(BigInteger value);
    JAXBElement<String>     createLetterBodyProductName(String value);
  // type instance factory
    LetterBody> createLetterBody();
}

public class LetterBody {
    // Mixed content can contain instances of Element classes
    // Name, Quantity and ProductName. Text data is represented as
    // java.util.String for text.
    @XmlMixed
    @XmlElementRefs({
            @XmlElementRef(name="productName", type=JAXBElement.class),
            @XmlElementRef(name="quantity", type=JAXBElement.class),
            @XmlElementRef(name="name", type=JAXBElement.class)})
    List getContent(){...}
}

A: What do you think you should be adding in there? I have used similar generation and had fields like this and the expectation was that it would be String content.
It'd probably help to show the xsd this was generated from.

A: May be helpful for smbd now.
You have to use:
getContent().add(new JAXBElement<>(new QName("MyInnerType"), MyInnerType.class, myInnerTypeInstance);


text:
Q: Is Google provides Android Icons related to application? From where i have get Android icons in different colors like search, add new, Navigation etc...
Is there any website which provides freely or should but those icon? if so from where  i have to download/buy whats the process?
I need common icons (were mentioned above) for all android applications in different colors

A: I can think of 3 scenarios:

*

*U can use some resources from the system's image directory directly.
You have to point to android.R.drawable....(instead of
R.drawable.... to get those list of images.

*There will be some others with will be in
sdk\platforms\android-17\data\res\...

*If you can't get those images in these, search in net


text:
Q: Query to count the number of tables I have in MySQL I am growing the number of tables I have and I am sometimes curious just to do a quick command line query to count the number of tables in my database.  Is that possible?  If so, what is the query?

A: To count number of tables just do this:
USE your_db_name;    -- set database
SHOW TABLES;         -- tables lists
SELECT FOUND_ROWS(); -- number of tables

Sometimes easy things will do the work.

A: This will give you names and table count of all the databases in you mysql
SELECT TABLE_SCHEMA,COUNT(*) FROM information_schema.tables group by TABLE_SCHEMA;

A: SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'dbName';

Source
This is mine:
USE databasename;
SHOW TABLES;
SELECT FOUND_ROWS();

A: SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'database_name';

A: In case you would like a count all the databases plus a summary, please try this:
SELECT IFNULL(table_schema,'Total') "Database",TableCount
FROM (SELECT COUNT(1) TableCount,table_schema
      FROM information_schema.tables
      WHERE table_schema NOT IN ('information_schema','mysql')
      GROUP BY table_schema WITH ROLLUP) A;

Here is a sample run:
mysql> SELECT IFNULL(table_schema,'Total') "Database",TableCount
    -> FROM (SELECT COUNT(1) TableCount,table_schema
    ->       FROM information_schema.tables
    ->       WHERE table_schema NOT IN ('information_schema','mysql')
    ->       GROUP BY table_schema WITH ROLLUP) A;
+--------------------+------------+
| Database           | TableCount |
+--------------------+------------+
| performance_schema |         17 |
| Total              |         17 |
+--------------------+------------+
2 rows in set (0.29 sec)

Give it a Try !!!

A: SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'dbo' and TABLE_TYPE='BASE TABLE'

A: There may be multiple ways to count the tables of a database. My favorite is this on:
SELECT
    COUNT(*)
FROM
    `information_schema`.`tables`
WHERE
    `table_schema` = 'my_database_name'
;

A: select name, count(*) from DBS, TBLS
where DBS.DB_ID = TBLS.DB_ID
group by NAME into outfile '/tmp/QueryOut1.csv'
fields terminated by ',' lines terminated by '\n';

A: from command line :
mysql -uroot -proot  -e "select count(*) from
information_schema.tables where table_schema = 'database_name';"

in above example root is username and password , hosted on localhost.

A: SELECT COUNT(*) FROM information_schema.tables

A:
mysql> show tables;

it will show the names of the tables, then the count on tables.
source

A: Hope this helps, and returns only number of tables in a database
Use database;

SELECT COUNT(*) FROM sys.tables;


text:
Q: testing out opencv's resizing functions but i keep getting this error been tinkering with python's open cv library and wanted to try resizing an image.
import cv2 as cv

img = cv.imread("photos/volcano.JPEG")

if img is None:
    sys.exit("Could not read the image.")

def rescaled_img(img, scale=.5):
    width = int(img.shape[2] * scale)
    height = int(img.shape[2] * scale)
    dimensions = (width, height)

    return cv.resize(dimensions, img, interpolation=cv.INTER_AREA)

imgresized = rescaled_img(img)

cv.imshow("volcano", img)
cv.imshow("resized", imgresized)

k = cv.waitKey(0)

if k == ord("s"):
    cv.imwrite("volcano.JPEG", img)

after running this code on the atom text editor's console i get:
return cv.resize(dimensions, img, interpolation=cv.INTER_AREA)
cv2.error: OpenCV(4.5.2) :-1: error: (-5:Bad argument) in function 'resize'
> Overload resolution failed:
>  - Can't parse 'dsize'. Expected sequence length 2, got 1271
>  - Can't parse 'dsize'. Expected sequence length 2, got 1271

Any idea what as to what I am doing wrong?
I am still new to coding and using stackoverflow so I apologize if I sound ignorant here.

A: I think you got the parameter order wrong in cv.resize
return cv.resize(dimensions, img, interpolation=cv.INTER_AREA)

This is the function I use:
def resize(src, factor, interpolation=cv.INTER_AREA):
    """ Resizes an image by the specified factor keeping the aspect ratio

    :param src: Image to be resized
    :param scale: Resize factor
    :param interpolation:
    :return: Resized image
    """
    height = src.shape[0]
    width = src.shape[1]
    dimensions = (int(height*factor), int(width*factor))
    return cv.resize(src, dimensions, interpolation)

Also, you can use imutils library (https://github.com/jrosebr1/imutils), that already implements a couple of useful functions for OpenCV.

A: i got the answer for your problem.
you have to convert your width and height to integer numbers to use them.
see my resize function code:
def rescaleimage(frame,scale,interpolation=cv.INTER_AREA):
   width = int(frame.shape[1] * scale)
   height = int(frame.shape[0] * scale)
   dimensions = (width,height)
   return cv.resize(frame,dimensions,interpolation)


text:
Q: If statement within Wordpress Good morning, I'm building a website for a client, I'm using Wordpress for the CMS and my PHP knowledge is very limited. I'm using the Custom Fields Plugin and I'm trying to add an if statement within the template to show the meta data if it the field is filled out within the CMS, this is what I have at the moment, but it still shows the button even if the meta field isn't filled out.
<?php if(get_field('owners_manual')) ?>
<?php {  ?>
    <a href="<?php the_field('owners_manual'); ?>" class="pdf-button" target=_"blank">Owners Manual
<?php }  ?>

<?php if(get_field('parts_booklet')) ?>
<?php {  ?>
    <a href="<?php the_field('parts_booklet'); ?>" class="parts-button" target=_"blank">Parts Booklet
<?php }  ?>

<?php if(get_field('sales_leaflet')) ?>
<?php {  ?>
    <a href="<?php the_field('sales_leaflet'); ?>" class="leaflet-button" target=_"blank">Sales Leaflet
<?php }  ?>

A: Try this
<?php if(get_field('owners_manual') != "") ?>
<?php {  ?>
    <a href="<?php the_field('owners_manual'); ?>" class="pdf-button" target=_"blank">Owners Manual
<?php }  ?>

<?php if(get_field('parts_booklet') != "") ?>
<?php {  ?>
    <a href="<?php the_field('parts_booklet'); ?>" class="parts-button" target=_"blank">Parts Booklet
<?php }  ?>

<?php if(get_field('sales_leaflet') != "") ?>
<?php {  ?>
    <a href="<?php the_field('sales_leaflet'); ?>" class="leaflet-button" target=_"blank">Sales Leaflet
<?php }  ?>

A: Resolved

                        <?php
                            if( get_field('owners_manual') ):
                            $owners_link = get_field('owners_manual');
                        ?>
                        <a href="<?php echo $owners_link ?>" class="pdf-button" target=_"blank">Owners Manual
                        <?php endif; ?>

                        <?php
                            if( get_field('parts_booklet') ):
                            $parts_link = get_field('parts_booklet');
                        ?>
                        <a href="<?php echo $parts_link ?>" class="parts-button" target=_"blank">Parts Booklet
                        <?php endif; ?>

                        <?php
                            if( get_field('sales_leaflet') ):
                            $sales_link = get_field('sales_leaflet');
                        ?>
                        <a href="<?php echo $sales_link ?>" class="leaflet-button" target=_"blank">Sales Leaflet
                        <?php endif; ?>


text:
Q: You must `await server.start()` before calling `server.applyMiddleware()` he estado tratando de resolver dicho error. Pero cuando coloco la función await.starServer () la consola de Vs Code se tilda y no ejecuta el código. Lo he intentado correr con git bush here y lo mismo. Lo extraño es que cuando borro dicha función el código se ejecuta saltando el error que coloqué en el título. Me podrían indicar por favor como lo puedo solucionar o si encuentran algún error en el código. Yo no tengo experiencia desarrollando y debo cumplir con un tiempo estipulado para no perder una beca. Ah y me falto aclarar que lo estoy configurando con formato Ts.

import { Query, Resolver } from "type-graphql";

@Resolver()

export class bookresolver {
    @Query (() => String)
    getAll () {

        return "All my books";

    };

}

Archivo server.ts

import express from "express";
import "reflect-metadata";
import { ApolloServer } from "apollo-server-express";
import { buildSchema } from "type-graphql";
import { bookresolver } from "./resolvers/book.resolver";

export async function startServer() {
     const app = express();

     const server = new ApolloServer({
         schema: await buildSchema({ resolvers: [bookresolver] })
     });

 start.Server()
     server.applyMiddleware({app, path: "/graphql" })

     return app;

};

Muchas gracias.