text:
Q: filter doesn't work properly when hiding specific column of a table on input uncheck i want to hide specific columns of a table when unchecking the checkbox and its working perfectly but the problem is i am using "dataTable" and it has filter to show records like 10 record or 25 or 50 and so on. let say i did hide a column "Age" by unchecking it and its worked perfectly but as you can see there is a show record filter as well and when i select to show records 25 or 50 or etc.., hidden column items visibles after the records 10, i have wasted lots of time on it but couldn't make it correct. can anyone help me with that??? below is the codes please check
LET ME GUIDE YOU TO ANALYSE THE PROBLEM:
 1. Unchecked any of the column like : "Age".
 2. Now select records 10 to 25 or 50 you will see the problem in the table below.

                    function filterGlobal() {
                        $('#example').DataTable().search(
                            $('#global_filter').val(),
                            $('#global_regex').prop('checked'),
                            $('#global_smart').prop('checked')
                        ).draw();
                    }

                    function filterColumn(i) {
                        $('#example').DataTable().column(i).search(
                            $('#col' + i + '_filter').val(),
                            $('#col' + i + '_regex').prop('checked'),
                            $('#col' + i + '_smart').prop('checked')
                        ).draw();
                    }

                    $(document).ready(function () {
                        $('#example').DataTable();

                        $('input.global_filter').on('keyup click', function () {
                            filterGlobal();
                        });

                        $('input.column_filter').on('keyup click', function () {
                            filterColumn($(this).parents('tr').attr('data-column'));
                        });
                    });

                    $(".nametoggleCheck").click(function () {
                        $('.dataTableShow td:nth-child(1),.dataTableShow th:nth-child(1)').stop().toggle();
                    })
                    $(".positiontoggleCheck").click(function () {
                        $('.dataTableShow td:nth-child(1),.dataTableShow th:nth-child(1)').stop().toggle();
                    })
                    $(".officetoggleCheck").click(function () {
                        $('.dataTableShow td:nth-child(1),.dataTableShow th:nth-child(1)').stop().toggle();
                    })
                    $(".agetoggleCheck").click(function () {
                        $('.dataTableShow td:nth-child(1),.dataTableShow th:nth-child(1)').stop().toggle();
                    })
                    $(".starttoggleCheck").click(function () {
                        $('.dataTableShow td:nth-child(1),.dataTableShow th:nth-child(1)').stop().toggle();
                    })
                    $(".salarytoggleCheck").click(function () {
                        $('.dataTableShow td:nth-child(1),.dataTableShow th:nth-child(1)').stop().toggle();
                    })

                        <input class="nametoggleCheck" type="checkbox" checked> Name

                        <input type="checkbox" class="positiontoggleCheck" checked> Pisition

                        <input type="checkbox" class="officetoggleCheck" checked> Office

                        <input type="checkbox" class="agetoggleCheck" checked> Age

                        <input type="checkbox" class="starttoggleCheck" checked> Start date

                        <input type="checkbox" class="salarytoggleCheck" checked> Salary

                            Name
                            Position
                            Office
                            Age
                            Start date
                            Salary

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

A: This is not working because you are using a custom hiding method, and it selects only the currently visible items without interacting with the datatable itself.
You should follow the datatable API like in their docs: https://datatables.net/examples/api/show_hide.html
I added a global var to keep the datatable object, you can move elsewhere, it was simpler for the example to set it global:

                    //var for the datatable object
                    var globDataTable;

                    function filterGlobal() {
                        $('#example').DataTable().search(
                            $('#global_filter').val(),
                            $('#global_regex').prop('checked'),
                            $('#global_smart').prop('checked')
                        ).draw();
                    }

                    function filterColumn(i) {
                        $('#example').DataTable().column(i).search(
                            $('#col' + i + '_filter').val(),
                            $('#col' + i + '_regex').prop('checked'),
                            $('#col' + i + '_smart').prop('checked')
                        ).draw();
                    }

                    $(document).ready(function () {
                        //store the datatable object
                        globDataTable = $('#example').DataTable();

                        $('input.global_filter').on('keyup click', function () {
                            filterGlobal();
                        });

                        $('input.column_filter').on('keyup click', function () {
                            filterColumn($(this).parents('tr').attr('data-column'));
                        });
                    });

                    $(".nametoggleCheck").click(function () {
                        //get column
                        var col = globDataTable.column(0);
                        //toggle visibility
                        col.visible( !col.visible() );
                    })
                    $(".positiontoggleCheck").click(function () {
                        //get column
                        var col = globDataTable.column(1);
                        //toggle visibility
                        col.visible( !col.visible() );
                    })
                    $(".officetoggleCheck").click(function () {
                        //get column
                        var col = globDataTable.column(2);
                        //toggle visibility
                        col.visible( !col.visible() );
                    })
                    $(".agetoggleCheck").click(function () {
                        //get column
                        var col = globDataTable.column(3);
                        //toggle visibility
                        col.visible( !col.visible() );
                    })
                    $(".starttoggleCheck").click(function () {
                        //get column
                        var col = globDataTable.column(4);
                        //toggle visibility
                        col.visible( !col.visible() );
                    })
                    $(".salarytoggleCheck").click(function () {
                        //get column
                        var col = globDataTable.column(5);
                        //toggle visibility
                        col.visible( !col.visible() );
                    })

                        <input class="nametoggleCheck" type="checkbox" checked> Name

                        <input type="checkbox" class="positiontoggleCheck" checked> Pisition

                        <input type="checkbox" class="officetoggleCheck" checked> Office

                        <input type="checkbox" class="agetoggleCheck" checked> Age

                        <input type="checkbox" class="starttoggleCheck" checked> Start date

                        <input type="checkbox" class="salarytoggleCheck" checked> Salary

                            Name
                            Position
                            Office
                            Age
                            Start date
                            Salary

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800

                            Tiger Nixon
                            System Architect
                            Edinburgh
                            61
                            2011/04/25
                            $320,800


text:
Q: lwuit app would not run on blackberry jde I built a j2me app using sun's lwuit , the application runs fine on my Oracle sdk simulator,but when I run this same app on blackberry jde I get this error
Error preverifying class com.sun.lwuit.animations.Transition3D
VERIFIER ERROR com/sun/lwuit/animations/Transition3D.initTransition()V:

Cannot find class javax/microedition/m3g/Node
C:\Users\Guest\Documents\NetBeansProjects\JTMobile\nbproject\build-impl.xml:436:   Preverification failed with error code 1.
BUILD FAILED (total time: 1 minute 38 seconds)

then I ignore this error and run the application again, it runs fine,
but when I launch the application I get this error
App Error 104, Uncaught Illegal argument then on the error confirmation box
Uncaught Exception ,Midlet jtMobile.Midlet not Found exception

I have checked all over the internet ,and it seems lwuit_midp.jar library isn't supported by blackberry , is there a way to run this app or configure the project so as to write lwuit j2me apps to run on blackberry, I some what prefer native lwuit and j2me Midlets to writing UIApplication from RIM, im using the latest lwuit 1_5, and blackberry OS 7.1/CLDC 1.1 MIDP 2.0 ,please help

A: Nokia work with MIDP.
Blackbery work with another library - RIM.
if You want to run the same application on Blackbeery you need to do like this:
    public class XXXXXXXtMIDlet extends
        //#ifdef RIM
        net.rim.device.api.ui.UiApplication
        //#else
//#         javax.microedition.midlet.MIDlet
        //#endif

In addtional , where the implemntion is specific to Blackberry you need to use ifdef RIM statment.

A: You can take a look on this thread, where you can find that if you remove the problematic classes from you lwuit file, you can get it working. Open the .jar file and delete this files.
Instead of this, I recommend you to use CodenameOne, which is a powerful tool which let us to develop with one lwuit based code, to a lot of platforms (Nokia, BB, Android, iOS) .

redpajama_set_name: RedPajamaStackExchange


text:
Q: find density function of sum of two independent exponential distribution If $X_1$ and $X_2$ are independent exponential random variables, both with mean $\beta$, find the density function for their sum.
My attempt:
Let $F_U(u)=P(X_1+X_2 \leq u)=\int_o^u\int_0^{u-x_2}\beta e^{-\beta x_1}\beta e^{\beta x_2}dx_1dx_2 = -e^{-\beta u}-\beta u e^{-\beta u}+1$.
so the density is $F'(u)=(u+1)e^{-\beta u}$.
But the solution says that it is not correct.

A: $$F'(u) = \beta e^{-\beta u} - \beta e^{- \beta u} +(-\beta)(-\beta u e^{-\beta u})= \beta^2 u e^{-\beta u}$$
Notice that I have used product rule for the second term.
A name for the sum of IID exponential distribution is known as Erlang distribution.

A: Try building the probability of $X_1$ first taken $X_2$ as given, an idea could be
$$\gamma(X_2)=Pr(X_1+X_2\le u|X_2),$$
then note that the cdf you are looking for is $F(x)=Pr(\gamma(X_2) \le x) = Pr(\gamma^{-1}(x) \le X_2) $.

A: There is an error in your integral. You have a wrong sign in the second exponent. If you correct it and redo the integral you will get a result $f(u) = \beta^2 u e^{- \beta u} $

A: Since you only wish to find the probability density function, you can save some effort.
$$\begin{align}f_U(u) &=\mathbf 1_{0\leqslant u}\cdot\dfrac{\mathrm d ~~}{\mathrm d u}\int_0^u\int_0^{u-x} f_{X_1}(x)f_{X_2}(y)\,\mathrm d y\,\mathrm d x \\[1ex] &= \mathbf 1_{0\leqslant u}\cdot\int_0^u f_{X_1}(x)\,f_{X_2}(u-x) \,\mathrm d x\\[1ex] &=\tfrac 1{\beta^2}\mathbf 1_{0\leqslant u}\cdot\int_0^u \mathrm e^{-x/\beta}\,\mathrm e^{-(u-x)/\beta}\,\mathrm d x\\[1ex]&=\tfrac u{\beta^2}\,\mathrm e^{-u/\beta}\,\mathbf 1_{0\leqslant u}\end{align}$$

PS: When the mean of an exponential distribution is $\beta$ then the pdf is $f_X(x)=\tfrac 1\beta\,\mathrm e^{-x/\beta}\,\mathbf 1_{0\leqslant x}$


text:
Q: JavaScript - hours, minutes, seconds, millisecond to floating point seconds for html audio I need to convert a string with hours, minutes, seconds and milliseconds "hh:mm:ss:mil" to the floating-point number that HTML audio player uses for currentTime.
I can't find any conversion algorithm that does this! The closest I've found converts to seconds as integers, while I need something like this
"00:00:38:000" -> 38.0 (NOT 2280)
"01:15:02:773" -> 4502.773
My Code so far - but it's wrong
function time2secs(time) {
    // 00:03:30 -> 3.5 seconds
    var t = time.split(':');
    if (t.length < 4) t[3] = 0; // if a missing millisecs, then set it to 0

    var seconds = parseInt(t[0]) * 60 * 60 + parseInt(t[1]) * 60 + parseInt(t[2]) + parseInt(t[3]) / 1000;

    return seconds / 60;
}

A: try this
function timeToSec(time){
    var arr=time.split(":");
  return parseInt(arr[0])*3600+ parseInt(arr[1])*60+ parseInt(arr[2])+ parseInt(arr[3])*0.1000
}
console.log(timeToSec("00:00:38:000" ))
console.log(timeToSec("01:15:02:773" ))

A: Does this code work as you expect?
function time2secs(time) {
    var t = time.split(':');
    if (t.length < 4) t[3] = 0;

    let second = (parseInt(t[0]) * 60 * 60) + (parseInt(t[1]) * 60) + parseInt(t[2]) + (parseInt(t[3]) / 1000);
    return t[3] == 0 ? second + ".0" : second;

}


text:
Q: Create lag numbers upto unique values I have a dataframe df, where I need to have the lag values to get the difference between times
df
ColA      ColB     Lag(ColB)
1      11:00:12    11:00:13
1      11:00:13    11:00:14
1      11:00:14       NA
2      11:00:15    11:00:16
2      11:00:16    11:00:17
2      11:00:17       NA
3      11:00:18    11:00:19
3      11:00:19    11:00:20
3      11:00:20       NA

Above only upto unique values I need to create a lag. If you see, the moment ColA changes from 1 to 2 and from 2 to 3, the lag is NA. So Is it possible to achieve this?

A: As mentioned by @Sotos, you need to group by your colA before doing the lag column and then calculate the diff time.
Using dplyr and lubridate packages, you can calculate diff time by group
library(dplyr)
library(lubridate)
df %>% group_by(ColA) %>% mutate(NewLag = lead(ColB)) %>%
  mutate(diff = hms(NewLag)-hms(ColB))

# A tibble: 9 x 5
# Groups:   ColA [3]
   ColA ColB     `Lag(ColB)` NewLag    diff
  <int> <chr>    <chr>       <chr>    <dbl>
1     1 11:00:12 11:00:13    11:00:13     1
2     1 11:00:13 11:00:14    11:00:14     1
3     1 11:00:14 NA          NA          NA
4     2 11:00:15 11:00:16    11:00:16     1
5     2 11:00:16 11:00:17    11:00:17     1
6     2 11:00:17 NA          NA          NA
7     3 11:00:18 11:00:19    11:00:19     1
8     3 11:00:19 11:00:20    11:00:20     1
9     3 11:00:20 NA          NA          NA

Is it what you are looking for ?
Example Data
structure(list(ColA = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L),
    ColB = c("11:00:12", "11:00:13", "11:00:14", "11:00:15",
    "11:00:16", "11:00:17", "11:00:18", "11:00:19", "11:00:20"
    ), `Lag(ColB)` = c("11:00:13", "11:00:14", NA, "11:00:16",
    "11:00:17", NA, "11:00:19", "11:00:20", NA)), row.names = c(NA,
-9L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x5569bf9b0310>)


text:
Q: how to update an Android ListActivity on changing data of the connected SimpleCursorAdapter I have the following code.
What I want to achieve is to update the shown list when I click an entry so I can traverse through the list.
I found  the two uncommented ways to do it here on stackoverflow, but neither works.
I also got the advice to create a new ListActivity on the data update, but that sounds like wasting resources?
EDIT: I found the solution myself. All you need to do is call "SimpleCursorAdapter.changeCursor(new Cursor);". No notifying, no things in UI-Thread or whatever.
import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

public class MyActivity extends ListActivity {
    private DepartmentDbAdapter mDbHelper;
    private Cursor cursor;
    private String[] from = new String[] { DepartmentDbAdapter.KEY_NAME };
    private int[] to = new int[] { R.id.text1 };
    private SimpleCursorAdapter notes;

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.departments_list);
    mDbHelper = new DepartmentDbAdapter(this);
    mDbHelper.open();

    // Get all of the departments from the database and create the item list
    cursor = mDbHelper.fetchSubItemByParentId(1);
    this.startManagingCursor(cursor);

    // Now create an array adapter and set it to display using our row
    notes = new SimpleCursorAdapter(this, R.layout.department_row, cursor, from, to);
    this.setListAdapter(notes);
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);

        // get new data and update the list
        this.updateData(safeLongToInt(id));
    }

    /**
     * update data for the list
     *
     * @param int departmentId id of the parent department
     */
    private void updateData(int departmentId) {
        // close the old one, get a new one
        cursor.close();
        cursor = mDbHelper.fetchSubItemByParentId(departmentId);

    // change the cursor of the adapter to the new one
    notes.changeCursor(cursor);
    }

    /**
     * safely convert long to in to save memory
     *
     * @param long l the long variable
     *
     * @return integer
     */
    public static int safeLongToInt(long l) {
    if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) {
        throw new IllegalArgumentException
            (l + " cannot be cast to int without changing its value.");
    }
    return (int) l;
    }

}

A: You need to notify your ListVIew when your data get changed.
adapter.notifyDataSetChanged();

in your case.
notes.notifyDataSetChanged();

Hope this may help you...

A: First, every time you open a new cursor, close the previous one and manage the new one.
Second, you change your cursor, but how does your cursor adapter know that ? It doesn't. Either you create an adapter that can change its cursor or your create a new SimpleCursorAdapter around your new cursor and plug it to the list.
But you were right, you should not recreate the list widget.


text:
Q: Creating dynamic URLs in htaccess I'm trying to write an .htaccess file that will make my URLs more attractive to search engines. I know basically how to do this, but I'm wondering how I could do this dynamically.
My URL generally looks like:
view.php?mode=prod&id=1234

What I'd like to do is take the id from the url, do a database query, then put the title returned from the DB into the url. something like:
/products/This-is-the-product-title

I know that some people have accomplished this with phpbb forum URLs and topics, and i've tried to track the code down to where it replaces the actual URL with the new title string URL, but no luck.
I know I can rewrite the URL with just the id like:
RewriteRule ^view\.php?mode=prod&id=([0-9]+) /products/$1/

Is there a way in PHP to overwrite the URL displayed?

A: At the moment you're wondering how to convert your ugly URL (e.g. /view.php?mode=prod&id=1234) into a pretty URL (e.g. /products/product-title). Start looking at this the other way around.
What you want is someone typing /products/product-title to actually take them to the page that can be accessed by /view.php?mode=prod&id=1234.
i.e. your rule could be as follows:
RewriteRule ^products/([A-Za-z0-9-])/?$ /view.php?mode=prod&title=$1

Then in view.php do a lookup based on the title to find the id. Then carry on as normal.

A: One way to do it, would be just like most mvc frameworks. You can redirect all your pages to the same index.php file, and you use your script to determine which page to load.
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

and your php file will have a script like this one:
  // get the url
  $uri = (isset($_SERVER['REQUEST_URI']))?$_SERVER['REQUEST_URI']: false;
  $query = (isset($_SERVER['QUERY_STRING']))?$_SERVER['QUERY_STRING']: '';
  $url = str_replace($query,'',$uri); // you can edit this part to do something with the query
  $arr = explode('/',$url);
  array_shift($arr);

  // get the correct page to display
  $controller =!empty($arr[0])?$arr[0]:'home'; // $arr[0] could be product/
  $action = isset($arr[1]) && !empty($arr[1])?$arr[1]:'index'; // $arr[1] can be product-title
    }

of course you will have to work this code to fashion your application
I hope this helps

A: One way would be to output a Location: header to force a redirect to the chosen URL.


text:
Q: How to redirect to seperate View from ajax get So my question is similar to this SO post  but I can not simply overwrite the document.
I'm using MVC and am able to call a controller's entry point from a View other than it's own.
the View (Say, ViewA) has a dialog, defined as:
$("#dialog-confirm").dialog({
            autoOpen: false,
            resizable: false,
            height: 390,
            width: 402,
            modal: true,
            buttons: {
                "Confirm": function () {

                    $.ajax({
                        type: "GET",
                        url: '/Result/Result',
                        data: $(this).serialize(),
                        success: function(data)
                        {
                            window.location.href = "<%:Url.Action("~/Result/Result")%>";
                        }
                    });

                    $(this).dialog("close");
                },
                cancel: function(){ $(this).close();}}
           });

When I confirm the dialog, I hit the entry point I wanted to in the ResultsController, but then my browser navigates to localhost:8000/ViewA/~/Result/Result instead of localhost:8000/Result/Result
ResultController.cs
public ActionResult Result()
{
     return RedirectToAction("Index");
}

How can I redirect to the page returned by Result() in the different controller?

A: Change
Url.Action("~/Result/Result")

To
Url.Action("Result", "Result")

https://msdn.microsoft.com/en-us/library/dd492758(v=vs.118).aspx


text:
Q: How to prevent beautifulsoap from extracting the information as strange symbols? I am trying to extract an information with beautifulsoap, however when I do it it extracts it with very rare symbols. But when I enter directly to the page everything looks good and the page has the label <meta charset="utf-8">
my code is:
HEADERS = {
        'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
        'referrer': 'https://google.com',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
        'Accept-Encoding': 'gzip, deflate, br',
        'Accept-Language': 'en-US,en;q=0.9',
        'Pragma': 'no-cache',
    }

urls = 'https://www.jcchouinard.com/web-scraping-with-python-and-requests-html/'
r = requests.get(urls, headers=HEADERS)
soup = bs4.BeautifulSoup(r.text, "html.parser")
print (soup)

Nevertheless, the result I get is this:
J{$%X Àà'8}±ŸÅ

I guess it's something with the encoding, however I don't understand why since the page is utf-8.
It is worth clarifying that this only happens in some cases, since with others I manage to extract the information without problems.
Edit: updated with a sample url.
Edit2: added the headers dictionary, which is the one that generates the problem.

A: import requests
from bs4 import BeautifulSoup

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0'
}

def main(url):
    r = requests.get(url, headers=headers)
    soup = BeautifulSoup(r.content, 'html.parser')
    print(soup.prettify())

main("https://www.jcchouinard.com/web-scraping-with-python-and-requests-html/")

You've just to add headers

A: The problem is Accept-Encoding HTTP header. There you have br specified, which means brotli compression method. requests module cannot handle that. Remove br and the server responds without this compression method.
import requests
from bs4 import BeautifulSoup

HEADERS = {
        'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
        'referrer': 'https://google.com',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
        'Accept-Encoding': 'gzip, deflate', # <-- remove br
        'Accept-Language': 'en-US,en;q=0.9',
        'Pragma': 'no-cache',
    }

urls = 'https://www.jcchouinard.com/web-scraping-with-python-and-requests-html/'
r = requests.get(urls, headers=HEADERS)
soup = BeautifulSoup(r.text, "html.parser")
print (soup)

Prints:
<!DOCTYPE html>

<html lang="fr-FR">
<head><style>img.lazy{min-height:1px}</style><link as="script" href="https://www.jcchouinard.com/wp-content/plugins/w3-total-cache/pub/js/lazyload.min.js?x73818" rel="preload"/>

...and so on.


text:
Q: socat - Monitoring USB port to standard CP2102 serial adaptor I have been trying to get a HEX dump of what is being sent/received to CP2102 serial converter chip. I can find examples of people monitoring hardware serial ports /dev/TTYS0 and the like.
socat -d -d pty,link=/dev/ttyUSB0,raw,echo=0 pty,link=/dev/ttyUSB1,raw,echo=0

Does anyone know of a resource that could tell me how to monitor a USB port like this? So far nothing has worked. Maybe I just don't understand the rerouting side of serial monitoring or something?

A: If possible, the easiest may be to adjust the software to emit hex. Most software will likely already have sdio.h (or equivalent) and hex-of-the-serial-data simply requires printf calls (or equivalent) on the data going to and from the serial file descriptor. No complication of an extra process ferrying the data to and fro and little extra latency.
If you're in a hurry something like strace (or sysdig SystemTap etc) could be used to record the communication though strace will slow a process down, a lot, and the output will require post-processing; the other two are kernel modules so may not be suitable.
strace -xx -y -e trace=read,write -p $pid_of_your_program_here

At the hardware level a Bus Pirate or similar may be another way to tap into the communication.
Meanwhile, socat(1) does appear to have a handy -x for hex option:
   -x     Writes  the  transferred  data not only to their target streams,
          but also to stderr. The output format is  hexadecimal,  prefixed
          with  ">  "  or "< " indicating flow directions. Can be combined
          with -v .

which after some experimentation I was able to listen in on a random Arduino via:
socat -x PTY,link=/dev/blah,raw,wait-slave /dev/serial/by-id/usb-Arduino...

and then your software could open up /dev/blah (or maybe instead run it via EXEC?). Note that no raw option was specified after the /dev/serial/by-id/usb-Arduino... path as with that set there were tcgetattr(6, ...): Inappropriate ioctl for device errors when socat tried to configure it. The socat output will likely also require post-processing, as it looks something like:
--
2017/10/09 16:32:20 socat[30806] I transferred 1 bytes from 6 to 5
< 2017/10/09 16:32:20.475916  length=31 from=2042 to=2072
 52 65 71 75 65 73 74 69 6e 67 20 74 65 6d 70 65  Requesting tempe
 72 61 74 75 72 65 73 2e 2e 2e 44 4f 4e 45 0a     ratures...DONE.
--


text:
Q: How to use regexp_replace to replace all blank? I want to use regexp_replace to replace all blank with '_'.
I use this statment:

select regexp_replace('"<div_class="CCL-temp-border"><div_class="input-group_moveDivEnd"_style="margin-bottom:_5px;_top:_auto;_left:_auto;_width:_100%;_position:_relative;_opacity:_1;_filter:_none;"_data-id="moveDivEnd_1545116285310">_;                          <span_class="input-group-addon_CCL-te (...)"', '\s', '_', 'g')

But the result is this:

"<div_class="CCL-temp-border"><div_class="input-group_moveDivEnd"_style="margin-bottom:_5px;_top:_auto;_left:_auto;_width:_100%;_position:_relative;_opacity:_1;_filter:_none;"_data-id="moveDivEnd_1545116285310">_;_______<span_class="input-group-addon_CCL-t (...)"

My statment is this:

select case when length(topiccontent)=0 THEN '_' else coalesce(regexp_replace(replace(replace(replace(topiccontent,chr(13), '_'),chr(10),'_'),' ','_'),'\s', '_', 'g'),'_') end  as topiccontent
  from ccl_topics

You can see the blank still exists, why?

A: I know why it can't be replaced.
There are some character restrictions when the data is pasted out from database.
The omitted part is converted to (...).
So (...) is not real characters, but ellipses.
For example, more than 600 characters exist in a column of a table, and then paste  it,the result with ellipsis marks.


text:
Q: Binary search given slightly inaccurate results The problem I am trying to solve is the following: I get N rectangular paper strips with 1cm width and length C. I need to cut the strips at a height where the sum of the areas of the cut strip is equal to A. You can see an example bellow for which N = 5, the strips are of length, 5,3,6,2 and 3 cm and A = 3cm where the cut is made at 4cm.

Note that I'm looking here for the red area.
The input is given as follows. The first line in each case begins with two integers N (1 ≤ N ≤ 10^5) and A (1 ≤ A ≤ 10^9) representing respectively the number of strips and the expected resulting area. The next line contains N integers, representing the length C_i (1 <= C_i <= 10^4) of each strip.
The input ends with A = C = 0, which should not be processed.
For each test case, output a single line, the height H of the cut that must be done so that the sum of the area of the cut strips is equal to A cm². Print the answer with 4 decimal places. Output ":D" if no cutting is required, or "-.-" if it's impossible.
This problem can be found here
My idea for solving this problem was to use a binary search where I pick a height in the middle of the strips and make it larger or smaller depending on whether my cut was too high or too low. My implementation of the problem is given bellow:
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>

using namespace std;

int main(){
    vector<int> v;  // Vector that holds paper heights
    int n;          // Number of papers
    double h,       // Height of the cut
           sum,     // Area sum
           min_n,   // Minimum height for cut to happen
           max_n,   // Maximum height for cut to happen
           a;       // Desired final area

    // Set desired output
    cout << fixed << setprecision(4);

    /* Get number of papers and desired area,
       terminates if N = A = 0
    */
    while(cin >> n >> a && (n||a)){
        v.resize(n); // Resize vector to fit all papers
        // Get all paper sizes
        for(int i=0;i<n;i++){
            cin >> v[i];
        }
        /* Sort the vector in decreasing order to
           simplify the search
        */
        sort(v.begin(),v.end(),greater<int>());
        max_n = v[0]; // Largest possible cut is at the height of the largest paper
        min_n = 0; // Smallest possible cut is at the base with height 0

        // Iterate until answer is found
        while(true){
            // Initialize cut height as the average of smallest and largest cut sizes
            h = (min_n + max_n)/2;

            /* The area sum is equal to the sum of the areas of each cut, which is
               given by the height of the paper minus the cut height. If the cut is
               higher than the paper, the cut has area 0.
            */
            sum = 0;
            // Using mascoj sugenstion, a few changes were added
            int s; // Temporary variable to hold number of time h is subtracted
            for(int i=0; i<n;i++){
                if(v[i] <= h) break; // From here onward cut area is 0 and there is no point adding
                sum += v[i]; // Removed the subtraction inside of the for loop
                s++; // Count how many paper strips were used
            }
            sum -= h*s // Subtracts the area cut from the s paper strips

            // If the error is smaller than the significant value, cut height is printed
            if(std::abs(sum-a) < 1e-5){
                // If no cut is needed print :D else print cut height
                (h < 1e-4 ? cout << ":D" << endl : cout << h << endl);
                break;
            }
            // If max_n is "equal" to min_n and no answer was found, there is no answer
            else if(max_n - min_n < 1e-7){
                cout << "-.-" << endl;
                break;
            }
            // Reduces search interval
            sum < a ? max_n = h : min_n = h;
        }
    }
    return 0;
}

The problem is, after submitting my answer I keep getting a 10% error. The website has a tool for comparing the output of you program with the expected output so I ran a test file with over 1000 randomly generated test cases and when I compared both I got a rounding error on the 4th decimal case, unfortunately, I don't have the file nor the script to generate test cases for me anymore. I tried changing the acceptable error to a smaller one but that didn't work. I can't seem to find the error, does any of you have an idea of what is happening?
ps: Although the problem doesn't say on the description, you can get cuts with fractions as heights

A: Might be your problem, maybe not: This line is exacerbating floating point error: sum += v[i]-h;
Floating points are only so accurate and compounding this error over a larger summation adds up. I would try using multiplication on h and subtracting that from the total sum of applicable lengths. Should be well within the range of the double precision format so I wouldn't worry about overrunning the format.

A: Not sure to understand your algorithm but I think that can be done a lot simpler using a map instead a vector.
In the following example the map mp memorize how much (the value) strips are of a given lenght (the key).
An advantage of the map is ordered.
Next you can see how much you have to save (not to cat) and calculate the level of the cut starting from zero, adding 1 when appropriate and adding a fraction when neccessary.
Hope the following example can help
#include <map>
#include <iomanip>
#include <iostream>

int main()
 {
   int                         n;
   int                         n2;
   int                         v;
   int                         cut;
   int                         a;
   std::map<int, std::size_t>  mp;
   long long int               sum;
   long long int               ts;

   std::cout << std::fixed << std::setprecision(4);

   while( (std::cin >> n >> a) && ( n || a ) )
    {
      mp.clear();

      n2  = 0;
      sum = 0LL;

      for ( auto i = 0 ; i < n ; ++i )
       {
         std::cin >> v;

         if ( v > 0 )
          {
            sum += v;

            ++mp[v];
            ++n2;
          }
       }

      // mp is a map, so the values are ordered

      // ts is "to save"; sum of lenghts minus a
      ts  = sum - a;

      // cut level
      cut = 0;

      // while we can add a full cm to the cut level
      while ( (ts > 0LL) && (n2 > 0) && (ts >= n2) )
       {
         ++cut;

         ts -= n2;

         if ( cut >= mp.cbegin()->first )
          {
            n2 -= mp.cbegin()->second;

            mp.erase(mp.cbegin());
          }
       }

      if ( (ts == 0LL) && (cut == 0) )
         std::cout << ":D" << std::endl; // no cut required (?)
      else if ( n2 == 0 )
         std::cout << "-.-" << std::endl; // impossible (?)
      else
         std::cout << (cut + double(ts) / n2) << std::endl;
    }
 }

p.s.: observe that a is defined as an integer in the page that you link.


text:
Q: Massive MySQL delete from CSV file To insert massive CSV file into MySQL, there is LOAD DATA INFILE, but is there any similar command to delete massive entries with keys stored in a massive CSV file?
If not, what would you see as the fastest way to perform such operation?
EDIT: Also which one of these 2 methods would you see as the most efficient:
Multiple deletes
DELETE FROM myTable WHERE mykey=1 LIMIT 1;
DELETE FROM myTable WHERE mykey=2 LIMIT 1;
...
DELETE FROM myTable WHERE mykey=300000 LIMIT 1;

Or Batch delete
DELETE FROM myTable WHERE mykey IN (1,2,...,10000);
DELETE FROM myTable WHERE mykey IN (10001,10002,...,20000);
...
DELETE FROM myTable WHERE mykey IN (...,...,300000);

Thanks!

A: DELETE TECHNIQUE #1
If you have a massive delete of keys, you may want to resort to the opposite of doing a massive DELETE: Create the table with the remaining values.
Let's say you loaded a table from the CSV file called KeysToDelete with the field mykey
Here is how to perform the massive DELETE without using DELETE
CREATE TABLE mynewtable FROM mytable;
INSERT INTO mynewtable
SELECT A.* FROM mytable A
LEFT JOIN KeysToDelete B USING (mykey)
WHERE B.mykey IS NULL;
ALTER TABLE mytable RENAME myoldtable;
ALTER TABLE mynewtable RENAME mytable;

That's it.
DELETE TECHNIQUE #2
If you want to use DELETE and the table is not that big, you could do a DELETE JOIN as follows:
DELETE A.* FROM mytable A INNER JOIN KeysToDelete B USING (mykey);

Here are my earlier posts where I discuss these techniques:

*

*Feb 15, 2012 : How to implement soft deletes?

*Mar 05, 2012 : Tombstone Table vs Deleted Flag in database syncronization & soft-delete scenarios

*Nov 07, 2012 : Can I do anything about a very long running KILL command?

*Aug 07, 2013 : How to delete duplicate records
Give it a Try !!!

A: I don't think there is a similar command, but if your keys are simple (not composed) you can do the trick.
I usually generate a DELETE script with an SELECT CONCAT statement
You have your "IDs" file :
root@test:/tmp# cat /tmp/id.out
1
2
34
56
2345
3
4

Create a temp table to store it in SQL:
CREATE TEMPORARY TABLE test.ids (id int PRIMARY KEY);

Load your IDs:
LOAD DATA INFILE '/tmp/id.out' INTO TABLE test.ids;

Then generate a delete.sql script with a SELECT CONCAT:
SELEC CONCAT("DELETE FROM myTable WHERE ID=", id," LIMIT 1;") FROM test.ids INTO OUTFILE "/tmp/delete.sql";

Now you have your delete script:
root@test:/tmp# cat "/tmp/delete.sql"
DELETE FROM myTable WHERE ID=1 LIMIT 1;
DELETE FROM myTable WHERE ID=2 LIMIT 1;
DELETE FROM myTable WHERE ID=3 LIMIT 1;
DELETE FROM myTable WHERE ID=4 LIMIT 1;
DELETE FROM myTable WHERE ID=34 LIMIT 1;
DELETE FROM myTable WHERE ID=56 LIMIT 1;
DELETE FROM myTable WHERE ID=2345 LIMIT 1;

Then you can run your DELETE scripts:
mysql> source /tmp/delete.sql
Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

You can also generate this type of script with OS tools (awk or notepad++)
You can run this type of script safely on a production master, you DELETE rows from the PK and you limit with LIMIT 1 so you do not risk to have replication lags.
Best Regards.
Max.


text:
Q: How to extract data from an already filled up pdf form using any program language? I have a pdf form, I've filled the fields in that form and saved that pdf file as a new pdf file. Now when I open the new pdf file, it automatically loads the data which was filled in earlier. Can I extract that data using any of the language from C/Java/PHP/Javascript, so that I can use that and save that into database?

A: Yes, you can. Easiest solution may be to use a PDF library to access the file.
PHP: http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/


text:
Q: How to efficiently find the maximum value out of this function? I apologize in advance. I am not a mathematician, so I do not know the proper terminology and notation. I am a software developer, and my software uses a function that I believe is very inefficient.
I need to find the value of x that results in the maximum value out of the function.
Currently, I will iterate over different x values thousands of times and compare the results of the function until I find the highest value. I suspect that there is a more efficient way to achieve this, perhaps like a formula that would give me the answer in one calculation instead of thousands iterations.
I also have a major constraint: I can only use integers. If an operation results in a decimal number (like a division), all the decimals will be truncated. I do not need an exact result for this calculation, but it should be reasonably precise.
In the function below, $c_{1}$ and $b_{1}$ to $b_{6}$ are given. I need to be able to change them in the formula between cycles, but I already know their value when I start iterating over different values of x. For instance, I would know that for a given cycle $c_{1} = 999$, $b_{1} = 123401014$, $b_{2} = 231248124$, etc.
Here is the function for which I need to find the value of x corresponding to $max(f(x))$:
$$
f(x) = x \times \frac{c_{1} \times b_{1}}{b_{2} \times 10000 + (x \times c_{1})} \times \frac{c_{1} \times b_{3}}{b_{4} \times 10000 + (\frac{x \times c_{1} \times b_{1}}{b_{2} \times 10000 + (x \times c_{1})} \times c_{1})} \times \frac{c_{1} \times b_{5}}{b_{6} \times 10000 + (\frac{c_{1} \times b_{3}}{b_{4} \times 10000 + (\frac{x \times c_{1} \times b_{1}}{b_{2} \times 10000 + (x \times c_{1})} \times c_{1})} \times c_{1})}
$$
Thank you so much in advance!
EDIT: x must be a positive integer. All the constants $c_{1}$ and $b_{1}$ to $b_{6}$ are also positive integers.

A: The first thing to do is to simplify the formula.  The way I see it,
$$f(x)=f_1(x)f_2(x)f_3(3)$$
where $$\begin{align}
f_1(x)&=\frac{b_1c_1x}{10000b_2+c_1x}\\
f_2(x)&=\frac{c_1b_3}{10000b_4+c_1f_1(x)}\\
f_3(x)&=\frac{c_1b_5}{10000b_6+c_1f_2(x)}
\end{align}$$
Please check carefully that I haven't made a mistake.
$f_1$ has the form of a linear polynomial divided by a linear polynomial, say $$f_1(x)=\frac{ax+b}{cx+d}$$ so $f_2(x)$ has the form $$f_2(x)=\frac{A}{B+C\frac{ax+b}{cx+d}}=\frac{Acx+Ad}{(Bc+Ca)x+(Bd+Cb)}$$ which is again a linear polynomial divided by a linear polynomial.  The same logic shows that when we substitute $f_2$ into $f_3$, we will again get a linear polynomial divided by a linear polynomial.
Since $f$ is the product of three functions of this form,. $f$ is a cubic divided by a cubic, and the formula for the derivative of a quotient shows that that the numerator of the derivative will be a fourth-degree polynomial.  The roots of this polynomial, will be the critical points of $f(x)$.  The values of $x$ at which local maxima and minima occur.
you can get the formula for the numerator of the derivative once and for all, as an expression involving $c_1,b_1,b_2,b_3,b_4,b_5,b_6$ with a computer algebra system.  Then you can plug in the actual values of these constants and get quartic polynomial that you'll need to solve numerically.  The CAS should be able to do that for you too.  There are four roots.  Of course, the roots will probably not be positive integers, and they may not all be real.  You need to take the positive roots, and check the the values of $f$ at the two integers closest to the roots.  You should also check at $x=1$.  At worst, you have to check $9$ values.
I hope this helps.
EDIT
I wrote this little python script
from sympy import ratsimp, symbols, latex

x,c1,b1,b2,b3,b4,b5,b6=symbols('x,c1,b1,b2,b3,b4,b5,b6')
TTHOU=10000
f1  = b1*c1*x/(TTHOU*b2+c1*x)
f2 = c1*b3/(TTHOU*b4+c1*f1)
f3= c1*b5/(TTHOU*b6+c1*f2)
f=ratsimp(f1*f2*f3)
lat = latex(f)
print(lat)

to calculate $f(x)$.  It produces Latex for the formula, which turns out to be $$\frac{b_{1} b_{3} b_{5} c_{1}^{3} x}{10000 b_{1} b_{6} c_{1}^{2} x + 10000 b_{2} b_{3} c_{1}^{2} + 1000000000000 b_{2} b_{4} b_{6} + b_{3} c_{1}^{3} x + 100000000 b_{4} b_{6} c_{1} x}$$
Unfortunately, it doesn't collect the terms in the denominator, but you can see that the formula is of the form $$\frac{Ax}{Bx+C}$$ where $A,B,C$ are positive integers.  When we clear denominators in the fractions, the numerator of $f_2$ turns out to be the denominator of $f1$ and the numerator of $f_3$ to be the denominator of $f_2$, so we get cancellation, and the degrees don't increase.
Now $$f(x)=\frac{Ax}{Bx+C}=\frac{A}{B+\frac Cx}$$  Since $C>0)$ we can see that as $x$ increases through positive inters, the denominator will decrease.  But if you divide by something smaller, you get something bigger, so $f(x)$ increases as $x$ does.  That means that there is no maximum value, which I find hard to reconcile with your description of your experience with this problem.
However, you may have simply been taking larger values of $x$ until you didn't see any more increase.  It's easy to figure out what the limiting value is.
$$f_1(x)=\frac{b_1c_1x}{10000b_2+c_1x}=\frac{b_1c_1}{\frac{10000b_2}x+c_1}$$  If we make $x$ large, we can make $\frac{10000b_2}x$ as close to $0$ as we care to, so the fraction gets arbitrarily close to $$\frac{b_1c_1}{c_1}=b_1$$ We substitue this limit into $f_2$ and then into $f_3$.  Time for some more sympy:
g1 = b1
g2 = c1*b3/(TTHOU*b4+c1*g1)
g3= c1*b5/(TTHOU*b6+c1*g2)
g=ratsimp(g1*g2*g3)
lat = latex(g)
print(lat)

This time we get $$\frac{b_{1} b_{3} b_{5} c_{1}^{2}}{10000 b_{1} b_{6} c_{1} + b_{3} c_{1}^{2} + 100000000 b_{4} b_{6}}\tag1$$  The function has a horizontal asymptote, which means that as $x$ gets very large, the graph looks like a horizontal line.  It actually always increases, but very, very slowly.  We never get to the value in $(1)$, but we can get as close as we like by taking $x$ large enough.


text:
Q: How to sum up multiple lists in Prolog? I am working on a prolog program, but I have no idea to finish the program. Here is the requirement.
The program allows multiple fact, however, the length of list in each fact must equals
Example 1
%fact
f(first, [1, 6, 10]).
f(second, [7, 3, 8]).
f(third, [5, 9, 5]).

Example 2
%fact
f(first, [1,6,10]).
f(second, [7,3,8]).
f(third, [5,9,5]).
f(fourth, [7,3,9]).
f(fifth, [7,7,2]).

Example 3
%fact
f(first, [1,6,10,54,11,6]).
f(second, [7,3,8,34,2,7]).

Now, I need to write a predicate sum_list(), so that users can do the following things.
Example 1
?-sum_list([first,second,third], Even, Result).
Even = 1
Result = [13,18,23]

Example 2
?-sum_list([first,second,third,fourth,fifth], Even, Result).
Even = 2
Result = [27,28,34]

Example 3
?-sum_list([first,second], Even, Result).
Even = 3
Result = [8,9,18,88,13,13]

Result is a list which contains the sum of each element in the corresponding fact lists.
Even is counting the number of even number in the Result, in Example 2, only 28 and 34 are even, so Even = 2.
Thanks.
Thanks for SimoV8's hints, and I get some ideas to solve in the way:
%fact
f(first, [1, 6, 10]).
f(second, [7, 3, 8]).

sum_list([Head|Tail], E, R) :-
    f(Head, P),
    sw(P, Tail, [R]),
    even(E,R).

sw(H1, [Head|Tail], [X|R]) :-
    f(Head,S),
    sum(H1, S, X),
    sw(X, Tail, R).

sw(_, [], []).

sum([H1|T1],[H2|T2],[X|L3]) :-
    sum(T1,T2,L3), X is H1+H2.

sum([],[],[]).

even(E, [X|R]) :-
    even(E2, R),
    ((X mod 2) =:= 1 -> E is E2; E is E2 + 1).

even(0, []).

However, the answer only accepts two f(), if more than two f(), it will return FALSE

A: Try this:
sum_list([], 0, []).
sum_list([H|T], E, [RH|RT]):- f(H, X),
                              sum(X, RH),
                              sum_list(T, E2, RT),
                              ((RH mod 2) =:= 1 -> E is E2; E is E2 + 1).
 sum([], 0).
 sum([H|T], S1):- sum(T, S2), S1 is H + S2.


text:
Q: ListActivity not loading adapters style, loading white screen I am working in android studio with GSON and Retrofit 1, which is stable. I am in need to find out why non of the information is showing, the GSON should be putting the JSON information in the model class of getters/setters. I am making a Movie App using the imdb api, I can share my code here if you would like to review the project as a whole, but otherwise below is some of the code:
GitHub Project
This is the detail item xml I am trying to populate then put in the list in the main xml.
 <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingRight="0dp"
    android:paddingBottom="0dp"
    android:paddingTop="0dp"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.evanglazer.moviezone.MainActivity"
    android:id="@+id/top">

     <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:id="@+id/movieView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

     <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="IMDB Rating:"
        android:id="@+id/imdbText"
        android:padding="10dp"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/movieView"
        android:layout_toEndOf="@+id/movieView" />

     <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:id="@+id/imdbRatingText"
        android:padding="10dp"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/imdbText"
        android:layout_toEndOf="@+id/imdbText"
        android:singleLine="true" />

     <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="UserBase Vote:"
        android:id="@+id/userText"
        android:padding="10dp"
        android:layout_centerInParent="@+id/imdbText"
        android:layout_below="@+id/imdbText"
        android:layout_alignRight="@+id/releaseDateText"
        android:layout_alignEnd="@+id/releaseDateText" />

     <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:id="@+id/userRatingText"
        android:padding="10dp"
        android:layout_below="@+id/imdbText"
        android:layout_toRightOf="@+id/imdbText"
        android:layout_toEndOf="@+id/imdbText"
        android:singleLine="true" />

     <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Release Date:"
        android:id="@+id/releaseText"
        android:padding="10dp"
        android:layout_below="@+id/userText"
        android:layout_toLeftOf="@+id/userRatingText"
        android:layout_toStartOf="@+id/userRatingText"
        />

     <TextView
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:textAppearance="?android:attr/textAppearanceMedium"
     android:id="@+id/releaseDateText"
     android:layout_below="@+id/releaseText"
     android:layout_alignRight="@+id/releaseText"
     android:layout_alignEnd="@+id/releaseText" />

    <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/middle">

   <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Trailer 1"
    android:id="@+id/trailer1"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

   <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Trailer 2"
    android:id="@+id/trailer2"
    android:layout_below="@+id/trailer1"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

   <EditText
    android:layout_width="wrap_content"
    android:layout_height="100dp"
    android:id="@+id/editText"
    android:layout_below="@+id/trailer2"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />
    </RelativeLayout>
    </RelativeLayout>

Here is the detail main:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:id="@+id/main2"
    android:layout_height="match_parent">

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true">
    </ListView>

</RelativeLayout>

Here is the detail activity:
public class DetailActivity extends ListActivity{

public static final String URL_IMAGE_ENDPOINT = "http://image.tmdb.org";
public static final String URL_API_ENDPOINT = "http://api.themoviedb.org";
FragmentManager fm = getFragmentManager();
List<MovieDetail> details;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.detail_main);
    //fm.beginTransaction().replace(R.id.main2, new Detail()).commit();
    //fm.beginTransaction().replace(R.id.main2, new NavBar()).commit();

    if (isOnline()) {
        requestData();
    } else {
        Toast.makeText(this, "Network isn't available", Toast.LENGTH_LONG).show();
    }
}

protected boolean isOnline() {
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = cm.getActiveNetworkInfo();
    if (netInfo != null && netInfo.isConnectedOrConnecting()) {
        return true;
    } else {
        return false;
    }
}
private void requestData()
{
    RestAdapter adapter = new RestAdapter.Builder()
            .setEndpoint(URL_API_ENDPOINT)
            .build();

    MovieAPI api = adapter.create(MovieAPI.class);

    api.getMovieDetails(new Callback<List<MovieDetail>>() {
        @Override
        public void success(List<MovieDetail> movieDetails, Response response) {
            details = movieDetails;
            // update display
            updateDisplay();
        }

        @Override
        public void failure(RetrofitError arg0) {
            // TODO Auto-generated method stub
        }
    });
}

protected void updateDisplay() {
    //Use FlowerAdapter to display data
    MovieDetailAdapter adapter = new MovieDetailAdapter(this,    R.layout.movie_detail_fragment, details);
    setListAdapter(adapter);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        Intent intent = new Intent(this,SettingActivity.class);
        startActivity(intent);
        return true;
    }

    return super.onOptionsItemSelected(item);
}

 }

Here is how I am api through retrofit:
 public interface MovieAPI {

    @GET("/3/movie/273248?api_key=ea8f68dc2c7b43a3df248b9a638f5fb4")
    void getMovieDetails(Callback<List<MovieDetail>> callback);

    @GET("3/movie/5493/movie/549")
    void getPopularMovies(Callback<List<MovieDetail>> response);
    }

Here is the model for the objects I am trying to read in from the callback:
public class MovieDetail {

private String poster_path;
private String release_date;
private int id;
private String original_title;
private double vote_average;
private int gridPos;
private Bitmap bitmap;

public int getGridPos() {
    return gridPos;
}

public void setGridPos(int gridPos) {
    this.gridPos = gridPos;
}

public String getPoster_path() {
    return poster_path;
}

public void setPoster_path(String poster_path) {
    this.poster_path = poster_path;
}

public String getRelease_date() {
    return release_date;
}

public void setRelease_date(String release_date) {
    this.release_date = release_date;
}

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public String getOriginal_title() {
    return original_title;
}

public void setOriginal_title(String original_title) {
    this.original_title = original_title;
}

public double getVote_average() {
    return vote_average;
}

public void setVote_average(double vote_average) {
    this.vote_average = vote_average;
}

public Bitmap getBitmap() {
    return bitmap;
}
public void setBitmap(Bitmap bitmap) {
    this.bitmap = bitmap;
}


text:
Q: Office 365 Powershell Logs Got Very Large I have many scheduled jobs running on a server in our environment, but this morning a monitoring team contacted me about a service account profile eating up all the disk space. I dug around and found logs in C:\Users\service_account\AppData\Local\Microsoft\Office365\Powershell directory, but 3 of them on different dates were over 10 GB in size.
I narrowed it down to one script we have the checks the AD dir sync every hour to make sure it doesn't take longer than an hour, but I'm not sure what the best practice is for this? Also, most logs in this location are only 4 kb in size and indicate typical tracking like, connection times, cmdlets initializing, etc.
I'm not sure how to open such a huge file to see what may be the problem. Has anyone else run into this kind of thing? I can't find much on line. Also, I do run Remove-pssession * to close my sessions. Thx in advance...

A: You have a couple of options.
Read your file from disk one line or groups of lines at a time, work with each line, and then  write each line back out to disk., if needed.
Instead of caching the entire file in RAM by using plain Get-Content, you're reading it off disk a bit at a time. The below represents a very simplistic example of how to do this.
$file = New-Object System.IO.StreamReader -Arg "test.txt"
while ($line = $file.ReadLine()) {
  # $line has your line
}
$file.close()

Or using ...
Get-Content -Readcount 100

... to process chunks of lines at a time, the above will give you arrays of 100 lines each.
There are recent posts on this forum regarding folks working with large files and PoSH and having to resort to using th e System.IO.StreamReader / System.IO.StreamWriter .Net aproach to handle the use case.
For example:
Unable to Find and Replace a string in 2GB XML file using Powershell
But there are lots more on this forum, just search for them using [powershell] large file


text:
Q: Using seneca mesh on rancher I have a Seneca mesh which is working flawlessly on my laptop. However it's being impossible making to make it work on rancher. All the containers end diying because mesh timeouts.
I've read the entire seneca-mesh source code and the underliying sneeze library. That gave me some clues about how to debug this, but that's the longest I got. For example, I realize that seneca-mesh provides several options to sneeze which in turn it provides those to the SWIM implementation they use.
I tried increasing the mesh join timeouts, suspecting that they were two narrow (which was true because they were 777ms). Here is what I set:
edit: I just realized that it will be better if I include the full
{
    pins: ['role:mesh,cmd:test'],
    host: '10.58.58.58',
    isbase: true,
    port: '39999',
    bases: ['10.40.40.1:39999', 'base-hostname:39001'],
    stop: false,
    balance_client: { debug: { client_updates: true } },
    jointime: 2000,
    sneeze:
    {
        silent: false,
        swim: { joinTimeout: 2777, pingTimeout: 2444, pingReqTimeout: 2333 }
    },
    discover:
    {
        custom: { active: true, find: dnsSeed },
        multicast: { active: false },
        registry: { active: false }
    }
}

Sadly the only difference it made was the timeout took longer. Thanks to the silent option you can see I set to false gives you very detailed logs, the only problem is that I can't understand why they are failing.
In my simplest scenario I have two servers, one acting as base (which starts without problems) and a mesh-node that should join the mesh through SWIM. Inspecting the logs I see that they are able to communicate, and the join request from the node are received by the base-node. This happens a couple of times, spaced by the defined timeout and after a couple of join request the base-node asks for leaving the mesh and a timeout occurs:
BASE NODE
SNEEZE 87271 add 10.88.250.29:46830 60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604 seneca~mesh { config:
19/6/2018 16:21:27   { type: 'web',
19/6/2018 16:21:27     port: 57280,
19/6/2018 16:21:27     host: '10.88.250.29',
19/6/2018 16:21:27     path: '/act',
19/6/2018 16:21:27     protocol: 'http',
19/6/2018 16:21:27     timeout: 5555,
19/6/2018 16:21:27     max_listen_attempts: 11,
19/6/2018 16:21:27     attempt_delay: 222,
19/6/2018 16:21:27     serverOptions: {},
19/6/2018 16:21:27     pin:
19/6/2018 16:21:27      [ 'cmd:*,role:profile',
19/6/2018 16:21:27        'cmd:probes.get,role:profile',
19/6/2018 16:21:27        'cmd:campaigns.get,role:profile',
19/6/2018 16:21:27        'cmd:universes.get,role:profile',
19/6/2018 16:21:27        'cmd:probes.del,role:profile',
19/6/2018 16:21:27        'cmd:campaigns.del,role:profile',
19/6/2018 16:21:27        'cmd:universes.del,role:profile' ],
19/6/2018 16:21:27     model: 'consume',
19/6/2018 16:21:27     ismesh: true,
19/6/2018 16:21:27     msgprefix: 'seneca_',
19/6/2018 16:21:27     callmax: 111111,
19/6/2018 16:21:27     msgidlen: 12,
19/6/2018 16:21:27     role: 'transport',
19/6/2018 16:21:27     hook: 'listen' },
19/6/2018 16:21:27  instance: '60226afpvh7z/1529418068191/11/3.6.0/profiles',
19/6/2018 16:21:27  'identifier$': '60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604',
19/6/2018 16:21:27  'tag$': 'seneca~mesh',
19/6/2018 16:21:27  'v$': 0 }
19/6/2018 16:21:30SNEEZE 90301 add 10.88.250.29:49483 60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604 seneca~mesh { config:
19/6/2018 16:21:30   { type: 'web',
19/6/2018 16:21:30     port: 57280,
19/6/2018 16:21:30     host: '10.88.250.29',
19/6/2018 16:21:30     path: '/act',
19/6/2018 16:21:30     protocol: 'http',
19/6/2018 16:21:30     timeout: 5555,
19/6/2018 16:21:30     max_listen_attempts: 11,
19/6/2018 16:21:30     attempt_delay: 222,
19/6/2018 16:21:30     serverOptions: {},
19/6/2018 16:21:30     pin:
19/6/2018 16:21:30      [ 'cmd:*,role:profile',
19/6/2018 16:21:30        'cmd:probes.get,role:profile',
19/6/2018 16:21:30        'cmd:campaigns.get,role:profile',
19/6/2018 16:21:30        'cmd:universes.get,role:profile',
19/6/2018 16:21:30        'cmd:probes.del,role:profile',
19/6/2018 16:21:30        'cmd:campaigns.del,role:profile',
19/6/2018 16:21:30        'cmd:universes.del,role:profile' ],
19/6/2018 16:21:30     model: 'consume',
19/6/2018 16:21:30     ismesh: true,
19/6/2018 16:21:30     msgprefix: 'seneca_',
19/6/2018 16:21:30     callmax: 111111,
19/6/2018 16:21:30     msgidlen: 12,
19/6/2018 16:21:30     role: 'transport',
19/6/2018 16:21:30     hook: 'listen' },
19/6/2018 16:21:30  instance: '60226afpvh7z/1529418068191/11/3.6.0/profiles',
19/6/2018 16:21:30  'identifier$': '60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604',
19/6/2018 16:21:30  'tag$': 'seneca~mesh',
19/6/2018 16:21:30  'v$': 0 }
19/6/2018 16:21:35SNEEZE 95647 remove 10.88.250.29:46830 60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604 seneca~mesh { config:
19/6/2018 16:21:35   { type: 'web',
19/6/2018 16:21:35     port: 57280,
19/6/2018 16:21:35     host: '10.88.250.29',
19/6/2018 16:21:35     path: '/act',
19/6/2018 16:21:35     protocol: 'http',
19/6/2018 16:21:35     timeout: 5555,
19/6/2018 16:21:35     max_listen_attempts: 11,
19/6/2018 16:21:35     attempt_delay: 222,
19/6/2018 16:21:35     serverOptions: {},
19/6/2018 16:21:35     pin:
19/6/2018 16:21:35      [ 'cmd:*,role:profile',
19/6/2018 16:21:35        'cmd:probes.get,role:profile',
19/6/2018 16:21:35        'cmd:campaigns.get,role:profile',
19/6/2018 16:21:35        'cmd:universes.get,role:profile',
19/6/2018 16:21:35        'cmd:probes.del,role:profile',
19/6/2018 16:21:35        'cmd:campaigns.del,role:profile',
19/6/2018 16:21:35        'cmd:universes.del,role:profile' ],
19/6/2018 16:21:35     model: 'consume',
19/6/2018 16:21:35     ismesh: true,
19/6/2018 16:21:35     msgprefix: 'seneca_',
19/6/2018 16:21:35     callmax: 111111,
19/6/2018 16:21:35     msgidlen: 12,
19/6/2018 16:21:35     role: 'transport',
19/6/2018 16:21:35     hook: 'listen' },
19/6/2018 16:21:35  instance: '60226afpvh7z/1529418068191/11/3.6.0/profiles',
19/6/2018 16:21:35  'identifier$': '60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604',
19/6/2018 16:21:35  'tag$': 'seneca~mesh',
19/6/2018 16:21:35  'v$': 0 }

CLIENT NODE:
As you can see there are several join request and finally a remove one, let's examine the client logs
19/6/2018 16:21:21SNEEZE 81049 joining 4 10.88.250.29:41450 60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604 seneca~mesh [ 'nanoservices-base1:39999', '10.42.209.107:39999' ] { joinTimeout: 2777,
19/6/2018 16:21:21  pingTimeout: 2444,
19/6/2018 16:21:21  pingReqTimeout: 2333,
19/6/2018 16:21:21  codec: 'msgpack',
19/6/2018 16:21:21  disseminationFactor: 22,
19/6/2018 16:21:21  interval: 111,
19/6/2018 16:21:21  pingReqGroupSize: 7,
19/6/2018 16:21:21  udp: { maxDgramSize: 2048 },
19/6/2018 16:21:21  local:
19/6/2018 16:21:21   { host: '10.88.250.29:41450',
19/6/2018 16:21:21     meta:
19/6/2018 16:21:21      { config: [Object],
19/6/2018 16:21:21        instance: '60226afpvh7z/1529418068191/11/3.6.0/profiles',
19/6/2018 16:21:21        'identifier$': '60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604',
19/6/2018 16:21:21        'tag$': 'seneca~mesh',
19/6/2018 16:21:21        'v$': 0 },
19/6/2018 16:21:21     incarnation: 1529418081049 } }
19/6/2018 16:21:24SNEEZE 84284 joining 5 10.88.250.29:42022 60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604 seneca~mesh [ 'nanoservices-base1:39999', '10.42.209.107:39999' ] { joinTimeout: 2777,
19/6/2018 16:21:24  pingTimeout: 2444,
19/6/2018 16:21:24  pingReqTimeout: 2333,
19/6/2018 16:21:24  codec: 'msgpack',
19/6/2018 16:21:24  disseminationFactor: 22,
19/6/2018 16:21:24  interval: 111,
19/6/2018 16:21:24  pingReqGroupSize: 7,
19/6/2018 16:21:24  udp: { maxDgramSize: 2048 },
19/6/2018 16:21:24  local:
19/6/2018 16:21:24   { host: '10.88.250.29:42022',
19/6/2018 16:21:24     meta:
19/6/2018 16:21:24      { config: [Object],
19/6/2018 16:21:24        instance: '60226afpvh7z/1529418068191/11/3.6.0/profiles',
19/6/2018 16:21:24        'identifier$': '60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604',
19/6/2018 16:21:24        'tag$': 'seneca~mesh',
19/6/2018 16:21:24        'v$': 0 },
19/6/2018 16:21:24     incarnation: 1529418084284 } }
19/6/2018 16:21:27SNEEZE 87269 joining 6 10.88.250.29:46830 60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604 seneca~mesh [ 'nanoservices-base1:39999', '10.42.209.107:39999' ] { joinTimeout: 2777,
19/6/2018 16:21:27  pingTimeout: 2444,
19/6/2018 16:21:27  pingReqTimeout: 2333,
19/6/2018 16:21:27  codec: 'msgpack',
19/6/2018 16:21:27  disseminationFactor: 22,
19/6/2018 16:21:27  interval: 111,
19/6/2018 16:21:27  pingReqGroupSize: 7,
19/6/2018 16:21:27  udp: { maxDgramSize: 2048 },
19/6/2018 16:21:27  local:
19/6/2018 16:21:27   { host: '10.88.250.29:46830',
19/6/2018 16:21:27     meta:
19/6/2018 16:21:27      { config: [Object],
19/6/2018 16:21:27        instance: '60226afpvh7z/1529418068191/11/3.6.0/profiles',
19/6/2018 16:21:27        'identifier$': '60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604',
19/6/2018 16:21:27        'tag$': 'seneca~mesh',
19/6/2018 16:21:27        'v$': 0 },
19/6/2018 16:21:27     incarnation: 1529418087269 } }
19/6/2018 16:21:30SNEEZE 90298 joining 7 10.88.250.29:49483 60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604 seneca~mesh [ 'nanoservices-base1:39999', '10.42.209.107:39999' ] { joinTimeout: 2777,
19/6/2018 16:21:30  pingTimeout: 2444,
19/6/2018 16:21:30  pingReqTimeout: 2333,
19/6/2018 16:21:30  codec: 'msgpack',
19/6/2018 16:21:30  disseminationFactor: 22,
19/6/2018 16:21:30  interval: 111,
19/6/2018 16:21:30  pingReqGroupSize: 7,
19/6/2018 16:21:30  udp: { maxDgramSize: 2048 },
19/6/2018 16:21:30  local:
19/6/2018 16:21:30   { host: '10.88.250.29:49483',
19/6/2018 16:21:30     meta:
19/6/2018 16:21:30      { config: [Object],
19/6/2018 16:21:30        instance: '60226afpvh7z/1529418068191/11/3.6.0/profiles',
19/6/2018 16:21:30        'identifier$': '60226afpvh7z/1529418068191/11/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529418068604',
19/6/2018 16:21:30        'tag$': 'seneca~mesh',
19/6/2018 16:21:30        'v$': 0 },
19/6/2018 16:21:30     incarnation: 1529418090298 } }
19/6/2018 16:21:30      ERR -   Error: seneca: Action name:mesh,plugin:define,role:seneca,seq:2,tag:undefined failed: [TIMEOUT].
19/6/2018 16:21:30      ERR -   Error: seneca: Action cmd:listen,role:transport failed: [TIMEOUT].
19/6/2018 16:21:30/home/dockerfileUser/node_modules/seneca/lib/common.js:278
19/6/2018 16:21:30        throw error(err, '[DEATH LOOP] die count: ' + diecount)
19/6/2018 16:21:30        ^
19/6/2018 16:21:30
19/6/2018 16:21:30Error: [TIMEOUT]
19/6/2018 16:21:30    at Object.act_tm [as ontm] (/home/dockerfileUser/node_modules/seneca/seneca.js:923:52)
19/6/2018 16:21:30    at Timeout.timeout_check [as _onTimeout] (/home/dockerfileUser/node_modules/gate-executor/gate-executor.js:216:16)
19/6/2018 16:21:30    at ontimeout (timers.js:475:11)
19/6/2018 16:21:30    at tryOnTimeout (timers.js:310:5)
19/6/2018 16:21:30    at Timer.listOnTimeout (timers.js:270:5)

It's obvious that the same join request are seen on both ends, but for some weird reason they don't agree on joining the mesh
As reference, here is a log that works on local:
[profiles - 70833]: SNEEZE 86079 joining 0 127.0.0.1:42294 uemigxtf6h6w/1529417884911/70833/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529417886077 seneca~mesh [ '127.0.0.1:39999', '127.0.0.1:39001' ] { joinTimeout:2777,
[profiles - 70833]:   pingTimeout: 2444,
[profiles - 70833]:   pingReqTimeout: 2333,
[profiles - 70833]:   codec: 'msgpack',
[profiles - 70833]:   disseminationFactor: 22,
[profiles - 70833]:   interval: 111,
[profiles - 70833]:   pingReqGroupSize: 7,
[profiles - 70833]:   udp: { maxDgramSize: 2048 },
[profiles - 70833]:   local:
[profiles - 70833]:    { host: '127.0.0.1:42294',
[profiles - 70833]:      meta:
[profiles - 70833]:       { config: [Object],
[profiles - 70833]:         instance: 'uemigxtf6h6w/1529417884911/70833/3.6.0/profiles',
[profiles - 70833]:         'identifier$':
[profiles - 70833]:          'uemigxtf6h6w/1529417884911/70833/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529417886077',
[profiles - 70833]:         'tag$': 'seneca~mesh',
[profiles - 70833]:         'v$': 0 },
[profiles - 70833]:      incarnation: 1529417886079 } }
[base0 - 70753]: SNEEZE 86089 add 127.0.0.1:42294 uemigxtf6h6w/1529417884911/70833/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529417886077 seneca~mesh { config:
[base0 - 70753]:    { type: 'web',
[base0 - 70753]:      port: 59881,
[base0 - 70753]:      host: '0.0.0.0',
[base0 - 70753]:      path: '/act',
[base0 - 70753]:      protocol: 'http',
[base0 - 70753]:      timeout: 5555,
[base0 - 70753]:      max_listen_attempts: 11,
[base0 - 70753]:      attempt_delay: 222,
[base0 - 70753]:      serverOptions: {},
[base0 - 70753]:      pin:
[base0 - 70753]:       [ 'cmd:*,role:profile',
[base0 - 70753]:         'cmd:probes.get,role:profile',
[base0 - 70753]:         'cmd:campaigns.get,role:profile',
[base0 - 70753]:         'cmd:universes.get,role:profile',
[base0 - 70753]:         'cmd:probes.del,role:profile',
[base0 - 70753]:         'cmd:campaigns.del,role:profile',
[base0 - 70753]:         'cmd:universes.del,role:profile' ],
[base0 - 70753]:      model: 'consume',
[base0 - 70753]:      ismesh: true,
[base0 - 70753]:      msgprefix: 'seneca_',
[base0 - 70753]:      callmax: 111111,
[base0 - 70753]:      msgidlen: 12,
[base0 - 70753]:      role: 'transport',
[base0 - 70753]:      hook: 'listen' },
[base0 - 70753]:   instance: 'uemigxtf6h6w/1529417884911/70833/3.6.0/profiles',
[base0 - 70753]:   'identifier$':
[base0 - 70753]:    'uemigxtf6h6w/1529417884911/70833/3.6.0/profiles~cmd:*,role:profile,cmd:probes.get,role:profile,cmd:campaigns.get,role:profile,cmd:universes.get,role:profile,cmd:probes.del,role:profile,cmd:campaigns.del,role:profile,cmd:universes.del,role:profile~1529417886077',
[base0 - 70753]:   'tag$': 'seneca~mesh',
[base0 - 70753]:   'v$': 0 }
[profiles - 70833]: SNEEZE 86139 add 127.0.0.1:39999 8tcsh6vibtus/1529417858791/70753/3.6.0/base0~cmd:test,role:mesh~1529417859689 seneca~mesh { config:
[profiles - 70833]:    { type: 'web',
[profiles - 70833]:      port: 53238,
[profiles - 70833]:      host: '0.0.0.0',
[profiles - 70833]:      path: '/act',
[profiles - 70833]:      protocol: 'http',
[profiles - 70833]:      timeout: 5555,
[profiles - 70833]:      max_listen_attempts: 11,
[profiles - 70833]:      attempt_delay: 222,
[profiles - 70833]:      serverOptions: {},
[profiles - 70833]:      pin: [ 'cmd:test,role:mesh' ],
[profiles - 70833]:      model: 'consume',
[profiles - 70833]:      ismesh: true,
[profiles - 70833]:      msgprefix: 'seneca_',
[profiles - 70833]:      callmax: 111111,
[profiles - 70833]:      msgidlen: 12,
[profiles - 70833]:      role: 'transport',
[profiles - 70833]:      hook: 'listen' },
[profiles - 70833]:   instance: '8tcsh6vibtus/1529417858791/70753/3.6.0/base0',
[profiles - 70833]:   'identifier$':
[profiles - 70833]:    '8tcsh6vibtus/1529417858791/70753/3.6.0/base0~cmd:test,role:mesh~1529417859689',
[profiles - 70833]:   'tag$': 'seneca~mesh',
[profiles - 70833]:   'v$': 0 }
[profiles - 70833]: Joined the mesh:  { id: 'uemigxtf6h6w/1529417884911/70833/3.6.0/profiles',
[profiles - 70833]:   tag: 'profiles',
[profiles - 70833]:   start: 1529417884911 }
[profiles - 70833]: Deferred services loaded

As I said, I tried every possible combination of timeouts and register methods, I asked for help on their gitter channel, I read the source code of the two main libraries used, an I'm unable to find an answer. I know there are users facing similar problems with rancher as explained here:
https://github.com/senecajs/seneca-mesh/issues/75 (by the way, the last comment is mine) but they at least are able to run a basic mesh on rancher, I can't even reach that point.


text:
Q: OpenSL ES for recording audio in android NDK I am starting to learn OpenSL ES for android, before I do I want to confirm if I record directly using JNI will it bypass manufacturer's pre-processing like AGC and low pass filtering? Will it provide raw PCM data source data?
Is most of the pre-processing done at the kernel driver level or at the library level?
Is there a way to get pure audio directly from drivers with JNI and does google or phone manufacturer's give this kind of access?

A: There is a very detail information about audio requirements for android device and application is connected to the device drivers. You will find information about the following here

*

*Application framework

*JNI

*Native framework

*Binder IPC

*Media Server

*HAL

*Kernel Driver

Hope this helps to people.


text:
Q: select row after update in mysql PDO How to select one row after update in one query with PDO and PHP?
like this:
function giftUpdate($username,$id,$date,$conn){
$update = $conn->prepare("UPDATE gifts SET used = 1 , user = :user , date = :date WHERE id = :id");
$update->bindParam("id" , $id );
$update->bindParam("date" , $date );
$update->bindParam("user" , $username );
$update->execute();
return $update ? true : false;

}
function giftGet($username,$currnetTime,$conn) {
$statment = $conn->prepare("SELECT * FROM gifts WHERE used = 0 ORDER BY `id` ASC");
$statment->execute();
$gift = $statment->fetch(PDO::FETCH_OBJ);
if($gift){
    $voucher = $gift->code;
    $voucherid = $gift->id;
    $vouchertype = $gift->type;
    $voucherkey = $gift->keys;

    if($voucher){
       $giftUpdate = giftUpdate($username,$voucherid,$currnetTime,$conn);
       if($giftUpdate){
        useUpdate($username , $conn);
       }
    }
}

usleep(50000);
return $gift ? $gift : false;

}
After update I need select the same row to send it to user.
(i`am one table for vouchers list with 1000row and column 'used' with 0 by default  , and with user request i need in one query update this row to be used 1 and select this row.)
my problem in this functions is Some users will receive a duplicate vouchers And a code is assigned to several users.
guys ... for this case Is it possible to use the transaction method? Or do you suggest using a transaction at all?
Edited:
I eventually changed the code below, but I'm still in line :
SELECT id FROM gifts WHERE used = 0 ORDER BY id ASC limit 1 FOR UPDATE)");
But when I put an id from the database instead of this code, it works!
function giftGet($username, $currnetTime, $conn)
{
$uniqid = uniqid('vouchers_');
$update = $conn->prepare("UPDATE gifts SET used = 1, uniqueid =:uniqueid , user = :user , date = :date WHERE id = (
                          SELECT id FROM gifts WHERE used = 0 ORDER BY `id` ASC limit 1 FOR UPDATE)");
$update->bindParam("date", $currnetTime);
$update->bindParam("uniqueid", $uniqid);
$update->bindParam("user", $username);
$update->execute();
$updaterowCount = $update->rowCount();
if ($updaterowCount)
    {
    $statment = $conn->prepare("SELECT * FROM gifts WHERE uniqueid = :uniqueid ORDER BY `id` ASC");
    $statment->bindParam("uniqueid", $uniqid);
    $statment->execute();
    $gift = $statment->fetch(PDO::FETCH_OBJ);
    $voucherid = $gift->id;
    if ($gift)
        {
        useUpdate($username, $voucherid, $conn);
        }
    }

return $gift ? $gift : false;
}

A: I would alter the table gifts and add a column uniqueid(varchar).
then use
$uniqid = uniqid('vouchers_');

and rewrite your update
"UPDATE gifts SET used = 1, uniqueid =:UNIQUEID , user = :user , date = :date WHERE id = (
SELECT id FROM gifts WHERE used = 0 ORDER BY `id` ASC limit 1 FOR UPDATE)";

now you can identify the updated record by uniqueid.
In Your Code there is a time-gap between the select and the update. 2 or more users can start at the same time the select, recieve the same voucher before it is updated with used = 1


text:
Q: Applying multiple styles on Textblock populated by Data binding I have a <TextBlock> element that look like this,
<TextBlock Text="{Binding Name, StringFormat= 'Name: {0}'}"/>

Now how would I go if I wanted to have the first part as Bold style and the second one as Italic style ,
eg.
Name: Person's name
At the moment using a style applies it on the result of my StringFormat.
Is there an easy way to accomplish this ?

A: Use two Runs:
<TextBlock>
    <Run Text="Name:" FontWeight="Bold"/>
    <Run Text="{Binding Name}" FontStyle="Italic"/>
</TextBlock>


text:
Q: Why does this Qt example work with addresses instead of the objects and functions themselves? And no SLOT/SIGNAL keywords? I've encountered this code in the Qt documentation:
Counter a, b;

QObject::connect(&a, &Counter::valueChanged,

                 &b, &Counter::setValue);

a.setValue(12);     // a.value() == 12, b.value() == 12
b.setValue(48);     // a.value() == 12, b.value() == 48

Why is there an & before a and b, and before the functions? a is the emitting object (provides the signal) and b is the receiving object (has the slot), so why is their address being taken here instead of just using the objects themselves (& takes the address of an object if I'm not mistaken)? In other Qt examples it's not like this (the address isn't used, the objects themselves are)
I'm not too sure how the & before the function calls (i.e. Counter::valueChanged and Counter::setValue) work...I think it forces them to return by reference, but I'm not sure how that's important here.
Lastly, why is it that there are not SLOT and SIGNAL keywords? Shouldn't it be SIGNAL(Counter::valueChanged) and SLOT(Counter::setValue)? Again, that's what I've seen in other examples of QObject:connect, and this example isn't making sense to me.
Any help is appreciated!

A: Look at this:
Counter a, b; // objects created on the stack, they are not pointers

// get the addresses of the objects and assign them as pointers.
Counter *aPointer = &a;
Counter *bPointer = &b;

The following will not compile because a and b are not pointers and QObject connect expects pointers to instances of classes that inherit from QObject.
QObject::connect(a, &Counter::valueChanged, b, &Counter::setValue);

The following will compile because you supply pointers:
QObject::connect(aPointer, &Counter::valueChanged, bPointer, &Counter::setValue);

Similarly this also works, because you take the address(aka pointer) of the objects:
QObject::connect(&a, &Counter::valueChanged, &b, &Counter::setValue);

That hopefully explains the & before the objects. Then there are the &'s before the function names. It's the syntax for a pointer to a member function:
&Counter::valueChanged

The the class name (Counter), appended with :: and the member function name (valueChanged), preceded with &.
It's a member of the pointer that is provided as the first argument in this case. This one is called a signal. Under the hood Qt calls them together.
QObject *sender = &a;
std::function<void()> signal = std::bind(&Counter::valueChanged,sender);
...
signal(); // the function is called here

The same happens for the slot.
Lastly, the SIGNAL() and SLOT() macros are used < Qt 5.0. So it's deprecated and should not be used anymore. In some rare cases you should still use it as there is no other alternative, e.g. with QtDBus but that's another topic.
I hope that clears some of your questions.


text:
Q: How to extract and translate months from a string variable I have a data.frame of months in both English and Dutch:
library(stringr)
months.english <- month.name
months.dutch <- c("januari", "februari", "maart", "april", "mei", "juni","juli", "augustus", "september", "oktober", "november", "december")
months <- data.frame(months.english, months.dutch)

I also have a variable of dates, which somewhat unstructured and in both English and Dutch:
time <- (c("1 januari 2001", "12 december 2001", "December 9 2001", "2001 maart 13"))
time <- data.frame(time)
time$months <- NA

I want to do the following: in the time data.frame I want the months variable to be the month from the dates string, but for those months that are in Dutch, I want the English translation such that dates$months is equal to c("January", "December", "December", "March").
How can I do this the quickest, possibly preventing a for loop (since the actual data.frame has more than 100000 rows)?

A: Here's a vectorized stringi approach.
Step 1: extract the dutch month names:
library(stringi)
m <- stri_extract_first(tolower(dates$time),
          regex = paste(months$months.dutch, collapse = "|"))

Step 2: match with english month names:
dates$months <- months$months.english[match(m, months$months.dutch)]

This should be pretty fast for your data size of 100k rows.
The result is:
dates
#              time   months
#1   1 januari 2001  January
#2 12 december 2001 December
#3  December 9 2001 December
#4    2001 maart 13    March

A: library(stringr)
library(dplyr)
months.english <- month.name
months.dutch <- c("januari", "februari", "maart", "april", "mei", "juni","juli", "augustus", "september", "oktober", "november", "december")
months <- data.frame(months.english, months.dutch)

mtable <- data_frame( key = c(months.dutch, months.english),
                      months = rep(months.english, 2))

time <- (c("1 januari 2001", "12 december 2001", "December 9 2001", "2001 maart 13"))
time <- data_frame(time) %>%
  mutate(translate = str_extract(time, "[A-Za-z]+")) %>%
  left_join(mtable, by = c('translate' = 'key'))

If you want to use the tidyverse, you can create a key table to join.


text:
Q: Jquery/CSS - transform:rotate(0deg) not working Context: I am creating a basic animation, where in a boy figure walks upto a girl's figure and stops. I am using CSS3- translate to achieve it. To stop the hand and leg from moving I am using Javascript event -
boy.addEventListener("webkitAnimationEnd", animation_end);

and the finally Jquery
$('#boy-right-leg').css('-webkit-animation-play-state','paused');

I want the legs to be straight, however it is crossed.
function animation_end() {
  $('#boy-right-leg').css('-webkit-animation-play-state','paused');
  $('#boy-left-hand').css('-webkit-animation-play-state','paused');
  $('#boy-left-leg').css('-webkit-animation-play-state','paused');
  $('#boy-right-leg').css('-webkit-transform','rotate(0deg)');
  $('#boy-left-leg').css('-webkit-transform','rotate(0deg)');
}

Issue: The CSS function in Jquery is not working. The legs are still crossed.The legs should be straight.
Please let me how to fix it?
Browser - Safari.
whole code - http://codepen.io/tusharsaurabh/pen/QKXXmY
Please note -
1. My code has mix of Jquery and Javascript, as I started with Javascript but to solve the issue I tried many things and slowly moved to Jquery.

A: When you change the value of 'animation-play-state' to 'paused' the transform stays with the value it has at that same moment.
To remove that value you can change the 'animation-iteration-count' to 1 for example, or remove the animation by changing its value to 'none'. But notice the value wont transition, it will simply jump.