Live data from Hacker News

GitHub Copilot available for JetBrains and Neovim

github.com

141–150 of 446 posts

Re: GitHub Copilot available for JetBrains and Neovim

#141
post #95

Earlier quoted context omitted.

Yesterday, I was disgusted to see framers putting up a house that clearly plagiarized the entire internal structure of my own. Same joint interfaces, same structural idioms when dealing with things like staircases, windows, and rafters, same fasteners, same adhesives, even the building materials! Aside from the most general aspects of the layout, it was exactly the same right down to the inch! People have no professi…

That analogy only works if you designed/architected your own house.

It may work if you design/architect houses for clients.

Re: GitHub Copilot available for JetBrains and Neovim

#142
I have a few questions about copilot. I haven’t gotten a chance to use it yet.

Is it irrational that this makes me a little anxious about job security over the longterm? Idk why but this was my initial reaction when learning about this.

Given the scenario where copilot and its likes becomes used in a widespread manner. Can it be argued that this might improve productivity but stifle innovation?

Im pretty early in my career but the rate things are capable of changing soon doesn’t sit too well with me.

Re: GitHub Copilot available for JetBrains and Neovim

#143

Earlier quoted context omitted.

Bit of a dodgy way to form query parameters though. Other than for a quick script.

How so?

code lacks context sensitive escaping

  api_path = base_url + urllib.parse.urlencode({
    'action': action,
    'format': letThisBeVariable,
    ...
    'gscoord': str(latitude.value) + '|' + str(longitude.value)
  })
see: https://docs.python.org/3/library/urllib.parse.html#urllib.p...

Mantra: when inserting data into a context (like an url) escape the data for that context.

Re: GitHub Copilot available for JetBrains and Neovim

#144

Earlier quoted context omitted.

Bit of a dodgy way to form query parameters though. Other than for a quick script.

How so?

Concatenating strings for example. As shown, it's the query string equivalent of sql injection.

Use something like URLBuilder, or URIParams, or whatever your platform supports. Don't use string concatenation ever, if at all possible, and if not possible (wtf?), then at least escape strings.

Re: GitHub Copilot available for JetBrains and Neovim

#145

Earlier quoted context omitted.

Bit of a dodgy way to form query parameters though. Other than for a quick script.

How so?

the "nice" way of doing this would would be to create a list of your stringified arguments, mapped urlencoding over them, and then join them with the parameter separator. this ends up being resilient to someone adding something that ends up being incorrect, and makes explicit in the code what you're trying to do.

Re: GitHub Copilot available for JetBrains and Neovim

#146
post #43

I signed up for the copilot technical preview right after it was announced a few months ago, but I haven't gotten an invite yet while all my friends who signed up later did (I feel a bit left out). Is there any way to get an invite sooner? What am I doing wrong?

I said I use VSCode all the time, which I suspect is the reason I got access. (I never use VSCode.)

I said I use VSCode all the time and just got access, having signed up at the very beginning (I, in fact, use VSCode all the time.)

Re: GitHub Copilot available for JetBrains and Neovim

#147

Earlier quoted context omitted.

Bit of a dodgy way to form query parameters though. Other than for a quick script.

How so?

I usually try to avoid working with URLs as bare strings like this, both for readability and correctness (URL encoding is tricky). With ‘requests’ you can do something like pass a dictionary of your query params and it takes care of forming the actual request URL.

https://docs.python-requests.org/en/latest/user/quickstart/#...

Re: GitHub Copilot available for JetBrains and Neovim

#149

Earlier quoted context omitted.

Bit of a dodgy way to form query parameters though. Other than for a quick script.

How so?

It's much safer (i.e. fewer degrees of freedom for bugs to appear) to use f-strings in situations like this one.

One correlated but ancillary benefit, is that there are fewer variables to simulate the state for in your brain, while you're reading the code. You don't have to wonder if a variable is going to change on you, in-between when it is initialized and when it is used.

It's safer still to use a library (e.g. urllib3) that does encoding for you (allowing you to omit magic strings like `"%7C"` from the logic of this function alltogther).

Like GP said, very handy for one-off scripts or areas of your codebase where quality is "less important". I may be pedantic, but I wouldn't give this a pass on code review.

Re: GitHub Copilot available for JetBrains and Neovim

#150
post #76

Copilot is crazy. The other day, I was writing a Python function that would call a Wikipedia API. I pulled from the internet an example of a GET request, and pasted it as a comment in my code. # sample call: https://en.wikipedia.org/w/api.php?action=query&format=json&list=geosearch&gscoord=37.7891838%7C-122.4033522&gsradius=10000&gslimit=100 Then I defined a variable, base_url = "https://en.wikipedia.org/w/api.php?"…

Bit of a dodgy way to form query parameters though. Other than for a quick script.

I'm not against "copying" code. I just looked up "python build url query" The first link describes the `urllib.parse. urlencode` function which takes a dict.

So I would build the query like so:

    from urllib.parse import urlencode
    urlencode({
        "action": "query",
        "format": "json",
        ...
        "gscoord": f"{str(latitude.value)}|{str(longitude.value)}",
    })
I think this is orders of magnitude clearer code. But that's a parameter that's subjective that CoPilot can't adjust for (although it can be better).
Post reply on HN