text:
Q: updating JTable date For initialization:
Vector<Vector> rowdata = new Vector<Vector>();
Vector columnname = new Vector();
JTabel result = new JTable(rowdata, columnname);
JScrollPane sqlresult = new JScrollPane(result);

In the later part, I assign values in rowdata and columnname vector. How to show new values in JTable on GUI?
In addition..
result.repaint();

..and..
((DefaultTableModel)result.getModel()).fireTabelDataChanged()

..seem to do nothing.

A: 1) use DefaultTableModel for JTable
2) define Column Class
3) add row(s) DefaultTableModel.addRow(myVector);
for example
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;

public class DefaultTableModelDemo {

    public static final String[] COLUMN_NAMES = {
        "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"
    };
    private DefaultTableModel model = new DefaultTableModel(COLUMN_NAMES, 0);
    private JTable table = new JTable(model);
    private JPanel mainPanel = new JPanel(new BorderLayout());
    private Random random = new Random();

    public DefaultTableModelDemo() {
        JButton addDataButton = new JButton("Add Data");
        JPanel buttonPanel = new JPanel();
        buttonPanel.add(addDataButton);
        addDataButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                addDataActionPerformed();
            }
        });
        model = new DefaultTableModel(COLUMN_NAMES, 0) {

            private static final long serialVersionUID = 1L;

            @Override
            public Class getColumnClass(int column) {
                return getValueAt(0, column).getClass();
            }
        };
        table = new JTable(model) {

            private static final long serialVersionUID = 1L;

            @Override
            public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
                Component c = super.prepareRenderer(renderer, row, column);
                if (isRowSelected(row) && isColumnSelected(column)) {
                    ((JComponent) c).setBorder(new LineBorder(Color.red));
                }

                return c;
            }
        };
        mainPanel.add(new JScrollPane(table), BorderLayout.CENTER);
        mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    }

    private void addDataActionPerformed() {
        for (int i = 0; i < 5; i++) {
            Object[] row = new Object[COLUMN_NAMES.length];
            for (int j = 0; j < row.length; j++) {
                row[j] = random.nextInt(5);
            }
            model.addRow(row);
        }
    }

    public JComponent getComponent() {
        return mainPanel;
    }

    public static void main(String[] args) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                JFrame frame = new JFrame("DefaultTableModelDemo");
                frame.getContentPane().add(new DefaultTableModelDemo().getComponent());
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.pack();
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
            }
        });
    }
}

A: rowdata and columnname are used for the initialization of JTable, after the component JTable exists you need to use JTable.getColumnModel() and JTable.getModel() to add columns or rows.
Or JTable.addColumn(TableColumn aColumn) if you only wants to add a column.
Look here if you want to know how to add a row following an example.


text:
Q: Power series examples with different properties I'm trying to accumulate some examples of power series with certain properties according to an exercise in Abbott's analysis text. I'm having trouble developing examples for the following:
1) power series absolutely convergent on $[-1,1]$ and divergent elsewhere
2) converges conditionally at $-1$ and absolutely at $1$
3) converges conditionally at $-1$ and $1$
The ratio test seemed promising for $\#1$... Namely I thought I can find a series whose ratio limit is $<1$ at $x=1$ and $-1$, but this is difficult (easy to find series that diverge at those end points).
Examples and thoughts on creative strategies appreciated.

A: $1)$ Try $\sum x^n/n^2$
$2)$ A power series takes the form $\sum a_n x^n$. If we have absolute convergence at $1$, then $\sum |a_n|$ is convergent. At $-1$, the series is $\sum (-1)^n a_n$, so it must converge absolutely. Thus, such an example doesn't exist.
$3)$ Consider $\sum a_n x^n$, where $a_n =0$ for odd $n$ and $a_n = (-1)^{n/2}/n$ for even $n$. The series is just $$\sum_{k=1}^{\infty} \frac{(-1)^k}{2k} x^{2k}$$

redpajama_set_name: RedPajamaStackExchange


text:
Q: reactjs function call returns undefined even when function has value The following client code calls a function
export async function verifyImage (image ) {

  const data = new FormData();
  ...

    let moderated;

          await verifyImage (image).then(function (response) {
            moderated = response;
          });

          console.log(moderated); //why is this always undefined?

and the function code is
  await axios({
    method: 'post',
    url:'https://api.someapi.com/1.0/check.json',
    data: data,
    headers: { 'Content-Type': 'multipart/form-data' },
  })
  .then(function (response) {
    // on success: handle response
    console.log("resp in moderate pics")
    console.log(sendVerifyResponse (response.data))
    const moderated = sendVerifyResponse (response.data);
    return moderated;
  })
  .catch(function (error) {
    // handle error
    if (error.response) console.log(error.response.data);
    else console.log(error.message);
    return false;
  });

The following log shows the correct values
console.log(sendVerifyResponse (response.data))

But return moderated; is always undefined.


text:
Q: Slim Framework how to capture route parameter by Name in interceptor I'm using v2 of Slim framework. Most of the APIs are of the format below:
https://abcXX.com/:version/customer/:CustomerID/XXX/....
So almost all of the APIs have :version and :CustomerID which is provided in the URL.
I'm writing a hookup like so, and wanted to know if there is any way to globally intercept it in hookup function
public function call()
{

    $this->app->hook('slim.before.dispatch', array($this, 'onBeforeDispatch'));
    $this->next->call();
}

public function onBeforeDispatch()
{
    $this->app->is_development_environment = IS_DEVELOMPENT_ENVIRONMENT;
    $route_params = $this->app->router()->getCurrentRoute()->getParams();
    $param_version = ???
}

I don't know how to get the :version's value from URL parameters. If I could do that, I'd be able to do some global handling at the very top, instead of having to write the code in each API handler function.
Please suggest how to do this.

A: I recommend avoiding hooks for determining which version of your API is being called. Consider grouping routes instead.
And I suggest using middlewares instead of hooks unless you really need hooks, they are different in nature.
Anyway, if you want to use hooks, here is an example of how to do it:
<?php
require_once ('../vendor/autoload.php');

$app = new \Slim\Slim();

$app->hook('slim.before.dispatch', function() use($app){
    $params = $app->router()->getCurrentRoute()->getParams();
    // Use $params['version'] to do what you want
    print "<pre>";
    print_r($params);
    print "</pre>";

});

$app->get('/:version/hello/:name', function ($version, $name) {
        print "Hello, " . $name;
});

$app->get('/:version/customer/:CustomerID/XXX', function($version, $customerId){
    print "Customers route";
});

$app->run();

Now if you open <host address>/2.1/hello/foo or <host address>/2.1/customer/1000/XXX you see in both cases you see ['version'] => 2.1 in $params.
But if you go with this approach, I think you should define all your route callbacks to accept a $version as their first parameter, which is absolutely unnecessary and redundant and makes code manipulation harder. But if you group routes, then you'll have something like:
$app->group('/2.1', function () use ($app {
    $app->get('/hello/:name', function ($name) {});
    $app->get('/customer/:CustomerID/XXX', function($customerId){});
});

which is cleaner and does not need extra effort.

A: Use Callback Function or Make a function to get params like it :-
$app->get('/books/:one/:two', function ($one, $two) {
    echo "The first parameter is " . $one;
    echo "The second parameter is " . $two;
});


text:
Q: Determining a Missing Data Value in Weighted Average When dealing with weighted averages, how do you solve for X?
$$
\frac{(  84X) + (40*16)}{100} = 10.5 .
$$

A: Here are the steps:

*

*Remove the fraction by multiplying both sides by $100$.

*Isolate the $X$ term by subtracting the $(40*16)$ from both sides.

*Remove the coefficient of $X$ by dividing both sides by $84$.


text:
Q: How to display the category so in WordPress? List:

Category: level 1

After select level 1, show:

Category: level 2 (level 3 / level 3 / level 3)
Category: level 2 (level 3 / level 3 / level 3)
Category: level 2 (level 3 / level 3 / level 3)
Category: level 2 (level 3 / level 3 / level 3)

Any idea or tutorial.
Thank you.

A: are you trying to build a drop down on hover? Do you have ul and li's ?
See this : jsfiddle.net/amkrtchyan/4jxph/2/


text:
Q: Replace just the text on a web page via Jquery Using Tampermonkey I want to reverse the text on the bbc news website (why? because), obviously this is locally only. I have already written something to replace a part of it, the problem is accessing all the text on the page. Is there an efficient way of doing this in JQuery?
e.g. I have a reverse() function, given:

  Text1
  Text2
  <fieldset>
    <legend>Text3</legend>

Is there some way of targetting Text1, Text2 and Text3 without touching anything else? I can write something to explicitly check the tagName while traversing the DOM and hope there's a text type, or something similar, but I'm wondering if JQuery already has something for doing this?
thanks

A: Reverse away!

$('*').contents().filter(function() {
  return this.nodeType === 3;
}).each(function() {
  this.nodeValue = esrever.reverse(this.nodeValue);
});

  Text1
  Text2
  <fieldset>
    <legend>Text3</legend>


text:
Q: What does this mean in sql? ... WHERE T1.x = T2.y I found this in someones code and it does not compare columns as it looks like, so i wonder what does it acctually compare? Is it all rows from T1 that are included in T2? Or does it compare current comparing value of T1 with current comparing value of T2? Or something else? Database used is Access
full example:
SELECT T1.id , T2.user_id FROM table1 T1, table2 T2 WHERE T1.id = T2.user_id

A: If you have 6 'A's in the ID field of table1 and 4 'A's in user_id from Table2 you will have 24 pairs of 'A's in the output.  (that is if the person didn't know what an ID field was of course.  ID's are supposed to be Unique.)
Oh and stop using Access.  You might like it to learn SQL but you can't do much of anything with it when you start your project.


text:
Q: EF7 MVC ASP.NET File upload in form I'm trying to upload a file alongside with some model information.
In my table I already have a field 'image' (string) to save the relative URL to the image.
But I don't really know how to do the uploading itself.
I've already read a lot off tutorials, but they all use HttpPostedFileBase, which isn't supported anymore?
This is what I have thus far:
Upload page:
@using (Html.BeginForm("Lets", "Create", FormMethod.Post, new { @enctype = "multipart/form-data" }))
            {
                @Html.AntiForgeryToken()
                <fieldset>

                            @Html.LabelFor(m => m.Lets.Name, new { @class="mdl-textfield__label" })
                            @Html.TextBoxFor(m => m.Lets.Name, new { @class= "form-control mdl-textfield__input" })

                            @Html.LabelFor(m => m.Lets.Images)
                            <input type="file" name="LetsImages" id="m.Lets.Images" />

                            @Html.LabelFor(m => m.Lets.Description, new { @class="mdl-textfield__label" })
                            @Html.TextBoxFor(m => m.Lets.Description, new { @class= "form-control mdl-textfield__input" })

                            @Html.LabelFor(m => m.Lets.Credits, new { @class="mdl-textfield__label" })
                            @Html.TextBoxFor(m => m.Lets.Credits, new { @class= "form-control mdl-textfield__input" })

                            @Html.LabelFor(m => m.Lets.Group)
                            @Html.DropDownListFor(m => m.Lets.GroupId, new SelectList(Model.Groups, "Id", "Name"), "-- Selecteer een Groep --", new { @class= "form-control" })

                    @Html.ActionLink("Terug naar het overzicht", "Index", new { }, new { @class= "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" })
                    <input type="submit" value="Save" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" />
                </fieldset>
            }

Controller:
 [HttpGet]
    public IActionResult Create()
    {
        var model = new LetsViewModel
        {
            Lets = new Lets(),
            Groups = _kletsContext.Groups.AsEnumerable(),
            Letses = _kletsContext.Lets.AsEnumerable().OrderBy(m => m.Name)
        };

        return View(model);
    }

    [HttpPost]
    [ValidateAntiForgeryToken]
    public IActionResult Create(LetsViewModel model)
    {
        LetsViewModel viewModel = null;
        try
        {
            if(!ModelState.IsValid)
                throw new Exception("The Lets model is not valid!");

                var letsImage = "INSERT LOGIC FOR IMAGEUPLOAD HERE?";
                model.Lets.UserId = User.GetUserId();
                model.Lets.StatusId = 1;
                model.Lets.Images = letsImage;

            _kletsContext.Lets.Add(model.Lets);
            if (_kletsContext.SaveChanges() == 0)
            {
               throw new Exception("The Lets model could not be saved!");
            }

            //Success(CreateMessage(ControllerActionType.Create, "klets", model.Name), true);

        return RedirectToAction("Index", "Home");

        }
        catch(Exception ex)
        {
            ModelState.AddModelError(string.Empty, "Unable to save changes.");

            viewModel = new LetsViewModel
            {
                Lets = model.Lets,
                Letses = _kletsContext.Lets.AsEnumerable().OrderBy(m => m.Name)
            };
        }
        return View(viewModel);
    }

I've added the place where I think the logic should come?
So what I want to do is:
Upload the Image to a folder
Rename it
Store the relative path as a string to the db.
Thank you

A: There is no HttpPostedFileBase in MVC6, you have to use IFormFile like this:
public FileDetails UploadSingle(IFormFile file)
{
    FileDetails fileDetails;
    using (var reader = new StreamReader(file.OpenReadStream()))
    {
        var fileContent = reader.ReadToEnd();
        var parsedContentDisposition = ContentDispositionHeaderValue.Parse(file.ContentDisposition);
        fileDetails = new FileDetails
        {
            Filename = parsedContentDisposition.FileName,
            Content = fileContent
        };
    }

    return fileDetails;
}

A: You can upload images using handlers , link to tutorials are
http://www.c-sharpcorner.com/blogs/uploading-files-using-jquery-ajax-in-asp-net1
http://www.binaryintellect.net/articles/f2a2f1ee-e18a-416b-893e-883c800f83f4.aspx
http://www.dotnetjalps.com/2011/12/async-file-upload-with-jquery-and.html?m=1
These tutorials are using jquery to pass the image to the handler and then handler saving the image in the folder. You can rename the image before uploading to the folder and get back the saved image name in response and then save image name along with other model properties.

A: I eventually got it working by:

*

*include using Microsoft.AspNet.Hosting; and using System.IO;
using System.Net.Http.Headers;

*Add public IHostingEnvironment _environment { get; set;}
to your controller (I added it to my commoncontroller, and then it's available to me on my controller)

*Then in my create:
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Create(LetsViewModel model, IFormFile LetsImages)
{
    LetsViewModel viewModel = null;
    try
    {
        if(!ModelState.IsValid)
            throw new Exception("The Lets model is not valid!");

            if(LetsImages != null)
            {
                    var targetDirectory = Path.Combine(_environment.WebRootPath, string.Format("images/uploads"));
                    var fileName = ContentDispositionHeaderValue
                    .Parse(LetsImages.ContentDisposition)
                    .FileName
                    .Trim('"');
                    var savePath = Path.Combine(targetDirectory, fileName);
                    var relPath = "/images/uploads/" + fileName;
                    try
                    {
                        LetsImages.SaveAs(savePath);
                        model.Lets.Images = relPath;
                    }
                    catch
                    {
                        throw new Exception("There was a problem with saving the file!");
                    }
            }
            else
            {
                model.Lets.Images = null;
            }
            model.Lets.UserId = User.GetUserId();
            model.Lets.StatusId = 1;

        _kletsContext.Lets.Add(model.Lets);
        if (_kletsContext.SaveChanges() == 0)
        {
           throw new Exception("The Lets model could not be saved!");
        }

        //Success(CreateMessage(ControllerActionType.Create, "klets", model.Name), true);

    return RedirectToAction("Index", "Home");

    }
    catch(Exception ex)
    {
        ModelState.AddModelError(string.Empty, "Unable to save changes.");

        viewModel = new LetsViewModel
        {
            Lets = model.Lets,
            Groups = _kletsContext.Groups.AsEnumerable(),
            Letses = _kletsContext.Lets.AsEnumerable().OrderBy(m => m.Name)
        };
    }
    return View(viewModel);
}

Just make sure you've created the folder where the images should belong, else it's not going to work without any error!
Thanks everybody for your help!


text:
Q: Testing simple Loading+fetch flow with Coroutines as Android Instrumented tests with StandardTestDispatcher I want to test the following very common usecase as an Instrumented Test in Android:

*

*When clicking a button a fetch() function is called in my ViewModel

*This function tells the view to show a loading-overlay

*It executes a fetch in a coroutine

*After the result is fetched it lets the view know to display the result

Here is the function in my Viewmodel:
fun fetch() {
    _loading.value = true //loading is shown
    viewModelScope.launch {
        val results = fetchUseCase() //suspend function
        _result.postValue(results)
        _loading.postValue(false) //loading is not displayed
    }
}

Here is the test which works according to this CodeLab https://developer.android.com/codelabs/advanced-android-kotlin-training-testing-survey#4:
@HiltAndroidTest
@UninstallModules(CoroutinesDispatcherModule::class)
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTestJunit4Deprecated {

@get:Rule
var hiltRule = HiltAndroidRule(this)

@ExperimentalCoroutinesApi
@get:Rule
var mainCoroutineRule = MainCoroutineRule()

@Before
fun setup() {
    ActivityScenario.launch(HomeScreenActivity::class.java)
}

@ExperimentalCoroutinesApi
@Test
fun fetchTest() {

    //pausing the long running tasks
    mainCoroutineRule.pauseDispatcher()

    //When clicking the button
    onView(withId(R.id.load_measurement_button)).perform(click())

    //loading is shown
    onView(withId(R.id.loading_overlay))
        .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))

    //continue fetch
    mainCoroutineRule.resumeDispatcher()

    // loading is not shown anymore and the result is there
    onView(withId(R.id.loading_overlay))
        .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
    onView(withId(R.id.message))
        .check(matches(withText("0")))
}
}

Unfortunately "pauseDispatcher()" and "resumeDispatcher" are Deprecated. I tried to use the "StandardTestDispatcher" and "advanceUntilIdle()" but it does not work as expected. The coroutine is never resumed. How can this test be rewritten, such that it works:

*

*Without deprecated function calls

*Without changing the productive code
?


text:
Q: dplyr equivalent of sql row_number() over (partition by group order by value) Initial situation
I have a data set of the following form:
library(dplyr)

dat <- tribble(
  ~name, ~iq,
  "ben",  100,
  "alex",  98,
  "mia",  110,
  "paco", 124,
  "mia",  112,
  "mia",  120,
  "paco", 112,
  "ben",   90,
  "alex", 107
)

I'd like to create a new column which ranks, grouped by name, the values iq in descending order. In SQL one could write
select
  name,
  iq,
  row_number() over (partition by name order by iq desc) as rank
from
  dat;

which would produce the following expected output (already ordered for simplicity):
#>   name     iq  rank
#>   <chr> <dbl> <int>
#> 1 alex    107     1
#> 2 alex     98     2
#> 3 ben     100     1
#> 4 ben      90     2
#> 5 mia     120     1
#> 6 mia     112     2
#> 7 mia     110     3
#> 8 paco    124     1
#> 9 paco    112     2

Questions
With my data, one can achieve the desired result with:
dat %>%
  group_by(name) %>%
  mutate(rank = with_order(order_by = iq,
                           fun      = row_number,
                           x        = desc(iq)
                           )
         ) %>%
  arrange(name, rank)

#> # A tibble: 9 x 3
#> # Groups:   name [4]
#>   name     iq  rank
#>   <chr> <dbl> <int>
#> 1 alex    107     1
#> 2 alex     98     2
#> 3 ben     100     1
#> 4 ben      90     2
#> 5 mia     120     1
#> 6 mia     112     2
#> 7 mia     110     3
#> 8 paco    124     1
#> 9 paco    112     2

However, I don't understand why the code works. When reading the documentation of dplyr::with_order(), it says the arguments are

*

*order_by = the vector to order by

*fun      = window function

*x, ...   = arguments to f
Given the description in the documentation and the working code, I have two questions I cannot answer:

*

*What is the purpose of the argument x? Why not just specify the vector to order by and the window function (like in sql)? What is meant by f?

*Why don't I have to write order_by = desc(iq)? To get the result I expect I have to write x = desc(iq) and set order_by = iq. This seems to contradict the documentation, which states that order_by = the vector to order by.


text:
Q: Is there any way to see how much space i am using in my yahoo mail I have many thousands of emails in yahoo mail.
Is there any way to see how much disk space that covers

A: No, there is not. However, for general usage this shouldn't be a problem since Yahoo offers 'unlimited' space.
Apart from that, you'd have to have all your emails in another client/service to determine their total size...


text:
Q: Drupal 8 - Load Slow Drupal 8 load really slow; front end and back end both are slow. Big pipe is enable by default, but it's still load very slow. I have over thousand of nodes. Anyway can make it load faster?

A: I suggest you should try Pantheon:
https://pantheon.io/
It provides two free sandbox websites with the free account.I've been using it for quite some time to host Drupal 8 websites and it has indeed been a great experience.

A: Use redis cache and cache all blocks within the site.
https://www.drupal.org/project/redis


text:
Q: std::ostream to QString? Is there a way to convert an std::ostream to a QString?
Allow me to expand in case it is useful:
I am writing a program in C++/Qt and I used to (not) deal with / debug exceptions by just using std::cout, as in for example:
std::cout << "Error in void Cat::eat(const Bird &bird): bird has negative weight" << std::endl;

Now I want to throw errors as QStrings and catch them later, so I would now write instead:
throw(QString("Error in void Cat::eat(const Bird &bird): bird has negative weight"));

My issue is that I've been overloading the operator << so that I can use it with many objects, for instance a Bird, so I would actually have written:
std::cout << "Error in void Cat::eat(const Bird &bird): bird " << bird << " has negative weight" << std::endl;

Is there a way that I can throw this as a QString now? I would like to be able to write something like:
std::ostream out;
out << "Error in void Cat::eat(const Bird &bird): bird " << bird << " has negative weight" << std::endl;
throw(QString(out));

but that doesn't work. What should I do?

A: You can use an std::stringstream as follows:
std::stringstream out;
//   ^^^^^^
out << "Error in void Cat::eat(const Bird &bird): bird " << bird << " has negative weight" << std::endl;
throw(QString::fromStdString(out.str()));
//           ^^^^^^^^^^^^^^^^^^^^^^^^^^

Specifically, the std::stringstream::str member function will get you an std::string, which you can then pass to the QString::fromStdString static member function to create a QString.

A: The std::stringstream class can receive input from overloaded << operators. Using this, combined with its ability to pass its value as a std::string, you can write
#include <sstream>
#include <QtCore/QString>

int main() {
    int value=2;
    std::stringstream myError;
    myError << "Here is the beginning error text, and a Bird: " << value;
    throw(QString::fromStdString(myError.str()));
}


text:
Q: How can I differentiate between a directory and a file path in python? I have written the following source code to test whether a string is a directory or a file.
import platform
from PathValidation import PathValidation # https://stackoverflow.com/a/34102855/159072

class SystemUtils:
    @staticmethod
    def is_file(path_string: str) -> bool:
        return not SystemUtils.is_directory(path_string)

    @staticmethod
    def is_directory(path_string: str) -> bool:
       is_win_os = SystemUtils.is_windows()

        if is_win_os is True:
            path_string = SystemUtils.to_windows_path(path_string)
        else:
            path_string = SystemUtils.to_unix_path(path_string)

        valid = PathValidation.is_pathname_valid(path_string)

        if valid is False:
           return False

        if is_win_os is True:
            if path_string.startswith("\\") or path_string.endswith("\\"):
                return True
        else:
            if path_string.startswith("/") or path_string.endswith("/"):
                return True
        # END of outer if
        return False

    @staticmethod
    def to_windows_path(path_string) -> str:
        path_string = path_string.replace("/", "\\")
        return path_string

    @staticmethod
    def to_unix_path(path_string) -> str:
        path_string = path_string.replace("\\", "/")
        return path_string

    @staticmethod
    def is_windows() -> bool:
        system_type = platform.system()
        if system_type == "Windows":
            return True
        else:
            return False

    @staticmethod
    def is_linux() -> bool:
        system_type = platform.system()
        if system_type == "Linux":
            return True
        else:
            return False

    @staticmethod
    def is_darwin() -> bool:
        system_type = platform.system()
        if system_type == "Darwin":
            return True
        else:
            return False

Can anyone suggest any better technique?

A: use pathlib.Path, in the std library.
from pathlib import Path

path_string = "xxx"

pa = Path(path_string)

print(f"{pa.is_file()}")
print(f"{pa.is_dir()}")


text:
Q: C++ dynamic array, increasing capacity I'm trying to implement a dynamic array and here is my function for increasing the capacity
int* changeCapacity(int *arr, int length, int newCapacity) {
    int *newArr = new int[newCapacity];

    if(length > newCapacity){
        return 0;
    } else {
        for(int i = 0; i < length; i++){
            newArr[i] = arr[i];
        }
        delete[] arr;
        arr = newArr;
        return arr;
    }
}

This is the error i get:

speicher(2465,0x7fff7cfc2310) malloc: * error for object 0x7f9742403910: pointer being freed was not allocated
  * set a breakpoint in malloc_error_break to debug

i'm calling it like this:
int* addElement(int *arr, int& length, int& capacity, int val){
if(length >= capacity){
    capacity = capacity * 2;
    changeCapacity(arr, length, capacity);

    arr[length] = val;
    length += 1;
    return arr;
}else{

    arr[length] = val;
    length += 1;
    return arr;
}

}

A: I assume that your problem must come from two things IMO :
First:
changeCapacity(arr, length, capacity);
arr[length] = val;

Here you doesn't get the new arr value (returned by changeCapacity()).
So your function addElement() will return Wrong pointer and on your next addElement() that will do free memory corruption.
Why do you have to get the new arr value?
You do the same as here
a = 1;
changeVar(a);
// value of a here?

int changeVar(int a)
{
   a = 5;
   return (a);
}

How will be the value of a? 1 because the argument of changeVar is a local variable.
Second:
You give a NULL value on your addElement() function.

A: Right now you are changing the address of arr, in which you have to pass the pointer by reference. Do this:
int* changeCapacity(int *&arr, int length, int newCapacity)

A: This is somewhat a guess based on the error message, but you have shown:
int* addElement(int *arr, int& length, int& capacity, int val)
{ //...
  changeCapacity(arr, length, capacity);
  //...
}

which calls:
int* changeCapacity(int *arr, int length, int newCapacity)
{ //...
  delete[] arr;
  //...
}

However, the original source of the arr argument to addElement() is unknown given the code you have posted so far. Are you by chance doing something like this:
foo()
{ int array[N];
  //...
  addElement(array, ...);
  //...
}

or maybe calling addElement() with a global array variable? In either of those cases, the original array is not allocated via a new[] to match the delete[], and this would appear to be what the runtime library is complaining about. The value of the pointer stated in the error message tends to make me think it was allocated on the stack initially.
Of course the other issues, like not capturing the return value of changeCapacity() and/or addElement(), and the possibility that changeCapacity() might return a NULL pointer are still valid as well, and should be fixed.

A: Here is a better way of doing it. Everything is well explained in the comments for anyone who wants to learn:
        #include <iostream>
        using namespace std;

        int* changeCapacity(int *arr, int length, int newCapacity);
        int* addElement(int *arr, int& length, int& capacity, int val);

        int main(){
            int length = 0; // no inital elements in array
            int capacity = 1; // initial capacity is one
            int* arr = new int[capacity]; // allocating space for values
            int* temp; // pointer for storing temporary values
            /* loop for adding elements to the array */
            for(int i=0;i<21;i++){
                temp = addElement(arr,length,capacity,i); // adding an element to the array
                if(temp == NULL) { // checks if execution was successful
                    cout<< "NULL returned...\n Exiting Now...";
                    return 0; // exits the program on failure
                }
                arr = temp; // changing the value of arr
            }
            /* loop for printing the array */
            for(int i=0;i<length;i++){
                cout<<arr[i]<<" ";
            }
            return 0;
        }
        /* function for increasing the capacity of array */
        int* changeCapacity(int *arr, int length, int newCapacity) {
            int *newArr = new int[newCapacity]; // definging a new array

            if(length > newCapacity){ // checking if the length of the array is valid
                cout<< "invalid length of array\n";
                return NULL;
            } else {
                /* loop for transferring values to the new array */
                for(int i = 0; i < length; i++){
                    newArr[i] = arr[i];
                }
                delete[] arr; // deleting the old array (clears the memory of the old array)
                // arr = newArr; removed as this is not needed
                return newArr; // returns the new array
            }
        }

        /* function for adding a new element to the array */
        int* addElement(int *arr, int& length, int& capacity, int val){
        if(length >= capacity){ // checks if the array has space for storing the given value or not
            capacity = capacity * 2; // doubles the capacity of the array
            int* temp = changeCapacity(arr, length, capacity); // changes the size of the array to the new one
            if(temp == NULL){ // checking if a null was returned
                cout<< "Failed to change capacity\n";
                return NULL; // returning  NULL
            }
            arr = temp; // the value of arr was not changed in your code (problem corrected)
            arr[length] = val; // stores the value in the array
            length += 1; // increasing the number of element count of the array
            return arr; // returns the new array
        }else{
            arr[length] = val; // stores the value in the array
            length += 1; // increasing the number of element count of the array
            return arr; // returns the new array
        }
        }


text:
Q: Reload partial view using AJAX with Json response in Rails When I call $.getJSON, i want to reload tbody elements. In other words, I need to delete all elements and put new elements by Json response.
JS
$(document).ready(function(){
  $('#position').sortable({
    update: function(event, ui) {
        var newOrder = $(this).sortable('toArray').toString();
         $.getJSON('/save_positions.json', {ids:newOrder}, function(data){
            ??????
         });
    }
  });
});

My View
# index.html.erb

  <%= render :partial => "activities"%>

Partial View
#_activities.html.erb

<% @activities.each do |activity| %>
  <tr id='<%= activity.id %>'>
    <%= activity.position %>
    <%= link_to activity.id, activity_path(activity) %>
    <%= activity.name %>
    <%= activity.estimated %>
    <%= activity.used %>
    <%=l activity.created_at %>

My Action (Application Controller)
def save_positions
  @activities = Activity.all(:order => 'position')

  respond_to do |format|
    format.json { render :json => @activities }
  end
end

A: From your code I get the impression that what you're trying to do is generate new HTML server-side and insert it into the document. If that's the case, try something like this:
$.get( '/save_positions', { ids : newOrder } ).done( function( data ) {

  $( "#position" ).html( $( data ).html() );

} );

If you really want to return JSON, then you'll probably want to return an array of objects and iterate over it to generate new HTML, perhaps using a templating engine like Mustache, e.g.:
No template engine:
$.getJSON( '/save_positions.json', { ids : newOrder } ).done( function( data ) {

  var positions = [];

  $.each( data, function ( key, val ) {

    // generate an element
    var el = $( "
" );

    // ...

    positions.push( el );

  } );

  $( "#position" ).empty().append( positions );

} );

or
JS:
$.getJSON( '/save_positions.json', { ids : newOrder } ).done( function( data ) {

  var positions = Mustache.render( template, data );

  $( "#position" ).html( positions );

} );

Mustache template:
{{#positions}}

  {{activity.position}}
  {{activity.url}}
  {{activity.name}}
  {{activity.estimated}}
  {{activity.used}}
  {{activity.created_at}}

{{/positions}}


text:
Q: InternalFrame design changed I've been developing an app for a long time which has been working fine till lately the design of the swing component's got worse or maybe turned into an older version (You can see the difference in the header of the two images and the JCalender design which is a imported jarfile).
I've tryed creating a new project and copying the source into it still it stay's the same .
So could someone inform me what may be the reason of this happenening ?
The internal frame with the bad design.

The internal frame before this design change happened (How it used to look like).


text:
Q: Change of AppDelegate class on OSX I have a cocoa project on OSX. For that, I had to change the class of the Appdelegate.
I did this in two steps: First I implemented the new appdelegate class (I didn't implement the NSApplicationDelegate protocol yet) and checked if it worked and compiled. In the new class I already implemented the applicationDidFinishLaunching method. Everything was still fine!
After that I changed the protocol implementation. I removed the prorocol from the old Appdelegate and inserted it in the new one. Even after this step everything seemed to be fine! The application compiled and worked as it should. But as I was somewhat sceptical, I inserted log statements in the new and the old class.
After inserting this, I had to see, that the application still used the old appdelegate!
Obviously, there is something where the name of the old appdelegate is still known! But where is that? Or do I have to do something else to reach my goal? Does anyone know what I have to do?

A: There are two things that have to happen: 1) an instance of your new class has to be instantiated. 2) That instance needs to be assigned to the delegate property of the application object (instance of NSApplication or a subclass).
In a typical Mac app, both of those things are done in the MainMenu NIB. That NIB contains a freeze-dried instance of the appropriate class. If you were to build the NIB from scratch, you would drag an "Object" (blue cube) from the Object library to the NIB document. By default, that would represent an instance of NSObject. You would then select it and bring up the Identity inspector where you would change its class to your new app delegate class. Since you're not building the NIB from scratch, there's already an Object in the NIB. You can select it and change its class.
The other step, assigning it to the delegate property of the application object, is done by connecting the delegate outlet of the placeholder for the application object in the NIB to the object. Again, since you're not building the NIB from scratch, that's already done.
So, in summary, you just need to change the class of the app delegate object in the MainMenu NIB.

Update: Here's a screen shot of what you have to change:


text:
Q: Videos produced with ffmpeg don't have frame width or height properties? I am using the following to produce my intermediate slideshow mp4 clips
ffmpeg    -r 1 -f image2 -vcodec mjpeg      -i 01.jpg    -i 01.mp3    -codec:v libx264 -r 24    -codec:a copy -b:a 128k    -shortest -y  01.mp4

And the produced 01.mp4 plays OK however, the properties detail under Windows don't show any frame size width or height?  Why is that? This may be an issue, see below...
I also produced an intro clip in AfterEffect using H.264 to produce an MP4 file.
I later have problem when I try to concatenate these 01.mp4 ,02.mp4, 03.mp4 with the intro.mp4 using the command line
ffmpeg -f concat   -i MyFileList.txt  -c copy  -y output.mp4

The resulting output.mp4 video causes VLC player to crash right after it completes playing the intro segment.
my xx.jpg files are 1600x1200 and my intro.mp4 is 1920x1080 24fps so perhaps there is an issue there as well.
I am not able to make sense of the purple and yellow lines from ffmpeg output during the concat perhaps you can help interpret, the output is attached.
Feel free to change any of the ffmpeg options for the production of my slideshow temp files 01.mp4, .02.mp4, 03.mp4 ... or during the concat operation, it's been a lot of guess work on my part.
BTW, the reason I am using concat is because I thought at first ffmpeg would be able to iterate on images 01,02...jpg and matching them up with there 01,02,....mp3 sound files but apparently that is not possible with some command line like this :)
ffmpeg -i %02d.jpg -i %02d.mp3 .... output.mp4

Thank you.
===== output from concat follows:
ffmpeg version N-79000-g66edd86 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 19.100 / 55. 19.100
  libavcodec     57. 28.100 / 57. 28.100
  libavformat    57. 28.100 / 57. 28.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 39.102 /  6. 39.102
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000044c960] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'mylist.txt':
  Duration: N/A, start: 0.000000, bitrate: 2996 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 2964 kb/s, 24 fps, 24 tbr, 24k tbn, 48 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, mono, s16p, 32 kb/s
    Metadata:
      handler_name    : SoundHandler
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf57.28.100
    Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 2964 kb/s, 24 fps, 24 tbr, 24k tbn, 24k tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, mono, 32 kb/s
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000028558c0] Auto-inserting h264_mp4toannexb bitstream filter
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235984, current: 120320; changing to 235985. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235985, current: 120832; changing to 235986. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235986, current: 121344; changing to 235987. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235987, current: 121856; changing to 235988. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235988, current: 122368; changing to 235989. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235989, current: 122880; changing to 235990. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235990, current: 123392; changing to 235991. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235991, current: 123904; changing to 235992. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235992, current: 124416; changing to 235993. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235993, current: 124928; changing to 235994. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235994, current: 125440; changing to 235995. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235995, current: 125952; changing to 235996. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235996, current: 126464; changing to 235997. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235997, current: 126976; changing to 235998. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235998, current: 127488; changing to 235999. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 235999, current: 128000; changing to 236000. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236000, current: 128512; changing to 236001. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236001, current: 129024; changing to 236002. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236002, current: 129536; changing to 236003. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236003, current: 130048; changing to 236004. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236004, current: 130560; changing to 236005. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236005, current: 131072; changing to 236006. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236006, current: 131584; changing to 236007. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236007, current: 132096; changing to 236008. This may result in incorrect timestamps in the output file.
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000028558c0] Auto-inserting h264_mp4toannexb bitstream filter
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236008, current: 132841; changing to 236009. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236009, current: 133353; changing to 236010. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236010, current: 133865; changing to 236011. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236011, current: 134377; changing to 236012. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236012, current: 134889; changing to 236013. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236013, current: 135401; changing to 236014. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236014, current: 135913; changing to 236015. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236015, current: 136425; changing to 236016. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236016, current: 136937; changing to 236017. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236017, current: 137449; changing to 236018. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236018, current: 137961; changing to 236019. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236019, current: 138473; changing to 236020. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236020, current: 138985; changing to 236021. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236021, current: 139497; changing to 236022. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236022, current: 140009; changing to 236023. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236023, current: 140521; changing to 236024. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236024, current: 141033; changing to 236025. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236025, current: 141545; changing to 236026. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236026, current: 142057; changing to 236027. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236027, current: 142569; changing to 236028. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236028, current: 143081; changing to 236029. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236029, current: 143593; changing to 236030. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236030, current: 144105; changing to 236031. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236031, current: 144617; changing to 236032. This may result in incorrect timestamps in the output file.
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000028558c0] Auto-inserting h264_mp4toannexb bitstream filter
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236032, current: 145363; changing to 236033. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236033, current: 145875; changing to 236034. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236034, current: 146387; changing to 236035. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236035, current: 146899; changing to 236036. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236036, current: 147411; changing to 236037. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236037, current: 147923; changing to 236038. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236038, current: 148435; changing to 236039. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236039, current: 148947; changing to 236040. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236040, current: 149459; changing to 236041. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236041, current: 149971; changing to 236042. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236042, current: 150483; changing to 236043. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236043, current: 150995; changing to 236044. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236044, current: 151507; changing to 236045. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236045, current: 152019; changing to 236046. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236046, current: 152531; changing to 236047. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236047, current: 153043; changing to 236048. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236048, current: 153555; changing to 236049. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236049, current: 154067; changing to 236050. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236050, current: 154579; changing to 236051. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236051, current: 155091; changing to 236052. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236052, current: 155603; changing to 236053. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236053, current: 156115; changing to 236054. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236054, current: 156627; changing to 236055. This may result in incorrect timestamps in the output file.
[mp4 @ 00000000004ad480] Non-monotonous DTS in output stream 0:0; previous: 236055, current: 157139; changing to 236056. This may result in incorrect timestamps in the output file.
frame=  309 fps=0.0 q=-1.0 Lsize=    3986kB time=00:00:12.93 bitrate=2525.2kbits/s speed= 166x
video:3927kB audio:50kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.232265%

===== Here is the output from ffprobe on intro.mp4
ffprobe version N-79000-g66edd86 Copyright (c) 2007-2016 the FFmpeg developers
  built with gcc 5.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 19.100 / 55. 19.100
  libavcodec     57. 28.100 / 57. 28.100
  libavformat    57. 28.100 / 57. 28.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 39.102 /  6. 39.102
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'intro.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.28.100
  Duration: 00:00:09.88, start: 0.000000, bitrate: 3003 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 2964 kb/s, 24 fps, 24 tbr, 24k tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, mono, s16p, 32 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

===== Here is the output of ffprobe on one of intermediate clips here 01.mp4
ffprobe version N-79000-g66edd86 Copyright (c) 2007-2016 the FFmpeg developers
  built with gcc 5.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 19.100 / 55. 19.100
  libavcodec     57. 28.100 / 57. 28.100
  libavformat    57. 28.100 / 57. 28.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 39.102 /  6. 39.102
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '01.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.28.100
  Duration: 00:00:01.02, start: 0.000000, bitrate: 1036 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], 1006 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, mono, s16p, 31 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

===== ffmpeg output when generating 01.mp4 when using the following suggested fix:
ffmpeg -loop 1 -i 01.jpg -i 01.mp3 -c:v libx264 -profile:v main -pix_fmt yuv420p -r 24 -video_track_timescale 24000 -c:a copy -shortest -y 01.mp4

ffmpeg version N-79000-g66edd86 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 19.100 / 55. 19.100
  libavcodec     57. 28.100 / 57. 28.100
  libavformat    57. 28.100 / 57. 28.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 39.102 /  6. 39.102
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, image2, from 'S:\_W\ARP_WEB\RC\KIDS\QURAN\AAYAAT - Allah\01 AlKursi\BMP\01.JPG':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 25065 kb/s
    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1920x1080 [SAR 96:96 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
[mp3 @ 00000000005d03a0] Estimating duration from bitrate, this may be inaccurate
Input #1, mp3, from 'S:\_W\ARP_WEB\RC\KIDS\QURAN\AAYAAT - Allah\01 AlKursi\SND\01.MP3':
  Duration: 00:00:09.85, start: 0.000000, bitrate: 32 kb/s
    Stream #1:0: Audio: mp3, 44100 Hz, mono, s16p, 32 kb/s
[swscaler @ 0000000002b30c40] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 00000000005ba520] using SAR=1/1
[libx264 @ 00000000005ba520] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 00000000005ba520] profile Main, level 4.0
[libx264 @ 00000000005ba520] 264 - core 148 r2665 a01e339 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'S:\_VIDS_PRODUCTIONS\20110219 MUMTI CLIPS\20160311 Epic Quran Recitations\01.MP4':
  Metadata:
    encoder         : Lavf57.28.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 24 fps, 24k tbn, 24 tbc
    Metadata:
      encoder         : Lavc57.28.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, mono, 32 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
Past duration 0.639992 too large
Past duration 0.679985 too large
Past duration 0.719994 too large
Past duration 0.759987 too large
Past duration 0.799995 too large
Past duration 0.839989 too large
Past duration 0.879997 too large
Past duration 0.919991 too large
Past duration 0.959999 too large
Past duration 0.999992 too large
frame=   43 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x
frame=   71 fps= 70 q=28.0 size=     133kB time=00:00:00.54 bitrate=2016.1kbits/s dup=0 drop=1 speed=0.533x
frame=  104 fps= 68 q=28.0 size=     144kB time=00:00:01.91 bitrate= 615.3kbits/s dup=0 drop=3 speed=1.26x
frame=  137 fps= 67 q=28.0 size=     154kB time=00:00:03.29 bitrate= 384.3kbits/s dup=0 drop=4 speed=1.61x
frame=  170 fps= 67 q=28.0 size=     165kB time=00:00:04.67 bitrate= 289.4kbits/s dup=0 drop=5 speed=1.84x
frame=  203 fps= 66 q=28.0 size=     176kB time=00:00:06.04 bitrate= 238.2kbits/s dup=0 drop=7 speed=1.98x
frame=  236 fps= 66 q=28.0 size=     186kB time=00:00:07.41 bitrate= 205.6kbits/s dup=0 drop=8 speed=2.08x
frame=  269 fps= 66 q=28.0 size=     197kB time=00:00:08.79 bitrate= 183.3kbits/s dup=0 drop=9 speed=2.16x
frame=  295 fps= 60 q=28.0 Lsize=     215kB time=00:00:09.87 bitrate= 178.2kbits/s dup=0 drop=11 speed=2.02x
video:167kB audio:38kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.696121%
[libx264 @ 00000000005ba520] frame I:2     Avg QP:11.38  size:144156
[libx264 @ 00000000005ba520] frame P:74    Avg QP:15.03  size:   194
[libx264 @ 00000000005ba520] frame B:219   Avg QP:24.20  size:   151
[libx264 @ 00000000005ba520] consecutive B-frames:  1.0%  0.0%  0.0% 99.0%
[libx264 @ 00000000005ba520] mb I  I16..4: 58.4%  0.0% 41.6%
[libx264 @ 00000000005ba520] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.7%  0.0%  0.0%  0.0%  0.0%    skip:99.3%
[libx264 @ 00000000005ba520] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  1.1%  0.0%  0.0%  direct: 0.0%  skip:98.9%  L0:27.6% L1:72.4% BI: 0.0%
[libx264 @ 00000000005ba520] coded y,uvDC,uvAC intra: 31.2% 32.8% 29.4% inter: 0.0% 0.1% 0.0%
[libx264 @ 00000000005ba520] i16 v,h,dc,p: 75% 18%  5%  2%
[libx264 @ 00000000005ba520] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34% 25% 18%  4%  4%  4%  4%  4%  5%
[libx264 @ 00000000005ba520] i8c dc,h,v,p: 68% 15% 13%  4%
[libx264 @ 00000000005ba520] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 00000000005ba520] ref P L0: 99.3%  0.2%  0.3%  0.2%
[libx264 @ 00000000005ba520] ref B L0: 96.4%  3.5%  0.1%
[libx264 @ 00000000005ba520] ref B L1: 99.3%  0.7%
[libx264 @ 00000000005ba520] kb/s:218.52

A: Using the 1920x1080 JPGs you exported, use this command to generate each MP4 and then run concat as before:
ffmpeg -loop 1 -i 01.jpg -i 01.mp3 -c:v libx264 -profile:v main -pix_fmt yuv420p -r 24 -video_track_timescale 24000 -c:a copy -shortest -y 01.mp4

If using 4:3 JPGs, use this command to generate 1920x1080 videos:
ffmpeg -loop 1 -i 01.jpg -i 01.mp3 -vf "scale=-1:1080,pad=1920:1080:(1920-iw)/2:(1080-ih)/2,setsar=1" -c:v libx264 -profile:v main -pix_fmt yuv420p -r 24 -video_track_timescale 24000 -c:a copy -shortest -y 01.mp4


text:
Q: gps app for android useing shapefiles I'm very new to android development.  I would like to make a android app for my senior project.  The idea for the project is this: build an app that will show one's location on a map be it on a road or path.  So it looks like using google maps and the Locator class this can be done.  But here is the thing I have shapefile for the path system in esir format.  It looks like one could export this from ArcGIS as a KML file, and then overlay it on top of the google map.  Now of course I would like the GPS location displayed to the user to "snap" to the nearest path if it is in say 15m of the path to help hide the inaccuracies in the GPS.  I would also like to be able to place notification icons on the map, e.g. path condition, that could be updated from time to time.  I do also have shapefiles for the roads, streams, lakes, etc. for the area, so I could just use them instead of google maps.  Is using google map and overlaying the KML file the best way to do this?  Does this sound like a doable project?

A: Of caurse it's a doable project .there are many solutions for this kinde of projects for your base map you can use google map , openstreetmap ,Bingmap (personnaly i prefer openstreetmap ),open layer  ..... , After that you can choose between google map api or Arcgis Api (personnaly i think that arcgis api is more Professional including all services of a GIS ) ... ,for Gps there ara many solutions one of theme is to update your Gpx file and project it like a  graphic layer in you app .


text:
Q: Github for mac download snow leopard Can anyone point me in the direction of a download link for a previous version of Github mac that will work with Snow leopord? The newest version has dropped support for it : http://mac.github.com/
I've been searching but I can't find anything. Alternatively I'll look into Tower but at £40 it's steep compared to Gits Free option.

A: The download link on mac.github.com is to https://central.github.com/mac/latest.
To see what the redirect is I use curl -D  , which gives a 302 to https://github-central.s3.amazonaws.com/mac%2FGitHub%20for%20Mac%2076.zip
Winding back the version numbers I got to 2056, the last version for Snow Leopard.

A: you can download the app here in this link http://davidramos.porexpertos.es/2012/10/github-para-snow-leopard/
But i couldnt log in with my account so lets see if you are lucky
Thanks


text:
Q: How to create custom facet labels with both bold and math expressions using facet_wrap in ggplot2? I've been working on this for days and can't seems to find a reproducible code (or even a lead) on how to do this. Long story short, I'm trying to create a publication quality figure in which I want my facet labels to look like this (although the -1 should be superscript :/):
(A) Decomposition rate (g·d^-1)
So I want my facet labels to both have a bold text, plain text, and math component. I'm using facet_wrap instead of facet_grid because I want to be able to specify the number of columns/rows. While I know how to make axis labels and such like this using
lab=expression(paste(bold("(a)")~plain("Decomposition rate")~"(g"%.%d^-1")"))

I can't just change the variable levels/names in the data frame b/c then ggplot2 doesn't recognize the bold and math expressions. Any leads or ideas would be much appreciated!


text:
Q: SQLite Android rawQuery вытащить несколько полей по id Есть база данных myvocabulary, в ней поля _id, fname, secname.
Хочу с помощью rawquery или query доставать строки по id(по 4 значения). Допустим, (1,7,8,17). И передать их курсору.
Искал,искал, но ничего так и не сработало.
Пробовал что-то типа
return mDB.rawQuery("select * from myvocabulary where _id = ?", columns);
В columns
String[] columns = {"1","2","3","4"};

A: Нашёл ответ:
    String[] columns = {"1","2","9","6"};
    return mDB.query("mytable", null, "_id = ? or _id = ? or _id = ? or _id = ?", columns, null, null, null);


text:
Q: How do I format the @sys.date & @sys.time for a Facebook Messenger response in DialogFlow? I have a demo bot which takes in the user's date & time as inputs, and just repeats it back to them. However, it gets repeated in the ISO-8601 format, which I don't want. I managed to format in the inline editor for Google Assistant, but it doesn't work in Facebook Messenger. Is there any way I can format it in the inline editor for Messenger as well?
This is the code I'm using, it formats it correctly in the test console, but on messenger in still uses the responses that I entered in Dialogflow. (e.g. Sure thing, I'll hook you up with a tune-up at $Time on $Date. See you then!)
const functions = require('firebase-functions');
const {dialogflow} = require('actions-on-google');

const WELCOME_INTENT = 'Default Welcome Intent';
const FALLBACK_INTENT = 'Default Fallback Intent';
const TUNEUP_INTENT = 'Book Tune-Up';
const DATE_ENTITY = 'Date';
const TIME_ENTITY = 'Time';
const timeZone = 'Europe/Belgrade';

const app = dialogflow();

function getLocaleTimeString(dateObj){
  return dateObj.toLocaleTimeString('en-US', { hour: 'numeric', hour12: true, timeZone: timeZone });
}

function getLocaleDateString(dateObj){
  return dateObj.toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric', timeZone: timeZone });
}

app.intent(TUNEUP_INTENT, (conv) => {
   const date = getLocaleDateString(new Date(conv.parameters[DATE_ENTITY]));
   const time = getLocaleTimeString(new Date(conv.parameters[TIME_ENTITY]));
   const responses = [`Sure thing, I'll hook you up with a tune-up at ${time} on ${date}. See you then!`,
                     `Cool! So to recap - I'll book you with a tune-up on ${date} at ${time}. Thanks for booking!`,
                     `Great, you're booked for ${date} at ${time}. See you then!`];

   conv.ask(responses[Math.floor(Math.random() * responses.length)]);
 });

exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);

A: You're on the right track - you need to use a fulfillment webhook to format the result the way you want it.
However, you're using the actions-on-google library, which only produces responses for the Google Assistant. If you want to produce output across all the integrations that Dialogflow supports, you should look into the dialogflow-fulfillment library. The concepts for it are similar to actions-on-google, but there are some slight style differences.


text:
Q: What is the derivative of $\frac{f^{(3)}(\xi(x))}{6}$ at $x=x_0$ The error of interpolating polynomial is
$$
E_n(x)=\frac{(x-x_0)(x-x_1)\cdots(x-x_n)}{(n+1)!}f^{(n+1)}(\xi(x))
$$
The derivative of $E_n(x)$ is
$$
E^{\prime}_n(x)=\frac{d}{dx}\left((x-x_0)(x-x_1)\cdots(x-x_n)\right)\frac{f^{(n+1)}(\xi(x))}{(n+1)!}\\
+(x-x_0)(x-x_1)\cdots(x-x_n)\frac{d}{dx}\left(\frac{f^{(n+1)}(\xi(x))}{(n+1)!}\right)
$$
In A Friendly Introduction to Numerical Analysis by Brian Bradie, the author gives the derivative of $f^{(3)}(\xi(x))/6$ at $x=x_0$ in the terms of divided differences
$$
\frac{d}{dx}\left(\frac{f^{(3)}(\xi(x))}{6}\right)_{\text{at }x=x_0}=\frac{d}{dx}f[x_0-h,x_0,x_0+h,x]_{\text{at }x=x_0}\\
$$
$$
\begin{align}
& =\lim_{\Delta\to0}\frac{f[x_0-h,x_0,x_0+h,x_0+\Delta]-f[x_0-h,x_0,x_0+h,x_0]}{\Delta}\\
& =\lim_{\Delta\to0}f[x_0-h,x_0,x_0+h,x_0+\Delta,x_0]\\
& =\lim_{\Delta\to0}f[x_0-h,x_0,x_0+h,x_0,x_0]\\
& =\frac{1}{24}f^{(4)}(\xi(x))\\
\end{align}
$$
But I don't understand this manner. How can I obtain $\frac{1}{24}f^{(4)}(\xi(x))$ without using divided differences?
Hint:
$$
\frac{1}{(n+1)!}\frac{d^i}{dx^i}f^{(n+1)}(\xi)=\frac{i!}{(n+i+1)!}f^{(n+i+1)}(\rho_i)
$$
where $i=1,2,\cdots,n$ and $\min(x_0,x_1,\cdots,x_n,x)<\rho_i<\max(x_0,x_1,\cdots,x_n,x)$.


text:
Q: Are approval requests that are submitted to queues distributed or shared among the users of the queue? I'm trying to create an approval process using a pool of users as approvers, but I don't know the full mechanics of Queues.
When a document is submitted to a queue for an approval, does that document get put into a shared pool, where any of the queue users can approve the document, or does the document get assigned to a single approver among that queue that has sole responsibility to approve said document?

A: Per this source:

When the assigned approver is a queue :

*

*Any queue member can approve or reject an approval request that is assigned to the queue.

*Approval request emails are sent to the queue email address. If the queue is set up to send email to members, then approval request emails
  are also sent to the queue members, except those whose approval user
  preferences are set to never receive approval request emails.

*When an approval request is assigned to a queue, each queue member's delegated approver also receives an approval request email
  notification.

*Because email notifications to a queue aren't intended for an external audience, any instances of the merge field
  {!ApprovalRequest.External_URL} in the email template are sent as the
  equivalent internal URL.

*Salesforce1 notifications for approval requests aren't sent to queues. For each approval step involving a queue, we recommend adding
  individual users as assigned approvers, so at least those individuals
  can receive the approval request notifications in Salesforce1. To have
  both queues and individual users as assigned approvers, select
  Automatically assign to approver(s) instead of Automatically assign to
  queue in the approval step.

*When an approval request is rejected and returned to the previous approver and the previous approver was a queue, the approval request
  is assigned to the user who approved it instead of the queue.

*The Approval History related list displays the queue name in the Assigned To column and the actual user who approved or rejected the
  approval request in the Actual Approver column.


text:
Q: read local JPG file within browser I am really struggling with this one: forgive me if the answer is right in front of my face.
I'm trying to find the easiest way to upload a JPG file through ajax.  I only need the byte array, which I can handle later: the challenge, I need to be able to do this all (or mostly) in javascript: most solutions I've looked at use a php script, which I cannot use.  I really just need a byte stream that I can handle afterwards.
I've looked at solutions such as this and this one, neither of which have resulted in much success.  I really don't need it to do much: I just need the byte array, and a postback cannot occur: if I need to grab the byte array on my final submission (after the image has been chosen) that would also work: I just don't know how to go about pulling information from an asp:FileUpload element from the client side if the file hasn't been uploaded.
Thanks all.

A: You can't really do any kind of server manipulation without server side scripting, such as PHP, ASP, java etc. If that was the case, it would be major security issue, since anyone can upload anything onto the host(server).
As far as certain data that you want to grab, you can use Actionscript 3 to pull image data (but it would require user to have Adobe Flash installed)

A: Was able to do this using an asp:FileUpload object, and no postback via. use of javascript's FileReader.  With FileReader, as long as the end user chooses a file, file information (such as bytes) are available to javascript, and can be read.


text:
Q: How to Promise in loop?

    var arr = ["node.js", "Java", "C#"];
var newArr = [];

let promise = new Promise((resolve, reject) => {

        for(let i = 0; i < arr.length; i++) {
            setTimeout(() => {
                newArr.push(arr[i])
                resolve(newArr);
            }, 1000);
        }

});

promise
        .then(result => {
             alert(result);
         }
);

Now it alerts data after first loop. How to display data from async operation with promises, after it passes whole loop?
Desired behavior: Add data to newArr in async mode, and display it after loop ends.

A: You need to have multiple promises with promise all

const myPromises = [];
for (let i=0; i<5; i++) {
  myPromises.push(new Promise((resolve, reject) => {
      setTimeout(() => {
        console.log("done", i);
        resolve(i)
      } , i*500);
  }));
}

Promise.all(myPromises).then(values => {
  console.log("All: ", values)
});


text:
Q: Transferring a data frame from R Studio Cloud to GoogleSheets seems prohibitively slow I have a data frame in R Studio cloud that is 85 rows by 207 columns (ultimately it may be as wide as 366 columns). The actual data is created using the code in this thread:
Function to generate multiple rows of vectors in R
Now that I have the data frame set up, I'm trying to use the googlesheets library to transfer it to an existing sheet (and will periodically update it as I get more data). I'm using this code to edit the google sheet:
gs_edit_cells(sheet, ws = "Test", input=data, anchor="A2")

I let it think for a long time (more than an hour) and it sat there with "Range affected by the update" and it never went through. If I slice it into several segments (doing say 30 or 60 or 90 columns at a time) then it does transfer but is prohibitively slow. This isn't a huge dataset, is there something I could improve in my code? I have loaded the sheet in advance and it does recognize it.


text:
Q: Finding recurrent and transient states with first hitting probabilities (Norris exercise 1.5.1) I want to see why the following attempt won't work .
Problem : In a discrete time markov chain (DTMC) $(X_n)_{n\ge 0}$  with transition matrix  P and state space I , which states are recurrent and which are transient?
$$ P =
\begin{bmatrix}
  0.50 & 0.00 & 0.00 & 0.00 & 0.50 \\
  0.00 & 0.50 & 0.00 & 0.50 & 0.00 \\
  0.00 & 0.00 & 1.00 & 0.00 & 0.00 \\
  0.00 & 0.25 & 0.25 & 0.25 & 0.25 \\
  0.50 & 0.00 & 0.00 & 0.00 & 0.50 \\
   \end{bmatrix}
$$
This DTMC has communicating classes : $\{1,5\} (closed) , \{2,4\} , \{3\}(closed)$
The attempt : From Norris theorem 1.5.3 ,

The following dichotomy holds:  (i) if
$P(T_i= \inf\{n\ge 1 : X_n = i \} <\infty | X_0 = i \in I) = P_i(T_i <\infty)=1$ , then $i$ is recurrent
  (ii) if
$P(T_i= \inf\{n\ge 1 : X_n = i \} <\infty | X_0 = i \in I) = P_i(T_i  <\infty) < 1$ , then $i$ is transient
In particular, every state is either transient or recurrent .

Similar to Norris section 1.3 but with the difference that $T_i \ge 1 $ instead of 0 . First define $H_i = \inf\{n\ge 0 : X_n = i \}$ , so that by markov property
$$
P_i(T_i<\infty) = \sum_{j \in I} p_{ij} P_j(H_i <\infty) =
\sum_{j \in I} p_{ij} h_{j}^{\{i\}}
$$
where we let $p_{ij}$ be the (i,j) entry of P  , and $ P_j(H_i <\infty) = h_{j}^{\{i\}} $ interpreted as $P_j(\text{hit} \; i)$ .
From Norris theorem 1.3.2  (applies only when $h_{j}^{\{i\}}$ is defined exactly as above) ,

The vector of hitting probabilities $h^{\{i\}} = \left( h_j^{\{i\}} : j \in I  \right)^T$ is the minimal non negative solution to the system of linear equations
$$\left\{
\begin{array}{cc}
 h_j^{\{i\}} = 1 & \text{for j = i}\\
 h_j^{\{i\}} = \sum_{k\in I } p_{jk} h_k^{\{i\}} & \text{for j $\neq$ i}\\
\end{array}\right.
$$
 ( Minimality means that if $x = (x_j : j \in I )$ is another solution with $x_j \ge 0$ for all j , then $x_j \ge h_j $ for all j . )

Hence , we have $P_i(T_i<\infty) = \sum_{j \in I} \sum_{k\in I } p_{ij} p_{jk} h_k^{\{i\}} \quad j \neq i  $ . So we need solve for $h^{\{i\}}$ first , theorem 1.3.2 could be represented by
$$
(I - P) h^{\{i\}}  = \mathbf{0}
$$
Let $A = (I - P | \mathbf{0} ) $ , then A has reduced row echelon form
$$ \left[
\begin{array}{ccccc|c}
  1.00 & 0.00 & 0.00 & 0.00 & -1.00 & 0.00 \\
  0.00 & 1.00 & 0.00 & -1.00 & 0.00 & 0.00 \\
  0.00 & 0.00 & 1.00 & -2.00 & 1.00 & 0.00 \\
  0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 \\
  0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 \\
   \end{array} \right]
$$
However , I couldn't solve for $h^{\{i\}}$ from this matrix , e.g
I obtain $h^{\{1\}} = \left( 1 , h_2^{\{1\}} , 2 h_2^{\{1\}} - 1 , h_2^{\{1\}}  , 1 \right)^T $ which I couldn't find any $h_2^{\{1\}}$ that makes it a minimal non negative solution .


text:
Q: How to select rows before the column value changes in SQL Server 2008? I have a help desk project in which we get tickets on some issues related to the project. I am showing the status of a ticket for each day of current week as per below image.
For example, the arrow shows the total number of tickets still open until this week's Monday.

The sql query is like this,
declare @day datetime
declare @maxdate datetime
set @maxdate = getdate()
set @day = Convert(Varchar(10),DATEADD(week, DATEDIFF(day, 0, getdate())/7, 0),110)
truncate table Tickets_Until_Current_Day
while  @day <= @maxdate
begin
insert into Tickets_Until_Current_Day
select convert(varchar(20),datename(dw,@day)), count(*) Total_Open_Tickets
FROM OPENROWSET('MSDASQL.1','DSN=SQLitehgq','Select * from tickets') AS a
where ticket_createdDate < @day + 1
and [status] = 'open'
set @day = @day + 1
end

Now suppose 5 tickets are closed on Tuesday which were created on Monday, then the number that arrow represents becomes 25 because the status in the table is now closed for those tickets.
But I want to show the same number throughout the week so that we can know how many tickets were really open at the end of Monday. e.g., If 30 tickets were open on Monday, at the end of the week, it must show 30 only.
Any help will be appreciated.
Thanks.


text:
Q: Return rows that of both table that has value in month column I have 2 tables and I want to combine them in a way that they give data that are base on month. like these :
table1 :
month   | data1 | data2
--------|-------|------
6       | 1     | 1
5       | 1     | 1
4       | 1     | 2
2       | 1     | 2
1       | 1     | 3

table2 :
month   | data3
--------|------
7       | 1
6       | 1
4       | 1
3       | 1
1       | 2

=> tableResult :
month   | data1 | data2 | data3
--------|-------|-------|-------
7       | 0     | 0     | 1
6       | 1     | 1     | 1
5       | 1     | 1     | 0
4       | 1     | 2     | 1
3       | 0     | 0     | 1
2       | 1     | 2     | 0
1       | 1     | 3     | 2

Is it possible to obtain that tableresult in sql query ?
or the only option is to query each table then process it with php?
by the way table1 and table2 are both views if it matters

A: use join and union
   select t1.month,data1,data1,t2.data3
   from table1 t1 left join table2 t2 on t1.month=t2.month
   union
   select t2.month,t1.data1,t1.date2,t2.data3
   from  table1 t1 right join table2 t2 on t1.month=t2.month

A: You are looking for full join:
select coalesce(t1.month, t2.month) as month,
       coalesce(t1.data1, 0) as data1,
       coalesce(t1.data2, 0) as data2,
       coalesce(t2.data3, 0) as data3
from t1 full join
     t2
     on t1.month = t2.month;


text:
Q: Erro "IndexError: list assignment index out of range" Esse programa quado executado uma certa quantidade de vezes ele mostra uma mensagem mostrada logo mais a baixo.
Agente Trem 1
    def Ttrem_Um(velocidade,linhas):
        velocidade = randint(55,100)
        return velocidade

Agente Trem 2
    def Ttrem_Dois(velocidade,linhas):
        velocidade = randint(55,100)
        return velocidade

    def lin(linhas1,linhas2,i,j):
        i = i+1
        linhas1[i] = 1

        #   linhas2[j+1] = 2
        #   velocidade =65 - 20
        #   velocidade2 = 65
        return linhas1

    def estacao(linhas1,linhas2,linha,velocidade,velocidade2,i,j,z):

        i = randint(0,10)
        j = randint(0,10)
        linhas1[i] = 1
        linhas2[j] = 2

        print('Trem {} esta na linha: {} \nTrem {} esta na linha: {}'.format(linhas1[i],i,linhas2[j],j))

        velocidade = Ttrem_Um(velocidade,linhas1)
        velocidade2 = Ttrem_Dois(velocidade,linhas2)
        print('Velocidade atual: \nTrem 1: {} \nTrem 2: {}'.format(velocidade,velocidade2))

        if velocidade != 65 and velocidade2 != 65:
            velocidade = 65
            velocidade2 = 65

        print('velocidade atualizada: \nTrem 1: {} \nTrem 2: {}'.format(velocidade,velocidade2))

        if(linhas1[i] == linhas2[j]):
            lin(linhas1,linhas2,i,j)
            print('Trem {} esta na linha: {} \nTrem {} esta na linha: {}'.format(linhas1[i],i,linhas2[j],j))

    velocidade = 0
    velocidade2 = 0
    i = 0
    j = 0
    z = 0
    linha = {'Trem_Um':1,'Trem_Dois':2}
    linhas1 = [0,0,0,0,0,0,0,0,0,0]
    linhas2 = [0,0,0,0,0,0,0,0,0,0]
    estacao(linhas1,linhas2,linha,velocidade,velocidade2,i,j,z)

Mensagem:

Traceback (most recent call last): File "estacao.py", line 53, in
   estacao(linhas1,linhas2,linha,velocidade,velocidade2,i,j,z) File
    "estacao.py", line 26, in estacao linhas1[i] = 1 IndexError: list
  assignment index out of range

como eu faço para arrumar esse erro?.

A: O problema nesse código é que as listas linhas1 e linhas2 possuem 10 elementos que vão da posição 0 até a posição 9 e dentro da função estacao você chama randint(0,10) para gerar um valor aleatório que será a posição na lista que você irá acessar.
Diferentemente do range() o random.randint pode retornar o valor de parada. Logo ele pode retornar o valor 10, e essa posição não existe na sua lista.
Para solucionar o problema apenas substitua randint(0,10) por randint(0,9).
Utilizando a função len():
A função len retorna a quantidade de elementos que uma sequência possui. Podemos utilizar esta função em listas, tuplas, dicionários, strings, etc.
Pensando nisso podemos substituir randint(0,9) por randint( 0, len(linhas1) - 1). A vantagem de escrever o código dessa forma é que você pode alterar o tamanho da sua lista sem precisar alterar sempre o valor que você passa como parada da função random.randint. Veja esse exemplo abaixo:
import random

def obtemPosicao(linhas):
    return random.randint(0, len(linhas) - 1)

linhas = [0,0,0,0,0,0,0,0,0]

print(obtemPosicao(linhas))

# Uma nova linha é criada e ela pode ser usada sem alterar a função obtemPosicao.
linhas.append(0)

print(obtemPosicao(linhas))


text:
Q: Read selected line from text file using Shell I have written this code, wanting to sieve out selected line from seating.txt. But it doesn't seem to work. Please help!
echo `sed -n "/$NUM/p" seating.txt`

File as followed:
29;,A2,A3,A1,E2,B1,B2,C1,C3,C2,D1,D2,D3,E1,E3,A4,E4,B3,B4,C4,D4
29;,A1,A2,A3,A4,B2,E4,C3,B3,D3,D2,E1,E2,C2,B4,C4,D4,C1,D1,E3,B1
43;,A2,D4,C3,B3,A4,E4
44;,A1,D4,E2,C3,A2
44;,A1,B2,C3,D4,A4

A: It's not clear what you're trying to accomplish exactly. If you're trying to print lines where $NUM occurs, your code works fine:
NUM=29
sed -n "/^$NUM/p" file

Results:
29;,A2,A3,A1,E2,B1,B2,C1,C3,C2,D1,D2,D3,E1,E3,A4,E4,B3,B4,C4,D4
29;,A1,A2,A3,A4,B2,E4,C3,B3,D3,D2,E1,E2,C2,B4,C4,D4,C1,D1,E3,B1

If you're trying trying to pass a line number, try:
NUM=4
sed -n "$NUM{p}" file

Results:
44;,A1,D4,E2,C3,A2

A: If you want a line containing $NUM then it's:
grep "$NUM" file

If you want a line with exactly $NUM before the first semi-colon it's:
grep "^$NUM;" file

If you want line number $NUM then it's:
awk -v num="$NUM" 'NR==num' file

If you want something else, tells us what and post some expected output to go with the sample input you posted.


text:
Q: Copy a row from one sheet to another sheet if the row contains certain values based on a range of numbers I would like to copy and paste a row if the row contains a certain value. HOWEVER, I have approx. 2500 values out of 100.000 that I need to obtain (copy and paste into separate rows). Thus, is there any possibility to create a VBA that allows me to create a loop or some sort, where I can specify these values?
E.g. instead of
For Each cell In Sheets(1).Range("A:A")
If cell.Value = "1" Then
    matchRow = cell.Row
    Rows(matchRow & ":" & matchRow).Select
    Selection.Copy

    Sheets("Sheet2").Select
    ActiveSheet.Rows(matchRow).Select
    ActiveSheet.Paste
    Sheets("Sheet1").Select
End If

I NEED:
For Each cell In Sheets(1).Range("A:A")
If cell.Value = "1 OR 3 OR 5 OR 10 OR 15, etc." Then
    matchRow = cell.Row
    Rows(matchRow & ":" & matchRow).Select
    Selection.Copy

    Sheets("Sheet2").Select
    ActiveSheet.Rows(matchRow).Select
    ActiveSheet.Paste
    Sheets("Sheet1").Select
End If

I am new to VBA and any help would be greatly appreciated...
Best,
Lisa

A: Use Select Case:
For Each cell In Sheets(1).Range("A:A")
Select Case cell.Value
  Case "1","3","5","10","15"
    matchRow = cell.Row
    Sheets("Sheet1").Rows(matchRow).Copy  Sheets("Sheet2").Rows(matchRow)
End Select


text:
Q: Client JS + Django Rest Framework After reading this article about separating server and client, Separate REST JSON API server and client?
I want to know if this problem also exists in Django.
In Django, are these 2 separate phenomenons?

*

*Django is MVC. Take out the view, have django as the backend and just send JSON. Create a separate say Emberjs or Angularjs app. Make these clients access backend's REST resources. In this case, how can you put the projects together to deploy to Heroku? Can you just deploy a "JAVASCRIPT-HEAVY-CLIENT" to Heroku, and have it just talk to ur REST server?

*Since Django is MVC, don't completely take out the view, but integrate Emberjs/Angularjs into the View, but still use REST resources? In this way, you can put all the angularjs components/js files into the static folder and deploy to Heroku.
Are these the same? and realistically, how do you put them together to be able to deploy to Heroku?

A: Heroku is a application server platform. It's not really designed to serve static code.
The approach I've previously taken is to build the Django part normally, and have a single view that serves out a bootstrap template for everything under the JS App root.
Say I have a {Angular,Ember} app living at mydomain.com/app/, then everything under that will serve the bootstrap template (which includes serialised values queried from database) and calls the JS boostrap method to startup your app, and then the app takes over routing from that point, and renders out it's views.
At this point, all the data for the views is coming from django-rest-framework/django-tasypie.
Using this method and leveraging django-pipeline & django-boto's S3 storage backend, You should be able to serve a decently sized project with Django & {Angular,Ember}


text:
Q: Continuous Poisson distribution: $\int_0^\infty \frac{t^n}{n!}dn$ I was thinking poission distribution, actually i like it. Then i thought there is no reason for some events to be integers. We can define occurences as half finished homeworks for example, or 3.7 apples etc.
So when i give wolfram an example, it actually calculates. Mean occurence of events is 3.2, what is the probability that i see this event to be between 1 and 4 ? It is about 0.6076
My question is that although wolfram calculates, i dont know and i couldnt find this integral (all density). Can it be calculated ?
$$\int_{0}^{+\infty}\frac{t^{n}}{n!}\,dn$$

A: Since $n!=\Gamma(n+1)$, you are then asking about a closed form of
$$
\int_0^\infty \frac{t^x}{\Gamma(x+1)}dx, \quad t>0. \tag1
$$ There is no known closed form of $(1)$, but this integral has been studied by Ramanujan who proved that

$$
\int_0^{\infty} \frac{t^x}{\Gamma(1+x)} \, dx = e^t - \int_{-\infty}^{\infty} \frac{e^{\large -te^x}}{x^2+\pi^2} \, dx, \quad t>0. \tag2
$$

Some useful related links are link 1, link 2, link 3.


text:
Q: How can I let my code return True or False based on the criteria set? I asked this before but since I didn't get a very clear response as to where I should  change my code, I'm gonna ask this here again :)
So I'm trying to analyze my list h and see whether for x in that list, are their two pairs of the first character in the elements or not
So for instance,
['AS', 'AD', 'CC', 'CH', 'CS'] returns False because there are 3 C and 2 , but there are supposed to be 2 of the same elements and one of a completely different element.

['AS', 'AD', 'SC', 'SH', 'CS'] returns True because there are 2 A, 2 S and one C.
['CS', 'CD', 'AC', 'AH', 'FS'] returns True because there are 2 C, 2 A and one F

['AS', 'CD', 'AC', 'CH', 'DS'] returns False because although there are two A, two C and one D, the A and C are not in order

Here is my code so far...
def two_pairs(h):
    for x in h:
        pairing = list[x[1]]
        if (pairing[1] == pairing[2]) and (pairing[3] == (pairing[4])):
            return True
        if (pairing[3] == pairing[4]) and (pairing[0] == (pairing[1])):
            return True
        if (pairing[0] == pairing[1]) and (pairing[3] == (pairing[4])):
            return True
        else:
            return False
print(two_pairs(['9r, 9♣, 4♠, 4♣, 10♣']))

This doesn't really work at all and I'm getting an error message that says
if (pairing[1] == pairing[2]) and (pairing[3] == (pairing[4])):
TypeError: There are no type variables left in list['r']

What should I change??
Note: the back characters can be anything from numbers to letters to special characters.

A: h is a list of a string. This makes x a single string
Therefore x[1] == 'r' and list() is a built-in Python function that you are indexing with list['r'], which is not valid syntax for what you seem to want to do.
The answer you accepted in the previous post seemed to do what you want, and the input was a list of strings, not a list of one string.
e.g. Start with print(two_pairs(['9r', '9♣', '4♠', '4♣', 10♣'])), however none of these string have more than two characters, so it is going to still fail around pairing[2], for example

are their two pairs of the first character in the elements or not

Start with this
l = ['AS', 'AD', 'CC', 'CH', 'CS']
first = l[0][0]
print(2 == sum(x.count(first) for x in l))  # True

Or maybe
l = ['AS', 'AD', 'CC', 'CH', 'CS']
firsts = [x[0] for x in l]
print({f: sum(x.count(f) for x in l) for f in firsts})  # {'A': 2, 'C': 4}