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
@zaydek
zaydek / bookmark.min.js
Last active Mar 25, 2020
A *simple* CSS debugger. To use, bookmark "Debug CSS" at https://zaydek.github.io/debug.css. Learn more here https://medium.freecodecamp.org/88529aa5a6a3 and https://youtu.be/2QdzahteCCs?t=1m25s (starts at 1:25)
View bookmark.min.js
/* debug.css | MIT License | zaydek.github.com/debug.css */ if (!("is_debugging" in window)) { is_debugging = false; var debug_el = document.createElement("style"); debug_el.append(document.createTextNode(`*:not(g):not(path) { color: hsla(210, 100%, 100%, 0.9) !important; background: hsla(210, 100%, 50%, 0.5) !important; outline: solid 0.25rem hsla(210, 100%, 100%, 0.5) !important; box-shadow: none !important; filter: none !important; }`)); } function enable_debugger() { if (!is_debugging) { document.head.appendChild(debug_el); is_debugging = true; } } function disable_debugger() { if (is_debugging) { document.head.removeChild(debug_el); is_debugging = false; } } !is_debugging ? enable_debugger() : disable_debugger();
View connection.go
package main
import (
"context"
"database/sql"
"encoding/base64"
"encoding/json"
"fmt"
"time"
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 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")
@zaydek
zaydek / inter.js
Last active Nov 7, 2019
Inter dynametrics (use em)
View inter.js
function InterDynamicTracking(fontSize) {
var a = -0.0223, b = 0.185, c = -0.1745;
// tracking = a + b * e ^ (c * fontSize)
return a + b * Math.pow(Math.E, c * fontSize)
}
// See rsms.me/inter/dynmetrics for reference.
const A = -0.0223 // Don’t change.
const B = 0.185 // Don’t change.
const C = -0.1745 // Don’t change.
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 :=
You can’t perform that action at this time.