This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ref = useRef(null) | |
useEffect( | |
useCallback(() => { | |
console.log(ref.current) | |
}, [ref]) | |
) | |
// useEffect(() => { | |
// console.log(ref.current) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es5", | |
"lib": [ | |
"dom", | |
"dom.iterable", | |
"esnext" | |
], | |
"allowJs": true, | |
"skipLibCheck": true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an example of a simple web app that uses a reducer via @pelotom's useMethods package. | |
// | |
// What I want to be able to do is use immer.js so I can just mutate a cloned state and | |
// also dispatch async request to imitate web requests. | |
// What I've worked out is simple: I use the useMethods package and wrap it into a custom | |
// useCustomMethods function which returns the state and the methods with logging. | |
// Besides that I just have one async function that takes a method as its argument and pipes | |
// its arguments into the action. This is for mocking HTTP requests that are not synchronous in nature. | |
// | |
// Because use-methods.js uses immer.js under the hood, this seems to work well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"fmt" | |
"os" | |
"os/exec" | |
"os/signal" | |
"path/filepath" | |
"strings" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<!-- ... --> | |
</head> | |
<body> | |
<template class="codex-note-template"> | |
<p class="codex-note" data-note-id="%noteID%"> | |
<a href="/%noteID%">%title%</a> | |
<span style="color: hsl(0, 0%, 50%);">Edited %edited%</span> | |
<a class="delete-button" style="color: hsl(210, 100%, 62.5%);" href="#">Delete</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type voidSignal struct { | |
code int // The HTTP status code. | |
err error // The error. | |
desc string // The error's description. | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table users ( | |
user_id text not null unique default url62(), | |
email_address text not null check (email_address ~ '^[^\s\@]+\@[^\s\.]+\.[^\s]+$')); | |
create table billing ( | |
user_id text not null references users (user_id), | |
tier_id int not null references tiers (tier_id), | |
auto_renew bool not null, -- Not nullable because auto renew is exported. | |
balance money null, | |
stripe_customer_id text not null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package routes | |
import ( | |
"database/sql" | |
"api17/go/pg" | |
) | |
// VoidableTx is a voidable transaction. A transaction is | |
// voided when a method or closure emits a bad HTTP code and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CreateUser has the following responsibilities: | |
// | |
// 1. Validate the intent. | |
// 2. Hash the passphrase. | |
// 3. Charge the token. | |
// 4. Create a user. | |
// | |
// FIXME: Confirm the user. | |
func CreateUser(w http.ResponseWriter, r *http.Request, vars *Vars) { | |
intent := &CreateUserIntent{} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package router | |
import ( | |
"net/http" | |
"net/url" | |
"reflect" | |
"strings" | |
"api16/go/routes" | |
"api16/go/utils" |