Skip to content

Instantly share code, notes, and snippets.

const fetch = require('node-fetch')
const gistIds = [
'221',
'218',
'214',
'213',
'209',
'207',
'203',
// node
fetch('https://api.github.com/rate_limit', {headers: {Authorization: 'Basic ' + Buffer.from(`csszen:${process.env.GIST_TOKEN}`).toString('base64')}}).then(r => r.json).then(console.log)
// browser
fetch('https://api.github.com/rate_limit', {headers: {Authorization: 'Basic ' + btoa(`csszen:${token}`)}}).then(r => r.json()).then(console.log)
function toDataURL (src, callback, outputFormat) {
const img = new Image()
img.crossOrigin = 'Anonymous'
img.onload = function () {
const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d')
canvas.height = this.naturalHeight
canvas.width = this.naturalWidth
ctx.drawImage(this, 0, 0)
const dataURL = canvas.toDataURL(outputFormat)
@csszen
csszen / how-to-add-image-to-gist.md
Created April 14, 2021 03:54 — forked from mroderick/how-to-add-image-to-gist.md
How to add an image to a gist

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone git@gist.github.com:<hash>.git     # or with ssh