Skip to content

Instantly share code, notes, and snippets.

@voxpelli
voxpelli / SASS_Color_Contrast.md
Last active August 21, 2022 11:49
Pure SASS script for calculating contrast ratios of colors. MOVED TO: https://github.com/voxpelli/sass-color-helpers

Pure SASS-adaption of Lea Verou's contrast-ratio javascript. Can be useful when eg. generating colored buttons from a single supplied color as you can then check which out of a couple of text colors would give the best contrast.

This script currently lacks the support for alpha-transparency that Lea supports in her script though.

In addition to the color-contrast adaption there's also some math methods that were needed to be able to calculate the exponent of a number and especially so when the exponent is a decimal number. A 2.4 exponent is used to calculate the luminance of a color and calculating such a thing is not something that SASS supports out of the box and not something I found a good pure-SASS script for calculating and I much prefer pure-SASS over ruby extensions. The math methods might perhaps be unecessary though if you're running Compass or similar as they may provide compatible math methods themselves.

Normal usage: `color: pick_best_color(#f00

@joshbeckman
joshbeckman / animatedScrollTo.js
Created September 30, 2013 14:51
ScrollTo animation using pure javascript and no jquery
document.getElementsByTagName('button')[0].onclick = function () {
scrollTo(document.body, 0, 1250);
}
function scrollTo(element, to, duration) {
var start = element.scrollTop,
change = to - start,
currentTime = 0,
increment = 20;
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
@jescalan
jescalan / stylis-lib-rails.md
Created November 8, 2013 19:41
Getting stylus libraries into rails
  1. put gem stylus in your Gemfile.
  2. create an empty directory named node_modules
  3. run npm install your-lib
  4. make an initializer and add this text to it: Stylus.use('your-lib') if defined?(Stylus)
  5. make a new stylus file in your app/assets folder
  6. use your library
@bricker
bricker / a.rb
Created December 16, 2013 19:15
def slides_exists_and_are_hashed_yaml
return if slides.blank?
slides_yml = YAML.load(slides)
if Array(slides_yml).any? { |_, v| v.nil? } || slides_yml.instance_of?(String)
errors.add(:slides, 'not a valid YAML file (did you include at least one key: value?)')
end
end
@jescalan
jescalan / stylus-plugins.md
Created January 5, 2014 01:20
Stylus Plugin Use

Stylus Plugin Use

This document will briefly review a few of the more common ways of using stylus plugins for those who are not familiar. Throughout these examples, we will be using a non-existant stylus plugin called example. Please change example out for whatever plugin you are actually trying to use!

Standalone/Node

First example is for if you are building your own stylus pipeline in node. This is a pretty standard way to do things.

@kyledrake
kyledrake / ferengi-plan.txt
Last active November 14, 2025 04:39
How to throttle the FCC to dial up modem speeds on your website using Nginx
# The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited
#
# Current known FCC address ranges:
# https://news.ycombinator.com/item?id=7716915
#
# Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft
#
# In your nginx.conf:
location / {
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active November 25, 2025 13:25
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@corysimmons
corysimmons / resize.js
Last active January 3, 2018 16:08
John Resig - Learning from Twitter Tiny JS Throttle
let didResize = false
window.addEventListener(`resize`, () => {
didResize = true
})
setInterval(() => {
if (didResize) {
// Do stuff
didResize = false