Skip to content

Instantly share code, notes, and snippets.

View bever1337's full-sized avatar

bever1337 bever1337

View GitHub Profile
@tlux
tlux / context.ts
Created March 15, 2023 12:59
Simple TypeScript wrapper to set and get Svelte contexts
import { getContext, setContext } from "svelte";
/**
* The context object.
*/
export interface Context<T> {
get: () => T;
set: (ctx: T) => T;
}
@mnpenner
mnpenner / color.ts
Last active April 22, 2024 02:41
RGB color hex to lightness
// based on https://stackoverflow.com/a/56678483/65387
type RGB = [r: number, g: number, b: number]
const UNK = 255 / 2
/**
* @param hex RGB hex string like "#CCCFDB"
* @returns RGB tuple in [0-255]
*/
@yoavniran
yoavniran / PreviewLayout.js
Created July 25, 2019 08:55
PreviewLayout for Gatsby & Netlify CMS to enable styled-components
import React, { useRef, useLayoutEffect } from "react";
import { StyleSheetManager } from "styled-components";
import PreviewContext from "./PreviewContext";
const WithPreviewContext = ({ children }) =>
<PreviewContext.Provider value={true}>
<main>
{children}
</main>
</PreviewContext.Provider>;
@fnky
fnky / ANSI.md
Last active June 30, 2024 00:05
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@flbuddymooreiv
flbuddymooreiv / readme.md
Last active February 6, 2024 22:31
erlang + rebar + cowboy Hello World

This is the process of setting up erlang, rebar3, and cowboy for a Hello World, starting with a clean Debian 8 install.

Update apt and install deps:

root@046edcaea45a:~# apt-get update
root@046edcaea45a:~# apt-get install erlang erlang-dev gcc
root@046edcaea45a:~# wget https://s3.amazonaws.com/rebar3/rebar3
root@046edcaea45a:~# mkdir ~/bin/
root@046edcaea45a:~# mv rebar3 ~/bin/
root@046edcaea45a:~# chmod +x ~/bin/rebar3 
@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff') format('woff'), /* Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
body {