🤓 Code Snippets

Share and store your most common code snippets. Use our snippet explanation generator to use AI to try and explain the code.

// This is how to replace the URL
window.location.replace("http://stackoverflow.com");

// This is how to change the URL
window.location.href = "http://stackoverflow.com";

Tony Lea

2 years ago

$ git commit -m "Something terribly misguided" # (0: Your Accident)
$ git reset HEAD~                              # (1)
[ edit files as necessary ]                    # (2)
$ git add .                                    # (3)
$ git commit -c ORIG_HEAD                      # (4)

Tony Lea

2 years ago

document.getElementById("demo");

Tony Lea

2 years ago

Route::view('/welcome', 'welcome');

Route::view('/welcome', 'welcome', ['name' => 'Taylor']);

Tony Lea

2 years ago

function getMeta(metaName) {
  const metas = document.getElementsByTagName('meta');

  for (let i = 0; i < metas.length; i++) {
    if (metas[i].getAttribute('name') === metaName) {
      return metas[i].getAttribute('content');
    }
  }

  return '';
}

console.log(getMeta('video'));

Tony Lea

2 years ago

Load More