text:
Q: overzealous filter on nested ng-repeat I have a series of ng-repeated ul/li sets, and I want to make one set of li's visible when a link at the ul level is clicked.
My code is based around the answer found here: https://stackoverflow.com/a/12431211 which suggests that model mutation is the right way to do this.
The filter seems to be more zealous than anticipated, and I end up with nothing.
How can I achieve this functionality?
div ng-controller="DeviceController">

        {{category.name}}

            {{device.name}}

function DeviceController($scope) {
    $scope.devices = [
        {name: 'Desktop',
         devices: [{id:1, name:'Olivia'},
                   {id:2, name:'Cayenne'}]
        },
        {name: 'Laptop',
         devices: [{id:3, name:'Probook'},
                   {id:4, name:'Asus G750'}]
        },
        {name: 'Tablet',
         devices: [{id:5, name:'Transformer Prime'},
                   {id:4, name:'Galaxy Note 10.1'}]
        }
    ];

    $scope.setCategory = function(category) {
        $scope.selected = category
    }

    $scope.isSelected = function(category) {
        return $scope.selected === category;
    }
}

fiddle is here: http://jsfiddle.net/3rV6w/6/
I can't figure out why that isSelected() function works well as a condition on the active class (in the referenced answer) but doesn't perform equally as a filter. Scope perhaps? various console.log's suggest that it should work, but..

A: I've ended up discarding the filter, and using ng-hide instead.

    {{category.name}}

        {{device.name}}

What I think was happening is that the ng-filter was comparing 'device' with the true/false returned by isSelected(category). This will never match, so no results made it past the filter.


text:
Q: API design: stream objects vs. functions vs. messages I'm designing API for a python library that accepts asynchronous input and produces the asynchronous output: various signals come in, and various signals are generated in response (there's no one-to-one relationship between input and output signals).
The input could come from a network socket/file/interactive (terminal-based) user input; or from a web framework view function. Similarly, the output may have to be sent to a socket/file/screen, or returned to a caller (in this last case, it should be buffered, and all output accumulated since the last call should be returned). The choice between different I/O channels is made once at the beginning and isn't changed while the program is running.
I assume the I/O layer uses multiple threads or processes or is asynchronous. And it calls my library functions.
What are the pros/cons of accepting as arguments two stream objects (for input and output); exposing functions that need to be called when an input is available or output is desired; using messages to communicate? Or perhaps some other approach is better?

A: Briefly:

*

*messages: a straightforward paradigm, and often the easiest to interface with, especially if you want to target a wide range of i/o (tcp, http, terminal...). In most cases, you have an independent in-between layer to cache and handle i/o streams.

*functions: well, that's perfect for libraries used in the same language. But if you want to interface with it at a higher level, you will need a wrapper around it anyway.

*streams: accepting streams directly in the lib is similar to messages but has a drawback. Mainly, everything regarding what can go wrong with streams (disconnected, timeouts, errors...) tends to end up as exception handling in your "business logic" instead of a separate layer.
IMHO, I wouldn't see it as an "this or that" question. Rather it might be interesting to look at it from this perspective:

streams are used to transmit messages which are the result of function calls

redpajama_set_name: RedPajamaStackExchange


text:
Q: Insert liveCuePoints in live broadcast - getting error 403 Forbidden We have a verified app with the following scopes:

*

*https://www.googleapis.com/auth/youtube.force-ssl

*https://www.googleapis.com/auth/youtubepartner

*https://www.googleapis.com/auth/youtube
This means we can use the YouTube Data API and YouTube Content ID API (for YouTube Partners).
We are trying to do ad inserts (insert LiveCuepoints) for a live broadcast on a YouTube partner channel, which is connected via our verified app. We are getting the following error when we use the LiveCuepoint insert API endpoint:
Request
POST /youtube/partner/v1/liveCuepoints?channelId={channelId}&onBehalfOfContentOwner={contentOwnerId} HTTP/1.1
Authorization: Bearer {accessToken}
Content-Type: application/json; charset=utf-8
Host: www.googleapis.com
Content-Length: 57

{"broadcastId":"{broadcastId}","settings":{"cueType":"ad"}}

Response
{
  "error": {
    "code": 403,
    "message": "Forbidden",
    "errors": [
      {
        "message": "Forbidden",
        "domain": "global",
        "reason": "forbidden"
      }
    ]
  }
}

Other requests (with the same credentials) to the YouTube Content ID API (such as listing contentOwners or listing liveBroadcasts) are working fine and without errors.
We've tried debugging this issue for many hours, researched online and tried different solutions but couldn't get this to work. Is there a special scope, setting or access needed to do ad inserts in a live broadcast? Is anyone having working example code to do liveCuepoint inserts?

A: For anyone interested: I found the solution.
We connected (via our verified app) as a channel. This was a mistake, you have to authenticate with an account, and this account must have administrator rights.
Now you receive an access token which can access all content owners and channels connected to that account. Inserting liveCuePoints now works fine!


text:
Q: how to fit too wide and long table (one table) into two pages I have a table which too long and wide as well. I tried to fit it into Latex but not fit correctly by using packages rotating' and tabularx' (landscape page). I do not have the experience to fit this long and wide table into Latex, which I would like to see this table on landscape two pages as there are more details should be clear to read them.
Here the code:
\documentclass{book} % thesis class
\usepackage{rotating}
\usepackage{tabularx}
\usepackage[labelfont=bf]{caption} % optional

\usepackage{ragged2e}

\begin{document}

\begin{sidewaystable}
\caption{Long wide table}
\label{tab:margParams}
\centering
%\resizebox{\textwidth}{!}{
\begin{tabularx}{\textwidth}{Xllllllllllll}
  \hline
& \multicolumn{6}{c}{\textbf{Group 0}} & \multicolumn{6}{c}{\textbf{Group 1}}  \\
  & Posterior Mean &  95\% HPD Interval & SD & Bias & MSE & Coverage & Posterior Mean &  95\% HPD Interval & SD & Bias & MSE & Coverage \\
  \hline
  &  \multicolumn{12}{c}{\textbf{Albumin}} \\
  E[Albumin:Intercept] & 3.69 & (3.64, 3.74) & 3.96$\times 10^{-3}$ & 1.48$\times 10^{-4}$ & 6.17$\times 10^{-4}$ & 0.96 & 3.38 & (3.28, 3.48)& 4.16$\times 10^{-3}$ & -1.12$\times 10^{-2}$ & 3.80$\times 10^{-3}$ & 0.89 \\
  E[Albumin:slope] & -6.85$\times 10^{-3}$ & (-9.17, -4.51)$\times 10^{-3}$ & 3.38$\times 10^{-4}$ & -2.28$\times 10^{-5}$ & 1.81$\times 10^{-6}$ & 0.89 & -1.42$\times 10^{-2}$ &( -1.91, -0.94)$\times 10^{-2}$ & 2.93$\times 10^{-4}$ & 1.92$\times 10^{-4}$ & 7.06$\times 10^{-6}$ & 0.91\\
  SD[Albumin:Intercept] & 2.64$\times 10^{-1}$ & (2.23, 3.07)$\times 10^{-1}$ & 1.73$\times 10^{-3}$ & 4.21$\times 10^{-4}$ & 3.81$\times 10^{-4}$ & 0.95 & 2.58$\times 10^{-1}$ &( 1.74, 3.43)$\times 10^{-1}$ & 3.30$\times 10^{-3}$ & -6.18$\times 10^{-3}$ & 2.21$\times 10^{-3}$ & 0.95 \\
  Corr[Albumin:Intercept,Albumin:slope] & 6.23$\times 10^{-3}$ & (-5.28,5.63)$\times 10^{-1}$ & 2.30$\times 10^{-2}$ & 7.09$\times 10^{-2}$ & 2.05$\times 10^{-2}$ & 0.99 & -2.23$\times 10^{-3}$ & (-6.72, 6.89)$\times 10^{-1}$ & 1.41$\times 10^{-2}$ & 6.24$\times 10^{-2}$ & 1.97$\times 10^{-2}$ & 0.99 \\
  Corr[Albumin:Intercept,log(Bilirubin):Intercept] & -1.79$\times 10^{-1}$ & (-3.54, -0.03)$\times 10^{-1}$ & 7.12$\times 10^{-3}$ & 1.72$\times 10^{-2}$ & 9.32 $\times 10^{-3}$& 0.95 & -1.80$\times 10^{-1}$ &( -5.11, 1.60)$\times 10^{-1}$ & 1.09$\times 10^{-2}$ & 1.65$\times 10^{-2}$ & 2.10$\times 10^{-2}$ & 0.99 \\
  Corr[Albumin:Intercept,log(Bilirubin):slope] & 1.74$\times 10^{-1}$ & (-1.72, 5.15)$\times 10^{-1}$ & 1.31$\times 10^{-2}$ & -3.70$\times 10^{-2}$ & 2.17$\times 10^{-2}$ & 0.96 & 5.92$\times 10^{-2}$ & (-6.01, 6.96)$\times 10^{-1}$ & 1.39$\times 10^{-2}$ & -1.52$\times 10^{-1}$ & 5.51$\times 10^{-2}$ & 0.99 \\
  Corr[Albumin:Intercept,Platelet:Intercept] & 1.43$\times 10^{-1}$ & (-0.33, 3.17)$\times 10^{-1}$ & 8.32$\times 10^{-3}$ & -4.84$\times 10^{-2}$ & 1.06$\times 10^{-2}$ & 0.90& 1.40$\times 10^{-1}$ & (-1.92, 4.65)$\times 10^{-1}$ & 1.09$\times 10^{-2}$ & -5.15$\times 10^{-2}$ & 3.09$\times 10^{-2}$ & 0.92 \\
  Corr[Albumin:Intercept,Platelet:slope] & 6.04$\times 10^{-2}$ & (-1.19, 2.40)$\times 10^{-1}$ & 8.06$\times 10^{-3}$ & -4.90$\times 10^{-2}$ & 1.15$\times 10^{-2}$ &0.89 & 3.21$\times 10^{-2}$ & (-3.10, 3.76)$\times 10^{-1}$ & 1.16$\times 10^{-2}$ & -7.73$\times 10^{-2}$ & 3.31$\times 10^{-2}$ & 0.90 \\
  Corr[Albumin:Intercept,Blood Vessel Malformations:Intercept] & -2.70$\times 10^{-1}$ & (-4.92, -0.43)$\times 10^{-1}$ & 8.93$\times 10^{-3}$ & 7.88$\times 10^{-2}$ & 1.93$\times 10^{-2}$ & 0.89 & -2.95$\times 10^{-1}$ & (-6.65, 0.93)$\times 10^{-1}$ & 1.22$\times 10^{-2}$ & 5.35$\times 10^{-2}$ & 3.12$\times 10^{-2}$ & 0.96 \\
  SD[Albumin:slope] & 3.62$\times 10^{-3}$ & (0.85, 7.22)$\times 10^{-3}$ & 5.89$\times 10^{-4}$ & -4.14$\times 10^{-3}$ & 2.50$\times 10^{-5}$ & 0.47 & 3.30$\times 10^{-3}$ & (0.07, 8.15)$\times 10^{-3}$ & 3.60$\times 10^{-4}$ & -4.46$\times 10^{-3}$ & 2.69$\times 10^{-5}$ & 0.54 \\
  Corr[Albumin:slope,log(Bilirubin):Intercept] & -2.98$\times 10^{-2}$ & (-5.60,5.03)$\times 10^{-1}$ & 2.38$\times 10^{-2}$ & -3.14$\times 10^{-2}$ & 1.85$\times 10^{-2}$ & 0.99 & -1.05$\times 10^{-2}$ & (-6.73, 6.52)$\times 10^{-1}$ & 1.33$\times 10^{-2}$ & -1.21$\times 10^{-2}$ & 1.60$\times 10^{-2}$ & 0.99 \\
  Corr[Albumin:slope,log(Bilirubin):slope] & -3.73$\times 10^{-2}$ &(-6.30, 5.68)$\times 10^{-1}$ & 2.30$\times 10^{-2}$ & 1.96$\times 10^{-1}$ & 5.31$\times 10^{-2}$ & 0.99 & -1.76$\times 10^{-2}$ & (-7.77, 7.50)$\times 10^{-1}$ & 1.24$\times 10^{-2}$ & 2.15$\times 10^{-1}$ & 5.62$\times 10^{-2}$ & 0.99 \\
  Corr[Albumin:slope,Platelet:Intercept] & -1.74$\times 10^{-1}$ & (-6.87, 3.65)$\times 10^{-1}$ & 3.11$\times 10^{-2}$ & 8.34$\times 10^{-2}$ & 3.09$\times 10^{-2}$ & 0.98 & -7.37$\times 10^{-2}$ & (-7.17, 5.89)$\times 10^{-1}$ & 1.40$\times 10^{-2}$ & 1.83$\times 10^{-1}$ & 5.04$\times 10^{-2}$ & 0.99 \\
  Corr[Albumin:slope,Platelet:slope] & -1.42$\times 10^{-1}$ & (-6.35,3.76)$\times 10^{-1}$ & 2.83$\times 10^{-2}$ & 1.18$\times 10^{-1}$ & 3.45$\times 10^{-2}$ & 0.99 & -9.37$\times 10^{-2}$ & (-7.17, 5.56)$\times 10^{-1}$ & 1.53$\times 10^{-2}$ & 1.67$\times 10^{-1}$ & 4.91$\times 10^{-2}$ & 0.99 \\
  Corr[Albumin:slope,Blood Vessel Malformations:Intercept] & 8.20$\times 10^{-2}$ & (-4.90, 6.36)$\times 10^{-1}$ & 2.84$\times 10^{-2}$ & -1.45$\times 10^{-1}$ & 4.16$\times 10^{-2}$ & 0.99 & 5.78$\times 10^{-2}$ &( -6.50, 7.41)$\times 10^{-1}$ & 1.52$\times 10^{-2}$ & -1.69$\times 10^{-1}$ & 4.78$\times 10^{-2}$ & 0.99 \\
  &  \multicolumn{12}{c}{\textbf{log(Bilirubin)}} \\
  E[log(Bilirubin):Intercept] & 2.06$\times 10^{-2}$ &( -1.04, 1.44)$\times 10^{-1}$ & 4.11$\times 10^{-3}$ & -7.45$\times 10^{-4}$ & 4.30$\times 10^{-3}$ & 0.94 & 1.24 & (0.99, 1.49) & 8.48$\times 10^{-3}$ & 6.19$\times 10^{-3}$ & 1.85$\times 10^{-2}$ & 0.95 \\
  E[log(Bilirubin):slope] & 1.03$\times 10^{-2}$ & (0.72, 1.35)$\times 10^{-2}$ & 1.30$\times 10^{-4}$ & 3.72$\times 10^{-4}$ & 2.83$\times 10^{-6}$ & 0.94 & 2.35$\times 10^{-2}$ &( 1.70, 2.99)$\times 10^{-2}$ & 3.26$\times 10^{-4}$ & -3.32$\times 10^{-4}$ & 1.26$\times 10^{-5}$ & 0.92 \\
  SD[log(Bilirubin):Intercept] & 8.53$\times 10^{-1}$ &(7.62,9.47)$\times 10^{-1}$ & 3.13$\times 10^{-3}$ & 7.79$\times 10^{-3}$ & 2.18$\times 10^{-3}$ & 0.96 & 8.43$\times 10^{-1}$ & (0.67, 1.03 )& 6.08$\times 10^{-3}$ & -1.90$\times 10^{-3}$ & 9.30$\times 10^{-3}$ & 0.93 \\
  Corr[log(Bilirubin):Intercept,log(Bilirubin):slope] & -1.30$\times 10^{-1}$ & (-4.31, 1.94)$\times 10^{-1}$ & 1.16$\times 10^{-2}$ & 4.44$\times 10^{-2}$ & 1.89$\times 10^{-2}$ & 0.98 & -5.56$\times 10^{-2}$ & (-6.61, 5.91)$\times 10^{-1}$ & 1.34$\times 10^{-2}$ & 1.19$\times 10^{-1}$ & 4.36$\times 10^{-2}$ & 0.99 \\
  Corr[log(Bilirubin):Intercept,Platelet:Intercept] & 2.36$\times 10^{-1}$ & (0.99, 3.72)$\times 10^{-1}$ & 4.62$\times 10^{-3}$ & -1.11$\times 10^{-2}$ & 5.76$\times 10^{-3}$ & 0.93 & 2.10$\times 10^{-1}$ & (-0.62, 4.74)$\times 10^{-1}$ & 8.78$\times 10^{-3}$ & -3.73$\times 10^{-2}$ & 1.98$\times 10^{-2}$ & 0.96 \\
  Corr[log(Bilirubin):Intercept,Platelet:slope] & -1.77$\times 10^{-1}$ & (-3.19, -0.32)$\times 10^{-1}$ & 4.72$\times 10^{-3}$ & 9.71$\times 10^{-3}$ & 5.49$\times 10^{-3}$ & 0.95& -1.66$\times 10^{-1}$ & (-4.43, 1.16)$\times 10^{-1}$ & 9.22$\times 10^{-3}$ & 2.09$\times 10^{-2}$ & 1.74$\times 10^{-2}$ & 0.97 \\
  Corr[log(Bilirubin):Intercept,Blood Vessel Malformations:Intercept] & 2.85$\times 10^{-1}$ & (0.96, 4.71)$\times 10^{-1}$ & 6.30$\times 10^{-3}$ & 1.49$\times 10^{-2}$ & 8.52$\times 10^{-3}$ & 0.94 & 2.41$\times 10^{-1}$ & (-0.93, 5.64)$\times 10^{-1}$ & 1.07$\times 10^{-2}$ & -2.95$\times 10^{-2}$ & 2.74$\times 10^{-2}$ & 0.94\\
  SD[log(Bilirubin):slope] & 1.17$\times 10^{-2}$ & (0.59, 1.70)$\times 10^{-2}$ & 4.85$\times 10^{-4}$ & -3.21$\times 10^{-3}$ & 2.31$\times 10^{-5}$ & 0.77 & 6.59$\times 10^{-3}$ & (0.03, 1.49)$\times 10^{-2}$ & 4.63$\times 10^{-4}$ & -8.35$\times 10^{-3}$ & 9.15$\times 10^{-5}$ & 0.52\\
  Corr[log(Bilirubin):slope,Platelet:Intercept] & -1.74$\times 10^{-1}$ &( -4.84, 1.38)$\times 10^{-1}$ & 1.18$\times 10^{-2}$ & -4.79$\times 10^{-3}$ & 1.71$\times 10^{-2}$ & 0.98 & -6.44$\times 10^{-2}$ & (-6.81, 5.75)$\times 10^{-1}$ & 1.30$\times 10^{-2}$ & 1.05$\times 10^{-1}$ & 2.88$\times 10^{-2}$ &0.99 \\
  Corr[log(Bilirubin):slope,Platelet:slope] & 1.52$\times 10^{-1}$ & (-1.55, 4.57)$\times 10^{-1}$ & 1.03$\times 10^{-2}$ & 2.67$\times 10^{-2}$ & 1.68$\times 10^{-2}$ & 0.98 & 5.53$\times 10^{-2}$ & (-5.60, 6.60)$\times 10^{-1}$ & 1.29$\times 10^{-2}$ & -6.95$\times 10^{-2}$ & 2.98$\times 10^{-2}$ & 0.99 \\
  Corr[log(Bilirubin):slope,Blood Vessel Malformations:Intercept] & 1.22$\times 10^{-2}$ & (-3.70, 3.95)$\times 10^{-1}$ & 1.32$\times 10^{-2}$ & 4.11$\times 10^{-3}$ & 2.68$\times 10^{-2}$ & 0.97 & 8.85$\times 10^{-3}$ &( -6.55,6.71)$\times 10^{-1}$ & 1.45$\times 10^{-2}$ & 7.24$\times 10^{-4}$ & 3.95$\times 10^{-2}$ & 0.98 \\
  &  \multicolumn{12}{c}{\textbf{Platelet Count}} \\
  E[Platelet:Intercept] & 5.54 & (5.49, 5.59) & 1.56$\times 10^{-3}$ & -1.43$\times 10^{-4}$ & 6.70$\times 10^{-4}$ & 0.94 & 5.46 & (5.36, 5.56) & 3.18$\times 10^{-3}$ & -3.39$\times 10^{-3}$ & 1.98$\times 10^{-3}$ & 0.98 \\
  E[Platelet:slope] & -4.37$\times 10^{-3}$ & (-6.52, -2.23)$\times 10^{-3}$ & 7.00$\times 10^{-5}$ & -7.29$\times 10^{-5}$ & 1.08$\times 10^{-6}$ & 0.94 & -1.13$\times 10^{-2}$ & (-1.58, -0.69)$\times 10^{-2}$ & 1.43$\times 10^{-4}$ & 6.08$\times 10^{-5}$ & 4.69$\times 10^{-6}$ & 0.97 \\
  SD[Platelet:Intercept] & 3.46$\times 10^{-1}$ & (3.11, 3.81)$\times 10^{-1}$ & 1.14$\times 10^{-3}$ & 8.28$\times 10^{-4}$ & 2.31$\times 10^{-4}$ & 0.99 & 3.57$\times 10^{-1}$ &( 2.87, 4.32)$\times 10^{-1}$ & 2.36$\times 10^{-3}$ & 1.22$\times 10^{-2}$ & 1.34$\times 10^{-3}$ & 0.98 \\
  Corr[Platelet:Intercept,Platelet:slope]& 4.56$\times 10^{-2}$ & (-0.97, 1.88)$\times 10^{-1}$ & 4.63$\times 10^{-3}$ & -1.58$\times 10^{-2}$ & 5.14$\times 10^{-3}$ & 0.96 & 5.86$\times 10^{-2}$ & (-2.20, 3.35)$\times 10^{-1}$ & 9.13$\times 10^{-3}$ & -2.86$\times 10^{-3}$ & 1.85$\times 10^{-2}$ & 0.96 \\
  Corr[Platelet:Intercept,Blood vessel malformations:Intercept] & -2.31$\times 10^{-1}$ & (-4.15, -0.44)$\times 10^{-1}$ & 6.19$\times 10^{-3}$ & 1.75$\times 10^{-2}$ & 9.42$\times 10^{-3}$ & 0.96  & -2.38$\times 10^{-1}$ & (-5.53, 0.87)$\times 10^{-1}$ & 1.05$\times 10^{-2}$ & 9.76$\times 10^{-3}$ & 2.27$\times 10^{-2}$ & 0.95\\
  SD[Platelet:slope] & 1.52$\times 10^{-2}$ & (1.36, 1.68)$\times 10^{-2}$ & 5.20$\times 10^{-5}$ & 3.84$\times 10^{-5}$ & 8.05$\times 10^{-7}$ & 0.92 & 1.56$\times 10^{-2}$ &( 1.24, 1.90)$\times 10^{-2}$ & 1.08$\times 10^{-4}$ & 4.31$\times 10^{-4}$ & 3.10$\times 10^{-6}$ & 0.95 \\
  Corr[Platelet:slope,Blood vessel malformations:Intercept] & -8.08$\times 10^{-2}$ & (-2.76, 1.15)$\times 10^{-1}$ & 6.38$\times 10^{-3}$ & -5.01$\times 10^{-4}$ & 8.81$\times 10^{-3}$ & 0.97 & -7.94$\times 10^{-2}$ & (-4.15, 2.60)$\times 10^{-1}$ & 1.11$\times 10^{-2}$ & 8.85$\times 10^{-4}$ & 2.82$\times 10^{-2}$ & 0.96\\
  &  \multicolumn{12}{c}{\textbf{Blood vessel malformations}} \\
  E[Blood vessel malformations:Intercept] & -2.53 & (-3.10, -1.99) & 1.91$\times 10^{-2}$ & 1.59$\times 10^{-2}$ & 6.86$\times 10^{-2}$ & 0.96 & -5.63$\times 10^{-1}$ &( -1.37, 0.23) & 2.60$\times 10^{-2}$ & 1.17$\times 10^{-1}$ & 2.08$\times 10^{-1}$ & 0.92 \\
  E[Blood vessel malformations:Slope] & 1.44$\times 10^{-2}$ & (-0.94, 3.83)$\times 10^{-2}$ & 7.85$\times 10^{-4}$ & -1.92$\times 10^{-4}$ & 1.16$\times 10^{-4}$ & 0.98 & 4.23$\times 10^{-2}$ & (0.25, 8.24)$\times 10^{-2}$ & 1.35$\times 10^{-3}$ & -5.77$\times 10^{-3}$ & 4.03$\times 10^{-4}$ & 0.95 \\
  SD[Blood vessel malformations:Intercept] & 1.87 & (1.38, 2.39) & 1.82$\times 10^{-2}$ & -7.58$\times 10^{-3}$ & 7.38$\times 10^{-2}$ & 0.94 & 1.87 & (1.06,2.75) & 3.37$\times 10^{-2}$ & -9.05$\times 10^{-3}$ & 2.72$\times 10^{-1}$ & 0.88\\
  \hline
  \end{tabularx}
\end{sidewaystable}
 \end{document}


text:
Q: Svg vs Canvas and rendering times for circle objects So i have done an webpage that tests rendering times times for SVG and Canvas. Test were done for diffrent browsers. I tought that Canvas will be better then SVG but from my test i see that Canvas has a problem with bigger objects and circle objects. I have results of my test here:
http://lezag2.linuxpl.info/wykresT2.html - this are reslts for 50.000 rectangles with a=500 pixsels
http://lezag2.linuxpl.info/wykresT4.html - this are results for 50.000 circles with r=250 pixels
I use simple code to generate objects on page.
Canvas:
var ctx = document.getElementById('canvas').getContext('2d');
for(var i=0;i<50000;i++){
ctx.beginPath();
var centreX = Math.random() * 1000;
var centreY = Math.random() * 1000;
var radius = 50;
var startAngle = 0 * Math.PI/180;
var endAngle = 360 * Math.PI/180;
ctx.arc(centreX,centreY,radius,startAngle,endAngle,false);
ctx.fillStyle = "rgb("+Math.floor(Math.random()*256)+","+ Math.floor(Math.random()*256)+","+ Math.floor(Math.random()*256)+")";;
ctx.fill();
ctx.closePath();
}

And SVG:
for (var i = 0; i < 50000; i++) {
var x = Math.random() * 1000,
    y = Math.random() * 1000;
var circ = document.createElementNS(svgns, 'circle');
circ.setAttributeNS(null, 'cx', x);
circ.setAttributeNS(null, 'cy', y);
circ.setAttributeNS(null, 'r', 50);
circ.setAttributeNS(null, 'fill', '#'+Math.round(0xffffff * Math.random()).toString(16));
document.getElementById('svgOne').appendChild(circ);
}

I am wondering why Canvas has such bad times compared to SVG. I tryd to google my problem but found only very comlpex tests. Could some one explain me why canvas has such bad times?? Also do i name it good - i mean rendering times??
EDIT
I forgot to show how i mesure rendering time.
befTime = (new Date()).getTime();
{
(drawing function)
}
var actTime = (new Date()).getTime();
var testTime = (actTime-befTime)/1000;

Thats why i asked if i dont name it wrong by saying "rendering time"

A: You cannot infer from your tests that svg is faster or slower than canvas, for several reasons :
minor reasons :

*

*closePath is not necessary, especially after filling.

*you recompute start/end angle on each loop for canvas.

*fillStyle has to be converted 'rgb(...)' in canvas and not in svg.

more important reason :

*

*drawing 50.000 canvas of 500 radius on a 1000X1000 canvas leads to a per-pixel overdraw
of... 78500 !!! This has just NOTHING to do with a real-use case, which is very annoying
to get any conclusion out of it.

even more important reason :

*

*you do not draw in synch (using requestAnimationFrame), so it is certain that your canvas code is often waiting for its buffer to be able to draw.

killing reason :

*

*You do not measure the render time of svg, just the svg creation + add to DOM time.
Not a single pixel is drawn in your svg loop : the actual render will be performed AFTER the javascript code returns : only then it will see that a reflow is necessary, and repaint everything.
AFAIK every browsers have only one thread for all operations going on a page : so your program will fully stop for rendering, during a time that you do not measure as of now.

Rq : You could try to measure svg draw time by using a short setInterval and seeing how many times really elapsed in between two calls instead of the real interval : this is the time when the system was stuck rendering.

Bottom line : you are comparing the time to create DOM objects and add them to the document vs the time to render circles on a out-of-sync canvas. No conclusion can be drawn out of those figures.


text:
Q: How To Detect If Another Process Reading My Application's Memory Is it possible to detect if another process reading the memory of my application? If so, can you give me any examples on how to accomplish this? (examples in C++ would be great)
Thank You

A: To detect a process that opens a handle to your process and calls ReadProcessMemory you must either, hook OpenProcess & ReadProcessMemory in every process or have a kernel mode driver that intercepts these calls.
Detecting ReadProcessMemory solely from inside the target process is usermode is not possible to my knowledge.  I have seen this question come up many times and have never seen an acceptable answer.


text:
Q: HTML form input not being recognized by Javascript? I have the super awesome jQuery validate and form plugins working all over my site without problems. Unfortunately, for one of my forms I have this weird problem where no form data gets submitted regardless of what I type into the form's textboxes.
To show you what I mean, when I console.log the field data before typing ("stored data") and upon submission ("live data") this is what I get (serialized using $.param):
stored data: full_name=&email_address=&password=
live data: full_name=&email_address=&password=

So nothing is being submitted on this form, whereas the "live data" for all other forms on my site which use the exact same JS codebase display whatever is inputed.
UPDATE Here's a JSFiddle for this form.
UPDATE 2 I'm realizing that this form's elements aren't being recognized by Javascript. So the background doesn't turn red if I do this.
$('#email_address').focus(
function(){
    $(this).css({'background-color' : 'red'});
});

Wow this is totally confusing, thoughts?

A: You have
$(document.body).on('click', ".ajaxFormBtn"

and
<button data-loading-text="Saving..." class=" btn btn-green btn-large txt24"
            value="Sign up" id="signupModalBtn" ><i class="icon-key icon-signin"></i>
            Sign up</button>

Notice anything missing from the button's class attribute?


text:
Q: iPhone - Convert CTFont to UIFont? I am trying to convert a CTFont to a UIFont without losing any of the styles and attributes such as:

*

*Font Name

*Font Size

*Font color

*Underlines

*Bold

*Italic

*etc

A: CTFontRef ctFont = ...;
NSString *fontName = [(NSString *)CTFontCopyName(ctFont, kCTFontPostScriptNameKey) autorelease];
CGFloat fontSize = CTFontGetSize(ctFont);
UIFont *font = [UIFont fontWithName:fontName size:fontSize];

Color and underline are not attributes of the font. Bold and italic are part of the font name.

A: With ARC:
UIFont *uiFont = [UIFont fontWithName:(__bridge NSString *)CTFontCopyPostScriptName(ctFont) size:CTFontGetSize(ctFont)];


text:
Q: Power BI / Power Query - M language - playing with data inside group table Hello M language masters!
I have a question about working with grouped rows when the Power Query creates a table with data. But maybe it is better to start from the beginning.
Important information! I will be asking for example only about adding an index. I know that there are different possibilities to reach such a result. But for this question, I need an answer about the possibility to work on tables. I want to use this answer in different actions (e.g table sorting, adding columns in group table).
In my sample data source, I have a list of fake transactions. I want to add an index for each Salesman, to count operations for each of them.
Sample Data

So I just added this file as a data source in Power BI. In Power query, I have grouped rows according to name. This step created form me column contained a table for each Salesman, which stores all his or her operations.
Grouping result

And now, I want to add an index column in each table. I know, that this is possible by adding a new column to the main table, which will be store a new table with added index:
Custom column function

And in each table, I have Indexed. That is good. But I have an extra column now (one with the table without index, and one with a table with index).
Result - a little bit messy

So I want to ask if there is any possibility to add such an index directly to the table in column Operations, without creating the additional column. My approach seems to be a bit messy and I want to find something cleaner. Does anyone know a smart solution for that?
Thank you in advance.
Artur

A: Sure, you may do it inside Table.Group function:
= Table.Group(Source, {"Salesman"}, {"Operations", each Table.AddIndexColumn(_, "i", 1, 1)})

P.S. To add existing index column to nested table use this code:
= Table.ReplaceValue(PreviousStep,each [index],0,(a,b,c)=>Table.AddColumn(a,"index", each b),{"Operations"})


text:
Q: Can't delete very large (1.2TB) files from Trash-computer freezes I have three very large files .hdf5 (each 1.2TB) in my trash that I can't get rid of. Obviously I have tried simply emptying the trash. I have also tried deleting from Terminal with
 rm -rf ~/.local/share/Trash/*

I have also tried directly deleting the files from the .Trash-1000/files folder. All of these options have resulted in my computer freezing. The only thing I can do that works then is pressing. Once I restart, they are back in the Trash. Curiously I tried a 'move to' another folder which appears to move the files, but then my computer crashes and when I restart, they are back in the Trash.
alt-SySRq-REISUB

The only added information I can give is that I put these in the Trash by mistake and tried to restore them which crashed my computer.
Any help would be appreciated - I have been on this problem for 24 hours.

A: I would have a look on the SMART status of the disk, to make sure this is not the problem.
If that is fine, you can try and give the process lower IO, in order for it to not freeze the system
sudo ionice -c3 rm -rf ~/.local/share/Trash/*

EDIT:
I don't understand why this is downvoted here ? I checked and it is an acceptable answer on serverfault

A: Try trash-cli toolkit..
You can install it with apt-get.

sudo apt-get install trash-cli

use trash-empty tool to remove trash, like:

sudo trash-empty

best wishes


text:
Q: cumulative percentile calculation in pyspark I have a dataframe like so:
|SEQ_ID |TIME_STAMP             |RESULT          |
+-------+-----------------------+----------------+
|3879859|2021-08-31 19:54:53.88 |25.9485244750994|
|3879859|2021-08-31 21:16:06.228|35.9163284302007|
|3879859|2021-08-31 22:28:46.306|41.9778823852006|
|3879859|2021-08-31 22:28:46.306|41.9778823852006|
|3879859|2021-08-31 23:12:08.058|39.9112701415998|
|3879859|2021-08-31 23:17:35.796|33.0476760864009|
|3879859|2021-08-31 23:47:17.383|60.2846145630007|
|3879859|2021-09-01 00:00:26.722|67.0690536499006|
|3879859|2021-09-01 00:00:26.722|67.0690536499006|
|3879859|2021-09-01 00:02:07.825|67.8424835205007|

For normal percentile calculation in pyspark I use the following:
df.groupBy('SEQ_ID')\
.agg(f.expr('percentile(RESULT, 0.25)').alias('Q1'),
     f.expr('percentile(RESULT, 0.50)').alias('Median'),
     f.expr('percentile(RESULT, 0.75)').alias('Q3'))\

But that takes all the data grouped by SEQ_ID.
I want to calculate the Q1, median, and Q3 for each row, using the rows above it.
|SEQ_ID |TIME_STAMP             |RESULT          |Q1   |Median|Q3   |
+-------+-----------------------+----------------+-----+------+-----+
|3879859|2021-08-31 19:54:53.88 |25.9485244750994|
|3879859|2021-08-31 21:16:06.228|35.9163284302007|
|3879859|2021-08-31 22:28:46.306|41.9778823852006|
|3879859|2021-08-31 22:28:46.306|41.9778823852006|
|3879859|2021-08-31 23:12:08.058|39.9112701415998|
|3879859|2021-08-31 23:17:35.796|33.0476760864009|
|3879859|2021-08-31 23:47:17.383|60.2846145630007|
|3879859|2021-09-01 00:00:26.722|67.0690536499006|
|3879859|2021-09-01 00:00:26.722|67.0690536499006|
|3879859|2021-09-01 00:02:07.825|67.8424835205007|

So the Q1, Median and Q3 for the first row would be: 25.9485244750994
For the 2nd row, the percentiles would be calculated with 25.9485244750994 and 35.9163284302007 and so on and so forth.
If I define a window such that
w=Window.partitionBy('SEQ_ID').orderBy(col('TIME_STAMP').asc()).rangeBetween(Window.unboundedPreceding,0)

Would the following code work?:
df.groupBy('SEQ_ID')\
.agg(f.expr('percentile(Pad_Wear, 0.25)').alias('Q1'),
     f.expr('percentile(Pad_Wear, 0.50)').alias('Median'),
     f.expr('percentile(Pad_Wear, 0.75)').alias('Q3')).over(w)

A: You can create a new "fake ID column" using monotonically_increasing_id, then either group by it or windowing by it, it will run row by row


text:
Q: Using UserDefault custom suite for namespacing keys I know the typical use case for using a custom suite for the UserDefaults in iOS (not macos) is to share data to app Extensions.
I am wondering if it does make sense using a custom suite like
class UserData {

    private var source = UserDefaults(suiteName: "MyApp.userData")!

    ...
}

to better isolate (or slightly better "namespace") the key-values related to a module of the app from another. In the simple example i would like to store some user related data (not worth being inserted in the regular DB) and wipe them out for example on user logout.
Using the standard UserDefaults would require me to prepend a prefix to the keys, or wrap all the calls, or similar approaches, but it seams to me that using a suite is just more suited (pun unintended), as i could directly deleted it or iterate over it (for reasons) without fear of touching other keys or worst overwrite existing ones (keys conflict).
TLDR: is it fine to use a more than a suite for persistence of small data in place of a monolitic UserDefault? Which cons could be facing, i have not found a single article (not involving extensions data sharing) and as usual Apple documentation is all but clear, if not misleading.
Bonus:
Initilly i though this would also rule out all those system injected keys, but it appear after a test that they are as well copied in the suite instance of the UserDefaults despite i haven´t "added" the suite as a child of the standard one, do you have an explanation for this?


text:
Q: Error column doesn't exist on custom module Odoo I'm working on a custom module and i need to add field to res.partner model. I've add some field to this model but since 1 week, when i try to add a new one i got this error :
ERROR: column res_partner.my_field does not exist

Other field works good but not this one :
my_field = fields.Boolean(default=False)

I really don't unterstand why i have this issue. I've try to add 'contacts' dependencies to my module, it have work on my local version but not on my online verison
If somone has any idea it could be really nice
Thanks for your help
Edit
res.partner classe
from odoo import api, fields, models

class ResPartner(models.Model):
    _inherit = 'res.partner'

    badge_ids = fields.One2many('mymodule.badge','client_i
    sub_ids = fields.One2many('mymodule.subs','client_id')
    #field that doesn't work
    my_field = fields.Boolean(default=False)

Manifest dependencies
'depends': ['base', 'sale', 'website', 'calendar','contacts', 'point_of_sale', 'base_automation'],

A: Looks like a bug. Here's possible workaround:
Add 'res' to dependencies as well as 'base', then restart odoo instance.
after confirming fields updated; remove 'res' from dependencies then upgrade module.
This behavior exist on Odoo versions above 8.0

A: class Partner(models.Model):
    _inherit = "res.partner"

   my_field = fields.Boolean()

Note: Give 'base' as dependencies in manifest of your custom module.

A: I did this to solve it

*

*Comment your custom fields in xml file

*Add depands "base", "res" in your manifest

*Restart odoo

*Remove "res", "base"

*Upgrade your custom module

*Make sure new field added in the model that you want to inherit

*Uncomment your field in xml file

*Upgrade your custom module

Odoo 10

A: UPDATE:
A good solution for that is to inherit the model as a new model and I assume this is the official solution as well:
Class ResPartner(models.model):
    _name = 'res.partner'
    _inherit = 'res.partner'

    my_field = fields.Char()


text:
Q: Moving files between accounts on a Mac I did something bad and killed my wife's login on her Early 2008 MB/10.7.5. Any attempt to log into that account crashes back to the login screen. Other accounts work fine.
I created a new account so she could get up and running, but of course all her documents/music/pictures are missing.
I'd like to move all those files. The typical suggestion uses the DropBox, but requires you to log into the original account - which I can't. So I'm looking for more techy solutions.
I'm sure a mv and chown will do this. Can anyone offer some guidance?

A: Try holding the Shift key as soon as you log into her old account. That will logon in safe mode. If that works, you can try to find out what the problem with the account is (Preference file corruption - use something like Preferential Treatment http://www.jonn8.com/html/pt.html or corrupt file permissions - use Disk Utility) or just move all the files out of that account and into the new one.


text:
Q: Content Search Query settings in Site Template We've added a CSWP to a site template, defined the query and added custom display templates with the Control and Item options. However, when we create new sites from the template, the new CSWP defaults to the standard "List" and "Picture..." Control and Item options. I have tried recreating the template but got the same each time. It seems odd that it takes part of the customisation. It also seems to default the Global nav to have unique settings, even though I've set the template to use the parent nav.
Can anyone suggest a solution?
Thanks
Bill

A: I've managed to find the cause and solution to this problem:
The cause is identified in Chris O'Brien's blog:
http://www.sharepointnutsandbolts.com/2013/04/provisioning-content-search-web-part.html
as being due to the way the tilde character is treated in the template Ids: ~sitecollection
In the comments Ivan Neganov provides a fix, i.e. to replace the tilde with escape characters: ~sitecollection
As I'm not a programmer and don't have VS, I couldn't make use of the solution until I found this posting: http://www.fmtconsultants.com/2014/10/solution-to-sharepoint-2013-issue-content-search-web-part-does-not-retain-properties-when-creating-a-site-from-a-custom-template, written by Abdur Raheem, Senior SharePoint Consultant, FMT Consultants, which explains how to strip out the Elements.xml file from the Site Template solution file, update it, as per Ivan's suggestion and recreate the solution.
I had issues with the DDFgenerator and spaces and with activating the uploaded solution but finally got it working :)

After reading Chris' blog, I tried just swaping for the escape characters in the site that is used to create the template, via SharePoint Designer but this broke the display template. Its possible, however, that using this broken template might produce a working solution, one it is saved as a site template, which would provide a very simple solution. It can't be that easy but when I next have to make this work, I'll give it a try and post the results


text:
Q: Invoking function breaks scope Same issue as here: AngularJS directive binding a function with multiple arguments
Following this answer: https://stackoverflow.com/a/26244600/2892106
In as small of a nutshell as I can.
This works:
<my-directive on-save="ctrl.saveFn"></my-directive>

With:
angular.module('app')
.controller('MyController', function($scope) {
  var vm = this;
  vm.saveFn = function(value) { vm.doSomethingWithValue(value); }
});

But when I convert to Typescript and use real classes, this breaks.
class MyController {
  constructor() {}

  saveFn(value) {
    this.doSomethingWithValue(value);
  }
}

In the Typescript version when debugging, "this" is referencing the Window global. So my scope is messed up somehow, but I don't know how to fix it. How can I get "this" to refer to MyController as expected?

A:
So my scope is messed up somehow

Use an arrow function instead of a method.
Fixed
class MyController {
  constructor() {}

  saveFn = (value) => {
    this.doSomethingWithValue(value);
  }
}

More
https://basarat.gitbooks.io/typescript/content/docs/arrow-functions.html


text:
Q: Webmatrix3: Inserting PHP code bugs out JavaScript color syntax I'm using Webmatrix3 for PHP developing.
I found this issue:
when I insert PHP code, like reading a PHP variable into my javascipt code, Webmatrix ide lost syntax hilighting, and all the code appears black.
The code syntax is still correct, but it's very difficult to code without color syntax help.

Any suggestion or trick to resolve this?


text:
Q: A List of Lists containing int and string, need to output X strings with highest int values based on TrackBar (not a sorted list) I have a List structured as:
"Then a sentence woop", 340
"and another one",      256
"in order they appear", 700
"in a linked file",     304

The list contains the highest scored sentence from each paragraph of a text file. I need to output each sentence, but with a track bar reduce how many are shown.
So remove the sentence with the lowest score, the issue is the list is ordered by the sentences appearance in the original text, and the output needs to be in this order. So if I had a track bar for the above list, it would have 4 points. If I move it to point 3 sentence 2 would vanish, point 2 sentence 2 and 4 would vanish.
The code where the list is generated is:
    public List<ScoredSentence> buildSummarySentenceList()
    {
        List<ScoredSentence> ultimateScoreslist = new List<ScoredSentence>();
        scoreCoord2 = -1;
        for (int x1 = 0; x1 < results.Length; x1++)
        {
            List<ScoredSentence> paragraphsScorelist = new List<ScoredSentence>();
            for (int x2 = 0; x2 < results[x1].Length; x2++)
            {
                scoreCoord2++;
                paragraphsScorelist.Add(new ScoredSentence(results[x1][x2], intersectionSentenceScores[scoreCoord2]));
            }
            var maxValue = paragraphsScorelist.Max(s => s.score);

            string topSentence = paragraphsScorelist.First(s => s.score == maxValue).sentence;
            int topScore = paragraphsScorelist.First(s => s.score == maxValue).score;

            ultimateScoreslist.Add(new ScoredSentence(topSentence, topScore));
        }
        return ultimateScoreslist;
    }

    public class ScoredSentence
    {
        public string sentence { get; set; }
        public int score { get; set; }

        public ScoredSentence(string sentence, int score)
        {
            this.sentence = sentence;
            this.score = score;
        }
    }

This code loops though a jagged array and a list of sentence to sentence scores, it results in a list as shown at the top.
Currently I output every sentence, and set the trackbar to be as long as there are sentences:
    protected void summaryOutput()
    {
        List<ScoredSentence> ultimateScoreslist = buildSummarySentenceList();
        trackBSummaryPercent.Maximum = ultimateScoreslist.Count;
        lblNoOfLines.Text += trackBSummaryPercent.Maximum.ToString();
        //make 2 lists for the reduction????
        for (var x = 0; x < ultimateScoreslist.Count; x++)
        {
            TextboxSummary.Text += ultimateScoreslist[x].sentence + "\n";
        }
    }

I have thought of on every onchange tick of the trackbar to have a second clone list and remove the lowest value entry. Then when the bar is moved up to somehow move the missing entries back from the clone list. I don't like this method as it may cause program speed issues when for example my current test text is 100 paragraphs long, and moving the trackbar a lot may make it become slow.

A: Add a displayed property to your ScoredSentence object.  Then whenever the list changes, or the track bar selection changes, run this method on it to update the set of displayed elements.  The main list should always be sorted in the order you want it displayed. numberToDisplay would be calculated by whatever means you are using to go from your UI to the number of items.
public void OnUpdate()
{
   var orderedEnumerable = ScoresList.OrderByDescending (s => s.Score);

   foreach (var s in orderedEnumerable.Take (numberToDisplay))
   {
      s.Displayed = true;
   }
   foreach (var s in orderedEnumerable.Skip(numberToDisplay))
   {
      s.Displayed = false;
   }
}

Then use the following instead of the list whenever you need to display it
ScoredSentences.Where(s=> s.Displayed);


text:
Q: Visual Studio Code: After setting breakpoints and deleting them Chrome constantly stops loading for milliseconds with "Paused in debugger" message This only happens after I have debugged and added breakpoints. Disabling or deleting them does nothing. VS Code sometimes still breaks at the old breakpoints and sometimes even at random places. Restarting the debugger works and the problem disappears.
What causes this and is there a way to fix this?


text:
Q: Android CustomListView updated fields are repeating when scrolled down I am having a problem in customlist view.
I have two buttons and one textView . Add and Subtract Buttons.
when click Add button the counter should be +1 and -1 respectively.
I have used a dummy string for checking whether it is actually updating the textView or not. But the problem is when I scroll down some of the items are having same value.
For example
1st item TextView is set to "HIII"
then if I scroll down the 11th ,21th ... is also set to "HIII"
Note: the max number that display can contain is 10 items so when I scroll down to 11th it is set to "HII".
public class CustomAdapter extends ArrayAdapter {
    Context context;
    LayoutInflater inflater;
    int resource;
    //ArrayList<Integer> count = new ArrayList<>();

    public CustomAdapter(Context context, int resource) {
        super(context, resource);
        this.context = context;
        this.resource = resource;

    }

    @Override
    public int getCount() {
        return 100;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
       ViewHolder mainHolder = null;
        if (convertView == null) {
            inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(resource, parent, false);
            Log.e("GET-VIEW", " Creating Views");
           final ViewHolder holder = new ViewHolder();
            holder.add = (Button) convertView.findViewById(R.id.add);
            holder.sub = (Button) convertView.findViewById(R.id.sub);
            holder.textView = (TextView) convertView.findViewById(R.id.numberTV);
            holder.add.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    holder.textView.setText("HIII");
                }
            });
            convertView.setTag(holder);
        } else {
           mainHolder = (ViewHolder) convertView.getTag();
        }

        return convertView;
    }
}

class ViewHolder {

    Button add, sub;
    TextView textView;

}

Please Help me. I want to know how to set tag of one with other(I mean how you know you need to set the tag with the other object or view)
Thanks

A: ListView recycles Views. It creates Views that will be re-used when scrolling down.
Thus, you have to call setText() and setOnClickListener() every time getView() is called, not only when button is clicked.
To achieve what you want, you have to store set text data in a model, like a SparseArray which maps positions to data.
public class CustomAdapter extends ArrayAdapter {
    Context context;
    LayoutInflater inflater;
    int resource;
    //ArrayList<Integer> count = new ArrayList<>();

    // Your data map by position
    SparseArray<String> data = new SparseArray<>();

    public CustomAdapter(Context context, int resource) {
        super(context, resource);
        this.context = context;
        this.resource = resource;

    }

    @Override
    public int getCount() {
        return 100;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
       final ViewHolder holder;
        if (convertView == null) {
            inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(resource, parent, false);
            Log.e("GET-VIEW", " Creating Views");
            holder = new ViewHolder();
            holder.add = (Button) convertView.findViewById(R.id.add);
            holder.sub = (Button) convertView.findViewById(R.id.sub);
            holder.textView = (TextView) convertView.findViewById(R.id.numberTV);
            convertView.setTag(holder);
        } else {
           holder = (ViewHolder) convertView.getTag();
        }

        holder.textView.setText(data.get(position));
        holder.add.setOnClickListener( new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final String text = "HIII";
                data.put(position, text);
                holder.textView.setText(text);
                notifyDataSetChanged();
            }
        });

        return convertView;
    }
}

class ViewHolder {

    Button add, sub;
    TextView textView;

}

A: write your onclick listener after else condition.
holder.add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                holder.textView.setText("HIII");
            }
        });

A: Take a look at your getView function:
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
   ViewHolder mainHolder = null;
    if (convertView == null) {
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(resource, parent, false);
        Log.e("GET-VIEW", " Creating Views");
       final ViewHolder holder = new ViewHolder();
        holder.add = (Button) convertView.findViewById(R.id.add);
        holder.sub = (Button) convertView.findViewById(R.id.sub);
        holder.textView = (TextView) convertView.findViewById(R.id.numberTV);
        holder.add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                holder.textView.setText("HIII");
            }
        });
        convertView.setTag(holder);
    } else {
       mainHolder = (ViewHolder) convertView.getTag();
    }

    return convertView;
}

You edit the content of your holder textView and add Button only when you create a new Viewholder.
The first time your listview shows its items, there will be always a new view created (and a new Viewholder, too) for all visible cells.
As soon as you scroll down, the adapter will take a now-invisble cell (maybe the frist cell) and recycle it to show a now-visible cell. In this case, your convertView in getView won't be null anymore, as the view was recycled.
So you should handle all your text changes an Listener and so on outside of your if statement to manage both cases (recycled and new).
For example:
    if (convertView == null) {
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(resource, parent, false);
        Log.e("GET-VIEW", " Creating Views");
        final ViewHolder holder = new ViewHolder();
        holder.add = (Button) convertView.findViewById(R.id.add);
        holder.sub = (Button) convertView.findViewById(R.id.sub);
        holder.textView = (TextView) convertView.findViewById(R.id.numberTV);

        convertView.setTag(holder);
    } else {
       mainHolder = (ViewHolder) convertView.getTag();
    }

    holder.textView.setText("");
    holder.add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                holder.textView.setText("HIII");
            }
        });

Edit
To save your data in a sparse array like Yaroslav Mytkalyk suggested would be a better approach.
Anyway, you have to handle recycled views.


text:
Q: If the current thread has the authority to exit Java virtual machine I'm trying the class SecurityManager. I want to check if the current thread has the authority to exit Java virtual machine. Below is the code I came up with.
SecurityManager appsm = System.getSecurityManager();
System.out.println("something");
appsm.checkExit(0);

I was expecting the SecurityManager.checkExit to throw a SecurityException. However, the IDE instead output NullPointerException.
Exception in thread "main" java.lang.NullPointerException
    at jtotheplatformenvironment.JTOThePlatformEnvironment.main(JTOThePlatformEnvironment.java:40)
C:\Users\Justin\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1

Why is this happening?

A: You need to execute the Java application with an extra parameter :
-Djava.security.manager

So the JVM would be started with a built-in default security manager (source) otherwise no security manager is created and that's why you get a NPE.

A: As per oracle documentation, you can set SecurityManager by using below API in System class
public static void setSecurityManager(SecurityManager s)

Sets the System security.
If there is a security manager already installed, this method first calls the security manager's checkPermission method with a RuntimePermission("setSecurityManager") permission to ensure it's ok to replace the existing security manager. This may result in throwing a SecurityException.

Otherwise, the argument is established as the current security manager. If the argument is null and no security manager has been established, then no action is taken and the method simply returns.


text:
Q: how to run a electron app without UI in terminal I have already explored previous questions but they don't answer my question.
I have a simple Electron app with 2 inputs and a button. 2 inputs are multiplied and answer is shown in H1 tag.

I want to run this app in CLI without opening UI. I should be able to do something like this.
npm start myApp x,y

x and y are 2 inputs and this should print the result of multiplication

A: You should be able to do that with NPM scripts. https://www.freecodecamp.org/news/introduction-to-npm-scripts-1dbb2ae01633/
[edit] Here's a very barebone app that to demo what you are looking for: CLICK ME
Read the noted in the myApp.js file to see it work.


text:
Q: Clojure generate externs ext.js files for ClojureScript I'm trying to parse some Javascript libraries with Clojure to generate externs files for using them in ClojureScript.
Clojure read-file function
I stumbled across and old Clojure source file that intended to do this, but has some deprecated code and doesn't work anymore, so I wanted to take some concepts from it and start over.
From the script of the Gists above I started with the read-file function.
(ns n01se.externs-for-cljs
  (:require [clojure.java.io :as io]
            [cljs.compiler :as comp]
            [cljs.analyzer :as ana]))

    (defn read-file [file]
      (let [eof (Object.)]
        (with-open [stream (clojure.lang.LineNumberingPushbackReader. (io/reader file))]
          (vec (take-while #(not= % eof)
                           (repeatedly #(read stream false eof)))))))

First Question: why eof is represented by a plain Object ?
Parsing Javascript
Then I fed this Javascript source code to the read-test-file function:
yayQuery = function() { // <= EXCEPTION: read exception at {
    var yay = {};
    yay.sayHello = function(message) {
    console.log(message);
    }

    yay.getMessage = function() {
    return 'Hello, world!';
    }

    return yay;
};

I startup the cider debugger and start checking the loop and as expected I get yayQuery.

So I got:

*

*yayQuery

*=

*function

*()

Until the reader gets to {, and this exception pops up.
Map literal must contain an equal number of forms.
Prevent read from "evaluating" ?
Hypothesis: Looks like the read function tries to interpret { so starts searching for a key ?
Second Question: If the hypothesis above is true. Can I avoid read from evaluating the code ?
I tried binding *read-eval* to false but I still got the same exception:
(ns externer.core
  (:require [clojure.java.io :as io])
  (:gen-class))

(defn read-test-file [file]
  (let [eof (Object.)]
    (with-open [stream (clojure.lang.LineNumberingPushbackReader. (io/reader file))]
      (binding [*read-eval* false]
        (take-while #(not= % eof)
                    (repeatedly #(read stream false eof)))))))

(defn -main
  [& args]
  (read-test-file (first args)))

I also tried edn also because of the unsafety of using read but I still got the same exception as above.
(ns externer.core
  (:require [clojure.java.io :as io])
  (:gen-class))

(defn read-test-file [file]
  (let [eof (Object.)]
    (with-open [stream (clojure.lang.LineNumberingPushbackReader. (io/reader file))]
        (take-while #(not= % eof)
                    (repeatedly #(edn/read {:eof eof} stream))))))

(defn -main
  [& args]
  (read-test-file (first args)))

Final Question: There's another more safe/correct way to generate externs automatically ?


text:
Q: PyQt5: how to do replacement using QRegularExpression I want to reserve all English characters and replace others. When using 're' module, it looks like that:
name = 'srw  959we'
result = sub('/W', '', name)

Then I get 'name = 'srwwe'. Now I want to use the class QRegularExpression to realize that, but the official document is so abbreviated that I found nothing useful. It will be appreciated if someone can give a brief and clear example for PyQt.

A: This cannot be done, because it requires the QString class, which is not included in PyQt (and the same goes for PySide). The equivalent to re.sub in Qt is QString.replace, and there is just no way to access it from PyQt. (The QRegularExpression.swap method does something entirely different, so is no help either).
QRegularExpression is only really useful in PyQt where you need to access a Qt API that requires passing an object of that type. For general string manipulation, just use Python's re module (or regex if you need additional functionality).


text:
Q: draw the following shaded area in R
Possible Duplicate:
Shading a kernel density plot between two points.

How to draw this graph in R, assuming normal pdf?

A: I answered that a while back on StackOverflow for something closely related. The question really is a duplicate and should be closed.  All these how do I shade below a curve questions are answered by a close read of help(polygon) and a study of the existing examples.

A: The code for getting shaded area below:
plot(dnorm,-4,4,xlab="x",ylab="pdf")
xvals <- seq(-2,1,length=50)
dvals <- dnorm(xvals)
polygon(c(xvals,rev(xvals)),c(rep(0,50),rev(dvals)),col="gray")

Result:


text:
Q: C / Copy String with dynamic malloc, from const char * org to char ** cpy I want to copy a const string const char * org to char **cpy, but my code doesn't work.
I was thinking getting the lenght of my original string and and using malloc to dynamically allocate memory, in order to just copy *org to **cpy would work, but it doesn't.
Where is my mistake? Cant't I use strcpy for a pointer to a pointer or how exactly do I do it?
I'm very new to this, so I appologize in advance if I don't see something really simple.
int string_dd_copy(char **cpy, const char * org)

    {
      int i = 0;
      while(org[i] != '\0'){
        ++i;
      }
      if(i == 0){
        return 0;
      }
      *cpy = malloc(i* sizeof(char));
      strcpy(*cpy, org);
      printf("%s", *cpy);

      return 1;
    }

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
int string_dd_copy();
char **a;
char *b = "Iam";
string_dd_copy(a, b);
return 0;
}

int string_dd_copy(char **cpy, const char * org)
{
  cpy = malloc(1 + strlen(org));
  strcpy(*cpy, org);
  return 1;
}

A: try this
#include <stdio.h>
#include <string.h>
#include <malloc.h>
int string_dd_copy( char **cpy, const char *org )
{
    if( strlen(org)  == 0 ){
        printf( "no data\n");
        return 0;
    }

    *cpy = malloc( strlen( org ) + 1 );

    strcpy( *cpy, org );

    printf("%s\n", *cpy);

      return 1;
}
int main()
{

    const char *teststring = "hello world";
    const char *noData = "";

    char *testptr;
    string_dd_copy( &testptr, teststring );
    free( testptr );

    string_dd_copy( &testptr, noData );
    return 0;
}


text:
Q: How to switch between Serilog and another logger in .Net Core through configuration? I need to be able to switch between Serilog and another logger, MyLog. Currently I am switching by comment/uncomment code as the following:
    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
            })
            //// === to switch between Serilog and MyLogger comment/uncomment code below ===
            //.UseSerilog((hostContext, loggerConfig) =>
            //    loggerConfig.ReadFrom.Configuration(hostContext.Configuration));
            .ConfigureLogging((hostBuilderContext, logging) =>
             {
                 logging.AddMyLogger(options =>
                 {
hostBuilderContext.Configuration.GetSection(MyLoggerOptions.LogOptions).Bind(options);
                 });
             });
}

This works, but I prefer to make it controlled by a appsettings.json setting, say, Logger. So here is my appsettings.json file:
{
  "Logger": "Serilog", // Use Serilog or MyLog

  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Grpc": "Information",
      "Microsoft": "Information",
      "Microsoft.Hosting.Lifetime": "Information"
    },
    "MyLog": {
      "Options": {
        "FolderPath": "logs",
        "FilePath": "Svr_{date}.log"
      },
      "LogLevel": {
        "Default": "Information",
        "Microsoft": "Error",
        "Microsoft.Hosting.Lifetime": "Error"
      }
    }
  },

  "Serilog": {
    "MinimumLevel": "Verbose",
    "Override": {
      "Microsoft.AspNetCore": "Warning"
    },
    "WriteTo": [
      {
        "Name": "Console "
      },
      {
        "Name": "File",
        "Args": {
          "path": "Logs\\Serilog_Server-.log",
          "formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog",
          "rollingInterval": "Day"
        }
      }
    ]
  }
}

and here is the code where I try to set log depending on the Loger setting:
public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseStartup<Startup>();
        })

        .ConfigureLogging((hostBuilderContext, logging) =>
        {
            string loger = hostBuilderContext.Configuration.GetValue<String>("Logger");
            if (loger == "MyLog")
            {
                logging.AddMyLogger(options =>
                {
                    hostBuilderContext.Configuration.GetSection(MyLoggerOptions.LogOptions).Bind(options);
                });
            }
            else if (loger == "Serilog")
            {
                logging.AddSerilog(); // here is the problem. Serilog doesn't write.
            }
        });

The problem of this code is the Serilog (MyLog is fine) - it doesn't write at all. My guess is that, since I don't have a way to pass in the configuration object, it might not get configured properly. But how do I fix it? or is there a better way to do this?
UPDATE
Tried what Camilo suggested as the following with an error. How do I get the configuration object from here?


text:
Q: How do you retrieve User Defined Runtime Attributes in Xamarin? On my XCode storyboard I have a custom image view (called CustomImageButton).  There is a section about User Defined Runtime Attributes:

I've seen a couple of examples about how to retrieve these values in Objective-C but can't work out how to convert to Xamarin C#.  The code I'm using is:
class CustomImageButton : UIImageView
{
    public CustomImageButton(IntPtr handle) : base(handle)
    {
        NSObject objType = ValueForKey(new NSString("bgType"));
        if (objType == null)
            // Do something here
    }

    public override NSObject ValueForUndefinedKey(NSString key)
    {
        return null;
    }
}

However, it always goes into the undefined key part and returns null.  How can I retrieve the string 'Transparent' for the key 'bgType'?

A: In your Custom (C#-based) UI class, add a property for your custom User Defined Runtime Attribute.
[Connect]
private NSString Stack {
    get {
        return (NSString)GetNativeField ("Stack");
    }
    set {
        SetNativeField ("Stack", value);
    }
}

This will in turn auto-generate the property in your ObjC custom class header file:
@property (nonatomic, retain) IBOutlet NSString *Stack;

Defined your attribute value:

When the xib or storyboard is loaded, this property gives the custom attribute a place to be stored for future reference.
Now you can access this value via ValueForKey:
partial void OnBottonUpInside (CustomButton sender) {
        NSString value = (NSString)sender.ValueForKey(new NSString("Stack"));
        Console.WriteLine(value);
}

Output Example:
2016-02-03 08:27:51.666 keyvalue[46492:2538387] OverFlow

Of course, I could have defined the property as public and just access it that way:
partial void OnBottonUpInside (CustomButton sender)
{
    Console.WriteLine (sender.Stack);
}

Note: Normally in ObjC you would just define this as a strong property, but Xamarin does not define it that way, but the result is the "same":
@property (strong) NSString *Stack;

A: @SushuHangover's response is correct and still works. However, if you want to avoid the deprecated GetNativeField() & SetNativeField() methods, then this would be the change that has worked for me:
[Connect]
private NSObject Stack
{
    get
    {
        return ValueForKey((NSString)"Stack");
    }
    set
    {
        SetValueForKey(value, (NSString)"Stack");
    }
}


text:
Q: Component not rendering out buttons I'm trying to render out a few buttons, but for some reason nothing is happening.  I'm not certain where my mistake is.  I have an OverviewRender class which will eventually handle different sets of buttons to render and an Overview class which calls OverviewRender to render out the buttons.
It feels like should be working, but the buttons aren't rendering.  If I move the buttons inside the Overview return function I see can see them.
import React, { Component } from 'react'
import SearchBar from 'material-ui-search-bar'
import sass from '../scss/application.scss'
import PropTypes from 'prop-types'
import RaisedButton from 'material-ui/RaisedButton'

class OverviewRender extends Component {
    render() {
        const mainMenu = () => {
            return (

                    <RaisedButton label="File Options"
                        style={{
                            height: '80px',
                            width: '180px',
                            fontSize: '44px',
                            padding: '1px'}}
                            />
                    <RaisedButton label="Setup Options"
                        style={{
                            height: '80px',
                            width: '180px',
                            fontSize: '44px',
                            padding: '1px'}}
                            />
                    <RaisedButton label="More Options"
                        style={{
                            height: '80px',
                            width: '180px',
                            fontSize: '44px',
                            padding: '1px'}}
                            />

            )
        }
        return (

                {mainMenu}

        )
    }
}

class Overview extends Component {
    constructor(props){
            super(props)
                this.state = {
                    open: false
                }
            }

    render() {
        return (

                <OverviewRender />

        )
    }
}

export default Overview;

A: It's because you have created a function mainMenu that creates your buttons, but you never call it.
Two options:
1. Move the mainMenu return contents directly into the div:
class OverviewRender extends Component {
    render() {
        return (

                <RaisedButton
                    label="File Options"
                    style={{
                        height: '80px',
                        width: '180px',
                        fontSize: '44px',
                        padding: '1px'
                    }}
                />
                <RaisedButton
                    label="Setup Options"
                    style={{
                        height: '80px',
                        width: '180px',
                        fontSize: '44px',
                        padding: '1px'
                    }}
                />
                <RaisedButton
                    label="More Options"
                    style={{
                        height: '80px',
                        width: '180px',
                        fontSize: '44px',
                        padding: '1px'
                    }}
                />

        )
    }
}

2. Move mainMenu out of the component to make it a functional component, which looks like what you are trying to achieve. And then you have to use it like you would any other component: <MainMenu />:
class OverviewRender extends Component {
    render() {
        return <MainMenu />
    }
}

const MainMenu = () => (

        <RaisedButton
            label="File Options"
            style={{
                height: '80px',
                width: '180px',
                fontSize: '44px',
                padding: '1px'
            }}
        />
        <RaisedButton
            label="Setup Options"
            style={{
                height: '80px',
                width: '180px',
                fontSize: '44px',
                padding: '1px'
            }}
        />
        <RaisedButton
            label="More Options"
            style={{
                height: '80px',
                width: '180px',
                fontSize: '44px',
                padding: '1px'
            }}
        />

);

A: User-Defined Components Must Be Capitalized

We recommend naming components with a capital letter. If you do have a component that starts with a lowercase letter, assign it to a capitalized variable before using it in JSX.

Just rename mainMenu to MainMenu an it should work.
See the docs: component must be capitalized

class OverviewRender extends React.Component {
    render() {
        const MainMenu =  ({name}) => (

                    <button label="File Options"
                        style={{
                            height: '80px',
                            width: '180px',
                            fontSize: '44px',
                            padding: '1px'}}
                            />
                    <button label="Setup Options"
                        style={{
                            height: '80px',
                            width: '180px',
                            fontSize: '44px',
                            padding: '1px'}}
                            />
                    <button label="More Options"
                        style={{
                            height: '80px',
                            width: '180px',
                            fontSize: '44px',
                            padding: '1px'}}
                            />

        );

        return (

                <MainMenu/>

        )
    }
}

ReactDOM.render( < OverviewRender / > , document.getElementById('root'));


text:
Q: DrawingObjects conflict with UserInterfaceOnly - Excel VBA I am trying to secure a workbook using the UserInterfaceOnly function, which runs on Workbook_Open, and it's working great.
However, I recently learned that I have to allow people to paste a picture in to the worksheet, so I added DrawingObject:=False. This has resulted in the apparent effect of the worksheet being locked in name only, but allowing full edit on locked and unlocked cells.
Any ideas would be greatly appreciated.
Private Sub Workbook_Open()

  Sheets("Template").Protect Password:="", UserInterfaceOnly:=True, DrawingObjects:=False

End Sub

A: Did some playing around and found that adding  Contents:=True is required to reset cell protections. Not sure if this is the ideal solution, but it worked. Not sure if leaving it as an answer or edit to my questions is preferable.


text:
Q: Postback Contains No Model Data I have a form that was not receiving any of my model information on the postback.  I have tried to comment out more and more to make it simple so I can see when it works and so far I am having no luck.  I have commented out most of the complex parts of the form and model so I do not know why I am having issues.
Below is the controller functions to show the form and to post it
public ActionResult MassEmail()
    {
        IEmailTemplateRepository templates = new EmailTemplateRepository();
        IEmailFromAddressRepository froms = new EmailFromAddressRepository();
        IEmployeeRepository emps = new EmployeeRepository();
        List<ProductVersion> vers = new List<ProductVersion>();
        MassEmailViewModel vm = new MassEmailViewModel();

        vers = productVersionRepository.All.OrderBy(o => o.Description).ToList();

        foreach (Employee e in emps.Employees.Where(o => o.Department == "Support" || o.Department == "Professional Services").OrderBy(o => o.Name))
        {
            if (e.Email != null && e.Email.Trim() != "")
            {
                vm.BCCAddresses = vm.BCCAddresses + e.Email + ",";
            }
        }
        if (vm.BCCAddresses != "")
        {
            vm.BCCAddresses = vm.BCCAddresses.Substring(0, vm.BCCAddresses.Length - 1);
        }

        ViewBag.PossibleCustomers = customerRepository.All.OrderBy(o => o.CustomerName);
        ViewBag.PossibleTemplates = templates.All.OrderBy(o => o.Description);
        ViewBag.PossibleFromAddresses = froms.All.OrderBy(o => o.Description);
        ViewBag.PossibleClasses = scheduledClassRepository.All.OrderByDescending(o => o.ClassDate).ThenBy(o => o.ClassTopic.Description);

        vm.CCAddresses = "bclairmont@harrisworld.com";
        //vm.Attachments = "";
        vm.Body = "";
        vm.Subject = "";
        vm.ToAddresses = "";
        vm.EmailFromAddressID = 1;

        return View(vm);
    }

    [HttpPost]
    public ActionResult MassEmail(MassEmailViewModel vm)
    {
        IEmailFromAddressRepository froms = new EmailFromAddressRepository();

        System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();

        message.From = new System.Net.Mail.MailAddress(froms.Find(vm.EmailFromAddressID).Email);

        string[] toAddresses = vm.ToAddresses.Split(',');
        for (int i = 0; i < toAddresses.GetUpperBound(0); i++)
        {
            message.To.Add(new System.Net.Mail.MailAddress(toAddresses[i]));
        }

        string[] CCAddresses = vm.CCAddresses.Split(',');
        for (int i = 0; i < CCAddresses.GetUpperBound(0); i++)
        {
            message.To.Add(new System.Net.Mail.MailAddress(CCAddresses[i]));
        }

        string[] BCCAddresses = vm.BCCAddresses.Split(',');
        for (int i = 0; i < BCCAddresses.GetUpperBound(0); i++)
        {
            message.To.Add(new System.Net.Mail.MailAddress(BCCAddresses[i]));
        }
        message.IsBodyHtml = true;
        message.BodyEncoding = Encoding.UTF8;
        message.Subject = vm.Subject;
        message.Body = vm.Body;

        for (int i = 0; i < Request.Files.Count; i++)
        {
            HttpPostedFileBase file = Request.Files[i];
            message.Attachments.Add(new Attachment(file.InputStream, file.FileName));
        }

        System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
        client.Send(message);

        return RedirectToAction("MassEmail");
    }

Next is the code for my View
@model TRIOSoftware.WebUI.Models.MassEmailViewModel

@{
    ViewBag.Title = "MassEmail";
}

@using (Html.BeginForm())
{

Mass E-Mail

    From

    @Html.DropDownListFor(model => model.EmailFromAddressID,
((IEnumerable<TRIOSoftware.Domain.Entities.EmailFromAddress>)
ViewBag.PossibleFromAddresses).OrderBy(m => m.Description).Select(option => new
SelectListItem
{
   Text = option.Description.ToString(),
   Value = option.ID.ToString(),
   Selected = (Model != null) && (option.ID == Model.EmailFromAddressID)
}), "Choose...")

    To

    @Html.TextBoxFor(model => model.ToAddresses, new { @class = "TagTextBox" })

    CC

    @Html.TextBoxFor(model => model.CCAddresses, new { @class = "TagTextBox" })

    <input type="button" id="BCC" value="BCC" class="btn"/>

    @Html.TextBoxFor(model => model.BCCAddresses, new { @class = "TagTextBox" })

    <input type="button" id="Subject" value="Subject" class="btn"/>

    @Html.TextBoxFor(model => model.Subject, new { id = "SubjectText", style =
    "width:100%" })

        @Html.TextAreaFor(model => model.Body, new { id = "BodyText" })

    <input type="submit" value="Send E-Mail" class="btn btn-primary"/>

    E-Mail Template

    @Html.DropDownList("EmailTemplate",
   ((IEnumerable<TRIOSoftware.Domain.Entities.EmailTemplate>)
   ViewBag.PossibleTemplates).Select(option => new SelectListItem
   {
       Text = option.Description,
       Value = option.ID.ToString(),
       Selected = false
   }), "Choose...", new { ID = "Template", style = "width:200px" })

}

@section sidemenu {
    @Html.Action("EmailsSideMenu", "Admin")
}

When I submit I get all null values except for the EmailFromAddressID which is 0 even though ti gets defaulted ot 1 when the view loads.
Any ideas?
EDIT____________________________________
I looked in DevConsole of Chrome and under network I coudl see my post request.  Below is the detailed informaiton it contained.  It looks to me liek the data did get sent to the server so I do not knwo why the server cant fill in my Model class
Request URL:http://localhost:53730/Customers/MassEmail
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Content-Type:application/x-www-form-urlencoded
Origin:http://localhost:53730
Referer:http://localhost:53730/Customers/MassEmail
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko)
Chrome/24.0.1312.52 Safari/537.17

Form Dataview sourceview URL encoded
EmailFromAddressID:1
ToAddresses:
CCAddresses:bclairmont@harrisworld.com
BCCAddresses:adunn@harrisworld.com,bclairmont@harrisworld.com,
bkelly@harrisworld.com,bhackett@harrisworld.com,jwade@harrisworld.com,
krichter@harrisworld.com,mroy-waters@harrisworld.com,
nburckhard@harrisworld.com,rlibby@harrisworld.com
Subject:Testing
Body:

Here is the class that gets passed back and forth from the clien tto server in case that helps
public class MassEmailViewModel
{
    //public MassEmailViewModel()
    //{
    //    ComplexQuery = new CustomerQueryViewModel();
    //}

    public int EmailFromAddressID;

   // public CustomerQueryViewModel ComplexQuery;

    public string ToAddresses;
    public string CCAddresses;
    public string BCCAddresses;
    public string Subject;
    public string Body;
    //public string Attachments;
}

A: 1) Have you tried specifing the route of the controller to which the model will be submited?. I mean, declaring the form like this:
@using (Html.BeginForm("YourAction","YourController", FormMethod.Post))

2) Why dont you just create a simple "Get" action that returns the strongly typed view and a "Post" action that receives the same model with the information you added in the view. Once you make work that, you can begin adding extra code so it is easy to trobleshoot the problem.
3) Make sure all of your helpers are inside the form.
4) Have you configured routing rules that can be making your post being redirected to another area, controller or action?

A: The DefaultModelBinder needs public properties not public fields.
Change your fields to properties and it should work:
public class MassEmailViewModel
{
    public int EmailFromAddressID { get; set; }

    public string ToAddresses { get; set; }
    public string CCAddresses { get; set; }
    public string BCCAddresses { get; set; }
    public string Subject { get; set; }
    public string Body { get; set; }
}


text:
Q: MVC : JQuery go to action with first row id Only here is table contain more row,each row has url : /Unit/Dept/Id
when ckick for any row button edit_dept go to the action with the first row parameter , each row come like /Unit/Dept/1

         Name

    @foreach (var item in Model)
    {

                <button id="edit_dept" class="btn-bootstrap-dialog edit_dept"> Edit</button>

    }

here is JQuery
i need to send the specific row parameter (Id) to action
@section scripts
{

thanks

A: When you use id selector like$('#Dept2') it will always going to select first element it find in DOM with Dept2 id.
But you can select your expected element with selecting parent and then using find to select element inside that particular element. You have to use $(this).closest('td').find('#Dept2') for that.
Try with.
var url = $(this).closest('td').find('#Dept2').data('url');


text:
Q: How to compare SQL fields of different tables, then replace the with value other fields? Situation: I am using wordpress and I have 60000 old posts. Now I have to update each posts with some new information. For some reason, I have to compare the custom fields in SQL and find the same post id. Then make the changes.
SQL struction:
table1(t1): wpxf_posts
column name1(c1): ID
column name2(c2): post_name
table2(t2): wpxf_postmeta
column name3(c3): post_id
column name4(c4): code
What I have to do:

*

*Compare value of c1 and c3

*if c1 = c3

*then c4 = c2

Here is a picture to help to describe

I read some posts but most of them teach us how to compare the difference. I am not sure if they suit my case as it seems did not find the same value.
This one may be helpful but I don't know how to apply to my situation.
SQL Replace used during a compare

A: Try using a case statement:
Update table2
Set c4 = Case When c1 = c2 Then c2 Else c4 End
From table2
     Join table1
          On (What ever column you should join on)


text:
Q: php activerecord many to many I've three models:
// student_id student_name
Student extends ActiveRecord\Model
{
    static $has_many = array(
        array('studentcourses')
    );
}

// course_id course_name
Course extends ActiveRecord\Model
{
    static $has_many = array(
        array('students')
    );
}

// course_id student_id
Studentcourse extends ActiveRecord\Model
{
    static $belongs_to = array(
        array('student')
    );
}

So by doing this I'll be able to retrive data from these tables easy:
$student = Student::find(1);

foreach ($student->studentcourses as $course)
{
    echo $course->name;
}

But insted of typing 'studentcourses', I'd like to type $student->courses instead to get all the courses the student goes to and $course->students to get a list of students in a specific course. How would the relationship setup look to get that?

A: I think what you need is many to many relationship. To set it up in PHP-AR:
// student_id student_name
Class Student extends ActiveRecord\Model
{
    static $has_many = array(
        array('courses', 'through' => 'studentcourses'),
        array('studentcourses')
    );
}

// course_id course_name
Class Course extends ActiveRecord\Model
{
    static $has_many = array(
        array('students', 'through' => 'studentcourses'),
        array('studentcourses')
    );
}

// course_id student_id
Class Studentcourse extends ActiveRecord\Model
{
    static $belongs_to = array(
        array('student'),
        array('course')
    );
}

Don't forget that the studentcourses table must contains: id (primary key), student_id, and course_id.


text:
Q: facebook sdk: share local picture with text is driving me crazy GOAL
In my camera app i want to let user share a picture with pre-formatted text and a description on the user's facebook wall.

INTRO
I Googled a lot and followed "the terrific" facebook-getting-started, trying many things, for !!days!!... no completely working solutions found yet.
At least i think i got some points:

*

*The great Android Intent action_send works great but not choosing facebook, that works for text OR for pictures, not for both (!!), see here

*applicationID, hashxxx, and everything else needed to link android app to facebook login, all things that i really don't understand and don't want to, done and at last working (thanx facebook for all this sh*t!!)

*share with facebook can be done (see here):
3a. using the facebook app (installed in the device)
3b. using a login session (if facebook app is not installed)

*Facebook wants us to use its SDK, it's very [b|s]ad, but i can stand it.

*case 3a - facebook suggests us to use the shareDialog, and -fighting a lot with code snippets and samples suggested!- i have been able to do it, but i need it to work also if facebook app is not installed (case 3b.)

*case 3b - facebook suggests to use the "ugly" feedDialog as a fallback (see here).
6a. feedDialog needs login and it's ok...
6b. it seems feedDialog cannot share local images, i really don't understand why... here facebook guide talks only about "URL" for the "picture" keyword...
5c. then i think i must use Request, i tried implementing it but nothing happened, i think i'm missing something... No useful references (=working examples) found.

CODE SNIPPETS copy/paste/edit from SO and developers.facebook
ShareDialog and session management in case facebook app is not installed IT'S WORKING
/**
 * share image with facebook, using facebook sdk
 * @param pathToImage
 */
private void shareWithFacebook(String pathToImage) {
    Log.i("SHARE", "share with facebook");
    if (FacebookDialog.canPresentShareDialog(getApplicationContext(), FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) {
        // Publish the post using the Share Dialog
        Log.i("SHARE", "share with ShareDialog");
        FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
        .setCaption("Sharing photo taken with MyApp.")
        .setName("Snail Camera Photo")
        .setPicture("file://"+pathToImage)
        .setLink("http://myapplink")
        .setDescription("Image taken with MyApp for Android")
        .build();
        uiHelper.trackPendingDialogCall(shareDialog.present());
    } else {
        // maybe no facebook app installed, trying an alternative
        // here i think i need a session
        if (Session.getActiveSession() != null && Session.getActiveSession().isOpened()) {
            publishFeedDialog(pathToImage);
        } else {
            Session session = Session.getActiveSession();
            if (!session.isOpened() && !session.isClosed()) {

                List<String> permissions = new ArrayList<String>();
                permissions.add("publish_actions");

                session.openForRead(new Session.OpenRequest(this)
                    .setPermissions(permissions)
                    .setCallback(mFacebookCallback));
            } else {
                Session.openActiveSession(this, true, mFacebookCallback);
            }
        }
    }
}

private Session.StatusCallback mFacebookCallback = new Session.StatusCallback() {
    public void call(final Session session, final SessionState state, final Exception exception) {
        if (state.isOpened()) {
            String facebookToken = session.getAccessToken();
            Log.i("SHARE", facebookToken);
            Request.newMeRequest(session, new Request.GraphUserCallback() {
                public void onCompleted(GraphUser user, com.facebook.Response response) {
                    publishFeedDialog(MP.LAST_TAKEN_FOR_GALLERY);
                }
            }).executeAsync();
        }
    }
};

feedDialog snippet, works for text fields, links, and remote url, but DOESN'T WORK FOR LOCAL PICTURES using "file://..." nor "file:///...". Error message: picture URL is not properly formatted.
private void publishFeedDialog(String pathToImage) {
    Bundle params = new Bundle();
    params.putString("name", "myapp Photo");
    params.putString("caption", "Sharing photo taken with myapp.");
    params.putString("description", "Image taken with myapp for Android");
    params.putString("link", "http://myapp.at.playstore");
    params.putString("picture", "file://"+pathToImage);

    WebDialog feedDialog = (
        new WebDialog.FeedDialogBuilder(EnhancedCameraPreviewActivity.this,//getApplicationContext(),
            Session.getActiveSession(),
            params))
        .setOnCompleteListener(new OnCompleteListener() {

            public void onComplete(Bundle values,
                FacebookException error) {
                Log.i("SHARE", "feedDialog.onComplete");
                if (error == null) {
                    // story is posted
                    final String postId = values.getString("post_id");
                    if (postId != null) {
                        Toast.makeText(getApplicationContext(),
                            "Posted story, id: "+postId,
                            Toast.LENGTH_SHORT).show();
                    } else {
                        // User clicked the Cancel button
                        Toast.makeText(getApplicationContext(),
                            "Publish cancelled",
                            Toast.LENGTH_SHORT).show();
                    }
                } else if (error instanceof FacebookOperationCanceledException) {
                    // User clicked the "x" button
                    Toast.makeText(getApplicationContext(),
                        "Publish cancelled",
                        Toast.LENGTH_SHORT).show();
                } else {
                    // Generic, ex: network error
                    Toast.makeText(getApplicationContext(),
                        "Error posting story",
                        Toast.LENGTH_SHORT).show();
                }
            }

        })
        .build();
    feedDialog.show();
}

Another try, using Request, it says:

photo upload problem. Error={HttpStatus: 403, errorCode: 200,
  errorType: OAuthException, errorMessage: (#200) Requires extended
  permission: publish_actions}

I tried adding publish_actions permission in the session management above, maybe i miss something...
private void publishFeedDialog(String pathToImage) {
    Request request=Request.newPostOpenGraphObjectRequest(
            Session.getActiveSession(),
            "PhotoUpload",
            "myApp Photo Upload",
            "file://"+pathToImage,
            "http://myapp.at.playstore",
            "Image taken with myApp for Android",
            null,
            uploadPhotoRequestCallback);
    request.executeAsync();
}

Last try with Request, absolutely nothing happens, both with or without "picture" keyword.
private void publishFeedDialog(String pathToImage) {
    Bundle parameters = new Bundle();
    parameters.putString("message", "Image taken with myApp for Android");
    parameters.putString("picture", "file://"+pathToImage);
    parameters.putString("caption", "myApp Photo");

    Request request = new Request(Session.getActiveSession(), "/me/feed", parameters, null);
    // also tried: Request request = new Request(Session.getActiveSession(), "/me/feed", parameters, com.facebook.HttpMethod.POST);
    request.executeAsync();
}

QUESTIONS
-1- Are there some faults in my 1..6 points?
-2- Can i share a local picture using FeedDialog?
-3- if not, how to when facebook app is not installed?
Thanks a lot!

A: I have the same problem, but I have a workaround.

*

*I can't find any wrong reasoning in your point 1-6, look like the same issues I've come acrossed.

*You can't share pictures locally, but...

*Code snippet below:

This will upload the picture to the users profile and post it on his\hers wall, afterwhich you can get the URL if needed:
private void uploadPicture(final String message, Session session) {
        Request.Callback uploadPhotoRequestCallback = new Request.Callback() {
            @Override
            public void onCompleted(com.facebook.Response response) {
                if (response.getError() != null) {
                     Toast.makeText(getActivity(), "Failed posting on the Wall", Toast.LENGTH_LONG).show();
                    return;
                }

            Object graphResponse = response.getGraphObject().getProperty("id");
            if (graphResponse == null || !(graphResponse instanceof String) ||
                    TextUtils.isEmpty((String) graphResponse)) {
                Toast.makeText(getActivity(), "Failed uploading the photo\no respons", Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(getActivity(), "Succsefully posted on the facebook Wall", Toast.LENGTH_LONG).show();
            }
        }
    };

    // Execute the request with the image and appropriate message
    Request request = Request.newUploadPhotoRequest(session, profileBitmap, uploadPhotoRequestCallback);
    Bundle params = request.getParameters();
    params.putString("message", message);
    request.executeAsync();
}

And to start facebook login when you don't have the APP, it's simpler, I use the following code snippet for calling the facebook SDK on facebook button:
@Override
public void onClick(View v) {
        switch (v.getId()) {
             case R.id.faceBookButton:
                        if (((imagePath != null && !imagePath.equals("")) || (message != null && !message.equals("")))) {
                            Session session = Session.getActiveSession();
                            if (!session.isOpened() && !session.isClosed()) {
                                session.openForPublish(new Session.OpenRequest(this)
                                        .setPermissions(Arrays.asList("public_profile", "publish_actions"))
                                        .setCallback(statusCallback));
                            } else {
                                if (profileBitmap != null) {
                                    uploadPicture(message, session);
                                } else {
                                    publishFeedDialog(message);
                                }
                            }
                        } else {
                            Toast.makeText(getActivity(), getString(R.string.checkin_fail), Toast.LENGTH_SHORT).show();
                        }
                  break;
           }
     }

In my case publishFeedDialog accepts the message you want to pass on, and not the image, but it doesn't matter. It opens up Facebook's message dialog anyway to which I haven't yet found a way to pass a predefined message from my EditText widget.


text:
Q: How to use VueStripe on vue2 Project? I added Vue Stripe on my vue2 Project and I have 2 similar errors on my code :

Property 'redirectToCheckout' does not exist on type 'Vue | Element | (Vue | Element)[]'.

Property 'publishableKey' does not exist on type 'CombinedVueInstance<Vue, unknown, unknown, unknown, Readonly<Record<never, any>>>'.

I followed the documentation on their website and everything is similar as their code so I don't know why I have those errors.
Screenshots

Here is my code if you want to check
<template >

        retrouner aux calendrier des soirées

{{ degustation[0].title }}

{{ degustation[0].description }}

Formulaire de réservation

                    Nom et prénom
                    <input type="text" class="w-input" maxlength="256" name="name" data-name="Name" placeholder="Ecrivez votre nom et prénom" id="name" data-kwimpalastatus="alive" data-kwimpalaid="1626170679038-0">
                    Email Address
                    <input type="email" class="w-input" maxlength="256" name="email" data-name="Email" placeholder="Ecrivez votre adresse email" id="email" required="" data-kwimpalastatus="alive" data-kwimpalaid="1626170679038-1">
                    Téléphone
                    <input type="text" class="w-input" maxlength="256" name="field" data-name="Field" placeholder="Ecrivez votre numéro de téléphone" id="field" required="" data-kwimpalastatus="alive" data-kwimpalaid="1626170679038-2">
                    Quantité
                    <input v-model="lineItems[0].quantity" type="number" class="w-input" maxlength="256" placeholder="Combien de places voulez vous acheter ?" required="">

                        <input type="hidden" name="name" value="Name">
                        <input type="hidden" name="prix" value="Prix">
                        <input type="hidden" name="image" value="Image">

              <stripe-checkout
                ref="checkoutRef"
                mode="payment"
                :pk="publishableKey"
                :line-items="lineItems"
                :success-url="successURL"
                :cancel-url="cancelURL"
              />
              <button @click="submit()" class="cta-button w-button">Payer</button>

</template>

Do I need to import something else or ?

A: A couple of things are happening here.
First, keep in mind that if you want to access the publishableKey in the template then you should add it in the object that you're returning in the data() function.
Try to do some checking before accessing checkoutRef, try this:
if (this.$refs.checkoutRef) {
  this.$refs.checkoutRef.redirectToCheckout()
}


text:
Q: Testing.fakes error when I try to debug my C# app I have a solution with 5 projects, one of them is a unittest and another one is an API Rest (donno if this is relevant hehe) . The problem I have is that when I added this unittest, I couldn't debug again my API, all the time a ' System.IO.FileNotFoundException' appears and I can't do nothing.
How could I fix this problem?
I tried removing all references via Visual Studio but still it is not working.

Could not load file or assembly 'Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Thanks!


text:
Q: GSON Date Format - Handling null date in the JSON parsing I am trying to convert the JSON to a custom bean. But I am facing issue when the date value is null in the JSON.
Valid JSON String, it is getting converted with out any issue as both from and to date has values:
{"title":"1201 Box Title 1","fromdate":"01/02/2017","description":"1201 Box Title 1","todate":"01/26/2017"}

JSON String with Error: Where from date is empty
{"title":"1201 Box Title 1","fromdate":"","description":"1201 Box Title 1","todate":"01/26/2017"}

Java code used for Initialization:
 Gson testGson = new GsonBuilder().setDateFormat("MM/dd/yyyy").create();
 MyTestBean myTestBean = testGson.fromJson(jsonString, MyTestBean.class);

In the bean fromdate and todate attributes are declared with the "Date" datatype
Error Stacktrace:
Exception in thread "main" com.google.gson.JsonSyntaxException:
at com.google.gson.DefaultDateTypeAdapter.deserializeToDate(DefaultDateTypeAdapter.java:107)
at com.google.gson.DefaultDateTypeAdapter.deserialize(DefaultDateTypeAdapter.java:82)
at com.google.gson.DefaultDateTypeAdapter.deserialize(DefaultDateTypeAdapter.java:35)
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:59)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
at com.google.gson.Gson.fromJson(Gson.java:755)
at com.google.gson.Gson.fromJson(Gson.java:721)
at com.google.gson.Gson.fromJson(Gson.java:670)
at com.google.gson.Gson.fromJson(Gson.java:642)
at JSONConverter.main(JSONConverter.java:15)
Caused by: java.text.ParseException: Unparseable date: ""
    at java.text.DateFormat.parse(DateFormat.java:366)
    at com.google.gson.DefaultDateTypeAdapter.deserializeToDate(DefaultDateTypeAdapter.java:105)
    ... 10 more

Could anyone please let me how to handle this issue in the right way.
One way I am trying to overcome the issue is as below, but wanted to know if there is any inbuilt option in GSON itsself to handle the null date:

*

*Declare the from and to dates in bean as String datatype

*Write a custom getter method in the bean which will do the parsing before returning the date which will be used by code using this bean

A: Consolidating the comments came from my question and placing the answer from those comments:
JSON string which worked fine with out any parsing issue is:
{"title":"1201 Box Title 1","fromdate":null,"description":"1201 Box Title 1","todate":"01/26/2017"}

After adding the required condition in the JS which is constructing the JSON to pass null instead of empty string fixed the issue.
Thanks @cricket_007 for pointing the issue that needs to be resolved.