Skip to content

Instantly share code, notes, and snippets.

@ngbrown
ngbrown / BlurImg.tsx
Last active December 11, 2023 08:56 — forked from WorldMaker/use-blurhash.ts
useBlurhash hook
import React, { useState, useCallback } from "react";
import { useBlurhash } from "./use-blurhash";
import { useInView } from "react-intersection-observer";
type Props = React.DetailedHTMLProps<
React.ImgHTMLAttributes<HTMLImageElement>,
HTMLImageElement
> & { blurhash?: string | null };
// Uses browser-native `loading="lazy"` to lazy load images
@ngbrown
ngbrown / calendar.css
Created August 3, 2020 04:54 — forked from AndyCross/calendar.css
How the Calendar Visual might look in a few files
.day {
fill: #fff;
stroke: #ccc;
}
.month {
fill: none;
stroke-width: 2px;
}
@ngbrown
ngbrown / Program.cs
Last active April 3, 2020 03:32 — forked from DanielSWolf/Program.cs
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);
@ngbrown
ngbrown / TUT017.md
Created May 13, 2018 04:03 — forked from dapperfu/TUT017.md
TUT017 Example YAML to MD.

active: true derived: false level: 1.5 links:

  • REQ004: 94f4db8d1a50ab62ee0edec1e28c0afb normative: true ref: '' reviewed: 98ba42c551fec65d9796fee72d15f844 title: Tutorial Requirement 17
public abstract class BindableBase : INotifyPropertyChanged
{
/// <summary>
/// Multicast event for property change notifications.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Checks if a property already matches a desired value. Sets the property and
/// notifies listeners only when necessary.
@ngbrown
ngbrown / TileCanvas.cs
Last active December 19, 2015 08:19 — forked from robfe/TileCanvas.cs
TileCanvas updated to be more efficient with adding and removing tiled images.
public class TileCanvas : Canvas
{
public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register(
"ImageSource",
typeof(ImageSource),
typeof(TileCanvas),
new PropertyMetadata(null, ImageSourceChanged));
private Size lastActualSize;
#! /usr/bin/python
# logging to DbgView with OutputDebugString
# from https://gist.github.com/ngbrown/d38064a844426a00fdaa and https://gist.github.com/wh13371/92df4715fc17eb74299d
import logging
import ctypes
# output "logging" messages to DbgView via OutputDebugString (Windows only!)
OutputDebugStringW = ctypes.windll.kernel32.OutputDebugStringW
OutputDebugStringW.argtypes = [ctypes.c_wchar_p]