Skip to content

Instantly share code, notes, and snippets.

@mixin default-arg($s: &) {
default-arg: inspect($s);
}
@mixin defaulted-in-body($s: null) {
$s: & !default;
defaulted-in-body: inspect($s);
}
output {
@function index-of-last-class($selector) {
$index: null;
$counter: 1;
@each $component in $selector {
@if str-index($component, ".") == 1 {
$index: $counter;
}
$counter: $counter + 1;
}
@return $index;
@chriseppstein
chriseppstein / SassMeister-input.scss
Created July 14, 2014 21:39
Generated by SassMeister.com.
// ----
// Sass (v3.4.0.rc.1)
// Compass (v1.0.0.alpha.20)
// ----
nav{
ul {
li {
$new-selector: append(nth(&, 1), unquote(".abc"));
@at-root #{$new-selector} {
@chriseppstein
chriseppstein / SassMeister-input.scss
Created July 17, 2014 15:13
Generated by SassMeister.com.
// ----
// Sass (v3.4.0.rc.1)
// Compass (v1.0.0.alpha.20)
// ----
#orchard .apple, .pear {
@at-root #{selector-append(".tree", &)} {example: selector-append;}
// Space after .tree doesn't do anything
@at-root #{selector-append(".tree ", &)} {example: selector-append;}
// Space before .tree throws an error
@chriseppstein
chriseppstein / lucky_shot.txt
Created July 17, 2014 19:01
Boom. Hit the race condition on the first try.
➜ Projects ruby -rubygems test_race_condition.rb
FUCK
➜ Projects ruby -rubygems test_race_condition.rb
➜ Projects ruby -rubygems test_race_condition.rb
➜ Projects ruby -rubygems test_race_condition.rb
➜ Projects ruby -rubygems test_race_condition.rb
➜ Projects ruby -rubygems test_race_condition.rb
➜ Projects ruby -rubygems test_race_condition.rb
➜ Projects ruby -rubygems test_race_condition.rb
➜ Projects ruby -rubygems test_race_condition.rb
= spans(!columns)
- for !column from 1 through !columns by 2 // though = .., to = ..., by = incrementor
+span(!column,!columns)
= span(!column, !columns)
.span-#{!column}
:width= 45px * !column + 15px
- if !column != !columns
:margin-right 15px
@chriseppstein
chriseppstein / Interview.md
Created August 28, 2014 18:27
An Interview I did for the Chinese launch of Sass & Compass in Action.

How did you come to be interested in Sass and then creating Compass?

When I found Sass in 2007 it was version 1.8 and part of another open source project called Haml which is an HTML templating language for ruby. While Haml was good, I found Sass to be revolutionary. It didn't have most of the features it has today, but it had enough for me to see the promise of a system where stylesheet libraries (often called CSS frameworks) could be distributed like software libraries with proper APIs and none of the downsides that traditional CSS Frameworks had.

@chriseppstein
chriseppstein / existence-check-shim.scss
Created September 2, 2014 23:49
How to shim sass 3.3 existence checks in older versions.
@function -my-function-exists($name) {
$name: unquote($name);
$result: function-exists($name);
@if $result == "function-exists(#{$name})" {
@return false;
} @else {
@return $result;
}
}
@chriseppstein
chriseppstein / str-replace.scss
Created September 4, 2014 15:35
String Replacement function in pure-sass
@function str-replace($source, $substring, $replacement, $fail-silently: false) {
$start: str-index($source, $substring);
@if $start {
@return str-slice($source, 1, $start - 1) + $replacement + str-slice($source, $start + str-length($substring))
}
@if $fail-silently {
@return $source;
} @else {
@error "'#{$substring}' was not found in '#{$source}'";
}