Skip to content

Instantly share code, notes, and snippets.

View jkriss's full-sized avatar

Jesse Kriss jkriss

View GitHub Profile
@jkriss
jkriss / response.test.ts
Created July 15, 2020 03:01
deno response test
import {
assert,
assertEquals,
} from "https://deno.land/std/testing/asserts.ts";
// this passes
Deno.test("should be able to get text and body from a text response", async () => {
const res = new Response('hi')
assert(res.body)
assertEquals(await res.text(), 'hi')
@jkriss
jkriss / pre-commit
Last active September 29, 2022 03:53
pre-commit hook for deno fmt formatting
#!/bin/sh
FILES=$(deno fmt)
if [ -n "$FILES" ]; then
echo "formatted, adding files $FILES"
echo "$FILES" | xargs git add
fi
exit 0
@jkriss
jkriss / index.html
Last active July 3, 2020 06:13
Template stamping
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>template stamping</title>
</head>
<body>
<div id=one></div>
<div id=two></div>
@jkriss
jkriss / gist:5c74a285c8f2479fda4b79cc6ca4ef44
Created June 29, 2020 19:44
list flat dependencies from package.json
cat pacakge.json | jq -r '.dependencies|keys|join(" ")'
function createObjects (acc, p) {
// rel="next" => 1: rel 2: next
var m = p.match(/\s*(.+)\s*=\s*"?([^"]+)"?/)
if (m) acc[m[1]] = m[2]
return acc
}
function parseLink(link) {
try {
var m = link.match(/<?([^>]*)>(.*)/)
@jkriss
jkriss / index.js
Created January 11, 2019 21:29
Stable anonymized data
const faker = require('faker')
const adler32 = require('adler-32')
faker.seed(adler32.str('jesse@example.com'))
faker.internet.email() // always returns 'Otha_OConnell@yahoo.com'
faker.seed(adler32.str('jk@example.com'))
faker.internet.email() // always returns 'Deangelo_Powlowski89@yahoo.com'
@jkriss
jkriss / README.md
Last active May 7, 2018 16:19
Simple Google Forms petition

Setup

  1. Make sure your Google Form is set up to save results to spreadsheet
  2. Follow the instructions from Tabletop.js to make the spreadsheet loadable (short version: publish to web, then make it public with link).
  3. Copy the example below (you'll need the tabletop script tag, the embedded javascript below it, and an element with an id for displaying the signers)
  4. Change publicSpreadsheetUrl in the example above to use the share link for your spreadsheet
  5. Change nameField to be the name of the column you want to display
@jkriss
jkriss / index.html
Created June 15, 2017 00:44
CTA Aggregator api example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CTA Aggregator API example</title>
</head>
<body>
<pre id="events"></pre>
@jkriss
jkriss / fave.js
Created January 7, 2017 05:13
Quick way to generate a solid color data uri (say, for a favicon)
// modified version of https://github.com/CMTegner/favicolor
var size = 1;
var canvas = document.createElement('canvas');
if (typeof canvas.getContext === 'function') {
var ctx = canvas.getContext('2d');
canvas.width = size;
canvas.height = size;
}

Keybase proof

I hereby claim:

  • I am jkriss on github.
  • I am jkriss (https://keybase.io/jkriss) on keybase.
  • I have a public key whose fingerprint is FFFE 99AB E363 7EBE AEC0 A03B 3A8C 3222 4FB2 CC77

To claim this, I am signing this object: