Q:

Java built-in Observable push notifications

UPDATE Added the full code to make it easier to understand.
I am trying to understand how to implement push vs pull notifications using Java built-in Observer.
the Observable class has 2 methods notifyObservers() and  notifyObservers(Object arg)
according to the docs:
Each observer has its update method called with two arguments: this observable object and the arg argument.
here is my Observer class
public class CurrentConditionsDisplay implements Observer, DisplayElement {
    private float temperature;
    private float humidity;
    private Observable observable;

    public CurrentConditionsDisplay(Observable observable) {
        this.observable = observable;
        observable.addObserver(this);
    }

    @Override
    public void display() {
        System.out.println("Current conditions: " + temperature + "F degrees and "
                + humidity + "% humidity");
    }

    @Override
    public void update(Observable o, Object arg) {
        /*
        if (o instanceof WeatherData) {
            WeatherData weatherData = (WeatherData) o;
            this.temperature = weatherData.getTemperature();
            this.humidity = weatherData.getHumidity();
        }*/

        if (arg instanceof WeatherData) {
        WeatherData weatherData = (WeatherData) arg;
        this.temperature = weatherData.getTemperature();
        this.humidity = weatherData.getHumidity();
        }

        display();
    }

and  in my observable class
public class WeatherData extends Observable {
    private float temperature;
    private float humidity;
    private float pressure;

    private void measurementsChanged() {
        setChanged();
        //notifyObservers();
        notifyObservers(this);
    }

    public void setMeasurements(float temperature, float humidity, float pressure) {
        this.temperature = temperature;
        this.humidity = humidity;
        this.pressure = pressure;
        measurementsChanged();
    }

    public float getTemperature() {
        return temperature;
    }

    public float getHumidity() {
        return humidity;
    }

    public float getPressure() {
        return pressure;
    }

I've tried both methods, and both objects can be cast down to WeatherData(the Observer) and then get the data from them.
using both methods seem like push notification-type for me, so what is the difference?
and how can I implement pull notification-type using it?

A:

From the documentation of notifyObservers():

Each observer has its update method called with two arguments: this observable object and null. In other words, this method is equivalent to: notifyObservers(null)

That means that you should never call notifyObservers(this)—it’s redundant.  Normally, the argument would be additional data about the change event.  This is analogous to more modern event listener classes (Observable and Observer are now deprecated) whose events contain data in addition to the event source.  For example, if you add an ActionListener to a button, pressing the button at runtime causes the ActionListener’s actionPerformed method to be called with an event that contains data such as the time when the action occurred.
A pull notification isn’t really a notification at all.  Pulling means you don’t wait to be told that something changed;  you ask whether anything has happened.
An example of this would be keeping a boolean field in your class that indicates whether any changes have occurred:
public class WeatherData {
    private boolean changed;

    // (other fields)

    public boolean checkForChanges() {
        boolean hasChanged = changed;
        // Now that someone has checked, reset the change flag
        changed = false;
        return hasChanged;
    }

    private void measurementsChanged() {
        changed = true;
        // Nothing else to do here.  Caller must "pull" (request) the
        // new state, by calling checkForChanges.
    }

As for how to do the pulling, just keep a reference to a WeatherData object in your CurrentConditionsDisplay class, and check whether it has changed:
public class CurrentConditionsDisplay implements DisplayElement {

    private final WeatherData weatherData;

    public CurrentConditionsDisplay(WeatherData observable) {
        this.weatherData = observable;
    }

    @Override
    public void display() {
        // This is the pull.
        if (weatherData.checkForChanges()) {
            this.temperature = weatherData.getTemperature();
            this.humidity = weatherData.getHumidity();
        }

        System.out.println("Current conditions: " + temperature + "F degrees and "
                + humidity + "% humidity");
    }


Q:

is this XOR cryptography secure?

can somebody explain this algorithm is secure or not? is there attack to break that? this algorithm uses common XOR cryptography but has some differences:
M(1) = key XOR Message(1)
M(2) = h(key) XOR Message(2)
M(3) = h(h(key)) XOR Message(3)
and so on
Notes:

M(i) is ciphered text
Message(i) is message that we are going to cipher it
key and Message(i) have the same lengths**
attacker just has the ciphered text and knows key making scheme(continues hashing) and XOR cryptography
hash algorithm is SHA-512

A:

If the attacker ever gets to know a plaintext-ciphertext pair, he can calculate the corresponding key.  And from that he can calculate all later keys. i.e. it's trivially vulnerable to a known plain text attack.
Note that when I say that the attacker guesses the message, I don't mean that he's sure that his guess is correct. He might make a few trillion guesses, and if one of them is correct, your whole scheme is broken.
And of course you must not ever reuse a key.

A more secure (but twice as slow) algorithm would be:
Key(i+1) = h("A"+key)
M(i) = h("B"+key) XOR Message(i)

Or a construction similar to CTR mode:
M(i) =  h(i+key) XOR Message(i)

But I still wouldn't use either.

But there is no reason to use such a homebrew algorithm. There are plenty of existing algorithms that work well. For example if you like a stream cipher design, you could use AES in CTR mode.

A:

Studying encryption algorithms is great fun.  Just remember you are playing, not producing anything serious.  As long as you are only keeping things like your personal diary (or maybe even passwords) encrypted and you keep the data secure, you will probably be fine.  This kind of counts as security through obscurity.  I would not recommend encrypting mass quantities of data that you REALLY need to keep private or anything that is available and of interest to the outside world, however.

In this case, if your message is shorter than the key size and hash block size and the key is single use and random, you are effectively using a one-use pad so everything in swell.   Provided your random number key generation is perfect, you have an unbreakable encryption mechanism.  As you add each block to the message, you are effectively calculating new keys using SHA-512, not adding any particular value.  If an attacker can assume the message consists of printable text and if the length of the message is long or the key is used repeatedly, it should would not be too difficult to find the original key.
It would be more effective to calculate:
M(1)=h(N + key) XOR Message(1)
M(2)=h(M(1)) XOR Message(2)
M(3)=h(M(2)) XOR Message(3)

(where N is the number of times the key has been used which is passed in clear text.)
That way the bad guys can’t calculate your key sequence ahead of time and decrypt your message before you can.  Also by using a salted hash of the key, the attacker won’t be able to predict the key sequence that will be used next time.

I read somewhere:

The first rule of cryptography is “Cryptography should be left to experts.”
The second rule is “You are not an expert.”

There is a reason people get PhDs in things like Computer Science and Mathematics.  There is a lot to learn and discover.  Something like this looks fine to me but no doubt it has a gaping hole that an attacker could drive a truck through.
Have fun and don't let grouchy people like me get you down.
/Bob Bryan


Q:

Troubleshooting IIS web package deployment with SQL database

I have a .NET MVC project that gets its data from a SQL database.
When I run the project in debug mode on my local machine, it runs without error; however, after I deploy the project to my IIS server (version 6 I believe) using Microsoft's Publish Wizard (create a .zip, move that .zip to the wwwRoot folder the website is pointed at), I encounter an issue: I access the website's main page via URL address, but when I enter the login ID, it produces a built-in error message "Invalid user ID".
The only time this error ever occurs when a valid ID is entered is if the database cannot be reached to check login credentials. So, using SQL Profiler, I tried to see if a query was made to the database - it appears that the answer is "no".
I have verified that the connection strings are configured correctly in the IIS environment, and can safely assume that there are no code-related errors with regards to this issue.
The question:  What other troubleshooting methods are available for IIS and SQL interactions to see what the root of this error is, or what suggestions might you have to try and eliminate the problem

A:

Add the user to the database logins and grant this user access to the database. Connection string in your code should have its credentials. Reason why it works on your machine is likely because you are sysadmin or something on the server. Look up a way to enter credentials in your connection string's parameters.
https://www.youtube.com/watch?v=Sp6lR15iWMk


Q:

Change class bg if checkbox is checked

I'm working on my portfolio website and need some help with a bit jQuery code. I want a parent class to react to the checkbox in it. In this case, the background color needs to change to #000 when the checkbox is active/checked.
I don't know what line of code to add to make my class react to the checkbox. I've searched on google on how to do it but didn't get much wiser. It's probably a really small thing but I would hope to get some help from you guys.

$("input[type='checkbox']").change(function() {
  if ($(this).is(":checked")) {
    $(this).parent();
  } else {
    $(this).parent();
  }
});
.product {
  background-color: #ccc;
  /* needs to change to #000 when active */
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

<div class="product">
  <input class="check" type="checkbox" name="logo"> Logo
</div>

A:

Basically you create a second (more specific) css selector for the active state, then you use your jQuery to toggle that state/class based on the checkbox value.
https://jsbin.com/betafupogu/1/edit?html,css,js,output
CSS
.product {
  background-color: #ccc; /* needs to change to #000 when active */
}

.product.active {
  background-color: #000;
}

jQuery
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script>

        $("input[type='checkbox']").change(function(){
    if($(this).is(":checked")){
        $(this).parent().addClass('active');
    }else{
        $(this).parent().removeClass('active');
    }
});

</script>


Q:

Disable button as long as several textfields are empty

I have the following code to disable a button as long a textfield is empty:
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {

        let text = (textField.text! as NSString).replacingCharacters(in: range, with: string)

        if !text.isEmpty{
            addButton.isEnabled = true
        } else {
            addButton.isEnabled = false
        }
        return true
}

It works fine, but now that I have 3 textfields, I want the button only to be enabled, if all textfields are not empty. So far, as soon as one textfield is filled in, the button is being enabled.
How can I adjust my code to do so?

A:

Add target to all textfields for .editingChanged event, and check if any textfield is empty. If all text fields contain text enable the button else disable the button.
class TestViewController: UIViewController, UITextFieldDelegate {
    let addButton = UIButton()
    let textField1 = UITextField()
    let textField2 = UITextField()
    let textField3 = UITextField()

    override func viewDidLoad() {
        super.viewDidLoad()
        textField1.addTarget(self, action: #selector(textChanged(_:)), for: .editingChanged)
        textField2.addTarget(self, action: #selector(textChanged(_:)), for: .editingChanged)
        textField3.addTarget(self, action: #selector(textChanged(_:)), for: .editingChanged)
    }
    @objc func textChanged(_ textField: UITextField) {
        addButton.isEnabled = [textField1, textField2, textField3].contains { $0.text!.isEmpty }
    }
}


Q:

Mathematica notebook autocompletion completely disappears

Just as what is described in the title, the notebook behaves as if it were originally designed to not have the autocompletion functionality at all. Neither Ctrl+K nor F2 works. Furthermore, reinstalling Mathematica does not help, either.
What measures could be taken that possibly help to recover the autocompletion functionality? I suspect that some items in "Option Inspector" might be responsible but I can not find them.

It seems that quite a few people encounter this problem recently.
But, for now, the "$UserBaseDirectory deletion / renaming methods" cannot thoroughly settle this issue, can they?

A:

I had exactly the same problem today (I have Mathematica 11.2 and Windows 10): the autocomplete suddenly disappeared and neither Ctrl+K or F2 worked.
I don't have any additional packages installed; only the basic Mathematica. I tried clean-starting and that didn't work.
I managed to get autocomplete to work again by deleting the $UserBaseDirectory and restarting:
See also

tutorial/ConfigurationFiles
How do I fix common problems by resetting Mathematica to its default configuration?

I hope this helps!
It appears that Shortcuts` package can be involved but it is not clear how, see update in:
https://mathematica.stackexchange.com/a/85824/5478
so before you delete whole $UserBaseDirectory you can try:
Needs @ "Shortcuts`"
UninstallShortcuts[]
(*+restart*)

A:

PacletUpdate["EntityFramework"]

should resolve the issue at this point.


Q:

How do I profile my app - the menu item is disabled?

How do I profile my app in xcode - the menu item is disabled?
Product > Profile is disabled

A:

This is very unlikely but still, one possible reason:
Make sure correct 'Executable' is selected in 'Profile' option for your Scheme. If the selected executable is 'None', profile option will be disabled.
In case you don't know how to check scheme settings, you can check these setting by selecting 'Edit Scheme' either from Scheme menu (App name and device/simulator drop downs near the Run and Stop button ) or from 'Product' menu of xcode


Q:

Need Help on LINQ-Query

I have 3 Tables:
Table User (UserID, Username)
Table Admin (AdminID, Username)
Table PM (PMID, SenderID, Sendertype, RecipientID, RecipientType)

Now I will, in 1 Query:

Get all Information from PM
if SenderType == 'A' join SenderID to Admin-Table, get Username
if SenderType == 'U' join SenderID to User-Table, get Username
if RecipientType == 'A' join RecipientID to Admin-Table, get Username
if RecipientType == 'U' join RecipientID to User-Table, Get Username

someone have an Idea how to solve in 1 query?

A:

Why not just have a single user table that instead has a user type of either User or Admin, you could save yourself a lot of trouble... LINQ queries translate directly to SQL, so I'm not sure if you can do an indeterminate join like that in just one query.
Alternatively, if you don't want to modify the tables you could also create a view that does basically the same thing.
Or, write a stored procedure.
If you really want to use LINQ, you'll probably have to do more than one query. You could union the two User/Admin tables with a third field to differentiate, and then join to your PM table using that dataset instead.


Q:

How do I get CAML for a custom content type

I am trying to get the CAML for a custom content type that I am creating. What I am really doing is creating the content type in Visual Studio 2010 via CAML and then deploying that content type to my sandbox using the new deploy features in VS 2010. At that point, I am modifying the content type using the SharePoint interface (i.e changing advanced settings, adding columns, etc) since it is easy to do via the web interface. What I would like to do, is after I have made my changed, update my CAML in Visual Studio to match my changes.
I want to do this because I am creating custom fields and content types for my project and want to create a solution with these customizations. Since there doesn't seem to be a way to do this (create custom fields and content types) as a solution using SharePoint without putting them into a list, I am using Visual Studio and CAML for this. I also want to use Visual Studio and CAML so that I can put these CAML xml files in source control so that I can version my custom fields and custom types.
I have tried using tools like http://spcamlviewer.codeplex.com/ but that doesn't seem to work with SP 2010.
Does anyone have any suggestions? I wish Visual Studio would just have an update from SP button after I have deployed my solution and made changes on the server so it would sync VS from the SP server.

A:

SharePoint Manager 2010


Q:

how to change datepicker holotheme day view in android

How can I change this days view to normal? I mean to display days not in a month view calendar, but in a form like months and years?
 <DatePicker
            android:id="@+id/datePicker"
            android:layout_width="312dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp" />

A:

If I understand your question correctly, you want to hide the calendar view but still display the day/month/year selector. To achieve that, change your XML to the following:
<DatePicker
    android:id="@+id/datePicker"
    android:layout_width="312dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dp"
    android:calendarViewShown="false" />


Q:

Edible lollipop sticks for a complicated birthday cake

I'm baking a cake for my sister. Though the cake will be simple. I decided to make chocolate cupcake lollipops. The cupcakes will read out her traits like nice, awesome etc. I need some advice on how to make edible sticks which will be connecting the base cake and the cupcakes.

I want them to be edible because long story short she always wondered why is there the point of the stick if its not eatable when she was young.
I also want to know how to prevent the cupcakes from sagging down and dropping on the base cake.

A:

The brainstorming in the comments has provided numerous examples:

Candy cigarettes
These are likely the most realistic sticks you will find, as they're usually completely white, but fairly soft so use care when attaching the muffin to the top:

Pocky / Mikado
These are chocolate covered biscuit sticks, they're much more sturdy but not the right colour:

There is also a Cookies & Cream flavoured Pocky, marketed as Pocky Panda, which is white and the closest resemblance they make. This may require being purchased from the internet though as I'd never heard of them before:

Rolled Chocolate Wafer Biscuits
These are simply tubes of wafer biscuits, typically filled with chocolate, such as DeBeukelaer Pirouline and Pepperidge Farm Pirouette:

Stick Candy and Rock
Quite simply sticks made out of candy, I suspect Rock will be less common outside the United Kingdom, but Stick Candy should be simple to find.
Rock is a hard candy tube up to an inch thick which could support a table, nevermind a cupcake:

Stick Candy is basically un-bent candy canes and less thick than rock, though very similar:


Q:

SQL - Find Differences Between Columns

Let's say I have the following table
Sku | Number | Name
11    1        hat
12    1        hat
13    1        hats
22    2        car
33    3        truck
44    4        boat
45    4        boat

Is there an easy way to figure out how to find the differences within each Number. For example, with the table above, I would want the query to output:
13 | 1 | hats

The reason for this is because our program processes the rows as long as the number matches the name. If there is an instance where the name doesn't match but the rest of the names do, it will fail.

A:

You can find the most common value (the "mode") using window functions and aggregation:
select t.*
from (select number, name, count(*) as cnt,
             row_number() over (partition by number order by count(*) desc) as seqnum
      from t
      group by number, name
     ) t
where seqnum = 1;

You could then find everything that is not the mode using a join.  The easier way is just to change the where condition:
select t.*
from (select number, name, count(*) as cnt,
             row_number() over (partition by number order by count(*) desc) as seqnum
      from t
      group by number, name
     ) t
where seqnum > 1;

Note:  If there are ties in frequency for the most common value, then an arbitrary most common value is chosen.
EDIT:
Actually, if you want the original skus, you might as well do the join:
with modes as (
      select t.*
      from (select number, name, count(*) as cnt,
                   row_number() over (partition by number order by count(*) desc) as seqnum
            from t
            group by number, name
           ) t
      where seqnum = 1
     )
select t.*
from t join
     modes
     on t.number = modes.number and t.name <> modes.name;

This will ignore NULL values (but the logic can easily be fixed to accommodate them).


Q:

How to remove properties of mongo objects in an array?

I hope the snippets below make my question more clearer. I can fetch an object that has embedded an array of category objects. From the category objects I want to show only certain properties.
So this is what I get now:
{
  "photo": [],
  "_id": "5ec55ae39eere8ert85bf8fe749",
  "title": "Blog about coding",
  "description": "Hi, I want to share with you my incredible journey as a software developer...",
  "rate": 3,
  "category": [
    {
      "_id": "5ec55ae39aaa78985f8fe74a",
      "name": "programming",
      "display_name": "Programming"
    }
  ],
  "createdAt": "2020-05-20T16:29:23.982Z",
  "updatedAt": "2020-05-20T16:29:23.982Z",
  "__v": 0
}

With the following code:
/* GET blog with id */
router.get("/:id", async (req, res, next) => {
    try {
        const blog = await Blog.findById(req.params.id); // How to filter out fields of objects in category array?
        res.send(blog);
    } catch(ex) {
        res.status(400).send(ex);
    }
});

This is what I actually want:
{
  "photo": [],
  "_id": "5ec55ae39eere8ert85bf8fe749",
  "title": "Blog about coding",
  "description": "Hi, I want to share with you my incredible journey as a software developer...",
  "rate": 3,
  "category": [
    {
      "display_name": "Programming"
    }
  ],
  "createdAt": "2020-05-20T16:29:23.982Z",
  "updatedAt": "2020-05-20T16:29:23.982Z",
  "__v": 0
}

So, in category I want only the "display_name"
How can I get this. I thought I saw a solution before, but I can't find it anymore.

A:

Since you're using .findById() which is mongoose wrapper to .findOne({_id: ObjectId()}) which offloads burden of converting input string to ObjectId(), but there is nothing much .find()'s can help on projection, You need to list all the fields as like given below :
/** .findById(inputString, projection) */

Blog.findById(req.params.id,
{
  "category.display_name": 1,
  "title": 1,
  "description": 1,
  "rate": 1,
  "createdAt": 1,
  "updatedAt": 1
})

/** Or */

Blog.findById(req.params.id,
{
  "category._id": 0,
  "category.name": 0,
})

Test : As playground can't use .findById test it using .find() :  mongoplayground
But if you lean towards using aggregation you can do lot more in projection :
const mongoose = require('mongoose');

/* GET blog with id */
router.get("/:id", async (req, res, next) => {
    try {
        const blog = await Blog.aggregate([{$match : {_id : mongoose.Types.ObjectId(req.params.id)}},
            { $addFields: { category: { $map: { input: "$category", in: { display_name: "$$this.display_name" } } } } }
        ]);
        res.send(blog);
    } catch(ex) {
        res.status(400).send(ex);
    }
});

Test : mongoplayground
Note : This aggregation query iterates thru category array and keep only display_name in each object, Use this pipeline only if you need to exclude a lot of fields in category objects. I would suggest to use second option in .findById() cause you no need to convert string to ObjectId() and an aggregation pipeline just to exclude fields name and _id inside objects of category array.


Q:

update_or_create not updating/creating objects

I found out that django 1.7 supports now update_or_create() method in queryset.
But when I try it, it is not working. There is no object created when I try this:
models.py
 class Model1(models.Model):
    name = models.CharField(max_length=100)
    status = models.CharField(max_length=100)
    user = models.ForeignKey(User, null=True, blank=True)

 class Model2(models.Model)
    model = models.ForeignKey(Model1, null=True, blank=True)
    field1 = models.CharField(max_length=100)
    field2 = models.CharField(max_length=100)
    user = models.ForeignKey(User, null=True, blank=True)

views.py
 def ModelUpdate(request)
     model1 = get_object_or_404(Model1, pk=request.POST['lid'])
     model1.status =2
     model1.save()

     #based on the model1, we want to create or update model2
     datadict ={'field1' : 1, 'field2':2,}
     model2, created = Model2.objects.update_or_create(model=model1,
                                                       defaults=datadict)
     if created:
         print('model2 obj created') #for checking purpose
    else:
         print('model2 obj not created')

    return render(request,'updated.html', {'update':'updated'})

I can see the message model2 obj created but the object was not saved in the database. What could be the problem?
UPDATE
Turns out it was my mistake. In the Model2, I defined the save method without returning  super(Model2, self).save(*args, **kwargs)
That's why it didn't save the objects.

A:

Maybe you verifying in the wrong way, because I created project with your models and everything works fine.
In my case I'm verifying that object was created/updated with objects.get() and printing values:
In [1]: from app1 import models

In [2]: m1 = models.Model1.objects.create(name=1, status=1)

In [3]: m1
Out[3]: <Model1: Model1 object>

In [4]: datadict ={'field1' : 1, 'field2':2,}

In [6]: model2, created = models.Model2.objects.update_or_create(model=m1, defaults=datadict)

In [7]: model2, created
Out[7]: (<Model2: Model2 object>, True)

In [8]: models.Model2.objects.get().field1, models.Model2.objects.get().field2
Out[8]: (u'1', u'2')

In [9]: datadict ={'field1' : 3, 'field2':4}

In [10]: model2, created = models.Model2.objects.update_or_create(model=m1, defaults=datadict)

In [11]: model2, created
Out[11]: (<Model2: Model2 object>, False)

In [12]: models.Model2.objects.get().field1, models.Model2.objects.get().field2
Out[12]: (u'3', u'4')

and
In [13]: models.Model2.objects.get().model.id
Out[13]: 1

In [14]: models.Model1.objects.get().id
Out[14]: 1


Q:

How to load balance (scale) a simple PHP application?

I constantly read on the Internet how it's important to correctly architect my PHP applications so that they can scale.
I have built a simple/small CMS that is written in PHP (think of Wordpress, but waaaay simpler).
I essentially have URLs like such: http://example.com/?page_id=X where X is the id in my MySQL database that has the page content.
How can I configure my application to be load balanced where I'm simply performing PHP read activities.
Would something like NGINX as the front door setup to route traffic to multi-nodes running my same code to handle example.com/?page_id=X be enough to "load balance" my site?
Obviously, MySQL is not being load balanced in this situation, though for simplicity - that makes that out of scope for this question.

A:

These are some well known techniques for scaling such an app.

Reduce DB hits
Most often the bottle neck will be your DB, so cache recent pages so that you reduce DB activity, perhaps in something like memcached.
Design your schema such that it is partition-able.
In the simplest case, separate your data into logical partitions, and store each partition in a separate mysql DB. Craigslist, for example, partitions data by city, and in some cases, by section within that. In your case, you could partition by Id quite simply.
Manage php sessions
Putting ngnx in front of a php website will not work if you use sessions. Load balancing php does have issues as sessions are persisted on local storage. Therefore you need to do session management explicitly. The traditional solution is to use memcached to store and look up some kind of cookie.
Don't optimize prematurely.
Focus on getting your application out so that the next magnitude of current users gets the optimal experience.

Note: Your main potential pain points are discussed here on SO


Q:

How to create router-link programmatically on html render using Datatables.net + Vue.js?

I have a Datatables.net jquery plugin as a vue component:
DatatablesCGU:
<template>

        <slot></slot>

</template>

On another component, i use this passing a datatables options with some custom renders on columns properties:
...
methods: {
            getOptions(){
                let options = this.getDefaultOptions();
                options.ajax.url = "/api/auth/usuarios";
                options.filtrador = this.filtrador;
                options.columns = [
                    this.colunaDeSelecao(this.modoPopup)
                    ,{name: "cpf", data: "cpf", title: "CPF"}
                    ,{name: "nome", data: "nome",  title: "Nome"}
                    ,{name: "email", data: "email",  title: "E-mail"}
                    ,{name: "id", data: "id", title: "Ações", visible: !(this.modoPopup), sortable:false, className:"dt-center", width: "200px", render: function(data, type, row) {
                        return `
                                    <button id='btnAlternar__${data}' data-id='${data}' class='btn btn-${row.ativo?"danger":"success"}' data-toggle='tooltip' title='${row.ativo?"Inativar":"Ativar"}'></button>

                                `;
                    }}
                ];
                options.initComplete = () =>{
                    this.getDefaultOptions().initComplete();
                    this.criarTogglersSituacao();
                };
                return options;
            }
...

If you notice the last column render creates a <a href='${window.$baseURL}auth/usuarios/${data}' ... that obviously isn't a router-link and doesn't trigger vue router properly, causing an undesired page refresh.
I need the link to do a router push instead of a page refresh. How is this possible?

A:

There is no good answer to that problem. datatables is not really compatible with Vue.js. With Vue, the usual way to go would be to pass your reactive HTML structure within a slot to such a library. Because datatables requires you to use a render function and return static HTML as a string, you cannot pass any JavaScript logic along.
The main problem is that you need to pass an event from the link tag to the Vue component. One approach would be to pass HTML in the render function which then can be selected with a specific selector (e.g. adding a class). You also need to add the link data/the item's ID to the HTML element (e.g. with a data-link="" attribute). When datatables has finished rendering, you can add a click listener to all the links. This click listener handler function needs to read the link/ID of the link and pass it to the router. Then, you can use Vue's router.push() function.
When you are implementing a solution with the above approach, make sure to assign and remove the click listeners depending on the lifecycle events of datatables. It might be necessary to add and remove the listeners on each page switch.


Q:

Stop playing music on third ViewController - Swift 4

I have a simple background music loop on my first ViewController that looks like this:
func setupMusic() {

    if audioEnabled == true {

        let soundFile = Bundle.main.path(forResource: "bgMusic", ofType: ".wav")

        do {
            try bgmusic = AVAudioPlayer (contentsOf: URL(fileURLWithPath: soundFile!))
        }  catch {
            print (error)
        }

        bgmusic.numberOfLoops = -1
        bgmusic.volume = 0.3
        bgmusic.play()

    }
}

I would like to know how I stop this looping background music from playing in another scene, in my case - the "User Settings" screen when the user selects the mute button.
bgmusic.stop() \\ Wont work because the object 'bgmusic' is not instantiated in the new scene?

A:

Option 1
class Service {

   static let shared = Service()
    var gmusic :AVAudioPlayer?
}

try Service.shared.gmusic = AVAudioPlayer (contentsOf: URL(fileURLWithPath: soundFile!))

then use
Service.shared.gmusic?.stop()

Option 2
in CurrentVC
 let settingsVc = //

 settingsVc.delegate = self

 present(settingsVc

//
 calss SettingsVC:UIViewController {

    var delegate:CurrentVC?

    func stop () {

     delegate?.gmusic.stop()

 }


Q:

In Github, I want to prevent members from merging a pull request

In my workflow I have two default branches: master (production) and dev (staging). All members create their branches from the dev branch. However, I want require the members to do a pull request to merge back into the dev branch. Additionally, I want to prevent those members from approving the pull request. I want to be the only one to approve a pull request merge after a code review.
I've been looking at protecting branches but I'm not sure if I'm on the right track.

A:

If you enable branch restrictions on your master and dev as mentioned https://help.github.com/articles/enabling-branch-restrictions/, everyone who branches out from these 2 will have to create a pull request which only you can merge


Q:

Sync Local Folder to FTP

I'm looking for an app I can put on my local server that will take files from C:\Source to a folder on my remote FTP Server every hour.
I was looking at rsync and it looked perfect until it told me I cant use my own FTP server. Any recommendations?
I'm going to have around 50,000 small files. nothing over 20kb, in the source folder, so the faster the ftp the better. Allway Sync is just too slow as well.

A:

I know two programs:

If you are willing to pay a little you have the FTP Synchronizer
Also there is a free version of a similar program that is called BestSync

I just found another one that looks good, however i've never used this: BatchSync FTP
I hope this helps :)


Q:

Deserializing SQL table to object collection

I'm trying to deserialize an SQL table to a collection of objects in PHP and I'm lost as to how I can do so.
In C#, the equivalent would be:
public class Object
{
    public string objectProperty { get; set; }
    public string anotherProperty { get; set; }
}

public void Deserialize()
{
    List<Object> collection = new List<Object>();

    // Assuming that we have an SQL statement returning a row

    foreach (Row row in returnedSqlRow)
    {
        collection.Add(new Object
        {
            objectProperty = row["objectProperty"],
            anotherProperty = row["anotherProperty"]
        });
    }
}

which would give me a nice collection of Objects to work with.
In my PHP I have the following:
class Book {
    public $CN; // cataloguenumber
    public $title;
    public $author;
    public $description;
    public $price;
    public $enteredby;
}

with my SQL statement being:
$books = pg_query($conn, 'SELECT cataloguenumber, title, author, description, price, enteredby FROM CSBooks');
I can easily access each value from the row like so:
    while($row = pg_fetch_row($books)) {

        echo $row[0] . '
';
        echo $row[1] . '
';
        echo $row[2] . '
';
        echo $row[3] . '
';
        echo $row[4] . '
';
        echo $row[5] . '
';
    }

But I'm lost as to how I can create an object collection and deserialize the row to a Book object and store it.  Is there a PHP equivalent? I've taken a look at pg_fetch_object() but it doesn't quite seem to be what I'm looking for.

A:

I think the solution is to use PDO and PDOStatement::fetchObject which will abstract all the pg_* functions and make your db interaction easier to manage.
It will return a stdObject instead of an array by default, but you can make it map your object.
There would be a dirty solution if you really need to use pg_* functions instead of PDO... (I am ashamed to suggest it)
$a = ['a'=>'bla', 'b'=>1];
$shame = (object) $a;

Then on your class, you just write a constructor to bind the columns to the object fields...


Q:

App custom notification light color

I am programming my own app and I have some issues with my notifications.
Is it possible to have custom notification light color in android?
Because when I try to set the color to #FF64B5F6 I didn't gte this color.
Or can I only set the color to these Color.RED, Color.MAGENTA?
And when I can set custom colors, is this the right way?
Java:
NotificationCompat.Builder(this.context).setLights(ContextCompat.getColor(this.context, R.color.c_account), 500, 500)

xml:
<color name="c_account">#FF512DA8</color>

Hope you guys can help me.

A:

Is it possible to have custom notification light color in android?

Well, you can try. It may not work.
First, some devices do not have an LED.
Of those that do, some devices do not use the LED for showing notifications.
Of those that do, some devices do not support different colors.
Of those that do, some devices will not support arbitrary colors (though ideally they map your requested color to one that they do support).
So, you are welcome to request a specific color. Just bear in mind that it is quite likely that you will not get the color that you want, and that there is no guarantee that you will get any sort of LED effect.


Q:

Cannot access ifreq structure definition, __USE_MISC macro undefined

I am trying to compile the following single C file (called main.c):
#include <stdio.h>

#define __USE_MISC 1
#include <net/if.h>

int main(int argc, char **argv)
{
ifreq id_ifreq;
fprintf(stdout, ">>>>>> OK <<<<<<\n");
}

... using "gcc main.c -o main". I get the following error:
main.c: In function ‘main’:
main.c:9:2: error: unknown type name ‘ifreq’

I know that "ifreq" structure definition lies within a "#ifdef __USE_MISC" macro, however, I cannot activate that block of code.
I developed the following code for checking which MACROS are defined (compiled with "gcc main.c -o main"):
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <net/if.h>

int main(int argc, char **argv)
{

   #ifdef __USE_MISC
       printf("__USE_MISC defined\n");
   #endif
   #ifdef _GNU_SOURCE
       printf("_GNU_SOURCE defined\n");
   #endif

   #ifdef _BSD_SOURCE
       printf("_BSD_SOURCE defined\n");
   #endif

   #ifdef _SVID_SOURCE
       printf("_SVID_SOURCE defined\n");
   #endif

}

The result is that they are all defined but the "_GNU_SOURCE" one. However, I am still not capable of using the definition of the "ifreq" structure included in the "net/if.h" file.
Anybody can help?

A:

You are omitting the struct keyword (in C, a struct definition is not a typedef)
#include <stdio.h>
#include <net/if.h>

int main(int argc, char **argv)
{
struct ifreq id_ifreq;
fprintf(stdout, ">>>>>> OK <<<<<<\n");
return 0;
}


Q:

Difference between URL::to and URL::route in laravel

What is the difference between
Register 1

and
Register 2

I defined the routes.php as
Route::get('/account/register','RegisterController@create');

When I click on 'Register 1' I got the following error
Route [/account/register] not defined.

But when I click on 'Register 2' ,it goes to the
RegisterController@create

A:

URL::route gets the URL to a named route. So in your case, if you name your route like this:
Route::get('/account/register', [
    'name' => 'register',
    'uses' => 'RegisterController@create'
]);

then you will be able to use
Register 1

in blade templates.

A:

Url::route is used only if you have named routes. So if I called my route "my route" then I could call it like so:
URL::route('my route');
But if you want to direct to a route that only has a destination and is not named, then you should use URL::to


Q:

Finding consecutive elements of an array using Java

I'm almost new at Java! I want to control if there are 4 consecutive elements in an array with 5 elements. Is there any way to do that? Can someone help me with that? Thanks! Consecutive like {2, 3, 4, 5}. If there is {3, 4, 2, 5} for example this is not consecutive.I want just a simple example if someone can help me.
I did this but I think this is incorrect:
 public int katerTeNjepasnjeshme()
 {
         int[] numrat=new int[zar.length];
         for(int i=0;i<zar.length;i++)
             numrat[i]=zar[i].getValue();
         int shuma=0;
         for(int i=0;i<zar.length-1;i++)
         {

    if(zar[i+1].getValue()==(zar[i].getValue()+1))
         Joptionpane.showMessageDialog(null,"Tere are cons elements");
}

A:

Here's the general idea:
Keep a counter (initialized appropriately), to keep track of the number of consecutive elements as you iterate over the elements.
If the counter reaches 4, you have found 4 consecutive elements.
If you encounter an element that is not consecutive, then reset the counter to 1, and proceed to check the next element.
Here is a sample code snippet:
public static void findConsecutive()
    {
        int[] array = {1,2,3,5,6,7,8,10};

        int counter = 1;
        int i = 1;
        for (i = 1; i < array.length; i++)
        {
            if (array[i] == (array[i-1] + 1))
            {
                counter++;
                if (counter == 4)
                {
                    System.out.println("Consecutive elements are at array index: " + (i - 3) + " to " + i);
                    break;
                }
            }
            else
            {
                counter = 1;
            }
        }
    }


Q:

Parsing/converting Nokia "Smart Feature OS" backup .ib files?

I have already written a bit on this in https://superuser.com/questions/1389657/backup-access-sms-on-nokia-3310-3g-2017-from-linux-pc ; basically, I'm trying to back up SMS messages on a Nokia 3310 3G onto a Ubuntu 18.04 PC; note that hardware system-on-chip and OS differs by version for a Nokia 3310 (2017):

System on chip / Operating system:

MediaTek MT6260 / Nokia Series 30+ (2G)
Spreadtrum SC7701B / Java-powered Smart Feature OS (3G)
Spreadtrum SC9820A / Yun OS (4G, CMCC)

I have the 3G, so I have a "Smart Feature OS" which apparently is a version of KaiOS (Is there any difference between KaiOS and 'Smart Feature OS'? : KaiOS), which apparently (KaiOS – A Smartphone Operating System | Hacker News) is a fork of Firefox OS.
When you hit Menu > Storage > Create backup (https://www.nokia.com/phones/en_int/support/nokia-3310-3g-user-guide/create-a-backup) on this phone, it generates a folder with files in it, named like this:
$ tree All-backup_01-01-2019_20-18-54
All-backup_01-01-2019_20-18-54
├── ibphone_head.in
├── phonebook.ib
└── sms.ib

I've never heard of .ib files before, and I was hoping someone here knew what they are. A quick look suggests IB File Extension - Open .IB File (InterBase Database), however I tried using these .ib files with http://fbexport.sourceforge.net/fbexport.php "Tool for exporting and importing data with Firebird and InterBase databases", and I get:
Engine Code    : 335544323
Engine Message :
file ./All-backup_01-01-2019_20-18-54/phonebook.ib is not a valid database

So, that's not it.
Here is a hexdump of ibphone_head.in - looks like there is no personal identifying info here:
$ hexdump -C All-backup_01-01-2019_20-18-54/ibphone_head.in
00000000  00 00 00 00 41 00 6c 00  6c 00 2d 00 62 00 61 00  |....A.l.l.-.b.a.|
00000010  63 00 6b 00 75 00 70 00  5f 00 30 00 31 00 2d 00  |c.k.u.p._.0.1.-.|
00000020  30 00 31 00 2d 00 32 00  30 00 31 00 39 00 5f 00  |0.1.-.2.0.1.9._.|
00000030  32 00 30 00 2d 00 31 00  38 00 2d 00 35 00 34 00  |2.0.-.1.8.-.5.4.|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000100  00 00 00 00 45 00 3a 00  5c 00 42 00 61 00 63 00  |....E.:.\.B.a.c.|
00000110  6b 00 75 00 70 00 73 00  5c 00 41 00 6c 00 6c 00  |k.u.p.s.\.A.l.l.|
00000120  2d 00 62 00 61 00 63 00  6b 00 75 00 70 00 5f 00  |-.b.a.c.k.u.p._.|
00000130  30 00 31 00 2d 00 30 00  31 00 2d 00 32 00 30 00  |0.1.-.0.1.-.2.0.|
00000140  31 00 39 00 5f 00 32 00  30 00 2d 00 31 00 38 00  |1.9._.2.0.-.1.8.|
00000150  2d 00 35 00 34 00 00 00  00 00 00 00 00 00 00 00  |-.5.4...........|
00000160  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000200  00 00 00 00 30 30 30 31  2e 30 30 30 30 33 00 00  |....0001.00003..|
00000210  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000230  00 00 00 00 00 00 6d 6d  69 6b 65 79 62 61 63 6b  |......mmikeyback|
00000240  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000250  00 00 00 00 00 00 03 00  00 00 00 00 b0 cd 09 00  |................|
00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000270  00 00 00 00 00 00 00 00  f3 dd 00 00 7e 2f 00 00  |............~/..|
00000280  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000002c4

So, it seems that strings are encoded with 2 bytes, "wide char"; and for the most part, ibphone_head.in seems to just encode the name of its containing/parent folder, All-backup_01-01-2019_20-18-54.
Here is a hexdump of phone book, where I've anonymized names to AAAAAAAAA and BBB:
$ hexdump -C -n 1900 All-backup_01-01-2019_20-18-54/phonebook.ib
00000000  70 00 68 00 6f 00 6e 00  65 00 62 00 6f 00 6f 00  |p.h.o.n.e.b.o.o.|
00000010  6b 00 2e 00 69 00 62 00  00 00 00 00 00 00 00 00  |k...i.b.........|
00000020  00 00 00 00 01 00 00 00  30 f8 04 00 62 01 00 00  |........0...b...|
00000030  62 01 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |b...............|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000240  00 00 00 00 98 03 00 00  01 00 00 00 ff ff ff ff  |................|
00000250  ff ff ff ff 01 00 01 00  00 00 00 00 00 00 00 00  |................|
00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000360  d9 d4 37 46 00 00 00 00  00 00 01 02 00 00 04 01  |..7F............|
00000370  07 12 80 88 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000380  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000003b0  09 00 41 00 41 00 41 00  41 00 41 00 41 00 41 00  |..A.A.A.A.A.A.A.|
000003c0  41 00 41 00 00 00 00 00  00 00 00 00 00 00 00 00  |A.A.............|
000003d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000005e0  00 00 00 00 00 00 00 00  00 00 00 00 ff ff ff ff  |................|
000005f0  ff ff ff ff 98 03 00 00  01 00 00 00 ff ff ff ff  |................|
00000600  ff ff ff ff 04 00 01 00  00 00 00 00 00 00 00 00  |................|
00000610  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000710  d9 d4 37 46 00 00 00 00  00 00 01 02 00 00 06 11  |..7F............|
00000720  83 29 23 13 58 f9 00 00  00 00 00 00 00 00 00 00  |.)#.X...........|
00000730  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000760  03 00 42 00 42 00 42 00  00 00 00 00              |..B.B.B.....|
0000076c

Here it seems d9 d4 37 46 is a delimiter for entries, and entries seem to be 0x3b0 = 944 bytes apart; cannot tell where the actual phone number is stored, though.
I won't be pasting the hexdump contents of sms.ib, because I fear to reveal more personal info than I intend to.
However, maybe what has been posted already, will help someone see if this is an already established file format? In any case, I'd like to convert the contents of these files to plain text ...

A:

The phonebook.ib is a proprietary file format. I did some analysis and got to the point where I am able to extract names and phones numbers from it.

Header is 580 bytes and doesn't seem to contain anything interesting.
Entries appear to begin with the entry length, encoded as 3 4-bit decimal nibbles followed by another digit (version number maybe?).

In my sample file all entries were 940 bytes and therefore had 94 03 as their first two bytes.  Other field entries I identified at different offsets:

entry+0x12a [1 byte]: Number of bytes representing phone number.
entry+0x12b [1 byte]: Seems like a two-digit decimal coded flag. If high nibble is set (e.g. 10) then phone number begins with +.
entry+0x12c: Phone number, decimal coded.  For example, 123456 would appear as 21 43 65. Special digits:

a is *
b is #
f is ignored (seen as a last digit when the number of digits is not even).

entry+0x16c [1 byte]: Name length.
entry+0x16e: Name in UTF-16 (i.e. 2 bytes per char).

Taking your snippet as an example:

0x36e is the phone length, 4 bytes.
0x36f is the extra flag, high nibble is 0 so no + prefix.
0x370 is where the phone number begins, 07 12 80 88 translates to 70210888.

A simple reference parser can be found at my repo: https://github.com/yossigo/phonebook_ib_export

A:

I was about to make the opposite script than Yossi's to convert .vcf files back into the .is format when I found a workaround to backup and restore all contacts to and from the vcf file format with the Nokia 3310 3G :
BACKUP CONTACTS TO VCF FILE: in your contacts, click the left button to share, select all of them using the option in the left button menu, send via Bluetooth to any device, you can then retrieve the vcf file from the other Bluetooth device OR from the /vCard/ folder at the root of your phone (sd card if one is plugged)
RESTORE CONTACTS FROM VCF FILE: copy the file anywhere on the phone or sd card, unplug the phone and use the embedded file browser to find the file, then follow Nokia’s engineer logic by not using the Open button but instead click on the left button and use the option Save vCard


Q:

Confused about the way objects are made in enums

After seeing how the compiler handles the enum's and you mentioning that the constants are instances it all made a lot more sense to me. I am however left with one more question.
public enum Weekday
{
  MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY
}

The compiler compiles it as follows;
class Weekday extends Enum
{
  public static final Weekday MONDAY  = new Weekday( "MONDAY",   0 );
  public static final Weekday TUESDAY = new Weekday( "TUESDAY ", 1 );
  public static final Weekday WEDNESDAY= new Weekday( "WEDNESDAY", 2 );
  public static final Weekday THURSDAY= new Weekday( "THURSDAY", 3 );
  public static final Weekday FRIDAY= new Weekday( "FRIDAY", 4 );
  public static final Weekday SATURDAY= new Weekday( "SATURDAY", 5 );
  public static final Weekday SUNDAY= new Weekday( "SUNDAY", 6 );

  private Weekday( String s, int i )
  {
    super( s, i );
  }

  //

In the example below I would like to explain my final question: I have seen code snippets like this:
enum Test
{
  EXAMPLE1(5), EXAMPLE2(6);

  private int number;

  Test(int number) {
    this.number = number;
  }

}

Test a = Test.EXAMPLE1;
System.out.println(a) outputs EXAMPLE1
System.out.println(a.number) outputs 5;

Now I get confused with the outputs above when the object stored in constant EXAMPLE1 is created like so:
public static final Test EXAMPLE1  = new Test( "EXAMPLE1",   0 );

Because first of all, the compiler adds the constructor and if this constructor exists, how is the constructor I defined even invoked?
private Test( String s, int i )
  {
    super( s, i );
  }

And second of all, even if the constructor I defined is somehow invoked, how does that result in outputting EXAMPLE1 when I say System.out.println(a)? Neither the constructor I defined, nor the constructor compiler the added, add the value value EXAMPLE1 to any field of the object stored in the constant EXAMPLE1. So how is it possible that System.out.println(a) outputs EXAMPLE1? How is this value even added to the object? I cannot see any constructor adding this value to the object.

A:

The compiler changes your constructor from:
Test(int number) {
    this.number = number;
}

to
private Test(String name, int ordinal, int number) {
    super(name, ordinal);
    this.number = number;
}

And that's why it works.
You can verify this if you want using the javap tool:
javap -p -c -cp <directory> <package>.Test


Q:

What Information Is Lost by Histogram Equalization?

I cannot think of a way to restore an original image after histogram equalization. But this latter seems to "enhance" (= increase contrast of) the image's details. What information is then lost by histogram equalization, if any?

A:

The expectation of information is called entropy. The loss of information can hence be understood as difference in entropy between source and processed image, assuming no random effect was added.
Together with my answer on why contrast is not an appropriate measure of entropy, this gives us the simple answer:
The loss in information is simply the number of bits necessary to count the different images that have the same processed image (i.e. after histogramm normalization).
Now, the math here gets pretty different whether you assume that pixels have real-valued intensities or discrete ones.
In the continuous case, you'd want to realize that histogram equalization applies a function to the pdf of the intensity, thereby adding negative differential entropy.
In the discrete case, multiple intensities of the source image will be mapped to a single intensity in the output: You can make statisitics of these ("empirical CDF") and from that derive how much information you lose.


Q:

Regex works but not with preg_match_all

I can't get the following Regex to work in PHP. Basically I am trying to take some horrendous Outlook HTML that contains a numbered list, remove the HTML, then Regex the plain text to get the list.
If I take the text that is produced by strip_tags() and test it on regex101.com, it finds the ordered list just fine. If I use that same regex in preg_match_all in PHP it produces an empty array.
Fiddles and regex101 below:
PHP:
$calendar_code = '

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">

This is a test of the agenda and objectives format

This shouldn’t get picked up

Dasdasdasd d asda sd  : asd obe: sad neither shood this

Objective: This is how the object should look, this is a long one

Agenda:

1.
Make like a tree

2.
And

3.
Get out of here

Some more stuff here, and here and ::: ;s

Sadfdsf sdfdfeswrfew

';

$strip = strip_tags($calendar_code);

echo "
";
echo $strip;

preg_match_all("/^(\d+\.)\s+([^\r\n]+)(?:[\r\n]*)/m", $strip, $matches);
print_r($matches);

PHPFiddle: http://phpfiddle.org/main/code/ygut-5jj5
As you can see I echo out the HTML stripped text. When I put this text in to regex101.com it works perfectly. See here: https://regex101.com/r/wW1kC9/1
I thought it might have something to do with the line endings, but I replaced all the HTML line endings with \n before doing the strip_tags() and it still doesn't work.
Can anyone see why this regex is not working with preg_match_all()
UPDATE:
It's been pointed out that non-breaking spaces are the reason, so removing or allowing for them in the regex will fix it. However it has also been pointed out that as the format of these lists will be quite random depending on the email client that sends the list, some using
 and some not for example, regex will not work for every situation, or even the majority of situations.
I need a better way of getting the contents of lists created by any number of different email clients.
For some background, people create these lists in emails and send them to a special email account. My code then accesses these emails and retrieves the lists for use elsewhere in my app. As these list are being created in the many different email clients available, they will invariably have different(random) formatting applied. For example when you create lists in Outlook 2016, it adds
 and  tags with styling to create the list.

A:

You have to decode HTML entities:
$strip = html_entity_decode(strip_tags($calendar_code));

Then there is another tricky part that you should take care of: after this decoding a non-breaking space will turn into its hex representation 0xC2 0xA0 which is not matched by \s token anymore so you have to consider its Unicode code point 00a0 as well:
preg_match_all("/^(\d+\.)[\s\x{00a0}]+([^\r\n]+)(?:[\r\n]*)/mu", $strip, $matches);

Live demo


Q:

VS13 C++ greedy match not greedy enough

Consider the following code:
wstring String = L"HMM";
wsmatch Matches;
if( regex_match( String, Matches, wregex( L"(H+|M+)([^HM]*)(H+|M+)([^HM]*)(H+|M+)" ) ) )
    wcout << Matches[1].str() << L"-" << Matches[3].str() << L"-" << Matches[5].str() << endl;
else
    wcout << L"No match\n";

You would expect that the second M+ would greedily consume all M's and give us a No match as result. Instead we get H-M-M as result.
It looks that VS13 tries to maximise the number of submatches and sacrifices the greediness for that?

A:

You would expect that the second M+ would greedily consume all M's and give us a No match as result.

The behavior you're describing is possessive, not greedy.  A greedy quantifier consumes as much as it can originally, but then gives back as much as necessary to achieve an overall match.
In flavors that support them, possessive quantifiers are formed by adding a + after the normal quantifier.  This regex would behave the way you expect:
(H++|M++)([^HM]*+)(H++|M++)([^HM]*+)(H++|M++)

However, the flavor you're using doesn't support possessive quantifiers.  Atomic groups can be used for the same thing, but you don't have those either.


Q:

Magento2 TypeError: cart is not a function

I ran into a issue where i could add products to cart and i got success message too but the minicart is not updating with the added items.
I got below error in console, I have upgraded the magento to 2.1.0

TypeError: cart is not a function in knockout.js

Did anyone came across this issue.

A:

I have updated the bind events in the minicart file by comparing the base codes, once after update. It worked.
Just compare the minicart.phtml file from theme

app\design\frontend\Theme_namespace\Theme_module\Magento_Checkout\templates\cart

with core template

vendor\magento\module-checkout\view\frontend\templates\cart

In these two files class and bind events may be different in your theme, that is why it is not updating.


Q:

Why is it necessary to add the "of" in "approved of "?

They surely wouldn't have approved my decision.

This sounds like perfect English to me.
But after searching on Google, I realized I was wrong, that I had to write instead:

They surely wouldn't have approved of my decision.

Why?

A:

Both sentences exist but with different meanings. "They surely wouldn't have approved my decision" means "they would not have agreed to accept it" so they had the authority to reject it.
"They surely wouldn't have approved of my decision" means "They would not have considered it to have been a good decision". So they didn't like it but couldn't necessarily have it changed.

A:

Approved implies actual control or supervision: the manager approved my expenses.
Approved of does not; rather, it implies merely an opinion: I approve of his choice of tie.


Q:

ListPicker Data Showing in Windows Phone

I am writing Windows Phone 8.1 app, I have binded listpicker with data, those data come from web service result, now, my problem is that, there are plenty and too much records, and therefore my app gets crash. How do I show just " 1 to 50" records?
See my code below:
XDocumnet doc = XDocument.Parse(e.Result);

List<string> list = new List<string>();

list = (from query in doc.Descendants("row")
       select new string
       {
           Id = query.Element("Id").Value,
           Name = query.Element("Name").Value
        }).ToList();

listPicker1.ItemsSource = list;

A:

Use Take
listPicker1.ItemsSource = list.Take(50);


Q:

Why was Vader surprised that Obi-Wan's body disappeared?

OK, I understand that Obi-Wan turned into a force ghost when Vader struck him down, but why was Vader surprised by the lack of a body? It's not the transition into a force ghost but Vader's reaction that bugs me.

A:

At the end of Revenge of the Sith (2005), Yoda talks to Obi-Wan Kenobi about meeting an old friend, his old master, Qui-Gon Jinn, who we know became a force ghost.

02:04:50 - Yoda: One who has returned from the netherworld of the Force.
02:04:53 - Yoda: Your old master.
02:04:56 - Obi-Wan: Qui-Gon?
02:05:00 - Yoda: How to commune with him I will teach you.

This is the first time, chronologically in the films, that the audience and any of the relevant main characters are introduced to the concept of force ghosts. Indeed Obi-Wan is surprised to hear about Qui-Gon in this scene.
Presumably, Anakin had also never heard of this concept of force ghosts before, or even if he did, at the very least could not fathom that Obi Wan could achieve such a feat. We can see from his reaction that he is unable to comprehend what just happened, he probably assumes that he defeated him, confused about the phenomena of the body disappearing, and later concludes that he died.
The following dialogue is from their lightsaber duel scene in Star Wars (1977).

01:27:08 - Ben: You can't win, Darth. If you strike me down...
01:27:12 - Ben: I shall become more powerful than you can possibly imagine.
01:27:22 - Vader: You should not have come back.

From Anakin's line (and his physical reaction, poking around the robes with his feet) there is evidence to suggest that he was, at least at the time, oblivious to the possibility of Obi-Wan becoming one with the force (turning into a force ghost).

A:

He didn’t understand what had happened
The knowledge of how to become a Force ghost was known to very few. Anakin certainly did not know it back during the Clone Wars era:

ANAKIN: Everything that we know about the Force tells us that an individual
  retaining their identity after death is impossible.
YODA: Everything that we know, yes.
  But what about what we know not? Hmm?
The Clone Wars: “Voices”

Qui-Gon learned it from the Force Priestesses, who had preserved this ancient art. Yoda learned it from Qui-Gon, with some help from the priestesses.

YODA: Now does my training begin?
PRIESTESS: The one you know as Qui-Gon Jinn will commune with you and
  guide your training. Like us, you shall learn to maintain your
  consciousness after death.
The Clone Wars : “Sacrifice”

If  even Yoda, Grand Master of the Jedi Order, was unaware of the possibility of becoming a Force ghost, surely Anakin, later Vader, also was. One might imagine that Palpatine might have told him, but Palpatine almost certainly was also unaware. Palpatine sought to cheat death, in the tradition of Darth Plagueis, but not by becoming a Force ghost: he wanted to make himself physically immortal and rule the temporal world. He wanted to control the midi-chlorians of life, not survive as a disembodied spirit and ultimately merge with the Cosmic Force. As Yoda says, after acquiring the knowledge of the Force Priestesses:

YODA: Yet, open to us, a path remains that unknown to the Sith is.
  Through this path, victory we may yet find. Not victory in the Clone
  Wars but victory for all time.
The Clone Wars: “Sacrifice”

Vader’s behavior and words bear this out. He appears to be entirely unaware that Obi-Wan exists as a Force ghost, even as of The Empire Strikes Back. He believes that Obi-Wan can no longer help Luke, for example:

“He could destroy us,” the Emperor croaks.
For a moment, Vader does not speak. When he does, his rich voice is
  slow and deliberate. “He is just a boy. Obi-Wan can no longer help
  him.”
The Empire Strikes Back: So You Want to Be a Jedi?

He also claims that Obi-Wan was "destroyed" and that there is no life after death:

“Don’t let yourself be destroyed, as Obi-Wan did.”
Vader’s black helm shimmers in the dim light of the reactor core. His
  cape sways softly, like silk, with each step he takes. “Do not believe
  the Jedi lies. There is no life after death. There is only death.”
  Behind his mask, he is smiling. He must be.
The Empire Strikes Back: So You Want to Be a Jedi?

In particular, as Sith, both Vader and Palpatine believed that the Jedi belief in life after death (even as part of the Force) was mistaken. They didn’t even believe that one could become one with the Force, let alone retain one’s identity.

SITH: We are the Sith.
YODA: Afraid of you I am not.
SITH: We shall
  see. There is no life after death. Only nothingness awaits you, Jedi.
  Your fear feeds
  our hunger for power.
  They will know you are here.
  We will tell them.
  You will die
  and be nothing.
The Clone Wars: “Sacrifice”

Now, what did he think had happened? It’s not clear. Probably he could sense through the Force that Obi-Wan was no longer there, so he did not believe that he had, for example, turned invisible. He was surely too arrogant to believe that Obi-Wan had, as he suggested, become “more powerful than [he] could possibly imagine” (nor would he have understood what that meant, even if he credited it). Perhaps he believed that Obi-Wan had used some trick to destroy himself, committing suicide rather than let Darth Vader kill him.

One might recall that Qui-Gon Jinn appeared to Anakin in the Mortis arc of The Clone Wars, and wonder why this hadn’t convinced him of the possibility of survival as a Force spirit. In that same arc, though, the Son, a powerful entity of the Dark Side, had appeared to him in the form of his deceased mother, Shmi Skywalker! He (and even Ahsoka and Obi-Wan) would have had ample reason to suspect that the vision of Qui-Gon was simply the Son, Daughter, or Father appearing in a different form for their own goals. Even without this sort of thing going on, many Jedi suspected that Qui-Gon was a trick of the Sith when Yoda heard him.


Q:

Would an expression tree work here?

I have the below method that I currently use to get the DB length of certain string fields (each property has an attribute called MetaDataFieldAttribute). It seems to work nicely however it's very 'stringly' typed with the property name.
     public static void Main(string[] args)
        {
            ...
            obj.PropertyName = str.TrimIfRequired(obj, "PropertyName");
        }

        public static string TrimIfRequired(this string str, object obj, string property)
        {
            var pi = obj.GetType().GetProperty(property);
            var attribute = pi.GetCustomAttributes<MetaDataFieldAttribute>().FirstOrDefault();
            if (attribute == null) return str;

            int length = attribute.Precision;
            return str.Length > length ? str.Substring(0, length) : str;
        }

I have a fairly basic understanding of expression trees, and my initial thought is that I could make the object/parameter of the method strongly typed rather than just passing through the string. Is this possible?

A:

Yeah, you can use Expressions here just to get strong typing for property names, so instead of writing property name as string, you can use expression with property access, and then code will get MemberInfo item for specific property from expression and will get attribute from here. So if you change propertyName in the future, this part won't compile as it will be strong typed.
here is working sample on .NetFiddle - https://dotnetfiddle.net/qYOfhE
And here is the code itself:
using System;
using System.Linq;
using System.Linq.Expressions;

public class Program
{
    public static void Main(string[] args)
    {
        var str = "TestTestTest";

        var propertyName = str.TrimIfRequired<Customer>((c) => c.FirstName);
        var propertyNameValue = str.TrimIfRequired<Customer>((c) => c.Age);
        Console.WriteLine(propertyName);
        Console.WriteLine(propertyNameValue);
    }
}

public static class Extensions
{
    public static string TrimIfRequired<T>(this string str, Expression<Func<T, object>> expr)
    {
        var me = expr.Body as MemberExpression;
        if (me == null && expr.Body is UnaryExpression)
        {
            me = ((UnaryExpression) expr.Body).Operand as MemberExpression;
        }

        if (me == null)
        {
            throw new ArgumentException("Invalid expression. It should be MemberExpression");
        }

        var pi = me.Member;
        var attribute = pi.GetCustomAttributes(typeof(MetaDataFieldAttribute), false).FirstOrDefault() as MetaDataFieldAttribute;
        if (attribute == null) return str;

        int length = attribute.Precision;
        return str.Length > length ? str.Substring(0, length) : str;
    }
}

public class Customer
{
    [MetaDataField(Precision = 6)]
    public string FirstName { get; set; }

    [MetaDataField(Precision = 2)]
    public int Age { get; set; }
}

public class MetaDataFieldAttribute : Attribute
{
    public int Precision { get; set; }
}


Q:

How to properly transform UIView's scale on UIScrollView movement

To have a similar effect to Snapchat's HUD movement, I have created a movement of the HUD elements based on UIScollView's contentOffset. Edit: Link to the Github project.
func scrollViewDidScroll(_ scrollView: UIScrollView) {
    self.view.layoutIfNeeded()

    let factor = scrollView.contentOffset.y / self.view.frame.height

    self.transformElements(self.playButton,
                           0.45 + 0.55 * factor, // 0.45 = desired scale + 0.55 = 1.0 == original scale
                           Roots.screenSize.height - 280, // 280 == original Y
                           Roots.screenSize.height - 84, // 84 == minimum desired Y
                           factor)
}

func transformElements(_ element: UIView?,
                       _ scale: CGFloat,
                       _ originY: CGFloat,
                       _ desiredY: CGFloat,
                       _ factor: CGFloat) {
    if let e = element {
        e.transform = CGAffineTransform(scaleX: scale, y: scale) // this line lagging

        let resultY = desiredY + (originY - desiredY) * factor
        var frame = e.frame
        frame.origin.y = resultY
        e.frame = frame
    }
}

With this code implemented the scroll as well as the transition appeared to be "laggy"/not smooth. (Physical iPhone 6S+ and 7+).
Deleting the following line: e.transform = CGAffineTransform(scaleX: scale, y: scale) erased the issue. The scroll as well as the Y-movement of the UIView object is smooth again.
What's the best approach to transform the scale of an object?

There are no Layout Constraints.
func setupPlayButton() {
        let rect = CGRect(x: Roots.screenSize.width / 2 - 60,
                          y: Roots.screenSize.height - 280,
                          width: 120,
                          height: 120)
        self.playButton = UIButton(frame: rect)
        self.playButton.setImage(UIImage(named: "playBtn")?.withRenderingMode(.alwaysTemplate), for: .normal)
        self.playButton.tintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        self.view.addSubview(playButton)
}

A:

This is happening because you are applying both: transform and frame. It will be smoother, if you apply only transform. Update your transformElements function as below:
    func transformElements(_ element: UIView?,
                       _ scale: CGFloat,
                       _ originY: CGFloat,
                       _ desiredY: CGFloat,
                       _ factor: CGFloat) {
    if let e = element {
        e.transform = CGAffineTransform(scaleX: scale, y: scale).translatedBy(x: 0, y: desiredY * (1 - factor))

    }
}


Q:

Is there an idiom for indicating that someone is overly serious about a particular situation?

I am wondering if there's an idiom for indicating or suggesting that a person is overly serious about a particular situation.
For example, let's say some friends are caught inside a small lodge due to heavy rains, and someone starts screaming and loses composure over it as if they were going to die. What idiom would you use to indicate that that person is being overly serious about that particular situation?

A:

You're being overly dramatic.

... meaning, "You're being much more emotional than the situation calls for." This may be said to a child who is throwing a tantrum.

You're being a drama queen.

This is similar to the above, but is typically used only in jest with a friend. I would not recommend that a man say this to a woman, nor a woman to a man, due to the gender polarization of the statement.
I wouldn't say either of these to someone who wasn't a close friend, as it's generally not socially acceptable to judge someone else's emotional responses to a situation.


Q:

CCMenuItemLabelAndSprite and CCSprite from CCSpriteBatchNode

I'm trying to create some Menu Item with Image & Label, using barry's class
    CGRect menuItemRect = CGRectFromString([[myAtlas objectForKey:@"menuItem.png"] objectForKey:@"textureRect"]);
    CCSprite *normalMenuItemSprite = [CCSprite spriteWithBatchNode:batchNode rect:menuItemRect];
    CCSprite *selectedMenuItemSprite = [CCSprite spriteWithBatchNode:batchNode rect:menuItemRect];

    CCMenuItemLabelAndSprite *aMenuItem = [CCMenuItemLabelAndSprite itemWithLabel:itemLabel normalSprite:normalMenuItemSprite selectedSprite:selectedMenuItemSprite];

    CCMenu *myMenu = [CCMenu menuWithItems:aMenuItem, nil];
    myMenu.anchorPoint = ccpzero;
    myMenu.position = ccp(330,280);
    [myMenu alignItemsHorizontallyWithPadding:100];
    [self addChild:myMenu];

If CCSprite is being rendered by CCSpriteBatchNode, CCSprite#draw SHOULD NOT be called is the error that shows up in my log
I know that I can't add any others objects beside CCSprites to CCSpriteBatchNode but how can I deal with this situation ?

A:

Try using spriteWithSpriteFrameName
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"myAtlas.plist"];

CCSprite *normalMenuItemSprite = [CCSprite spriteWithSpriteFrameName:@"menuItem.png"];


Q:

Div inside body not filling 100%

I have a webpage which has a large amount of unused space at the bottom of the body which I am unable to get rid of.
The body content is not filling 100% of the outer body.
I have tried most things in an attempt to fix this but nothing works - these include setting html, body to height: 100% and body to min-height: 100%.
I've also made the body content to 100% but the content will not fill the body. Hopefully someone can help!
html, body{
        margin: 0;
        padding: 0;
        height: 100%;
    }

    html {

        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
    }

    body {
        background-color: #3BB9C5;
        position: absolute;
        min-height: 100%;
        top: 0;
        bottom: 0;
        right: 0;
        left: 0;
    }

A:

body, html{
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}
body{
    background: #3BB9C5;
}
div{
    height: 100%;
}

sample text

This should help


Q:

Do we need to check CRUD permissions on custom metadata type/custom setting to pass the AppExchange security review

I have an application that we need to upload on AppExchnage but we need to pass the security review so I have a query on the custom metadata type so do we need to check the isAccessible() permission for this or we don't need to check this.

A:

The short answer is: No, you don't need to check Field Accessibility for Custom Metadata Types.
To expand on this a bit: There is no watertight documentation on this, but the ISVForce Guide does talk you through the steps of the security review here: https://developer.salesforce.com/docs/atlas.en-us.packagingGuide.meta/packagingGuide/security_review.htm?search_text=security%20scanner
The part where they look at whether you're using the required Field Accessibility checks is the code scanner step. You can find the code scanner here: https://security.secure.force.com/sourcescanner/
I've used this code scanner against the Managed Package I've worked on and it doesn't throw errors for missing Field Accessibility checks for Custom Metadata Types. In other words: When the Security Review team runs the code scanner, it will not flag this up for them either.
The best way to confirm that this is the case for your Managed Package too is to run the code scanner yourself and confirm that no errors show up for you either! :-)


Q:

Installing psycopg2 for python 3

I am having trouble installing psycopg2 on my Mac with pip.
pip3 install psycopg2
sudo pip3 install psycopg2
pip install flask-sqlalchemy psycopg2
sudo easy_install psycopg2

I have tried every solution I can find, yet every time I get the same error:
Collecting psycopg2
Using cached psycopg2-2.6.2.tar.gz
Installing collected packages: psycopg2
  Running setup.py install for psycopg2 ... error
    Complete output from command /usr/local/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/mn/t5nqmwlj5wb99lyzrkq_d0qc0000gn/T/pip-build-darwcjmh/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/mn/t5nqmwlj5wb99lyzrkq_d0qc0000gn/T/pip-eqwp14v4-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.6-intel-3.5
    creating build/lib.macosx-10.6-intel-3.5/psycopg2
    copying lib/__init__.py -> build/lib.macosx-10.6-intel-3.5/psycopg2
    copying lib/_json.py -> build/lib.macosx-10.6-intel-3.5/psycopg2
    copying lib/_range.py -> build/lib.macosx-10.6-intel-3.5/psycopg2
    copying lib/errorcodes.py -> build/lib.macosx-10.6-intel-3.5/psycopg2
    copying lib/extensions.py -> build/lib.macosx-10.6-intel-3.5/psycopg2
    copying lib/extras.py -> build/lib.macosx-10.6-intel-3.5/psycopg2
    copying lib/pool.py -> build/lib.macosx-10.6-intel-3.5/psycopg2
    copying lib/psycopg1.py -> build/lib.macosx-10.6-intel-3.5/psycopg2
    copying lib/tz.py -> build/lib.macosx-10.6-intel-3.5/psycopg2
    creating build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/__init__.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/dbapi20.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/dbapi20_tpc.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_async.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_bug_gc.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_bugX000.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_cancel.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_connection.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_copy.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_cursor.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_dates.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_errcodes.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_extras_dictcursor.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_green.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_lobject.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_module.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_notify.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_psycopg2_dbapi20.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_quote.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_transaction.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_types_basic.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_types_extras.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/test_with.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/testconfig.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    copying tests/testutils.py -> build/lib.macosx-10.6-intel-3.5/psycopg2/tests
    Skipping optional fixer: buffer
    Skipping optional fixer: idioms
    Skipping optional fixer: set_literal
    Skipping optional fixer: ws_comma
    running build_ext
    building 'psycopg2._psycopg' extension
    creating build/temp.macosx-10.6-intel-3.5
    creating build/temp.macosx-10.6-intel-3.5/psycopg
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.6-intel-3.5/psycopg/psycopgmodule.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/green.c -o build/temp.macosx-10.6-intel-3.5/psycopg/green.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/pqpath.c -o build/temp.macosx-10.6-intel-3.5/psycopg/pqpath.o
    psycopg/pqpath.c:198:17: warning: implicit conversion from enumeration type 'ConnStatusType' to different enumeration type 'ExecStatusType' [-Wenum-conversion]
                    PQstatus(conn->pgconn) : PQresultStatus(*pgres)));
                    ^~~~~~~~~~~~~~~~~~~~~~
    psycopg/pqpath.c:1628:17: warning: implicit conversion from enumeration type 'ConnStatusType' to different enumeration type 'ExecStatusType' [-Wenum-conversion]
                    PQstatus(curs->conn->pgconn) : PQresultStatus(curs->pgres)));
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    2 warnings generated.
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/utils.c -o build/temp.macosx-10.6-intel-3.5/psycopg/utils.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/bytes_format.c -o build/temp.macosx-10.6-intel-3.5/psycopg/bytes_format.o
    In file included from psycopg/bytes_format.c:81:
    In file included from ./psycopg/psycopg.h:33:
    ./psycopg/config.h:71:13: warning: unused function 'Dprintf' [-Wunused-function]
    static void Dprintf(const char *fmt, ...) {}
                ^
    1 warning generated.
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/connection_int.c -o build/temp.macosx-10.6-intel-3.5/psycopg/connection_int.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/connection_type.c -o build/temp.macosx-10.6-intel-3.5/psycopg/connection_type.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/cursor_int.c -o build/temp.macosx-10.6-intel-3.5/psycopg/cursor_int.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/cursor_type.c -o build/temp.macosx-10.6-intel-3.5/psycopg/cursor_type.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/diagnostics_type.c -o build/temp.macosx-10.6-intel-3.5/psycopg/diagnostics_type.o
    In file included from psycopg/diagnostics_type.c:27:
    In file included from ./psycopg/psycopg.h:33:
    ./psycopg/config.h:71:13: warning: unused function 'Dprintf' [-Wunused-function]
    static void Dprintf(const char *fmt, ...) {}
                ^
    1 warning generated.
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/error_type.c -o build/temp.macosx-10.6-intel-3.5/psycopg/error_type.o
    In file included from psycopg/error_type.c:27:
    In file included from ./psycopg/psycopg.h:33:
    ./psycopg/config.h:71:13: warning: unused function 'Dprintf' [-Wunused-function]
    static void Dprintf(const char *fmt, ...) {}
                ^
    1 warning generated.
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/lobject_int.c -o build/temp.macosx-10.6-intel-3.5/psycopg/lobject_int.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/lobject_type.c -o build/temp.macosx-10.6-intel-3.5/psycopg/lobject_type.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/notify_type.c -o build/temp.macosx-10.6-intel-3.5/psycopg/notify_type.o
    In file included from psycopg/notify_type.c:27:
    In file included from ./psycopg/psycopg.h:33:
    ./psycopg/config.h:71:13: warning: unused function 'Dprintf' [-Wunused-function]
    static void Dprintf(const char *fmt, ...) {}
                ^
    1 warning generated.
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/xid_type.c -o build/temp.macosx-10.6-intel-3.5/psycopg/xid_type.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/adapter_asis.c -o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_asis.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/adapter_binary.c -o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_binary.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/adapter_datetime.c -o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_datetime.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/adapter_list.c -o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_list.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/adapter_pboolean.c -o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_pboolean.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/adapter_pdecimal.c -o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_pdecimal.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/adapter_pint.c -o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_pint.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/adapter_pfloat.c -o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_pfloat.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/adapter_qstring.c -o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_qstring.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/microprotocols.c -o build/temp.macosx-10.6-intel-3.5/psycopg/microprotocols.o
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/microprotocols_proto.c -o build/temp.macosx-10.6-intel-3.5/psycopg/microprotocols_proto.o
    In file included from psycopg/microprotocols_proto.c:27:
    In file included from ./psycopg/psycopg.h:33:
    ./psycopg/config.h:71:13: warning: unused function 'Dprintf' [-Wunused-function]
    static void Dprintf(const char *fmt, ...) {}
                ^
    1 warning generated.
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090504 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.5.4/include -I/usr/local/Cellar/postgresql/9.5.4/include/server -c psycopg/typecast.c -o build/temp.macosx-10.6-intel-3.5/psycopg/typecast.o
    psycopg/typecast.c:494:5: warning: incompatible pointer types initializing 'PyAsyncMethods *' with an expression of type 'int (PyObject *, PyObject *)' (aka 'int (struct _object *, struct _object *)') [-Wincompatible-pointer-types]
        typecast_cmp, /*tp_compare*/
        ^~~~~~~~~~~~
    1 warning generated.
    /usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g -Qunused-arguments -Qunused-arguments build/temp.macosx-10.6-intel-3.5/psycopg/psycopgmodule.o build/temp.macosx-10.6-intel-3.5/psycopg/green.o build/temp.macosx-10.6-intel-3.5/psycopg/pqpath.o build/temp.macosx-10.6-intel-3.5/psycopg/utils.o build/temp.macosx-10.6-intel-3.5/psycopg/bytes_format.o build/temp.macosx-10.6-intel-3.5/psycopg/connection_int.o build/temp.macosx-10.6-intel-3.5/psycopg/connection_type.o build/temp.macosx-10.6-intel-3.5/psycopg/cursor_int.o build/temp.macosx-10.6-intel-3.5/psycopg/cursor_type.o build/temp.macosx-10.6-intel-3.5/psycopg/diagnostics_type.o build/temp.macosx-10.6-intel-3.5/psycopg/error_type.o build/temp.macosx-10.6-intel-3.5/psycopg/lobject_int.o build/temp.macosx-10.6-intel-3.5/psycopg/lobject_type.o build/temp.macosx-10.6-intel-3.5/psycopg/notify_type.o build/temp.macosx-10.6-intel-3.5/psycopg/xid_type.o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_asis.o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_binary.o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_datetime.o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_list.o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_pboolean.o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_pdecimal.o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_pint.o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_pfloat.o build/temp.macosx-10.6-intel-3.5/psycopg/adapter_qstring.o build/temp.macosx-10.6-intel-3.5/psycopg/microprotocols.o build/temp.macosx-10.6-intel-3.5/psycopg/microprotocols_proto.o build/temp.macosx-10.6-intel-3.5/psycopg/typecast.o -L/usr/local/lib -lpq -lssl -lcrypto -o build/lib.macosx-10.6-intel-3.5/psycopg2/_psycopg.cpython-35m-darwin.so
    ld: library not found for -lssl
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command '/usr/bin/clang' failed with exit status 1

    ----------------------------------------
Command "/usr/local/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/mn/t5nqmwlj5wb99lyzrkq_d0qc0000gn/T/pip-build-darwcjmh/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/mn/t5nqmw

Has anyone else ran into this or have a solution to this issue?

A:

Probably, you didn't re-install xcode after upgrading?
xcode-select --install