Skip to content

Instantly share code, notes, and snippets.

Avatar

Glen Maddern geelen

View GitHub Profile
@geelen
geelen / idea.md
Last active Jun 11, 2020
Cracking the Cryptic webapp helper
View idea.md

Cracking the Cryptic sudoku webapp helper

This just detects if you've made a clear error as you're solving something (only looks at the basic sudoku rules, nothing fancy):

image

To install, just open your developer console (⌘⇧I or Cmd Shift I, then select console) and paste in the source code below:

@geelen
geelen / a.md
Last active May 29, 2020
(all night) Long HTTP Request demo
View a.md

Example of FAB streaming.

  1. Open https://www.youtube.com/watch?v=nqAvFx3NxUM
  2. Paste the following in the terminal:
curl "https://despacito.glen.workers.dev/?https://gist.githubusercontent.com/geelen/779758741e57f717a93e7bff7f2a6c5f/raw/ac8eb260f7fd2130ff5b648b91924ce1262262b0/lyrics.vtt"
  1. About 11 seconds into the video, hit enter.
@geelen
geelen / traits.ts
Created Apr 7, 2020
ARGH TYPESCRIPT WHY WONT YOU OBEY ME
View traits.ts
import { css } from 'styled-components'
type RulesDefn = {
[k: string]: string
}
type TrainBuilder<T extends RulesDefn> = {
[k in keyof T]: TrainBuilder<T>
} & {
toString: () => string[]
@geelen
geelen / input.js
Created Dec 9, 2019
Proxy memo async
View input.js
const someExpensiveOperation = async x => {
await new Promise(resolve => setTimeout(resolve, 1000))
return x.toUpperCase()
}
const PROXY_MEMO = Object.create(
new Proxy(
{},
{
get(_, handler) {
View gist:127e1e9dbeee080f00bbddba4b2f8182
type Query = {
book(id: ID!): Book!
author(id: ID!): Author!
}
type Book = {
id: ID!
name: String
author: Author
}
View lambda@edge vs cloudflare workers.sh
root@vps190992:~/go/bin# ./hey https://serverless-ssr.now.sh/ssr/preact
Summary:
Total: 14.7408 secs
Slowest: 6.9887 secs
Fastest: 0.2357 secs
Average: 1.9901 secs
Requests/sec: 13.5678
View giftunnel.js
(async () => {
const rows = 44
const cols = 36
const fps = 12
const gif = "http://i.imgur.com/ifR7csn.gif"
const rotate = false
const mirror = false
const vertmirror = false
document.body.innerHTML = ''
View idontwanttolosethis.js
(async () => {
const cols = 44
const rows = 36
const size = 90
const speedX = 0.02
const speedY = 0.0
const loadImage = url => {
const img = document.createElement('img')
View chain.js
const chain = rules => {
class ChainLink {
constructor(rules) {
this.rules = rules;
}
toString() {
return this.rules
}
}
@geelen
geelen / _.md
Last active Mar 1, 2019
Sync a document from Bear Writer's DB to a file on disk
View _.md

Sync a document from Bear Writer's DB to a file on disk

I really like Bear Writer's interface, but it stores all its notes in an SQLite DB. I spent ages rigging up a nice Markdown + Webpack pipeline for a React blog before I realised this, and rather than admit my mistake, potentially pushing forward to concentrate on the content rather than procrastinating on the pipeline, I built this.

Screenshot showing copying the doc id

Grab the Document ID from Bear, then run:

yarn add sqlite3 untildify
You can’t perform that action at this time.