Skip to content

Instantly share code, notes, and snippets.

@kylegillen
kylegillen / blurhashDataURL.ts
Created November 17, 2023 16:43 — forked from mattiaz9/blurhashDataURL.ts
Convert blurhash to a base64 DataURL string (no canvas or node-canvas)
import { decode } from "blurhash"
export function blurHashToDataURL(hash: string | undefined): string | undefined {
if (!hash) return undefined
const pixels = decode(hash, 32, 32)
const dataURL = parsePixels(pixels, 32, 32)
return dataURL
}
@kylegillen
kylegillen / siblings-by-count.scss
Created April 22, 2016 19:49 — forked from zakirt/siblings-by-count.scss
Sass mixin for styling elements based on sibling count.
// -----------------------------------------------------------------------------
// @author Zakir Tariverdiev
// @created August 2, 2014
// @desc Sass mixin that provides convenient way to style element's siblings.
// Based on the example from Lea Verou's blog:
// http://lea.verou.me/2011/01/styling-children-based-on-their-number-with-css3/
// @param (string) $sibling-count - number of expected siblings. You can also use
// use such forms as "n + 3" and "3n" for "at least 3 siblings" and
// "siblings divisible by 3," for example. These forms must be enclosed in
// quotes for proer parsing though.