Skip to content

Instantly share code, notes, and snippets.

Zaydek zaydek

Block or report user

Report or block zaydek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View inter.css
/*
* // 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; }
View CodeBlock.js
// 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 && "```"}
View lorem.sublime-snippet
<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>
View connection.go
package main
import (
"context"
"database/sql"
"encoding/base64"
"encoding/json"
"fmt"
"time"
View color.go
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")
View App.js
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)
View naiveUseQuery.js
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
zaydek / init.sql
Created Nov 1, 2019
What I’ve learned so far using GraphQL + Postgres.
View init.sql
-- 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 :=
View graphql.go
package main
import (
"database/sql"
"encoding/json"
"fmt"
"log"
"github.com/graphql-go/graphql"
You can’t perform that action at this time.