Skip to content

Instantly share code, notes, and snippets.

View mattfelten's full-sized avatar

Matt Felten mattfelten

View GitHub Profile
@skullface
skullface / lint-autofix.yml
Created November 19, 2021 03:21
Teensy GitHub Action to autofix linting errors (from the script defined in your package.json) per https://mskelton.medium.com/auto-formatting-code-using-prettier-and-github-actions-ed458f58b7df
name: Lint and autofix
on:
pull_request:
branches: [main]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
import React from "react";
export type ColorScheme = "light" | "dark";
export default function useColorSchemePreference(
defaultColorScheme: ColorScheme = "light"
) {
let darkQuery = "(prefers-color-scheme: dark)";
let [colorScheme, setColorScheme] = React.useState<ColorScheme>(
typeof window === "object" && window.matchMedia
@Merott
Merott / tailwind-colors-as-css-variables.md
Last active April 26, 2024 11:06
Expose Tailwind colors as CSS custom properties (variables)

This is a simple Tailwind plugin to expose all of Tailwind's colors, including any custom ones, as custom css properties on the :root element.

There are a couple of main reasons this is helpful:

  • You can reference all of Tailwind's colors—including any custom ones you define—from handwritten CSS code.
  • You can define all of your colors within the Tailwind configuration, and access the final values programmatically, which isn't possible if you did it the other way around: referencing custom CSS variables (defined in CSS code) from your Tailwind config.

See the Tailwind Plugins for more info on plugins.

Bundling Design Systems/Component Libraries

First of all you need to decide who will be your target consumers based on the following:

  1. They have the same environment(webpack config, babel config) setup as you where you built your design system(this is mostly possible if you use monorepos/same configs where all the teams share the same environment).

  2. They don't have the same environment which is the case when you work in bigger teams and you want to distribute your design system as any other npm package which is already built and can be used directly.

If your use case falls under case no. 1 then you can just compile the source babel src -d build and leave the bundling to the consumer projects tools(webpack/rollup)

@rsrchboy
rsrchboy / smartcow.txt
Created August 4, 2014 17:24
smart cow!
____________________________________________________________________________
/ Care at the Beginning \
| |
| What lies still is easy to grasp; What lies far off is easy to anticipate; |
| What is brittle is easy to shatter; What is small is easy to disperse. Yet |
| a tree broader than a man can embrace is born of a tiny shoot; A dam |
| greater than a river can overflow starts with a clod of earth; A journey |
| of a thousand miles begins at the spot under one's feet. Therefore deal |
| with things before they happen; Create order before there is confusion. |
| |
@azmenak
azmenak / gulpfile.js
Last active April 24, 2017 21:35
Example Gulpfile for Jekyll
var options, paths,
gulp = require("gulp"),
merge = require("merge-stream"),
path = require("path"),
clean = require("gulp-clean"),
concat = require("gulp-concat"),
markdown = require("gulp-markdown"),
minifyCSS = require("gulp-minify-css"),
removeLines = require("gulp-remove-lines"),
#!/bin/bash
PROGNAME=${0##*/}
INPUT=''
QUIET='0'
NOSTATS='0'
max_input_size=0
max_output_size=0
usage()
@jescalan
jescalan / instructions.md
Last active December 13, 2015 19:29
I often run php apps alongside ruby, node, etc. MAMP drives me crazy because it's slow, doesn't work with pow, and only uses it's own mysql install, when i already have a system mysql install for everything else. This is how to get php apps running without MAMP on OSX Lion.

Running PHP Apps Without MAMP on OSX Lion

  1. Create a ~/Sites folder if you don’t already have one
  2. Enable PHP by uncommenting the php5_module line in /etc/apache2/httpd.conf
  3. Find the line that read User _www and change the _www to your username (whoami)
  4. Find the DirectoryIndex line and change it to DirectoryIndex index.php index.html index.htm
  5. Change the DocumentRoot line to DocumentRoot "/Users/yourusername/Sites/"
  6. Change the <Directory line to <Directory "/Users/yourusername/Sites/">
  7. Run sudo apachectl restart
  8. Restart your computer (yes, this is necessary)
@stuntbox
stuntbox / gist:4557917
Last active March 23, 2023 03:32
Slightly smarter filtering to remove hard-coded width and height attributes from *all* images in WordPress (post thumbnails, images inserted into posts, and gravatars). Handy for responsive designs. Add the code below to the functions.php file in your theme's folder (/wp-content/themes/theme-name/ ). Remember to rename the function as needed to …
/**
* Filter out hard-coded width, height attributes on all images in WordPress.
* https://gist.github.com/4557917
*
* This version applies the function as a filter to the_content rather than send_to_editor.
* Changes made by filtering send_to_editor will be lost if you update the image or associated post
* and you will slowly lose your grip on sanity if you don't know to keep an eye out for it.
* the_content applies to the content of a post after it is retrieved from the database and is "theme-safe".
* (i.e., Your changes will not be stored permanently or impact the HTML output in other themes.)
*