Skip to content

Instantly share code, notes, and snippets.

$ compass help imports
Usage: compass imports
Prints out the imports known to compass.
Useful for passing imports to the sass command line:
sass -r compass `compass imports` a_file_using_compass.sass
@chriseppstein
chriseppstein / generalized_memoizer.scss
Last active August 29, 2015 13:57
Memoization in Sass
// This approach lets you generically memoize any function by changing the call site:
@function something-slow-to-compute($arg-1, $arg-2) {
@return ... slow calculation ... ;
}
$cached-values: ();
@function cached($function-name, $args...) {
$cached-value: map-get($cached-values, ($function-name, $args));
@if $cached-value {
@mixin css-edit-warning {
/*! WARNING: This CSS file was generated from a Sass file. Do NOT edit it. */
}
%relative { position: relative; }
%absolute { position: absolute; }
.something { @extend %absolute; }
.something-else { @extend %relative; }
// Given an html element with class .something and class .something-else
// The cascade will resolve to position absolute instead of position relative as you'd expect.
// This is because the position aspect of these classes is not an essential inheritance relationship.
// It is simply composition -- so only mixins should be used.
82c82
< CONFIG["LIBRUBY_DLDFLAGS"] = "-undefineddynamic_lookup -multiply_definedsuppress -install_name $(libdir)/$(LIBRUBY_SO) -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(ruby_version) $(XLDFLAGS)"
---
> CONFIG["LIBRUBY_DLDFLAGS"] = "-Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -install_name $(libdir)/$(LIBRUBY_SO) -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(ruby_version) $(XLDFLAGS)"
125c125
< CONFIG["DLDFLAGS"] = "-undefineddynamic_lookup -multiply_definedsuppress"
---
> CONFIG["DLDFLAGS"] = "-Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress"
$journey: (states: complete in-progress current, packets: (strengths: blue, others: green, networking: pink, approach: yellow, coworker: purple))
@function journey-image($state, $packet-color)
@if $state == complete
@return url('/assets/journey/#{$packet-color}-gem.png')
@else
@return url('/assets/journey/#{$packet-color}-gem-outline.png')
@each $packet, $packet-color in map-get($journey, packets)
@each $state in map-get($journey, states)
@chriseppstein
chriseppstein / SassMeister-input.scss
Created May 21, 2014 20:05
Generated by SassMeister.com.
// ----
// Sass (v3.3.7)
// Compass (v1.0.0.alpha.18)
// ----
$debug-browser-support: true;
$svg-gradient-shim-threshold: 1%;
@import "compass/css3/images";
div {
module Sass::Script::Functions
def file_exists(path)
return bool(false) unless options[:filename] # not all sass has a file name (e.g. std input)
current_directory = File.dirname(options[:filename]) rescue nil # a sass filename from an importer may not be processable by File.dirname
return bool(false) unless current_directory && File.exist?(current_directory) # not all sass files are served from the filesystem
full_path = File.expand_path(path.value, current_directory) # a relative path will be expanded against the current_directory of the sass file, symlinks will be followed, absolute paths will be left alone.
return bool(File.exist?(full_path))
end
end
foo = 1 unless defined?(foo)
foo #=> nil
FOO = 1 unless defined?(FOO)
FOO # => 1
@import susy
@for $i from 1 through 100
.span#{$i}
+span($i)