Skip to content

Instantly share code, notes, and snippets.

/*
* // https://cdpn.io/zaydek/debug/qBEqJaa/PNkvYKyZnVqA
* const fontSizes = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
* for (const fontSize of fontSizes) {
* const em = (1 - fontSize / 16) / 20
* console.log(`[style*="font-size: ${fontSize}px"] { letter-spacing: ${em}em; }`)
* }
*/
[style*="font-size: 10px"]:not([style*="font-family"]) { letter-spacing: 0.01875em; }
[style*="font-size: 11px"]:not([style*="font-family"]) { letter-spacing: 0.015625em; }
// Compound component.
//
// https://codepen.io/zaydek/pen/PowjgOg
const CodeBlock = props => (
<div style={stylex.parse("p-y:16 b:gray-100 br:8 overflow -x:scroll")}>
{props.children.map((each, index) => (
<code key={each.key} style={{ ...stylex.parse("p-x:16 inline-block"), minWidth: "100%", ...codeLineStyle }}>
<Syntax
start={!index && props.open}
end={index + 1 === props.children.length && "```"}
<snippet>
<content><![CDATA[
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
]]></content>
<tabTrigger>Lorem</tabTrigger>
</snippet>
package main
import (
"context"
"database/sql"
"encoding/base64"
"encoding/json"
"fmt"
"time"
package main
import "fmt"
var (
Blackf = newColorf("\033[1;30m%s\033[0m")
Redf = newColorf("\033[1;31m%s\033[0m")
Greenf = newColorf("\033[1;32m%s\033[0m")
Yellowf = newColorf("\033[1;33m%s\033[0m")
Purplef = newColorf("\033[1;34m%s\033[0m")
import React from "react"
const GraphQLContext = React.createContext()
const useQuery = (query, variables) => useQueryOrMutation(query, variables)
const useMutation = (query, variables) => useQueryOrMutation(query, variables)
function useQueryOrMutation(query, variables = {}) {
const { url, headers, credentials } = React.useContext(GraphQLContext)
let endpoint = "http://localhost:8000/graphql"
let headers = { "Content-Type": "application/json" }
let credentials = "same-origin"
function useQuery(query, variables = {}) {
const [loading, setLoading] = React.useState(false)
const [data, setData] = React.useState(null)
const [status, setStatus] = React.useState(0)
const [statusText, setStatusText] = React.useState("")
@zaydek-old
zaydek-old / init.sql
Created November 1, 2019 19:03
What I’ve learned so far using GraphQL + Postgres.
-- Postgres:
create extension pgcrypto;
create function gen_random_int(max int, out rand int) as $$
select floor(random() * max)::int + 1;
$$ language sql;
create function url62(out id text) as $$
declare
base text :=
package main
import (
"database/sql"
"encoding/json"
"fmt"
"log"
"github.com/graphql-go/graphql"
  • list
  • list