text:
Q: Assign different values to different struct variables using loop I have a struct of Examinee like below (each has 1 id and their scores of different subjects):
struct Examinee
{
    string id;
    float math, literature, physic, chemistry, biology, history, geography, civic_education, natural_science,
          social_science, foreign_language;
};

Now i want to write a function that reads from a string different values and assign them to an Examinee. The string looks like this (each info is separated by a comma):

BD1200001,9,4.0,5.0,10,3.5,7.5,4.25,7.0,7.75,9.25,2.0

This is what i have done so far:
Examinee readExaminee(string line_info) {

//turn line_info to char*
    int Line_info_length = line_info.length();
    char* info = new char[Line_info_length + 1];
    strcpy(info, line_info.c_str());

//create examinee
    Examinee examinee;

//read id into examinee by token
    char* token = strtok(info, ",");
    examinee.id = token;

//read score and assign to subjects
    while (token != NULL)
    {
        float score = strtof(token, NULL);

        //assign score to appropriate subject

        token = strtok(NULL, ",");
    }

    delete[] info;
    return examinee;
}

The question is: Can i assign each score to each subject in while loop like above? How can i do that? If not, is assigning each score manually the only way?

A: I'd change the design of Examinee. Something along these lines:
struct Examinee
{
  enum Subject {kSubjMath, kSubjLiterature, ..., kSubjForeignLanguage, kSubjCount};
  string id;
  float scores[kSubjCount];
};

This way you can access scores in a loop, e.g.
for (int subj = 0; subj < Examinee::kSubjCount; ++subj) {
 examinee.scores[subj] = some_score;
}

Or access specific score as examinee.scores[Examinee::kSubjLiterature]

If you are unable or unwilling to change Examinee, you can sort of simulate this locally:
Examinee examinee;
float* scores[] = {&examinee.math, &examinee.literature, ..., &examinee.foreign_language};
for (int subj = 0; subj < std::extent_v<scores>; ++subj) {
  *scores[subj] = some_value;
}


text:
Q: iOS: show json info on detailView when click on annotation I have a json file with some information I want to show this information on map, I can show Long and Lat on map, when you click on Annotation I have a button I want to show detail of my json on detail view, my problem is that I donot know how to show/send information on detail view based on annotation clicked,
Here is how I will load my detailViwe
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
{
    DetailViewController *detail = [[DetailViewController alloc] initWithNibName:nil
bundle:nil];

    // my question is here In my detail view I have label like status, company, how to add json info here

    detail.status.text = ??!!!
    detail.company.text = ??!!!

    [self.navigationController pushViewController:detail animated:YES];
}

In my Log I have the correct status printed but in my detail view controller I have null printed
- (void)viewDidLoad
{
[super viewDidLoad];

self.status.text = _status.text;
    NSLog(@"Status %@ ",_status );
    NSLog(@"Status is %@ ",self.status.text);

}

Print is Status null
// // // Status is null

A: You can access data from the MKAnnotationView provided in
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
The view object has an annotation property that will give you an object adopting the MKAnnotation protocol. This could be MKPointAnnotation as you already have, if just a title and subtitle will do. But you could also define a custom annotation class that holds onto a status and a company:
MyAnnotation *annotation = view.annotation;
// annotation.status
// annotation.company

You'd have to create a MyAnnotation instance and insert the data in the place where you currently are creating newAnnotation.
As for once you have the data you need and you want to pass it to the DetailViewController, I suggest looking at this SO answer or Ole Begemann's tips here. In short, you can create a public property of your detail view controller, and then do something like:
    DetailViewController *destinationController = [[DestinationViewController alloc] init];
    destinationController.name = annotation.status;
    [self.navigationController pushViewController:destinationController animated:YES];

In summary, your method could then look something like this:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
{
    MyAnnotation *annotation = view.annotation;

    DetailViewController *detail = [[DetailViewController alloc] initWithNibName:nil
bundle:nil];

    detail.status = annotation.status;
    detail.company = annotation.company;

    [self.navigationController pushViewController:detail animated:YES];
}

And then set the UILabel texts in your detail view controller:
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.statusTextField.text = self.status;
    self.companyTextField.text = self.company;
}

Update to clarify the creation of MyAnnotation:
You always have the option of creating a custom class. Here could be an example for MyAnnotation.h:
#import <MapKit/MapKit.h>

@interface MyAnnotation : MKPointAnnotation

@property (strong, nonatomic) NSString *status;
@property (strong, nonatomic) NSString *company;

@end

Then in your map view controller import: #import "MyAnnotation.h"
and use MyAnnotation instead of MKPointAnnotation:
// create the annotation
newAnnotation = [[MyAnnotation alloc] init];
newAnnotation.title = dictionary[@"applicant"];
newAnnotation.subtitle = dictionary[@"company"];
newAnnotation.status = dictionary[@"status"];
newAnnotation.company = dictionary[@"company"];
newAnnotation.coordinate = location;
[newAnnotations addObject:newAnnotation];

redpajama_set_name: RedPajamaStackExchange


text:
Q: Adding a default value to text-input in simple-form I want to add a default value to a text-input field using simple-form.
With :placeholder it is not used as default....
<%= f.input :user, :placeholder => 'user@example.com' %>

A: <%= f.input :user, :input_html => { :value => 'user@example.com' } %>

A: You can do this in the controller and keep data details out of your forms.  Instead of this:

def new
  @article = Article.new
end

you can do this:

def new
  # hardcode default values (as shown) or generate on the fly
  @article = Article.new(title: "10 Best Things")
end

The "new" form will open with the default (pre-set) values filled in.  This should work with simple-form, plain old Rails, or any other form generator that does does things the Rails way..

A: You can simply do:
<% f.text_field, value: 'user@example.com' %>

text_field is good if you are working with form search gem like Ransack.

A: On rails 5.1 placeholder: 'aaaaaaaaaaa' works. E.g.
<%= f.input :user, :placeholder => 'user@example.com' %>

will work on rails 5.1

A: You can try this option:
<%= f.input :user, label: 'user@example.com' %>


text:
Q: {Multiplexors} combine 2:1 to from 8:1 I have a question of combining 2:1 to form single 8:1 multiplexor
This is acheivable by using 7   2:1, with 4 of it at the first level, 3 of it at the second level, and 1 of it at the third level.  Then you just hook up the control bit of the first level together, and the second level together and so on. But my question is for the 3 bits "control bits", do you need another decoder or something?

A: Like this:-

simulate this circuit – Schematic created using CircuitLab


text:
Q: Can't get rid of color in UITableView's tableFooterView I have a standard UITableView with three sections. At the bottom of the table I'm trying to add a tableFooterView. It seems as though there's a standard spacing between the last row in the table and the top of the tableFooterView, which is fine, but my problem is that there is a different color in this spacing that I can't get rid of. I need that spacing to match the background of my tableView.
Here's some code:
self.menuTable.backgroundColor = [UIColor redColor];
self.menuTable.backgroundView = nil;
self.menuTable.separatorColor = [UIColor clearColor];
self.menuTable.delegate = self;
self.menuTable.sectionHeaderHeight = 10.0;

UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
footer.backgroundColor = self.menuTable.backgroundColor;
UILabel *footerLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 0, 205, 100)];
footerLabel.text = @"foo bar.";
footerLabel.textColor = [UIColor blackColor];
footerLabel.backgroundColor = self.menuTable.backgroundColor;
footerLabel.numberOfLines = 10;
footerLabel.font = [UIFont italicSystemFontOfSize:11.0];
[footerLabel sizeToFit];

[footer addSubview:footerLabel];
self.menuTable.tableFooterView = footer;

Here's a screenshot (sorry about the red, but it's the easiest way to see the differences in colors).

A: Whoops. Earlier I was trying to add a sectionFooterView, and had implemented tableView:heightForFooterInSection:, returning 20 for the last section. That's where that gap was coming from, and it had a default color of white. Since I'm now placing the text as the tableFooterView, I just removed that delegate callback and everything is rendering as expected.

A: Try this
self.menuTable.backgroundColor = [UIColor clearColor];
self.view.backgroundColor = [UIColor redColor];


text:
Q: Towers of Hanoi: Model recursive solution to a non-recursive solution I am having a go at recursive and iterative approaches to problem solving using the Towers of Hanoi puzzle.

f refers to from/source, helper - auxiliary/intermediate position, t - target/destination

Here is the recursive implementation where we just print the moves:
def towers_of_hanoi_v1(n):
    """
    Recursive approach
    """

    def move(f, t):
        print(f"Move disc from {f} to {t}!")

    def hanoi(n, f, helper, t):
        if n:
            hanoi(n - 1, f, t, helper)
            move(f, t)
            hanoi(n - 1, helper, f, t)

    return hanoi(n, "A", "B", "C")

My attempt at converting the above to an iterative solution is as follows:
class Disc:
    def __init__(self, size):
        self.size = size

def towers_of_hanoi_v2(n):
    """
    Iterative approach
    """

    def mapper(queue):
        """
        util to map queue to its respective label
        """
        if queue is A:
            label = "A"
        elif queue is B:
            label = "B"
        elif queue is C:
            label = "C"
        return label

    def move(f, t):
        """
        utility function to print moves
        """
        print(f"Move disc from {mapper(f)} to {mapper(t)}!")

    def valid_moves(giver, taker):
        """
        utility function to figure out next legal move:
        - One of the towers could be empty, so we can only move to it and not from it
        - Tower x can have a larger disk than tower y.
        """
        if not len(giver):
            giver.appendleft(taker.popleft())
            move(taker, giver)

        elif not len(taker):
            taker.appendleft(giver.popleft())
            move(giver, taker)

        elif giver[0].size > taker[0].size:
            giver.appendleft(taker.popleft())
            move(taker, giver)

        else:
            taker.appendleft(giver.popleft())
            move(giver, taker)

    def hanoi(n, src, helper, dest):
        if n % 2 == 0:
            helper, dest = dest, helper

        moves = pow(2, n) - 1

        for i in range(1, moves + 1):
            if i % 3 == 1:
                valid_moves(src, dest)

            elif i % 3 == 2:
                valid_moves(src, helper)

            elif i % 3 == 0:
                valid_moves(helper, dest)

    """
    Initialise towers as stacks. We use stacks so that we can always look at
    the current top disk and compare the sizes between top disks of two towers
    """
    A = collections.deque(maxlen=n)
    B = collections.deque(maxlen=n)
    C = collections.deque(maxlen=n)

    """
    Populate initial tower while assigning sizes
    sizes will be crucial as we can not move a large disk onto a small disk
    """
    for i in reversed(range(n)):
        A.append(Disc(n - i))

    return hanoi(n, A, B, C)

Incorporated this feedback. The iterative approach needed an auxiliary data structure, I used a stack:
n = 4

Recursive approach:
Move disc from A to B!
Move disc from A to C!
Move disc from B to C!
Move disc from A to B!
Move disc from C to A!
Move disc from C to B!
Move disc from A to B!
Move disc from A to C!
Move disc from B to C!
Move disc from B to A!
Move disc from C to A!
Move disc from B to C!
Move disc from A to B!
Move disc from A to C!
Move disc from B to C!
None

Iterative approach:
Move disc from A to B!
Move disc from A to C!
Move disc from B to C!
Move disc from A to B!
Move disc from C to A!
Move disc from C to B!
Move disc from A to B!
Move disc from A to C!
Move disc from B to C!
Move disc from B to A!
Move disc from C to A!
Move disc from B to C!
Move disc from A to B!
Move disc from A to C!
Move disc from B to C!
None

Do you have a cleaner approach?

A: If you look into your solution, it's almost correct but it doesn't consider the conditions to validate a legal move.
For example, in n=2, there will be a move between B and C. But you've to decide the correct swap direction.
There can be many scenarios,

*

*One of the towers could be empty, so we can only move to it and not from it.

*Tower x can have a larger disk than tower y.
So, you should implement it with a list/stack where you can always look into the current top disk and compare the sizes between top disks of two towers. Then, before each movement, you'll have to decide the correct direction of movement based on the rules of the game.


text:
Q: Why are my marks not drawn? I'm somewhat stumped by the following simple plot at the moment.  I expected three black marks to be drawn.  Instead, I see no points being drawn (only the axes).  This is based on old code, so I'm quite sure it worked before:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[only marks]
\addplot[black] coordinates {(0,0) (1,1) (2,2)};
\end{axis}
\end{tikzpicture}
\end{document}

Why am I not seeing any points plotted, and how should I alter my code so I will?

A: You should pass only marks to the \addplot not to the axis.
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[]
\addplot[black,only marks] coordinates {(0,0) (1,1) (2,2)};
\end{axis}
\end{tikzpicture}
\end{document}


text:
Q: ListView NullpointerException issue at BaseAdapter I have tried to make a ListView using a CustomViewAdapter, but I am getting a NullPointerException.
MainActivity:
private Context context=this;
private ListView listView;
private List<AlarmModel> alarms;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_alarm_list);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    listView = (ListView) findViewById(R.id.listAlarm);

    // get data from SQLite
    DatabaseHandler db = new DatabaseHandler(context);

    db.addAlarmDB(new AlarmModel());
    db.addAlarmDB(new AlarmModel());
    alarms = db.getAllAlarmDB();

    //adding adapter
    CustomListViewAdapter adapter = new CustomListViewAdapter(context,alarms);
    listView.setAdapter(adapter);
}

This is my CustomListViewAdapter along with ViewHolder:
public class CustomListViewAdapter extends BaseAdapter {

private Context context;
private LayoutInflater inflater;
private List<AlarmModel> alarmListData = new ArrayList<>();

public CustomListViewAdapter(Context context, List<AlarmModel> data){
    this.context = context;
    this.alarmListData = data;
    inflater = LayoutInflater.from(this.context);
}

//this is ViewHolder class
public class ViewHolder{
    TextView alarmTimeText;
    TextView alarmTitleText;
    Switch alarmStatusSwitch;
}

@Override
public int getCount() {
    return alarmListData.size();
}

@Override
public AlarmModel getItem(int position) {
    return alarmListData.get(position);
}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder hold;

    //bind with list view
    if (convertView==null){
        convertView = inflater.inflate(R.layout.alarm_list_content,null);
        hold = new ViewHolder();
        hold.alarmTitleText = (TextView) convertView.findViewById(R.id.alarmTImeText);
        hold.alarmTitleText = (TextView) convertView.findViewById(R.id.alarmTitleText);
        hold.alarmStatusSwitch = (Switch) convertView.findViewById(R.id.alarmStatusSwitch);
        convertView.setTag(hold);
    }else{
        hold = (ViewHolder) convertView.getTag();
    }

    /// get data from model
    AlarmModel alarmData = getItem(position);
    hold.alarmTimeText.setText(alarmData.getTime());
    hold.alarmTitleText.setText(alarmData.getTitle());

    //this is for switch of alarm status
    if(alarmData.getStatus()==1){
        hold.alarmStatusSwitch.setChecked(true);
    }else{
        hold.alarmStatusSwitch.setChecked(false);
    }
    return convertView;
}

}
Logcat:
gist
PS: At CustomListViewAdapter.java:72 alarmData object isn't empty. I have checked it with Log.d.


text:
Q: Error 500 with django 1.6 app running on apache 2.4 and python 3.3 with mod_wsgi For the past months I've been coding a django-app for my current employer and they now want to deploy it to the server. I know there have been a lot of threads regarding this problem but none of them helped me solving this.
I'm using Python 3.3 with Django 1.6 and mod_wsgi on a Windows 7 PC. The server is a Apache 2.4 via XAMPP.
Over the last couple of days I tried to publish my app to the server but it didn't work. I think I made some progress, going from a non-functional server over a "Access denied" error to the current state where I get a server error 500. I feel like getting really close, however I'm totally stuck now and need some help.
This is part of  my httpd.conf:
WSGIPythonPath "C:/TSDE_Workarea/Kmg1yh/SharCC/Workspaces/ReservationTool/PythonReDesign/trunk"
WSGIPythonHome "C:/TSDE_Workarea/Kmg1yh/SharCC/Workspaces/ReservationTool/PythonReDesign/trunk"
WSGIScriptAlias / "C:/TSDE_Workarea/Kmg1yh/SharCC/Workspaces/ReservationTool/PythonReDesign/trunk/PythonReDesign/wsgi.py"

<Directory "C:/TSDE_Workarea/Kmg1yh/SharCC/Workspaces/ReservationTool/PythonReDesign/trunk/PythonReDesign">
    <Files wsgi.py>
        #Options Indexes FollowSymLinks Includes ExecCGI
        Order allow,deny
        Allow from all
        #Require all granted
    </Files>
    DirectoryIndex wsgi.py
</Directory>

My wsgi.py looks like this (Just the basic one that django creates when starting a new project. I tried adding new paths to wsgi.py but it didn't change anything.):
"""
WSGI config for PythonReDesign project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""

import os, sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "PythonReDesign.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Now when I start my server and try to access the page, I get the infamous 500 error. The apache error log gives me the following errors:
[Fri Jan 10 15:08:40.017397 2014] [:error] [pid 6676:tid 1876] [client 127.0.0.1:61162] mod_wsgi (pid=6676): Target WSGI script 'C:/TSDE_Workarea/Kmg1yh/SharCC/Workspaces/ReservationTool/PythonReDesign/trunk/PythonReDesign/wsgi.py' cannot be loaded as Python module.
[Fri Jan 10 15:08:40.017397 2014] [:error] [pid 6676:tid 1876] [client 127.0.0.1:61162] mod_wsgi (pid=6676): Exception occurred processing WSGI script 'C:/TSDE_Workarea/Kmg1yh/SharCC/Workspaces/ReservationTool/PythonReDesign/trunk/PythonReDesign/wsgi.py'.
[Fri Jan 10 15:08:40.017397 2014] [:error] [pid 6676:tid 1876] [client 127.0.0.1:61162] Traceback (most recent call last):\r
[Fri Jan 10 15:08:40.017397 2014] [:error] [pid 6676:tid 1876] [client 127.0.0.1:61162]   File "C:/TSDE_Workarea/Kmg1yh/SharCC/Workspaces/ReservationTool/PythonReDesign/trunk/PythonReDesign/wsgi.py", line 13, in <module>\r
[Fri Jan 10 15:08:40.017397 2014] [:error] [pid 6676:tid 1876] [client 127.0.0.1:61162]     from django.core.wsgi import get_wsgi_application\r
[Fri Jan 10 15:08:40.017397 2014] [:error] [pid 6676:tid 1876] [client 127.0.0.1:61162] ImportError: No module named 'django'\r

I'm really stuck here and it's driving me nuts. Any help will be greatly apprecciated! Thanks in advance!
EDIT:
Errorlog when omitting PythonHome:
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] mod_wsgi (pid=5288): Exception occurred processing WSGI script 'C:/TSDE_Workarea/Kmg1yh/SharCC/Workspaces/ReservationTool/PythonReDesign/trunk/PythonReDesign/wsgi.py'.
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] Traceback (most recent call last):\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\core\\urlresolvers.py", line 339, in urlconf_module\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     return self._urlconf_module\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] AttributeError: 'RegexURLResolver' object has no attribute '_urlconf_module'\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] \r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] During handling of the above exception, another exception occurred:\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] \r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] Traceback (most recent call last):\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\core\\handlers\\base.py", line 101, in get_response\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     resolver_match = resolver.resolve(request.path_info)\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\core\\urlresolvers.py", line 318, in resolve\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     for pattern in self.url_patterns:\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\core\\urlresolvers.py", line 346, in url_patterns\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\core\\urlresolvers.py", line 341, in urlconf_module\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     self._urlconf_module = import_module(self.urlconf_name)\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\Lib\\importlib\\__init__.py", line 90, in import_module\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     return _bootstrap._gcd_import(name[level:], package, level)\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "<frozen importlib._bootstrap>", line 1584, in _gcd_import\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "<frozen importlib._bootstrap>", line 1565, in _find_and_load\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "<frozen importlib._bootstrap>", line 1022, in load_module\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "<frozen importlib._bootstrap>", line 1003, in load_module\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "<frozen importlib._bootstrap>", line 868, in _load_module\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\TSDE_Workarea\\Kmg1yh\\SharCC\\Workspaces\\ReservationTool\\PythonReDesign\\trunk\\PythonReDesign\\urls.py", line 6, in <module>\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     from PythonReDesign.views import *\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\TSDE_Workarea\\Kmg1yh\\SharCC\\Workspaces\\ReservationTool\\PythonReDesign\\trunk\\PythonReDesign\\views.py", line 9, in <module>\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     import PythonReDesign.commons as com\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] ImportError: No module named 'PythonReDesign.commons'\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] \r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] During handling of the above exception, another exception occurred:\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] \r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] Traceback (most recent call last):\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 206, in __call__\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     response = self.get_response(request)\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\core\\handlers\\base.py", line 196, in get_response\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\core\\handlers\\base.py", line 231, in handle_uncaught_exception\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     return debug.technical_500_response(request, *exc_info)\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\views\\debug.py", line 69, in technical_500_response\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     html = reporter.get_traceback_html()\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\views\\debug.py", line 323, in get_traceback_html\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     c = Context(self.get_traceback_data())\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\views\\debug.py", line 281, in get_traceback_data\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     frames = self.get_traceback_frames()\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\views\\debug.py", line 428, in get_traceback_frames\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     pre_context_lineno, pre_context, context_line, post_context = self._get_lines_from_file(filename, lineno, 7, loader, module_name)\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "C:\\Python33\\lib\\site-packages\\django\\views\\debug.py", line 379, in _get_lines_from_file\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]     source = loader.get_source(module_name)\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683]   File "<frozen importlib._bootstrap>", line 605, in _requires_frozen_wrapper\r
[Fri Jan 10 16:23:06.296711 2014] [:error] [pid 5288:tid 1868] [client 127.0.0.1:61683] ImportError: importlib._bootstrap is not a frozen module\r

A: The problem is you don't have the site-packages on your PATH. Let's look at the line WSGIPythonHome. According to the mod_wsgi documentation, this configuration directive is used for (emphasis mine):

Used to indicate to Python when it is initialised where its library
files are installed. This should be defined where the Python
  executable is not in the PATH of the user that Apache runs as, or
  where a system has multiple versions of Python installed in different
  locations in the file system, especially different installations of
  the same major/minor version, and the installation that Apache finds
  in its PATH is not the desired on

In other words, it's good if your server has multiple python installations and you're afraid it will get them mixed up. But as you mentioned in part of your comments, you're not using a virtualenv. So there's no need to use that directive. With it, what you're actually doing is misdirecting apache to look for python libraries in the wrong location, meaning it doesn't find the module django. Removing it solves that problem
As for the second problem that occured, it will probably take some digging, because it seems to be related to your own models, and is probably unrelated to apache. Running the devserver helps find those out and dealing with them easier. Good luck!

A: Can you try replacing \r at the end of your lines in wsgi.py with \n? There is no problem with your apache and mod_wsgi setup. You can enable viewing of all the whitespace characters if you are using notepad++.

A: Since the error message says that it cannot find django, I suspect that this is a virtualenv problem. Have you installed django inside a virtual environment?
If so, please ensure that the site-packages are in your path as well as mentioned in the Django docs.


text:
Q: Adding git add to Grunt githooks plugin I am currently working on implementing a pre-commit hook with grunt git hooks. I am new to using this plugin and it's a bit unclear if I can use this plugin to do what I initially set out to do.
Currently, I have two grunt tasks triggering for every git commit as below.
    githooks: {
        all: {
            'pre-commit' : 'compass requirejs'
        }
    }

Above generates git pre-commit hook as below.
#!/usr/bin/env node

// GRUNT-GITHOOKS START
var exec = require('child_process').exec;

exec('grunt compass requirejs', {
       cwd: 'C:\\development\\Sourcecode\\qnb-home'
     }, function (err, stdout, stderr) {

  console.log(stdout);

  var exitCode = 0;
  if (err) {
    console.log(stderr);
    exitCode = -1;
  }

  process.exit(exitCode);
});

// GRUNT-GITHOOKS END

Whilst above ensure the tasks are been run before the git commit,  it does not add the newly created minified files (compiled SASS and r.js files) to the existing commit.
So ,I would like to add a git add --all to the pre-commit hook using grunt githooks. Is it this possible to do? Any comment/answer would be highly appreciated.

A: You can use grunt-githook's template option to create a custom template that would exec the git add --all command. This getting started article provides a good example of how to create a custom template.
That said, running git add -all before every commit will make picking which files to commit a lot more work than usual. You'll have to stash the changes you don't want to be part of your commit before you do it and unstash them afterwards. It might be worth being a bit more targeted in what you add, if you need to add these files to the repository at all. They can be generated from the sources after all.


text:
Q: How can I guarantee that T is a class? I have the next code:
public static T GetSerializedCopy<T> (T src)
{
  //some code to obtain a copy
}

How I can guarantee that T will be a class, not a struct or enum or simething else?

A: public static T GetSerializedCopy<T> (T src) where T : class

This is the link to MSDN for generic type constraints.

A: It is a common mistake (see the answers here) to think that adding where T : class to the generic method/type declaration achieves this - but this is wrong. This actually means "T must be a reference type", which includes delegates and interfaces too (plus arrays, and things like string).
If you want a class, there are two ways; the easiest is to insist on where T : class, new(), since neither an interface nor a delegate can have constructors. This does have false negatives, though, in terms of rejecting classes without public parameterless constructors.
The only other way is at runtime:
if(!typeof(T).IsClass) throw new InvalidOperationException("T must be a class");

Equally, where T : struct doesn't mean "T must be a value-type", either! It means "Tmust be a non-nullable value-type"; types involving Nullable<> do not satisfy T : struct, despite the fact that Nullable<Foo> is a struct.

A: It's pretty easy to ensure that...
    public static T GetSerializedCopy<T>(T src) where T : class
    {
        //some code to obtain a copy
        return default(T);
    }

A: you can use Type Constraints, on your interfaces. Type constraint
where T : class

A: use this:
where T: class

Yes..
public static T GetSerializedCopy<T> (T src)
   where T : class
{
  //some code to obtain a copy
}


text:
Q: Doctrine : Default value on joinColumn field New to symfony2 and Doctrine.
How can I set a default value to the field foo_id (which is a reference on Foo table) to point on the ID 1 of the Foo table (which exists in all cases) ?
Me\NavigationBundle\Entity\PublicText:
    type: entity
    table: public_text
    id:
        id:
            type: integer
            id: true
            generator:
                strategy: AUTO
    fields:
        title:
            type: string
            length: '255'
            nullable: false
        content:
            type: string
            length: '2000'
            nullable: false
    manyToOne:
        foo:
            #How to set a default value???
            targetEntity: \Me\NavigationBundle\Entity\Foo
            joinColumn:
                name: foo_id
                referencedColumnName: id
                nullable: false
    lifecycleCallbacks: {  }

I tried a lot of things without success :

*

*Set default value to ID 1 in the constructor of Foo

*Perform a request to retrieve the Foo object of ID 1 in the Me entity (could works, but bad practice)

A: Look up columnDefinition at Doctrine Column Annotations Reference¶
Pros:  You can set up your own column definition
Cons: doctrine orm:schema-tool used by Doctrine (if you use it), gets confused and always reports columns that have a custom columnDefinition as changed.  As it it will always tell you to run the change command for your column definition, as documented here:

SchemaTool will not detect changes on the column correctly anymore if you use "columnDefinition".

Example
/**
 * @ManyToOne(targetEntity="YourType")
 * @JoinColumn(
 *     name="your_type_id",
 *     referencedColumnName="id",
 *     nullable=false,
 *     columnDefinition="INT NOT NULL DEFAULT 1"
 * )
 */
private $yourType;

A: Please note that using columnDefinition alone will work for generating migrations but will break the ORM context and potentially cause FK integrity issues. You will still need to add the object association to the ORM for persisting entities. See warnings from Ocramius
Example:
(new PublicText())
    ->getFoo(); //null - expected object(Foo)#1 (1) { ["id"] => int(1) }

I have seen many ways to achieve this in doctrine 2.
Constructor
In general, the quickest way and what most users do is require an association in the constructor.
public function __construct(Foo $foo)
{
   $this->foo = $foo;
}

Then you can use getReference to retrieve it in your controller without needing to query the database. See http://doctrine-orm.readthedocs.org/en/latest/reference/advanced-configuration.html#reference-proxies
$foo = $em->getReference('app:Foo', 1);
$text = new \Path\To\Entity\PublicText($foo);
$em->persist($text);
$em->flush();

LifeCycleEvents
My preferred way Another method to set the default value with most ManyToOne relationships is to utilize the LifeCycleEvents http://doctrine-orm.readthedocs.org/en/latest/reference/events.html
Though it does have some caveats to be aware of. So be sure to RTM before implementing into production environments. In this case it should work fine, but I don't know your entire mapping structure.
 use Doctrine\ORM\Event\LifecycleEventArgs;

/**
 * @Entity
 * @HasLifeCycleEvents
 */
class PublicText
{
    // ...

    /**
     * @PrePersist
     * @param \Doctrine\ORM\Event\LifecycleEventArgs $event
     */
    public function onPrePersist(LifecycleEventArgs $event)
    {
        if (false === empty($this->foo)) {
           return;
        }
        $this->foo = $event->getEntityManager()->getReference('app:Foo', 1);
    }
}

Then in your controller.
$text = new \Path\To\Entity\PublicText;
$em->persist($text); //retrieve and set foo if not set in the Entity Event.
$em->flush();

Repository Method
Another option within your Entity is to just set the property's value using a Repository.
Define Repository Class in Entity
/**
 * @Entity(repositoryClass="PublicTextRepo")
 */
class PublicText
{
    // ...
}

Repository
use Doctrine\ORM\EntityRepository;

class PublicTextRepo extends EntityRepository
{
   public function create()
   {
       $text = new \Path\To\Entity\PublicText;
       $foo = $this->_em->getReference('app:Foo', 1);
       $text->setFoo($foo );
       return $text;
   }
}

Then in your controller you can then do
$text = $em->getRepository('app:PublicText')->create();
$em->persist($text);
$em->flush();

Discriminator Map
Though not always viable depending on the use case. One of the ways I go about defining a default value of an Entity is creating a DiscriminatorMap with single table inheritance. http://doctrine-orm.readthedocs.org/en/latest/reference/inheritance-mapping.html#single-table-inheritance.
This way when the object is created the default value is automatically set in the database, and locks the object as that type. The issue is that the resulting value is not an object like it is in the other methods above.
To get the object's discriminator static value, you can use constants within the objects you define.
/**
 * @Entity
 * @InheritanceType("SINGLE_TABLE")
 * @Table(name="user")
 * @DiscriminatorColumn(name="type", type="string")
 * @DiscriminatorMap({Person::TYPE="Person", Employee::TYPE="Employee"})
 */
class Person
{
    const TYPE = 'person';

    /**
     * @return string [person|employee]
     */
    public function getType()
    {
        return $this::TYPE;
    }
    // ...
}

/**
 * @Entity
 */
class Employee extends Person
{
    const TYPE = 'employee';
    // ...
}

Then all you need to do in your controller is.
$employee = new \Path\To\Entity\Employee;
$em->persist($employee); //inserts with `user.type` as `employee`
$em->flush();

echo $employee->getType(); //employee

A: With annotation you can use :  options={"default" = YourValue} on a @ORM\Column, So in yaml I think you can add
options:
    default: yourValue

I'm not sure, i gie you an idea...


text:
Q: not able to ping using hostname but not problem using IP I'm trying to ping from Ubuntu to Windows using windows name and get this error: ping: WIN-ServerName: Temporary failure in name resolution
But when I ping from Ubuntu using IP address of the windows server, I get this results.
64 bytes from 192.168.0.79: icmp_seq=1 ttl=128 time=0.344 ms
64 bytes from 192.168.0.79: icmp_seq=2 ttl=128 time=0.243 ms
64 bytes from 192.168.0.79: icmp_seq=3 ttl=128 time=0.299 ms
64 bytes from 192.168.0.79: icmp_seq=4 ttl=128 time=0.329 ms

I have already installed winbind and libnss-winbind and libpam-winbind.
Here are my conf files:
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         files systemd
group:          files systemd
shadow:         files
gshadow:        files

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4 wins
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

The resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad

The Host file
host
127.0.0.1   localhost
127.0.1.1   nat-virtual-machine

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

What am I missing? Thanks


text:
Q: How to use event listeners inside react render? In my code, I want to display the value on the screen. When that value changes it should display the changed value. But that is not happening in my code. I thought that I should add an event listener. But I can't understand how to add it. In this code, I have used web workers.
Home.js
import React, { Component, useState } from "react";
import ReactCountdownClock from "react-countdown-clock";
import worker from "./worker.js";
import WebWorker from "./workerSetup";
import "./App.css";

class Home extends Component {
  constructor(props) {
    super(props);
    this.value = 0;
    this.handleWebWorker = this.handleWebWorker.bind(this);
  }

  handleWebWorker = () => {
    let count = 10;
    this.worker = new WebWorker(worker);
    this.worker.postMessage(count);

    this.worker.addEventListener("message", (event) => {
      this.value = event.data;
      console.log("Tester 3", this.value);
    })
  }

  render() {

    return (

        <button onClick={this.handleWebWorker}>Click me</button>

{this.value}

    );
  }
}

export default Home;

worker.js

export default () => {
  self.onmessage = function (e){
      console.log("Tester 2",e.data);
      let x=e.data;

      while(x>0){
          x--;
          postMessage(x);

      }

  }

};

A: I've changed up some of your method/variable names, but this should work for what you are attempting to do:
https://codesandbox.io/s/xenodochial-neumann-xh78p?file=/src/App.js


text:
Q: String from CSV into array (Java) I am trying to put column values (CSV file) into an array.
The CSV file:

My code:
    public void readFile1()
    {
    try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {

    while ((line = br.readLine()) != null) {

        // use comma as separator
        String[] passengerDetails = line.split(cvsSplitBy);

        bookingDetails pd = new bookingDetails(passengerDetails[0], passengerDetails[1], passengerDetails[2], passengerDetails[3]);
        String x = passengerDetails[2];
        System.out.println(passengerDetails[2]); // how to put these values inside an array

    }

} catch (IOException e) {
    e.printStackTrace();
}}

The output of my code:


text:
Q: Monotonicity of the cycle index polynomial under restriction The cycle index (polynomial) of the symmetric group $\mathfrak{S}_n$ is given by the formula:
$$Z(\mathfrak{S}_n)(x_1,\dots,x_n)=\sum_{1j_1+2j_2+\cdots+nj_n=n}\prod_{k=1}^n\frac{x_k^{j_k}}{k^{j_k}j_k!}.$$
Some examples: $Z(\mathfrak{S}_1)=x_1, Z(\mathfrak{S}_2)=\frac1{2!}(x_1+x_2)$ and
$$Z(\mathfrak{S}_3)=\frac1{3!}(x_1^3+3x_1x_2+2x_3).$$
I wish to ask:

QUESTION. Assume $1\geq x_1\geq x_2\geq \cdots\geq 0$. Is this true? If so, is there a combinatorial reason for it?
$$Z(\mathfrak{S}_{n+1})(x_1,\dots,x_{n+1})\leq Z(\mathfrak{S}_n)(x_1,\dots,x_n).$$


text:
Q: Windows Server 2019 - RDP is not accepting valid user credentials I have setup a fresh Windows Server 2019 installation on an ESXI host, and the WS2019 guest will only allow the Admin user to establish an RDP connection.
I have configured 2 additional users (so that we can stop sharing admin accounts!) and added said users to the admin group as well as the remote users group.
I have successfully logged in locally (via ESXI web console) to both of the new users, to account for some potential issues when logging in via RDP for the first time. This is how I know the passwords are working correctly.
I have also confirmed the requisite group+security+firewall policies, and assume they are as needed since the admin user can RDP successfully into the server.
So, what else could I be missing? Why would RDP deny a valid UN/PW set for users in the right groups?
"Credentials did not work"

A: Assuming you haven't joined the guest win2019 server to an AD, Check you specified the username as either .\username or as servername\username in the rdclient
I believe 'Username' on its own defaults to using the client-pc or client-pc-domain as the user domain


text:
Q: Does distribution with these properties exist? Let X be a random variable with support that covers 0 (i.e. r.v. can take both positive and negative values) and positive mean: $EX>0$. Let $X^+=max(X,0)$.
Question: for which class of distributions $\frac{E(X^+)}{P(X\ge0)}$ is a decreasing function of $EX$?
Is there a single distribution with this property? (at least for some values of $EX$)
Using direct differentiation w.r.t. EX, I came up with the following question: is there a distribution for which
$\frac{E(X^+)}{P(X\ge0)}> \frac{1-F(0}{f(0)}$? (alternatively:
$\frac{E(X^+)}{(P(X\ge 0))^2}> \frac{1}{f(0)}$)


text:
Q: Can anyone color code a column with an if statement? Here is what I am trying to do.
I have a SharePoint 2010 list that I want to color code dates based on that it expires 364 days after the date entered.
Example:

If the date is older then 334 then it will turn yellow.  If the date
  is older then 364 then it will turn red.

Can anyone please help me with this?  I am an limited admin and can only do this with an if states... no SharePoint Designer.

A: You are asking for a No SharePoint Designer and SharePoint 2010 solution.
It can be done in a Calculated Column without the use of any other Webparts like documented on the blogs the other answers refer to.
The technique is documented at http://www.viewmaster365.com/#/How
The cons of this approach are also documented.
But it ain't easy; Calculated Columns are terrible to debug, so make one typo and you're on a wild goose chase.
It also requires some basic understanding of Javascript. Again see http://www.viewmaster365.com/#/How for the explanation.
Comparing with Today and highlighting row
I suggest you start with a Task list (with default Due Date column) to get comfortable with this Formula. Remember to set the datatype to Number!
This Javascript code (executed on every Item row) will color the Row based on the Due Date; I have changed the Range to include your date range. You can edit both the CSS and Range arrays to your likings.
="-4100){"
&"    var Range=[-364,-334,-7,0,7,14,21];"
&"    var CSS=['salmon','lightCoral','Pink','lightGoldenrodYellow','lightGreen','mediumSeaGreen','limeGreen'];"
&"    for (i=0;i<Range.length;i++){Color=CSS[i];if(days<Range[i]){ break;}}"
&"    TR.style.backgroundColor=Color;"
&"    var text=document.createTextNode(days+' days '+((days<0)?'past':'left'));"
&"    this.parentNode.appendChild(text,this);"
&"  }"
&"}"">"

Remember, debugging Calculated Columns is a PITA; you will be pulling your hairs out regularly.... I am completly bold after working on this technique  for the past year.
More Formulas you can built yourself step by step at: http://www.viewmaster365.com/#/Create/
Update - more compact formula and some different JavaScript techniques
I used this code in an App which also adds interactivity to Priority, Progress and Status Fields.
All using one Calculated Column Formula. But since the limitation is 4000 bytes I had to be creative with the JavaScript used to minify it as much as possible and at the same time not pollute the global scope.
This is a working (but less readable) Formula showing some other JavaScript techniques. The .innerHTML line might be interesting to change in the example above.
="-42165){"
&"for(C=0;C<R.length;C++){if(N<R[C])break}"
&"T.style.backgroundColor=['salmon','yellow','pink','lightgreen','none'][C];"
&"this.parentNode.innerHTML=N<0?-N+' days past':N+' days to go';"
&"}"
&"}"">"

*

*Removed the GIF single quotes because the Browser will add them up to the next space

*walk up the DOM instead of using fixed parentNodes (also great to get to the TABLE)

*Shorthand e5 notation replaces 00000 saving three bytes

*-42165 is SharePoints default date for a blank value

*break statement without enclosing {;} saves 3 bytes

*color array as a constant, no need for a separate variable

*this.parentNode.innerHTML will replace the HTML code of the img.
Note: not handy when you are debugging your code with F12.. as it will replace your code :-)

*can be compressed more; but that would make it completely unreadable o:-)

Update 2 - editing Formulas in the SharePoint UI
Well, as mentioned before, it sucks.
I have code on this GitHub page which does a Formula check on every keypress.
It is a distilled version of the advanced Editor I have developed for myself (but I can't make the Pro version public as it can really do bad things to SP and I do not want to be swamped with support calls)


text:
Q: Youtube video downloader in php failed - forbidden I'm from bangladesh. i have an youtube downloader php script but its not work some videos to download. when i click download button, its download videoplayback and showing me text Failed - Forbidden.
I can't download same as below videos. Most of video not downloaded.
Download website is: http://mcv12.masudtools.xyz/
Such as this video:

https://www.youtube.com/watch?v=DL5-XssXkxo

Also i have error log:

[13-Jul-2017 12:51:44 UTC] PHP Notice:  Undefined index: adaptive_fmts in /home/masudtoo/public_html/mcv12/VideoYoutubeProvider.php on line 126
  [13-Jul-2017 12:51:45 UTC] PHP Notice:  Undefined index: type in /home/masudtoo/public_html/mcv12/VideoYoutubeProvider.php on line 85
  [13-Jul-2017 12:51:45 UTC] PHP Notice:  Undefined offset: 1 in /home/masudtoo/public_html/mcv12/VideoYoutubeProvider.php on line 88

126 line is:
$adaptive_fmts = $this->fullInfo['adaptive_fmts'];

85 line is:
$type = explode(';', $item['type']);

88 line is:
$ext = $baseType[1];

full VideoYoutubeProvider.php code:
class VideoYoutubeProvider extends VideoAbstractProvider
{

public $fullInfo = null;

/**
 * Get provider name
 * @return string
 */
public function getProviderName()
{
    return "Youtube video";
}

/**
 * Checks video url for belonging to this provider
 *
 * @param string $url video url for check
 * @return boolean returning true if service available this video url
 */
static public function checkUrl($url)
{
    return !!preg_match("/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/i", $url);
}

/**
 * Return base video information
 *
 * @return BaseVideoInfo
 * @throws VideoDownloaderBaseInfoException
 */
public function getBaseInfo()
{
    $fullInfo = $this->getFullInfo();
    $baseInfo = new BaseVideoInfo();
    $baseInfo->name = $fullInfo['title'];
    $videoId = $fullInfo['video_id'];
    $preview = new VideoPreviewUrl();
    $preview->width = 1280;
    $preview->height = 720;
    $preview->name = 'maxresdefault';
    $preview->url = "https://img.youtube.com/vi/$videoId/hqdefault.jpg";
    $baseInfo->previewUrls = [$preview];
    $baseInfo->mainPreviewUrl = $preview;
    $html = $fullInfo['html'];
    if (preg_match('/
]+>(.+)<\/p>/', $html, $matches)) {
        $baseInfo->description = strip_tags(str_replace('
', "\n", $matches[1]));
    }
    return $baseInfo;
}

/**
 * Return array of download information for video
 *
 * @return VideoDownloadInfo[]
 * @throws VideoDownloaderDownloadException
 */
public function getDownloadsInfo()
{
    $fullInfo = $this->getFullInfo();
    $fmts = $fullInfo['url_encoded_fmt_stream_map'];
    $downloadsInfo = [];
    $title = $fullInfo['title'];
    foreach ($fmts AS $item) {
        $url = $item['url'] . '&title=' . urlencode($title);
        $headers = RequestHelper::getResponseHeaders($url);
        $downloadInfo = new VideoDownloadInfo();
        $downloadInfo->fileSize = (int)$headers['Content-Length'];
        $downloadInfo->url = $url;
        $downloadInfo->fileType = $headers['Content-Type'];
        $ext = explode('/', $downloadInfo->fileType);
        $ext = $ext[1];
        $downloadInfo->name = $title . '.' . $ext;
        $downloadsInfo[] = $downloadInfo;
    }
    $fmts = $fullInfo['adaptive_fmts'];
    foreach ($fmts AS $item) {
        $type = explode(';', $item['type']);
        $type = $type[0];
        $baseType = explode('/', $type);
        $ext = $baseType[1];
        $baseType = $baseType[0];
        if ($baseType === 'audio') {
            $downloadInfo = new VideoDownloadInfo();
            $downloadInfo->fileSize = (int)$item['clen'];
            $downloadInfo->name = $title . '.' . $ext;
            $url = $item['url'] . '&title=' . urlencode($title);
            $downloadInfo->url = $url;
            $downloadInfo->fileType = $type;
            $downloadsInfo[] = $downloadInfo;
            break;
        }
    }
    return $downloadsInfo;
}

private function getFullInfo()
{
    if (is_null($this->fullInfo)) {
        preg_match("/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/i", $this->url, $matches);
        $videoId = $matches[7];
        $fullInfoSource = file_get_contents("http://www.youtube.com/get_video_info?&video_id=$videoId&asv=3&el=detailpage&hl=en_US");
        $fullInfoSource = explode('&', $fullInfoSource);
        $this->fullInfo = [];
        foreach ($fullInfoSource AS $item) {
            $item = explode('=', $item);
            $this->fullInfo[$item[0]] = urldecode($item[1]);
        }
        $url_encoded_fmt_stream_map = $this->fullInfo['url_encoded_fmt_stream_map'];
        $url_encoded_fmt_stream_map = explode(',', $url_encoded_fmt_stream_map);
        $this->fullInfo['url_encoded_fmt_stream_map'] = [];
        foreach ($url_encoded_fmt_stream_map AS $downloadItem) {
            $downloadInfo = [];
            parse_str($downloadItem, $downloadInfo);
            $this->fullInfo['url_encoded_fmt_stream_map'][] = $downloadInfo;
        }

        $adaptive_fmts = $this->fullInfo['adaptive_fmts'];
        $adaptive_fmts = explode(',', $adaptive_fmts);
        $this->fullInfo['adaptive_fmts'] = [];
        foreach ($adaptive_fmts AS $item) {
            $itemInfo = [];
            parse_str($item, $itemInfo);
            $this->fullInfo['adaptive_fmts'][] = $itemInfo;
        }

        $this->fullInfo['html'] = file_get_contents("https://www.youtube.com/watch?v=$videoId");
        $this->fullInfo['video_id'] = $videoId;
    }
    return $this->fullInfo;
}
}

Please help me to solve it. thanks

A: Try this to get Youtube Video source from only youtube video id
    // Get Youtube Source
function getYoutubeVideoSource1($id = 'jNQXAC9IVRw'){
    parse_str(file_get_contents("http://youtube.com/get_video_info?video_id=".$id),$info);
    $streams = $info['url_encoded_fmt_stream_map'];
    $streams = explode(',',$streams);
    //dd($streams);
    // store value in array
    $video_stream = array();
    foreach ($streams as $stream){
        parse_str($stream,$data);
        $data = array(
            'type' => $data['type'],
            'quality' => $data['quality'],
            'url' => $data['url'],
        );
        $video_stream[] = (object) $data;
    }
    print_r($video_stream);

    //return $video_stream;
}

Here you will get an array of video steam.
   array:4 [▼
  0 => {#216 ▼
    +"type": "video/webm; codecs="vp8.0, vorbis""
    +"quality": "medium"
    +"url": "https://r3---sn-ugp5obax-q5je.googlevideo.com/videoplayback?ipbits=0&ei=qC_9Wa3HD9rcogOXgZuAAw&lmt=1380226535526270&expire=1509786632&sparams=clen%2Cdur%2Cei%2C ▶"
  }
  1 => {#211 ▶}
  2 => {#212 ▶}
  3 => {#218 ▶}
]

Now you can get video link like this
// Get Youtube Batch Download link
function youtubeBatchDownloadLink($videoId, $format){
    $video_source = getYoutubeVideoSource ($videoId);
    $url = $video_source[$format]->url;
    print_r($url);
    //return $url;
}

Hope this will help you

A: Since the latest response is out of date with the current results from youtube, I'd like to post an update. For anyone using the above code url_encoded_fmt_stream_map throws errors because YouTube changed the value of that parameter to player_response.
The code below will output a JSON object containing the YouTube video source urls.
<?php
/*
YouTubeLinkSourcer
by digitallysavvy
based on code by [egy.js](https://www.instagram.com/egy.js/);
v0.1
*/
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');

function get_error($ErrorExaction){
    $myObj = new stdClass();
    $myObj->error = true;
    $myObj->msg = $ErrorExaction;

    $myJSON = json_encode($myObj,JSON_PRETTY_PRINT);
    echo $myJSON;
    exit;
}

// pass youtube url via param
if(isset($_GET['ytURL']) && $_GET['ytURL'] != "") {
    // parse the url param to split the string
    parse_str( parse_url( $_GET['ytURL'], PHP_URL_QUERY ), $vars );
    $id = $vars['v']; // get the video id from the v query param
    $dt = file_get_contents("https://www.youtube.com/get_video_info?video_id=$id&el=embedded&ps=default&eurl=&gl=US&hl=en");

    if (strpos($dt, 'status=fail') !== false) {

        $x=explode("&",$dt);
        $t=array(); $g=array(); $h=array();

        foreach($x as $r){
            $c=explode("=",$r);
            $n=$c[0]; $v=$c[1];
            $y=urldecode($v);
            $t[$n]=$v;
        }

        $x=explode("&",$dt);
        foreach($x as $r){
            $c=explode("=",$r);
            $n=$c[0]; $v=$c[1];
            $h[$n]=urldecode($v);
        }
        $g[]=$h;
        $g[0]['error'] = true;
        echo json_encode($g,JSON_PRETTY_PRINT);

    } else {
        // decode the response
        $x=explode("&",$dt);
        $t=array(); $g=array(); $h=array();

        foreach($x as $r){
            $c=explode("=",$r);
            $n=$c[0]; $v=$c[1];
            $y=urldecode($v);
            $t[$n]=$v;
        }
        // get the "player_response" field and parse it as JSON
        $player_response = json_decode(urldecode($t['player_response']), true);

        // if response is missing streaming data - show an error and exit
        if(!array_key_exists("streamingData",$player_response)){
          get_error('ops! this video has something wrong! :( ');
        }
        // get reference to the streaming data object
        $streams = $player_response["streamingData"];
        // loop through the list and print out all formats
        echo "{ \"formats\": [";
        foreach ($streams["formats"] as $formats) {
          echo "{ \"". $formats["qualityLabel"] ."\": \"". $formats["url"] ."\" },";
        }
        echo "], \"adaptiveFormats\": [";
        foreach ($streams["adaptiveFormats"] as $adaptiveFormats) {
            if(array_key_exists("qualityLabel",$adaptiveFormats)){
                echo "{ \"". $adaptiveFormats["qualityLabel"] ."\": \"". $adaptiveFormats["url"] ."\" },";
            } else {
                break; // end the loop
            }
        }
        echo "]}";
    }
} else {
     get_error("Ops, there is no youtube link!");
}

call this script using:
/YouTubeSourcer.php?ytURL=https://www.youtube.com/watch?v=nMAzchVWTis


text:
Q: Subclassing an NSScrollView's DocumentView How can one subclass an NSScrollView's DocumentView in order to do some custom drawing? I need to do some work with NSShadow inside of the scroll view.

A: The document view is just a normal view (subclass of NSView,) so all you have to do is to create a view, either programmatically or in Interface Builder, and set the scroll view's documentView property to the new view.
You can set the property in a suitable awakeFromNib method, for instance.


text:
Q: Como obtener datos de un formulario con JSF? Tengo el siguiente formulario y quiero recuperar los datos que se envien

<f:view>
    <h:form id="form_pruebas" class="form-horizontal">

                <h:outputLabel for="intentosAp" value="Intentos de aplicación" style="display: inline-block width: 70px"/>

                <h:inputText id="intentosAp" value="#{configuraciones.datosEntrada.intentosAplicacion}" style="width: 60px;" required="true" maxlength="2"/>

                <h:outputLabel for="intentosExi" value="Intentos exitosos:" style="display: inline-block width: 25px"/>

                <h:inputText id="intentosExi" value="#{configuraciones.datosEntrada.intentosExitosos}" style="width: 60px;" required="true" maxlength="3"/>

                <h:outputLabel for="intentosFall" value="Intentos fallidos" style="display: inline-block width: 50px"/>

                <h:inputText id="intentosFall" style="width: 60px;" value="#{configuraciones.datosEntrada.intentosFallidos}" required="true" maxlength="3"/>

                <h:commandButton value="Enviar" type="submit" action="#{datosEntrada.obtenerParametros}"/>

    </h:form>
</f:view>

Tengo la clase DatosEntrada donde estan mapeados los campos

public class DatosEntrada{

    @Getter @Setter private String intentosAplicacion;
    @Getter @Setter private String intentosExitosos;
    @Getter @Setter private String  intentosFallidos;

}

y la clase Configuraciones donde quiero que vaya toda la logica, no se como recuperar los datos que envian, es la primera vez que trabajo con JSF

@ManagedBean
@ViewScoped
public class Configuraciones{

    private DatosEntrada datosEntrada;

    @PostConstruct
    public void initView(){

    }

    public void obtenerParametros(){

    }
}

A: En la clase Configuraciones deberías agregar un setter para datosEntrada. En el método obtenerParametros ya podrías usar datosEntrada.
@ManagedBean
@ViewScoped
public class Configuraciones{

  private DatosEntrada datosEntrada;

  public void setDatosEntrada(DatosEntrada datosEntrada) {
   this.datosEntrada = datosEntrada;
  }

  @PostConstruct
  public void initView(){
  }

  public void obtenerParametros() {
   // Usar los datos, ejemplo:
   datosEntrada.getIntentosExitosos();
  }
}

Además, en el formulario deberías usar el bean configuraciones:
<h:commandButton value="Enviar" type="submit" action="#{configuraciones.obtenerParametros}"/>


text:
Q: Checking for only one group of columns values to be present in dataframe I had asked a similar scenario in below question ,and thought based on the answer I could figure out the solution, but I am lost .
Checking for only column value to be present in dataframe
Problem statement is as below-
I need to group column validation values, and find such that only one group of columns has values.
I have three groups :-
all_non_tiered_rates_blank = (df[['age_0', 'age_0_tobacco', 'age_1',
                                          'age_1_tobacco', 'age_2', 'age_2_tobacco', 'age_3', 'age_3_tobacco', 'age_4',
                                          'age_4_tobacco',
                                          'age_5', 'age_5_tobacco', 'age_6', 'age_6_tobacco', 'age_7', 'age_7_tobacco',
                                          'age_8',
                                          'age_8_tobacco',
                                          'age_9', 'age_9_tobacco', 'age_10', 'age_10_tobacco', 'age_11',
                                          'age_11_tobacco', 'age_12',
                                          'age_12_tobacco',
                                          'age_13', 'age_13_tobacco', 'age_14', 'age_14_tobacco', 'age_15',
                                          'age_15_tobacco',
                                          'age_16', 'age_16_tobacco',
                                          'age_17', 'age_17_tobacco', 'age_18', 'age_18_tobacco', 'age_19',
                                          'age_19_tobacco',
                                          'age_20', 'age_20_tobacco',
                                          'age_21', 'age_21_tobacco', 'age_22', 'age_22_tobacco', 'age_23',
                                          'age_23_tobacco',
                                          'age_24', 'age_24_tobacco',
                                          'age_25', 'age_25_tobacco', 'age_26', 'age_26_tobacco', 'age_27',
                                          'age_27_tobacco',
                                          'age_28', 'age_28_tobacco',
                                          'age_29', 'age_29_tobacco', 'age_30', 'age_30_tobacco', 'age_31',
                                          'age_31_tobacco',
                                          'age_32', 'age_32_tobacco',
                                          'age_33', 'age_33_tobacco', 'age_34', 'age_34_tobacco', 'age_35',
                                          'age_35_tobacco',
                                          'age_36', 'age_36_tobacco',
                                          'age_37', 'age_37_tobacco', 'age_38', 'age_38_tobacco', 'age_39',
                                          'age_39_tobacco',
                                          'age_40', 'age_40_tobacco',
                                          'age_41', 'age_41_tobacco', 'age_42', 'age_42_tobacco', 'age_43',
                                          'age_43_tobacco',
                                          'age_44', 'age_44_tobacco',
                                          'age_45', 'age_45_tobacco', 'age_46', 'age_46_tobacco', 'age_47',
                                          'age_47_tobacco',
                                          'age_48', 'age_48_tobacco',
                                          'age_49', 'age_49_tobacco', 'age_50', 'age_50_tobacco', 'age_51',
                                          'age_51_tobacco',
                                          'age_52', 'age_52_tobacco',
                                          'age_53', 'age_53_tobacco', 'age_54', 'age_54_tobacco', 'age_55',
                                          'age_55_tobacco',
                                          'age_56', 'age_56_tobacco',
                                          'age_57', 'age_57_tobacco', 'age_58', 'age_58_tobacco', 'age_59',
                                          'age_59_tobacco',
                                          'age_60', 'age_60_tobacco',
                                          'age_61', 'age_61_tobacco', 'age_62', 'age_62_tobacco', 'age_63',
                                          'age_63_tobacco',
                                          'age_64', 'age_64_tobacco']].notna().all(axis=1))

Second group:-
all_tiered_rates_blank = (df[['single', 'single_and_spouse', 'single_and_children', 'family', 'child_only']].notna().all(axis=1))

Third group :-
fixed_price_check = ((df['fixed_price'].notna()) & (df['fixed_price'] >= 0))

Only one out of these 3 column groups should have a value and return True. If more than one group returns True  , it should be returning me False.
which means : - either one of all_non_tiered_rates_blank , all_tiered_rates_blank and fixed_price_check can be True else it is a False.
How can I handle this.
Sample data-:
 hios_plan_identifier wellthie_issuer_identifier  plan_year group_or_individual_plan_type data_sourced_from effective_start_date effective_end_date   age_0  age_0_tobacco   age_1  age_1_tobacco   age_2  age_2_tobacco   age_3  age_3_tobacco   age_4  age_4_tobacco   age_5  age_5_tobacco   age_6  age_6_tobacco   age_7  age_7_tobacco   age_8  age_8_tobacco   age_9  age_9_tobacco  age_10  age_10_tobacco  age_11  age_11_tobacco  age_12  age_12_tobacco  age_13  age_13_tobacco  age_14  age_14_tobacco  age_15  age_15_tobacco  age_16  age_16_tobacco  age_17  age_17_tobacco  age_18  age_18_tobacco  age_19  age_19_tobacco  age_20  age_20_tobacco  age_21  age_21_tobacco  age_22  age_22_tobacco  age_23  age_23_tobacco  age_24  age_24_tobacco  age_25  age_25_tobacco  age_26  age_26_tobacco  age_27  age_27_tobacco  age_28  age_28_tobacco  age_29  age_29_tobacco  age_30  age_30_tobacco  age_31  age_31_tobacco  age_32  age_32_tobacco  age_33  age_33_tobacco  age_34  age_34_tobacco  age_35  age_35_tobacco  age_36  age_36_tobacco  age_37  age_37_tobacco  age_38  age_38_tobacco  age_39  age_39_tobacco  age_40  age_40_tobacco  age_41  age_41_tobacco  age_42  age_42_tobacco  age_43  age_43_tobacco  age_44  age_44_tobacco  age_45  age_45_tobacco  age_46  age_46_tobacco  age_47  age_47_tobacco   age_48  age_48_tobacco   age_49  age_49_tobacco   age_50  age_50_tobacco   age_51  age_51_tobacco   age_52  age_52_tobacco   age_53  age_53_tobacco   age_54  age_54_tobacco   age_55  age_55_tobacco   age_56  age_56_tobacco   age_57  age_57_tobacco   age_58  age_58_tobacco   age_59  age_59_tobacco   age_60  age_60_tobacco   age_61  age_61_tobacco   age_62  age_62_tobacco   age_63  age_63_tobacco   age_64  age_64_tobacco rating_zone_code county_fips  fixed_price  prices_indexed_by_quantity_of_children  single  single_and_spouse  single_and_children  family  child_only  issuer_id  state_id  medical_plan_id  county_id  rating_zone_id zip_code_county_id
0      99806CAAVMQ-TMP                   UHC99806       2074                         Group               uhc           2018-10-01         2018-12-31  396.23         396.23  396.23         396.23  396.23         396.23  396.23         396.23  396.23         396.23  396.23         396.23  396.23         396.23  396.23         396.23  396.23         396.23  396.23         396.23  396.23          396.23  396.23          396.23  396.23          396.23  396.23          396.23  396.23          396.23  431.45          431.45  444.92          444.92  458.39          458.39  472.89          472.89  487.39          487.39  502.41          502.41  517.95          517.95  517.95          517.95  517.95          517.95  517.95          517.95  520.02          520.02  530.38          530.38  542.81          542.81  563.01          563.01  579.59          579.59  587.87          587.87  600.30          600.30  612.73          612.73  620.50          620.50  628.79          628.79  632.93          632.93  637.08          637.08  641.22          641.22  645.37          645.37  653.65          653.65  661.94          661.94  674.37          674.37  686.28          686.28  702.86          702.86  723.58          723.58  747.92          747.92  776.93          776.93  809.56          809.56   846.85          846.85   883.62          883.62   925.06          925.06   965.98          965.98  1011.04         1011.04  1056.62         1056.62  1105.82         1105.82  1155.03         1155.03  1208.38         1208.38  1262.24         1262.24  1319.74         1319.74  1348.22         1348.22  1405.72         1405.72  1455.44         1455.44  1488.07         1488.07  1528.99         1528.99  1553.85         1553.85             GA01      06-013          NaN                                     NaN     NaN                NaN                  NaN     NaN         NaN        484        17          1601286       6013            1135               None
1      99806CAAVMQ-TMP                   UHC99806       2074                         Group               uhc           2018-10-01         2018-12-31  470.93         470.93  470.93         470.93  470.93         470.93  470.93         470.93  470.93         470.93  470.93         470.93  470.93         470.93  470.93         470.93  470.93         470.93  470.93         470.93  470.93          470.93  470.93          470.93  470.93          470.93  470.93          470.93  470.93          470.93  512.79          512.79  528.79          528.79  544.80          544.80  562.03          562.03  579.27          579.27  597.12          597.12  615.59          615.59  615.59          615.59  615.59          615.59  615.59          615.59  618.05          618.05  630.36          630.36  645.14          645.14  669.15          669.15  688.85          688.85  698.69          698.69  713.47          713.47  728.24          728.24  737.48          737.48  747.33          747.33  752.25          752.25  757.18          757.18  762.10          762.10  767.03          767.03  776.87          776.87  786.72          786.72  801.50          801.50  815.66          815.66  835.36          835.36  859.98          859.98  888.91          888.91  923.39          923.39  962.17          962.17  1006.49         1006.49  1050.20         1050.20  1099.44         1099.44  1148.08         1148.08  1201.63         1201.63  1255.80         1255.80  1314.28         1314.28  1372.77         1372.77  1436.17         1436.17  1500.19         1500.19  1568.52         1568.52  1602.38         1602.38  1670.71         1670.71  1729.81         1729.81  1768.59         1768.59  1817.22         1817.22  1846.77         1846.77             GA01      06-013          NaN                                     NaN     1.0                1.0                  1.0     1.0         1.0        484        17          1601286       6013            1135               None
2      99806CAAVMQ-TMP                   UHC99806       2074                         Group               uhc           2018-10-01         2018-12-31  284.01         284.01  284.01         284.01  284.01         284.01  284.01         284.01  284.01         284.01  284.01         284.01  284.01         284.01  284.01         284.01  284.01         284.01  284.01         284.01  284.01          284.01  284.01          284.01  284.01          284.01  284.01          284.01  284.01          284.01  309.25          309.25  318.90          318.90  328.56          328.56  338.95          338.95  349.35          349.35  360.11          360.11  371.25          371.25  371.25          371.25  371.25          371.25  371.25          371.25  372.74          372.74  380.16          380.16  389.07          389.07  403.55          403.55  415.43          415.43  421.37          421.37  430.28          430.28  439.19          439.19  444.76          444.76  450.70          450.70  453.67          453.67  456.64          456.64  459.61          459.61  462.58          462.58  468.52          468.52  474.46          474.46  483.37          483.37  491.91          491.91  503.79          503.79  518.64          518.64  536.09          536.09  556.88          556.88  580.26          580.26   606.99          606.99   633.35          633.35   663.05          663.05   692.38          692.38   724.68          724.68   757.35          757.35   792.62          792.62   827.89          827.89   866.13          866.13   904.74          904.74   945.95          945.95   966.36          966.36  1007.57         1007.57  1043.21         1043.21  1066.60         1066.60  1095.93         1095.93  1113.75         1113.75             GA01      06-013          NaN                                     1.0     NaN                NaN                  NaN     NaN         NaN        484        17          1601286       6013            1135               None
3      99806CAAVMQ-TMP                   UHC99806       2074                         Group               uhc           2018-10-01         2018-12-31     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN             GA01      06-013          1.0                                     NaN     NaN                NaN                  NaN     NaN         NaN        484        17          1601286       6013            1135               None
4      99806CAAVMQ-TMP                   UHC99806       2074                         Group               uhc           2018-10-01         2018-12-31  388.31         388.31  388.31         388.31  388.31         388.31  388.31         388.31  388.31         388.31  388.31         388.31  388.31         388.31  388.31         388.31  388.31         388.31  388.31         388.31  388.31          388.31  388.31          388.31  388.31          388.31  388.31          388.31  388.31          388.31  422.82          422.82  436.02          436.02  449.22          449.22  463.43          463.43  477.64          477.64  492.36          492.36  507.59          507.59  507.59          507.59  507.59          507.59  507.59          507.59  509.62          509.62  519.77          519.77  531.95          531.95  551.75          551.75  567.99          567.99  576.11          576.11  588.30          588.30  600.48          600.48  608.09          608.09  616.21          616.21  620.27          620.27  624.34          624.34  628.40          628.40  632.46          632.46  640.58          640.58  648.70          648.70  660.88          660.88  672.56          672.56  688.80          688.80  709.10          709.10  732.96          732.96  761.39          761.39  793.36          793.36   829.91          829.91   865.95          865.95   906.56          906.56   946.66          946.66   990.82          990.82  1035.48         1035.48  1083.70         1083.70  1131.93         1131.93  1184.21         1184.21  1237.00         1237.00  1293.34         1293.34  1321.26         1321.26  1377.60         1377.60  1426.33         1426.33  1458.31         1458.31  1498.41         1498.41  1522.77         1522.77             GA01      06-013          NaN                                     NaN     NaN                NaN                  NaN     NaN         NaN        484        17          1601286       6013            1135               None
5      99806CAAVMQ-TMP                   UHC99806       2074                         Group               uhc           2018-10-01         2018-12-31  259.88         259.88  259.88         259.88  259.88         259.88  259.88         259.88  259.88         259.88  259.88         259.88  259.88         259.88  259.88         259.88  259.88         259.88  259.88         259.88  259.88          259.88  259.88          259.88  259.88          259.88  259.88          259.88  259.88          259.88  282.98          282.98  291.81          291.81  300.64          300.64  310.16          310.16  319.67          319.67  329.52          329.52  339.71          339.71  339.71          339.71  339.71          339.71  339.71          339.71  341.07          341.07  347.86          347.86  356.02          356.02  369.26          369.26  380.14          380.14  385.57          385.57  393.72          393.72  401.88          401.88  406.97          406.97  412.41          412.41  415.13          415.13  417.84          417.84  420.56          420.56  423.28          423.28  428.71          428.71  434.15          434.15  442.30          442.30  450.12          450.12  460.99          460.99  474.57          474.57  490.54          490.54  509.57          509.57  530.97          530.97   555.43          555.43   579.55          579.55   606.72          606.72   633.56          633.56   663.11          663.11   693.01          693.01   725.28          725.28   757.55          757.55   792.54          792.54   827.87          827.87   865.58          865.58   884.27          884.27   921.97          921.97   954.59          954.59   975.99          975.99  1002.82         1002.82  1019.13         1019.13             GA01      06-013          NaN                                     NaN     NaN                NaN                  NaN     NaN         NaN        484        17          1601286       6013            1135               None
6      99806CAAVMQ-TMP                   UHC99806       2074                         Group               uhc           2018-10-01         2018-12-31  247.78         247.78  247.78         247.78  247.78         247.78  247.78         247.78  247.78         247.78  247.78         247.78  247.78         247.78  247.78         247.78  247.78         247.78  247.78         247.78  247.78          247.78  247.78          247.78  247.78          247.78  247.78          247.78  247.78          247.78  269.80          269.80  278.22          278.22  286.64          286.64  295.71          295.71  304.78          304.78  314.17          314.17  323.89          323.89  323.89          323.89  323.89          323.89  323.89          323.89  325.19          325.19  331.66          331.66  339.44          339.44  352.07          352.07  362.43          362.43  367.62          367.62  375.39          375.39  383.16          383.16  388.02          388.02  393.20          393.20  395.79          395.79  398.38          398.38  400.98          400.98  403.57          403.57  408.75          408.75  413.93          413.93  421.70          421.70  429.15          429.15  439.52          439.52  452.47          452.47  467.70          467.70  485.84          485.84  506.24          506.24   529.56          529.56   552.56          552.56   578.47          578.47   604.05          604.05   632.23          632.23   660.74          660.74   691.51          691.51   722.27          722.27   755.64          755.64   789.32          789.32   825.27          825.27   843.09          843.09   879.04          879.04   910.13          910.13   930.54          930.54   956.12          956.12   971.67          971.67             GA01      06-013          NaN                                     NaN     NaN                NaN                  NaN     NaN         NaN        484        17          1601286       6013            1135               None
7      99806CAAVMQ-TMP                   UHC99806       2074                         Group               uhc           2018-10-01         2018-12-31     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN            NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN     NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN      NaN             NaN             GA01      06-013          NaN                                     NaN     NaN                NaN                  NaN     NaN         NaN        484        17          1601286       6013            1135               None
8      99806CAAVMQ-TMP                   UHC99806       2074                         Group               uhc           2018-10-01         2018-12-31  236.12         236.12  236.12         236.12  236.12         236.12  236.12         236.12  236.12         236.12  236.12         236.12  236.12         236.12  236.12         236.12  236.12         236.12  236.12         236.12  236.12          236.12  236.12          236.12  236.12          236.12  236.12          236.12  236.12          236.12  257.11          257.11  265.13          265.13  273.16          273.16  281.80          281.80  290.44          290.44  299.39          299.39  308.65          308.65  308.65          308.65  308.65          308.65  308.65          308.65  309.88          309.88  316.06          316.06  323.47          323.47  335.50          335.50  345.38          345.38  350.32          350.32  357.73          357.73  365.13          365.13  369.76          369.76  374.70          374.70  377.17          377.17  379.64          379.64  382.11          382.11  384.58          384.58  389.52          389.52  394.45          394.45  401.86          401.86  408.96          408.96  418.84          418.84  431.18          431.18  445.69          445.69  462.98          462.98  482.42          482.42   504.64          504.64   526.56          526.56   551.25          551.25   575.63          575.63   602.48          602.48   629.65          629.65   658.97          658.97   688.29          688.29   720.08          720.08   752.18          752.18   786.44          786.44   803.42          803.42   837.68          837.68   867.31          867.31   886.75          886.75   911.13          911.13   925.95          925.95             GA01      06-013          1.0                                     NaN     NaN                NaN                  NaN     NaN         NaN        484        17          1601286       6013            1135               None

A: all_non_tiered_rates_blank = df[['age_0', 'age_0_tobacco', 'age_1', 'age_1_tobacco', ..... 'age_64', 'age_64_tobacco']]
all_non_tiered_rates_blank['count_notnull']=all_non_tiered_rates_blank.count(axis=1)
all_non_tiered_rates_blank['value_all_non_tiered'] = np.where(all_non_tiered_rates_blank['count_notnull']==(len(all_non_tiered_rates_blank.columns)-1),(len(all_non_tiered_rates_blank.columns)-1),np.NaN)

all_tiered_rates_blank = df[['single', 'single_and_spouse', 'single_and_children', 'family', 'child_only']]
all_tiered_rates_blank['count_notnull']=all_tiered_rates_blank.count(axis=1)
all_tiered_rates_blank['value_all_tiered'] = np.where(all_tiered_rates_blank['count_notnull']==(len(all_tiered_rates_blank.columns)-1),(len(all_tiered_rates_blank.columns)-1),np.NaN)

fixed_price_check = df['fixed_price']
prices_indexed_by_quantity_of_children_check = df['prices_indexed_by_quantity_of_children']

#Concatenate all the 4 DataFrames into one DataFrame df_final
df_final = pd.concat([all_non_tiered_rates_blank[['value_all_non_tiered']], all_tiered_rates_blank[['value_all_tiered']], fixed_price_check, prices_indexed_by_quantity_of_children_check], axis=1)

#Will give a count of non-NULLs.
df_final['count_notnull']=df_final.count(axis=1)

#df_bool is your boolean dataframe. It will be True if only 1 of the 4 DataFrames has a value, otherwise False
df_bool = df_final['count_notnull'].map(lambda x:x==1)


text:
Q: Actual Android device not found adb devices I have written a simple app and would like to try it out on my Samsung Galaxy i9000. After some trouble finding the proper USB-driver i finally have the device show up in the Device Manager under Android Phone/Android Composite ADB Interface. I am running Vista SP1 and my phone is a Samsung Galaxy i9000 with 2.1-update1.
The problem I'm having is when running "adb servies" in cmd the device list is empty, and the device is not showing up in Eclipse.

*

*The phone is in developer (debug) mode

*I have added android:debuggable="true" for the app in the manifest-file

*I have tried several times to kill and restart adb in the cmd-prompt without result

*I have rebooted both phone and computer several times

*Used usddeview to completely remove previous drives before installing the proper ones

I ran the following in the commandprompt:

*

*adb kill-server

*set ADB_TRACE=all

*adb nodaemon server

Then i ran Eclipse and got this (never mind the wierd sdk-path :P):
C:\Program Files\JCreatorV4LE\Android\android-sdk-windows\tools>adb kill-server

C:\Program Files\JCreatorV4LE\Android\android-sdk-windows\tools>set ADB_TRACE=al
l

C:\Program Files\JCreatorV4LE\Android\android-sdk-windows\tools>adb nodaemon ser
ver
bit_buffer_init 002A2780
bit_buffer_init 002A37C0
adb_socketpair: returns (100, 101)
fdevent_update: add 1 to 101
event_looper_hook: call hook for 101 (new=0, old=1)
transport: local client init
Created device thread
transport: client_socket_thread() starting
socket_loopback_server: port 5037 type tcp => fd 102
fdevent_update: add 1 to 102
event_looper_hook: call hook for 102 (new=0, old=1)
_event_socketpair_start: hook 101(pair:100) for 65 wanted=1
_event_socket_start: hooking 102(lo-server:5037) for 1 (flags 41)
adb_win32: waiting for 2 events
socket_loopback_client: could not connect to tcp:5555
socket_loopback_client: could not connect to tcp:5557
socket_loopback_client: could not connect to tcp:5559
socket_loopback_client: could not connect to tcp:5561
socket_loopback_client: could not connect to tcp:5563
socket_loopback_client: could not connect to tcp:5565
socket_loopback_client: could not connect to tcp:5567
socket_loopback_client: could not connect to tcp:5569
socket_loopback_client: could not connect to tcp:5571
socket_loopback_client: could not connect to tcp:5573
socket_loopback_client: could not connect to tcp:5575
socket_loopback_client: could not connect to tcp:5577
socket_loopback_client: could not connect to tcp:5579
socket_loopback_client: could not connect to tcp:5581
socket_loopback_client: could not connect to tcp:5583
socket_loopback_client: could not connect to tcp:5585
adb_win32: got one (index 1)
_event_socket_check 102(lo-server:5037) returns 1
adb_win32: signaling 102(lo-server:5037) for 1
adb_socket_accept on fd 102 returns fd 119
LS(1): created (fd=119)
Connecting to smart socket
Creating smart socket
SS(0): created 00407E60
fdevent_update: add 1 to 119
event_looper_hook: call hook for 119 (new=0, old=1)
SS(0): enqueue 16
SS(0): len is 12
SS(0): 'host:version'
writex: 119 0022CCA8 12: 4f4b41593030303430303161  OKAY0004001a
writex: 119 ok
SS(0): handled host service 'version'
SS(0): closed
adb_close: 119(accept:102(lo-server:5037))
LS(1): closed
_event_socketpair_start: hook 101(pair:100) for 65 wanted=1
adb_win32: waiting for 2 events
adb_win32: got one (index 1)
_event_socket_check 102(lo-server:5037) returns 0
adb_win32: waiting for 2 events
adb_win32: got one (index 1)
_event_socket_check 102(lo-server:5037) returns 1
adb_win32: signaling 102(lo-server:5037) for 1
adb_socket_accept on fd 102 returns fd 120
LS(2): created (fd=120)
Connecting to smart socket
Creating smart socket
SS(0): created 00407E60
fdevent_update: add 1 to 120
event_looper_hook: call hook for 120 (new=0, old=1)
_event_socketpair_start: hook 101(pair:100) for 65 wanted=1
_event_socket_start: hooking 120(accept:102(lo-server:5037)) for 1 (flags 41)
adb_win32: waiting for 3 events
adb_win32: got one (index 1)
_event_socket_check 102(lo-server:5037) returns 0
adb_win32: waiting for 3 events
adb_win32: got one (index 2)
_event_socket_check 120(accept:102(lo-server:5037)) returns 1
adb_win32: signaling 120(accept:102(lo-server:5037)) for 1
SS(0): enqueue 22
SS(0): len is 18
SS(0): 'host:track-devices'
device tracker 002A6D98 created
LS(0) bound to 'track-devices'
SS(0): okay
SS(0): closed
LS(2): enqueue 4
_event_socketpair_start: hook 101(pair:100) for 65 wanted=1
adb_win32: waiting for 3 events

This make any sense? I've spent hours trying to figure this out so any suggestion at all is appreciated.
/Johan

A: I had a same kind of device not detecting issue when i have updated the android sdk tools. After searching internet and referring other resources, i found that the sdk update process had replaced the adb_usb.ini file which is located in the .android folder on the user profile folder. Then i have added the usb driver keys for my device ( which came with the driver installer folder ) to that  adb_usb.ini file. Then i have restarted the adb server with the following commands.
adb kill-server
adb start-server
Then the device is detected and i have solved my issue. I hope this will fix your issue..


text:
Q: Disqus api: count the number of comments on each page of my blog I would like to create a list with the number of comments on each page of my blog.
Is possible with the Disqus API?
There is a call that counts comments starting from the URL of the page?
Thanks.

A: The Disqus API has an endpoint called threads/list which returns the details for a thread, including the number of comments. You can learn about this method here: http://disqus.com/api/docs/threads/list/
You can see a code example illustrating how to use the endpoint here: https://github.com/disqus/DISQUS-API-Recipes/blob/master/php/get-thread-details.php