Skip to content

Instantly share code, notes, and snippets.

View nhall's full-sized avatar

Nick Hall nhall

  • Fastspot
  • Baltimore
View GitHub Profile
@nhall
nhall / csv_io.py
Created April 16, 2026 02:10
Append-only CSV with deduplication and atomic writes
"""
csv_io.py — append-only CSV with deduplication and atomic writes.
No pandas required.
Functions:
read_csv(filepath) → list of dicts
write_csv(rows, filepath, columns) → row count (atomic write)
append_csv(rows, filepath, columns) → None
append_csv_deduped(rows, filepath, columns, key_fn) → new row count
"""
@nhall
nhall / contrast.js
Last active June 7, 2019 17:39
Automating contrast accessibility
function AccessibleColor(el) {
var backgroundRGB = el.css("backgroundColor");
backgroundRGB = backgroundRGB.substring(backgroundRGB.length - 1, 4).replace(/\s/g, "").split(",");
var sum = Math.round((
(parseInt(backgroundRGB[0]) * 299) +
(parseInt(backgroundRGB[1]) * 587) +
(parseInt(backgroundRGB[2]) * 114)) / 1000);
if (sum > 128) {
@nhall
nhall / contrast.scss
Last active June 7, 2019 17:38
Automating contrast accessibility
@mixin accessible-color($color: #000) {
$red: red($color);
$green: green($color);
$blue: blue($color);
color: rgb(
(((($red * 299) + ($blue * 114) + ($green * 587)) - 128000) * -1000),
(((($red * 299) + ($blue * 114) + ($green * 587)) - 128000) * -1000),
(((($red * 299) + ($blue * 114) + ($green * 587)) - 128000) * -1000)
);
@nhall
nhall / navigation.html
Last active June 7, 2019 17:37
HTML for a flexible and accessible navigation element.
<nav aria-labelledby="nav_title">
<h2 class="visually_hide" id="nav_title">Site Navigation</h2>
<ul aria-labelledby="nav_title">
<li><a href="#">Academics</a></li>
<li><a href="#">Admission</a></li>
<li><a href="#">Student Life</a></li>
<li><a href="#">News</a></li>
<li><a href="#">About</a></li>
</ul>
</nav>
@nhall
nhall / SassMeister-input.scss
Created August 27, 2014 15:52
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.0)
// ----
// _config.scss
$homepage-id: 7170;
// _home.scss
@nhall
nhall / SassMeister-input.scss
Created May 14, 2014 17:55
Generated by SassMeister.com.
// ----
// Sass (v3.3.7)
// Compass (v1.0.0.alpha.18)
// ----
// Using `@at-root`
.parent {
background-color: #0e0e0e;
@nhall
nhall / SassMeister-input.scss
Created May 14, 2014 17:49
Generated by SassMeister.com.
// ----
// Sass (v3.3.7)
// Compass (v1.0.0.alpha.18)
// ----
// Using `&` operator and parent selectors
/*! All Sass versions */
.parent {
background-color: #0e0e0e;
@nhall
nhall / _config.scss
Last active August 29, 2015 13:56
Sample Sass _config.scss partial
/* _config.scss v1.0.0 */
// Vendor Dependencies
// ==========================================================================
@import "compass";
// Site attributes
// ==========================================================================
$attr_border_box: true !default;
// Modernizr mixin to create .modernizr selector -
// codepen.io/sturobson/pen/xcdha
@mixin fallback($property, $support: true) {
@if $support == true {
.#{$property} & {
@content;
}
}
@else {
.no-#{$property} & {
@nhall
nhall / cycle.css
Last active December 17, 2015 12:59
Cycle plugin defaults.
ul.slideshow,
ul.slideshow li {
height: 300px;
width: 450px;
margin: 0;
padding: 0;
overflow: hidden;
}
.slideshow { position: relative; }
.slideshow li {