Skip to content

Instantly share code, notes, and snippets.

@ngbrown
ngbrown / calendar.css
Created Aug 3, 2020 — forked from AndyCross/calendar.css
How the Calendar Visual might look in a few files
View calendar.css
.day {
fill: #fff;
stroke: #ccc;
}
.month {
fill: none;
stroke-width: 2px;
}
@ngbrown
ngbrown / BlurImg.tsx
Last active Apr 2, 2021 — forked from WorldMaker/use-blurhash.ts
useBlurhash hook
View BlurImg.tsx
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 / Program.cs
Last active Apr 3, 2020 — forked from DanielSWolf/Program.cs
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
View Program.cs
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 — forked from dapperfu/TUT017.md
TUT017 Example YAML to MD.
View TUT017.md

active: true derived: false level: 1.5 links:

  • REQ004: 94f4db8d1a50ab62ee0edec1e28c0afb normative: true ref: '' reviewed: 98ba42c551fec65d9796fee72d15f844 title: Tutorial Requirement 17
View output.debug.string.py
#! /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]
View BindableBase.cs
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 Dec 19, 2015 — forked from robfe/TileCanvas.cs
TileCanvas updated to be more efficient with adding and removing tiled images.
View TileCanvas.cs
public class TileCanvas : Canvas
{
public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register(
"ImageSource",
typeof(ImageSource),
typeof(TileCanvas),
new PropertyMetadata(null, ImageSourceChanged));
private Size lastActualSize;