Live data from Hacker News

I figured out how to get GitHub Copilot to run in the terminal

github.com

41–50 of 105 posts

Re: I figured out how to get GitHub Copilot to run in the terminal

#41
post #38
post #35

Earlier quoted context omitted.

Why? Wiki doesn't say anything about it and when I run it, the result looks fine > $ for((i=1;i > rand.txt ; done > $ cat rand.txt | sort | uniq -c 1051 1 932 10 1012 2 1042 3 983 4 1015 5 1042 6 1035 7 992 8 995 9

`cat /dev/urandom | od -N 1 -An -i` gives you a uniform random number between 0 and 255. The following mod 10 in the awk command introduces "modulo bias", which you can read about here https://research.kudelskisecurity.com/2020/07/28/the-definit... You can see it quite intuitively if you iterate over all possible numbers between 0 and 255: $ (for i in {0..255}; do; echo $i | awk '{print $1 % 10 + 1}'; done) | sort -n…

But that is not how /dev/(u)random works and does not give U(255). Generally speaking, it gives some hash of some user/device activity, from these resources:

https://linuxhint.com/dev_random_vs_dev_urandom/

https://en.wikipedia.org/wiki//dev/random

Re: I figured out how to get GitHub Copilot to run in the terminal

#42
post #41
post #38

Earlier quoted context omitted.

`cat /dev/urandom | od -N 1 -An -i` gives you a uniform random number between 0 and 255. The following mod 10 in the awk command introduces "modulo bias", which you can read about here https://research.kudelskisecurity.com/2020/07/28/the-definit... You can see it quite intuitively if you iterate over all possible numbers between 0 and 255: $ (for i in {0..255}; do; echo $i | awk '{print $1 % 10 + 1}'; done) | sort -n…

But that is not how /dev/(u)random works and does not give U(255). Generally speaking, it gives some hash of some user/device activity, from these resources: https://linuxhint.com/dev_random_vs_dev_urandom/ https://en.wikipedia.org/wiki//dev/random

I know how urandom works (consider reading the articles you linked). The number between 0 and 255 is produced by the `od` command:

https://man7.org/linux/man-pages/man1/od.1.html

Re: I figured out how to get GitHub Copilot to run in the terminal

#43
post #37
post #17

By the way, the example snippet given to "echo a random number between 1 and 10" is incorrect, pedantically speaking. It's random, but not uniformly so. It's biased towards lower numbers (1-6).

Could someone explain how? I don't grok the command. My best guess is this relates to hexadecimal.

`od -N 1 -An -i` reads one byte from stdin (urandom in this case) and prints it as a decimal string (with value between 0 and 255). The awk command receives that number and prints it back out modulo 10.

Re: I figured out how to get GitHub Copilot to run in the terminal

#44
It’s generally claimed that reading other people’s code is harder than writing your own. I mean, everybody loves writing code on a greenfield project but hates maintenance of legacy code, right? So, why do people like these code generators? The only explanation I can see is that people use them and then don’t read the code. Which would be horrifying.

(I stay away for obvious copyright reasons.)

Re: I figured out how to get GitHub Copilot to run in the terminal

#45
post #35
post #17

By the way, the example snippet given to "echo a random number between 1 and 10" is incorrect, pedantically speaking. It's random, but not uniformly so. It's biased towards lower numbers (1-6).

Why? Wiki doesn't say anything about it and when I run it, the result looks fine > $ for((i=1;i > rand.txt ; done > $ cat rand.txt | sort | uniq -c 1051 1 932 10 1012 2 1042 3 983 4 1015 5 1042 6 1035 7 992 8 995 9

If you sum the occurrences of numbers 1-6, you get 1051 + 1012 + 1042 + 983 + 1015 + 1042 = 6145. The expected count (if the numbers were uniformly random) is only 6000, on average. If you repeat your experiment, you will find that this sum is greater than 6000 more often than not.

Re: I figured out how to get GitHub Copilot to run in the terminal

#46

This is really cool! Here's an example of using emacs to do it. Uses tabnine for real time completion, and Copilot/Codex for more advance completions. https://semiosis.github.io/posts/nlsh-plus-tabnine-real-time... It uses NLSH and Cterm. https://semiosis.github.io/nlsh/ https://semiosis.github.io/cterm/

I just did an exposision of a bunch of them.

https://mullikine.github.io/posts/ai-terminals/

Also, there is ii, the fully imaginary interpreter

Re: I figured out how to get GitHub Copilot to run in the terminal

#47
post #44

It’s generally claimed that reading other people’s code is harder than writing your own. I mean, everybody loves writing code on a greenfield project but hates maintenance of legacy code, right? So, why do people like these code generators? The only explanation I can see is that people use them and then don’t read the code . Which would be horrifying. (I stay away for obvious copyright reasons.)

> So, why do people like these code generators?

To cover the lack of good libraries and/or language abstractions.

Re: I figured out how to get GitHub Copilot to run in the terminal

#48
post #44

It’s generally claimed that reading other people’s code is harder than writing your own. I mean, everybody loves writing code on a greenfield project but hates maintenance of legacy code, right? So, why do people like these code generators? The only explanation I can see is that people use them and then don’t read the code . Which would be horrifying. (I stay away for obvious copyright reasons.)

I think many people see GitHub Copilot as a code generator, without having used it, and then wonder like you.

But afaik almost everybody uses it as autocomplete on steroids.

So the reasoning behind using it is the exact same as using autocomplete in I.e. Intellij.

It's just slightly more powerful, since it will usually autocomplete the whole line (occasionally a bit more), instead of just the current keyword.

Re: I figured out how to get GitHub Copilot to run in the terminal

#49
post #37
post #17

By the way, the example snippet given to "echo a random number between 1 and 10" is incorrect, pedantically speaking. It's random, but not uniformly so. It's biased towards lower numbers (1-6).

Could someone explain how? I don't grok the command. My best guess is this relates to hexadecimal.

The calculation maps a random number R in range 0..255 to numbers 1..10 via

    R % 10 + 1
The problem is that 10 does not evenly divide 256, hence for large R, the mapping will be incomplete. Specifically,

    250 => 1
    251 => 2
    252 => 3
    253 => 4
    254 => 5
    255 => 6
with no more random numbers available to yield results 7, 8, 9 and 10.

Re: I figured out how to get GitHub Copilot to run in the terminal

#50
post #44

It’s generally claimed that reading other people’s code is harder than writing your own. I mean, everybody loves writing code on a greenfield project but hates maintenance of legacy code, right? So, why do people like these code generators? The only explanation I can see is that people use them and then don’t read the code . Which would be horrifying. (I stay away for obvious copyright reasons.)

It is absolutely amazing for writing boilerplate code that is also context aware. It saves me hours of typing. It's hard to explain if you've never tried it because you're ideologically opposed to it, but stop being close minded and try it out, I promise it's a great tool to assist your programming.
Post reply on HN