Skip to content

Instantly share code, notes, and snippets.

@mpalpha
mpalpha / tailwind-modular-scale.js
Created February 18, 2020 18:40
generate modular scale classes for tailwind. (requires: https://github.com/modularscale/modularscale-js)
const ModularScale = require('modularscale-js');
module.exports = function ms({ addUtilities, config, e }) {
const values = config('theme.ms', {
sizes: [
{ size: 'sm', value: -1 },
{ size: 'base', value: 0 },
{ size: 'lg', value: 1 },
{ size: 'xl', value: 2 },
{ size: '2xl', value: 3 },
@mpalpha
mpalpha / adaptive-text-color.scss
Created January 24, 2020 14:43
SASS: Adaptive Text Color Function
/*
* Adaptive Text Color Function
*
* Example:
* .text-contrast {
* color: adaptive-text-color(#fff);
* }
*
*/
@mpalpha
mpalpha / nearest-colors.js
Last active February 21, 2020 18:25
find nearest tailwind default color by hex value. requires "https://www.npmjs.com/package/nearest-color"
const Color = require('color');
// get the nearest color/s for tailwindcss
//
// install:
// npm install gist:33df8e232bf36e422e3abf3566a59ee0 --save
// or
// yarn add gist:33df8e232bf36e422e3abf3566a59ee0
//
// tailwind.config.js example:
// extend: {
@mpalpha
mpalpha / scroll-animate.js
Last active January 22, 2020 14:08
ScrollMagic GSAP animations dynamically via data attributes
// Demo:
// https://codepen.io/mpalpha/pen/bGNmpxB
// Dependencies:
// https://cdnjs.cloudflare.com/ajax/libs/gsap/3.0.5/gsap.min.js
// https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js
// https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/animation.gsap.min.js
// https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js
// https://cdnjs.cloudflare.com/ajax/libs/smooth-scroll/16.1.0/smooth-scroll.min.js
@mpalpha
mpalpha / index.js
Last active August 29, 2019 14:56
Storybook menu sort utility - sort storybook stories by external array of strings. ex: storySorter(['core', 'components']
/* Storybook menu sort utility
* Allows you to sort storybook stories by an external array of strings.
*
* install:
npm install gist:0cdded150eb533938b502cc958ee529a --save
*
*
* example storybook config.js:
import storySorter from 'story-sorter';
addParameters({
@mpalpha
mpalpha / destructuring.js
Created August 20, 2019 14:09 — forked from mikaelbr/destructuring.js
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@mpalpha
mpalpha / sortByArray.js
Last active July 31, 2019 15:30
sort stories by external array for storybook's "storySort" option
/*
* "addParameters" in config.js
*
* addParameters({
* options: {
* storySort: sortByArray,
* }
* });
*/
@mpalpha
mpalpha / storybook.loading.observer.js
Last active June 28, 2019 19:55
dom ready or storybook root change observer.
// application init
const appInit = () => new App();
// story init
const storyInit = () => {};
// story load
const storyLoad = () => new App();
// Init handler
@mpalpha
mpalpha / ubunturpiefix.sh
Last active June 24, 2019 23:41
fix ubuntu 18.x+ SDL issue for retropie.
# fix ubuntu 18.x+ SDL issue for retropie.
RETROPIECFG=/opt/retropie/configs/all/retropie.cfg
if [ ! -f $RETROPIECFG ]; then
sudo sed --in-place 's/2.0.8/2.0.9/g' $HOME/Retropie-Setup/scriptmodules/supplementary/sdl2.sh
mkdir -R /opt/retropie/configs/all/
echo "own_sdl2=\"0"\" >> /opt/retropie/configs/all/retropie.cfg
sudo rm /usr/share/doc/libsdl2-2.0-0/copyright
sudo apt remove libsdl2-dev
sudo apt --fix-broken install
sudo apt autoremove
@mpalpha
mpalpha / default.pa
Last active January 8, 2021 19:28
Atomic Pi HDMI working audio Pulse Audio Configuration file /etc/pulse/default.pa from https://www.reddit.com/r/Atomic_Pi/wiki/index#wiki_fix_for_hdmi_audio
#!/usr/bin/pulseaudio -nF
#
# check if you are missing pavucontrol. run "which pavucontrol"
# If so, install it and Download a working Atomic Pi HDMI audio configuration file.
# run "sudo apt install -y pavucontrol && sudo curl -o /etc/pulse/default.pa -L https://gist.githubusercontent.com/mpalpha/5e0d87f514bca0f87769864655300c99/raw"
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by