Skip to content

Instantly share code, notes, and snippets.

@ahamid
ahamid / postcss-function-sass-color-mod
Created September 18, 2019 17:26
implement sass color functions on top of postcss-color-function/postcss-functions
// reproduce sass darken/lighten/fade function syntax on top of
// postcss-color-function (https://github.com/postcss/postcss-color-function) via
// postcss-functions https://github.com/andyjansson/postcss-functions
// https://github.com/jonathantneal/precss/issues/38
// postcss-sass-colors.js
const colorFn = require('css-color-function')
function applyFn(value, fn, frac) {
return colorFn.convert('color(' + value + ' ' + fn + '(' + frac + '))')
@ahamid
ahamid / machine.js
Created January 20, 2022 21:20
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@ahamid
ahamid / ImageUploader
Created May 27, 2011 16:51
CarrierWave mixed content upload processing
require 'carrierwave/processing/mini_magick'
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
IMAGE_EXTENSIONS = %w(jpg jpeg gif png)
DOCUMENT_EXTENSIONS = %w(exe pdf doc docm xls)
def store_dir
"files/#{model.id}"