Skip to content

Instantly share code, notes, and snippets.

Chris Eppstein chriseppstein

Block or report user

Report or block chriseppstein

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View general.sass
// Clearing floats without extra markup
// Based on How To Clear Floats Without Structural Markup by PiE
// [http://www.positioniseverything.net/easyclearing.html]
// From the official sass documentation.
=clearfix
display: inline-block
&:after
content: "."
display: block
height: 0
View gist:9439001
$ 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
View generalized_memoizer.scss
// 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 {
View _base.scss
@mixin css-edit-warning {
/*! WARNING: This CSS file was generated from a Sass file. Do NOT edit it. */
}
View cascade-issue.scss
%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.
View gist:69686a5eeaf35d542233
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"
View SomeBadAssSass.sass
$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
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// Sass (v3.3.7)
// Compass (v1.0.0.alpha.18)
// ----
$debug-browser-support: true;
$svg-gradient-shim-threshold: 1%;
@import "compass/css3/images";
div {
View file_exists.rb
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
View wtf.rb
foo = 1 unless defined?(foo)
foo #=> nil
FOO = 1 unless defined?(FOO)
FOO # => 1
You can’t perform that action at this time.