Skip to content

Instantly share code, notes, and snippets.

View mattsacks's full-sized avatar

Matt Sacks mattsacks

View GitHub Profile
@mattsacks
mattsacks / README.md
Last active August 21, 2023 08:00
Purging CSS with CSS Modules

Tailwind.css and CSS Modules make a lovely pairing. You get to write things like:

/* In your styles.module.css file: */
.heading {
  composes:
    global(bg-primary)
    global(p-6)
@mattsacks
mattsacks / SassMeister-input.scss
Created May 25, 2014 23:04
Generated by SassMeister.com.
// ----
// Sass (v3.3.7)
// Compass (v1.0.0.alpha.18)
// ----
%fart {
color: brown;
}
%fart {
@mattsacks
mattsacks / address-input.scss
Last active August 29, 2015 14:00
Generated by SassMeister.com.
// ----
// Sass (v3.3.6)
// Compass (v1.0.0.alpha.18)
// ----
%address-input {
color: red;
&-city, &-state {
color: blue;
}
@mattsacks
mattsacks / preventHistorySwipe.js
Created May 22, 2013 22:46
Prevent back/forward gestures when scrolling an element left/right on OS X
// prevent back/forward gestures when scrolling an element left/right on OS X
var preventHistorySwipe = function(element) {
// not even on the right platform bro
if (navigator.userAgent.indexOf('Macintosh') === -1) return;
element.addEventListener('mousewheel', function(e) {
var x = e.wheelDeltaX;
// scrolling up or down? then i don't give a shit
if (x === 0) return;
@mattsacks
mattsacks / README.md
Last active December 13, 2015 20:28
Star Polygons
@mattsacks
mattsacks / Date_hack.js
Created December 26, 2012 18:58
Changing the default date from the Date constructor
var defaultDate = '1/10/2013';
window['d8'] = Date;
Date = function(time) {
return time == null ? new d8(defaultDate) : new d8(time);
}
for (var key in Date.prototype) Date[key] = d8[key];
// fix mootools and d3
Date.parse = d8.parse;
$a: white
$b: blue
$c: black
$letters: a b c
$colors: $a $b $c
@for $i from 1 through length($letters)
$letter: nth($letters, $i)
$color: nth($colors, $i)
@mattsacks
mattsacks / README.md
Created June 7, 2012 02:59
N-Point Comparison to 15-Point
@mattsacks
mattsacks / README.md
Created June 6, 2012 23:15
Multi-Point Line Animation

Animating the addition/subtraction of points along a path causes jerkiness. This is a demonstration of what that could look like between 5-15 points on a normal distribution.

It can probably be solved in some way by re-drawing the line with the new number of points, interpolating between the old number of points so that it looks exactly the same - then just animating those points to their new coordinate.

@mattsacks
mattsacks / .ctags
Created February 13, 2012 18:16
JavaScript ctags w/ MooTools
--langdef=js
--langmap=js:.js
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/,object/
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*new Class\(\{/\1/,class/
--regex-js=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/,function/
--regex-js=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*([^)])/\1/,function/
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/,array/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^"]'[^']*/\1/,string/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^']"[^"]*/\1/,string/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*.+([,;=]|$)/\5/,variable/