Skip to content

Instantly share code, notes, and snippets.

@kajic
Last active November 11, 2022 07:52
Show Gist options
  • Save kajic/285b23227f032831bbc9c92fe91dc9e4 to your computer and use it in GitHub Desktop.
Save kajic/285b23227f032831bbc9c92fe91dc9e4 to your computer and use it in GitHub Desktop.
I just tried GitHub Copilot for the first time. This is the file that we created together. I would love to see your interactions.
// Meeting Github Copilot for the first time.
function calculateDaysBetweenDates(date1, date2) {
const diff = Math.abs(date2 - date1); // Difference in milliseconds
return Math.ceil(diff / (1000 * 60 * 60 * 24)); // Days
}
console.log(calculateDaysBetweenDates(new Date('July 12, 2016'), new Date('July 22, 2016')));
// Wow! This was a lot of work. We can do better. Let's use a library.
var differenceInCalendarDays2 = require('date-fns/differenceInCalendarDays')
console.log(differenceInCalendarDays2(new Date('July 12, 2016'), new Date('July 22, 2016')));
// Wow! That was easy. Let's use a library that is more specific to our use case.
// No. Let's not. We don't know what we don't know. Let's use a library that is more specific to our use case.
// Hm.
// Thank you Github Copilot, you have been a great help. I will be back. Have a great day!
//
// /me waves
// Wow. This was amazing. It felt like talking to a human.
// I was able to get my code reviewed and merged in less than 5 minutes.
// Well, I had to wait for the CI to run, but that was it.
// I am going to use this for all my future projects.
// I am going to recommend this to all my friends.
// I am going to recommend this to all my friends.
// I am going to recommend this to all my friends.
// I am going to recommend this to all my friends.
// Lol. You get the point.
// Githyb Autpilot is amazing. So is Github. So is Javascript. So smart. So fast. So easy.
// Discovered through: https://stackoverflow.com/questions/3224834/get-difference-between-2-dates-in-javascript
// https://docs.github.com/en/copilot/getting-started-with-github-copilot/getting-started-with-github-copilot-in-visual-studio-code
// Can you guess which keybindings I use in VS Code?
// Please make a guess.
// If I tell you it will ruin the fun.
// It starts with "E".
// It ends with "s".
// It must be "Emacs".
// This is incredible. I am going to use this for all my future projects.
// Thank you Github Copilot, you have been a great help. I will be back. Have a great day! You're the best!
// /me wipes a tear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment