Skip to content

Instantly share code, notes, and snippets.

@awestmoreland
awestmoreland / nth-fail.scss
Last active December 17, 2015 04:59
This failed because 4 and 6 are both factors of 12, so the omega is added to the 12th member by the :nth-child(4n+4) rule, then removed by the :nth-child(6n+6) rule. Solution: Reverse the order (remove, then add).
figure{
@include at-breakpoint($size-20){
@include span-columns(3,12);
&:nth-child(4n+4){
@include omega;
}
&:nth-child(6n+6){
@include remove-omega;
}
}
@awestmoreland
awestmoreland / sass-var-concat.scss
Last active July 19, 2021 19:47
Concatenation of sass value+units. See also: http://stackoverflow.com/a/9862328
// Set sizes without units
$basefont: 20;
$total-width-px: 1169;
$column-width-px: 72;
// Concatenation of units by addition results in conversion to string. This is bad
$basefont-px: $basefont+'px'; // = "20px"
// Conversion to pixels using multiplication
$basefont-px: $basefont*1px; // = 20px;
@awestmoreland
awestmoreland / susy-vars.scss
Last active December 17, 2015 05:09
Variable-izing susy/scss values
// Basic Grid
// (72 x 12) + (25 x 11) + (15 x 2) = 1169
// Define pixels:
$total-width-px: 1169;
$column-width-px: 72;
$gutter-width-px: 25;
$grid-padding-px: 15;
$total-columns: 12;
$base-font: 20;
@awestmoreland
awestmoreland / gist:5976065
Created July 11, 2013 14:42
Load Typekit if fonts not already loaded
// Set kit ID
var typekitID = "tk999999";
var testFont = "wf-proximanova-n4-active";
// Wait... then load Typekit if font not active
setTimeout("addTypekit(typekitID);",3000);
function addTypekit(typekitID,testFont){
@awestmoreland
awestmoreland / base64-web-font-embed-code
Created August 8, 2013 07:18
Geoff Evason's method of embedding base64-encoded web fonts into CSS file to circumvent CORS in Firefox. http://geoff.evason.name/2010/05/03/cross-domain-workaround-for-font-face-and-firefox https://github.com/geoffevason
@font-face {
font-family: 'MyFontFamily';
src: url('myfont-webfont.eot?') format('embedded-opentype');
}
@font-face {
font-family: 'MyFontFamily';
url(data:font/truetype;charset=utf-8;base64,BASE64_ENCODED_DATA_HERE) format('truetype'),
url(data:font/woff;charset=utf-8;base64,BASE64_ENCODED_DATA_HERE) format('woff'),
url('myfont-webfont.svg#svgFontName') format('svg');
@awestmoreland
awestmoreland / bourbon-with-neat.css
Last active December 27, 2015 10:09
Mixin for Bourbon + Neat to reset margins and omega when changing media queries. Call on a collection with parent class .columns (feel free to argue about my use of figcaption).
/* This is the CSS output by the SCSS file */
.columns {
*zoom: 1;
}
.columns:before, .columns:after {
content: " ";
display: table;
}
.columns:after {
@awestmoreland
awestmoreland / course_detail.html
Last active January 2, 2016 11:59
Statamic: Trying to work out how to display information from pages selected via a Suggest field. Support request logged here: http://support.statamic.com/discussions/general-questions-best-practices/6499-how-to-display-information-from-pages-selected-via-a-suggest-field
<h2>Course instructors:</h2>
<dl>
{{ instructor }}
{{ get_content from="{{ value }}" }} <!-- {{value}} returns incorrect data. {value} returns nothing. -->
<dt>Title:</dt><dd>{{ title }}</dd>
<dt>Company:</dt><dd>{{ company_name }}</dd>
<dt>Link:</dt><dd><a href="{{ value }}">{{ value }}</a></dd>
@mixin griddy($cols) {
> *{
@if($cols > 1) {
@for $i from 1 through $cols {
&:nth-child(#{$i}n+#{$i}) {
@include span-columns($grid-columns / $cols);
clear: none;
}
}
&:nth-child(#{$cols}n + #{$cols}) {
SELECT * FROM promotion_translations
JOIN promotions ON promotions.id = promotion_translations.promotion_id
WHERE promotion_translations.id = YOUR_ID