Skip to content

Instantly share code, notes, and snippets.

@tj
tj / enums.go
Last active August 19, 2020 18:40
type User enum {
Authenticated struct {
Name string
}
Anonymous struct {}
}
// and/or
type Authenticated struct {
input[type="search"]::-webkit-search-cancel-button {
--size: 11px;
--background: #7F7F7F;
--icon: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI3IiBoZWlnaHQ9IjciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjMiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgY2xhc3M9ImZlYXRoZXIgZmVhdGhlci14Ij48cGF0aCBkPSJNMTggNkw2IDE4TTYgNmwxMiAxMiIvPjwvc3ZnPgo=");
-webkit-appearance: none;
height: var(--size);
width: var(--size);
border-radius: 50%;
background: var(--background) var(--icon) 50% 50% no-repeat;
}
input[type="search"]::-webkit-search-cancel-button {
--size: 11px;
--background: #7F7F7F;
--icon: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI3IiBoZWlnaHQ9IjciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjMiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgY2xhc3M9ImZlYXRoZXIgZmVhdGhlci14Ij48cGF0aCBkPSJNMTggNkw2IDE4TTYgNmwxMiAxMiIvPjwvc3ZnPgo=");
-webkit-appearance: none;
height: var(--size);
width: var(--size);
border-radius: var(--size);
background: var(--background) var(--icon) 50% 50% no-repeat;
}
@tj
tj / lambda.md
Last active May 29, 2020 16:06
Lambda proposal

The goal is for the next version of Up to provide all of the runtimes which Lambda already supports. Up lets users write regular HTTP servers, using any framework they prefer. Up works by translating Lambda events to and from HTTP requests, using a Go proxy inside of the Lambda.

Currently Lambda imposes limitations which prevent this from working well with all runtimes, since the Go proxy needs to be the handler, while the runtime files/interpreters still need to be present.

I see two solutions to this problem, the first is to expose the existing runtimes as layers, allowing the proxy to live in a "provided" runtime, but still reference the others for their files. The second is to allow layers to act as the entrypoint/bootstrap, while still allowing the user to select an existing runtime as they normally would, just giving precedence to the layer.

Thanks!

@tj
tj / remap.sh
Created March 4, 2020 13:31
Remap tilde and left shift on a UK keyboard
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x7000000E1}, {"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}]}'
cat << 'EOF' > ~/.keymappings && chmod +x ~/.keymappings
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x7000000E1}, {"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}]}'
EOF
sudo /usr/bin/env bash -c "cat > /Library/LaunchDaemons/org.custom.keymappings.plist" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@tj
tj / app.js
Last active October 4, 2021 19:38
const http = require('http')
const rpc = require('./rpc')
/**
* Pets service.
*/
class Pets {
constructor(db = []) {
@tj
tj / querying.md
Last active February 8, 2024 17:48
Querying for https://apex.sh/logs/

Apex Logs utilizes a purpose-built query language for searching and aggregating structured log events.

Events

An Apex Log event requires the following properties:

Name Type Description
id string The unique identifier of the event.
@tj
tj / asya
Created January 24, 2018 18:39
...e$e.$...e$ ...e$e.$...e
!$6lkasd!$6lkasd!$6l !$6lkasd!$6lkasd!
;,a1wert;,a1wert;,a1wert ;,a1wert;,a1wert;,a1we
.asxzcvb.asxzcvb.asxzcvb.as .asxzcvb.asxzcvb.asxzcvb.
1qaswedfqas1wedfqas1wedfqas1wedfqas1wedfqas1edfqas1ewdfqa
:lkjhgfdlkj:hgfdlkj:hgfdlkj:hgfdlkj:hgfdlkj:gfdhlkj:gfdhlk
3edcvfr4edc3vfr4edc3vfr4edc3vfr4edc3vfr4edc3fr4vedc3fr4ved
1234ewqa2341ewqa2341ewqa2341ewqa2341ewqa2341wqa2341weqa234
o[piuytr[piouytr[piouytr[piouytr[piouytr[pioytru[pioytru[p
z/xcvbnm/xczvbnm/xczvbnm/xczvbnm/xczvbnm/xczbnmv/xczbnmv/x
@tj
tj / in.go
Last active September 23, 2017 15:02
package main
func main() {
log := NewLogger()
log.Info("Foo")
log.Info("Bar")
log.Error("Boom")
}
func NewLogger() Logger {
@tj
tj / snippets.coffee
Last active September 1, 2018 19:01
Atom snippets for Go
'.source.go':
'Options':
'prefix': 'options'
'body': '''
// Option function.
type Option func(*$1)
// New with the given options.
func New(options ...Option) *$1 {