Skip to content

Instantly share code, notes, and snippets.

View s-taylor's full-sized avatar

Simon Taylor s-taylor

View GitHub Profile
@s-taylor
s-taylor / au.lua
Created June 23, 2022 05:27 — forked from numToStr/au.lua
Neovim autocmd in lua
--
-- Move this file to your neovim lua runtime path ie. ~/.config/nvim/lua/au.lua
--
local cmd = vim.api.nvim_command
local function autocmd(this, event, spec)
local is_table = type(spec) == 'table'
local pattern = is_table and spec[1] or '*'
local action = is_table and spec[2] or spec
if type(action) == 'function' then
@s-taylor
s-taylor / compile-alacritty-windows.md
Created May 15, 2020 06:44
How to compile Alacritty from source in Windows
@s-taylor
s-taylor / README.md
Created May 6, 2020 06:08 — forked from borekb/README.md
How to link to headings in GitHub issues and pull requests

How to link to headings in GitHub issues and pull requests

If you have an issue comment / PR description on GitHub, it doesn't automatically get anchors / IDs that you could link to:

Screenshot 2019-07-11 at 13

What I like to do is to add a visible # character like this:

Screenshot 2019-07-11 at 13 42 21

@s-taylor
s-taylor / example.js
Created September 27, 2017 22:54
Understanding async await - part 10
function fetchStuff(data) {
  try {
  const page = data.page;
return fetchResults(page)
 .then(res => res.results);
  } catch (err) {
  return Promise.reject(err);
  }
}
@s-taylor
s-taylor / example.js
Last active September 27, 2017 22:52
Understanding async await - part 9
async function fetchStuff(data) {
  const page = data.page;
const results = await fetchResults(page);
  return res.results;
}
fetchStuff()
.catch(err => { /* handle error here */ });
@s-taylor
s-taylor / example.js
Last active September 27, 2017 22:44
Understanding async await - part 8
function fetchStuff(data) {
  const page = data.page;
return fetchResults(page)
  .then(res => res.results);
}
fetchStuff()
.catch(err => { /* handle error here */ });
@s-taylor
s-taylor / example.js
Last active September 27, 2017 22:35
Understanding async await - part 7
async function someFunc () {
 // since we’re using await on someAsyncThing and the promise rejected
// this line will now throw it will throw `new Error('Boom')`
  const result = await someAsyncThing();
 // this line will not execute
 return result.value;
}
// externally we’ll get a rejected promise returned containing `Error('Boom')`
await someFunc();
// But since we’re using await here, the rejected promise gets turned back
@s-taylor
s-taylor / example.js
Last active September 27, 2017 22:25
Understanding async await - part 6
function () {
// someAsyncThing being a function that returns a promise
 return someAsyncThing()
 .then(result => result.value);
}
@s-taylor
s-taylor / example.js
Last active September 27, 2017 22:25
Understanding async await - part 5
async function () {
// someAsyncThing being a function that returns a promise
  const result = await someAsyncThing();
  return result.value;
}
@s-taylor
s-taylor / example.js
Created September 22, 2017 05:33
Understanding async await - part 4
throw new Error('Boom');