Skip to content

Instantly share code, notes, and snippets.

fs = require 'fs'
pathutil = require 'path'
jade = require 'jade'
parseFiles = (dirname) ->
filenames = fs.readdirSync dirname
for file in filenames
continue if file.slice(0,1) is '.'
path = pathutil.join dirname, file
stats = fs.statSync pathutil.join dirname, path
@davidtheclark
davidtheclark / defancifyBootstrap.js
Last active December 16, 2015 15:08
De-Fancify Bootstrap with Grunt, using the grunt-text-replace plugin. After installing grunt-text-replace, incorporate this code into your own grunt.initConfig object. The goal is to remove box-shadows, text-shadows, border-radii, gradients, and gradientBars from Bootstrap's standard UI elements -- outputting a version of Bootstrap's LESS (or SC…
/*
Grunt is here: http://gruntjs.com/
The plugin grunt-text-replace is here: https://github.com/yoniholmes/grunt-text-replace
After reading those instructions, it should be clear how to use the following.
*/
module.exports = function(grunt) {
grunt.initConfig({
@davidtheclark
davidtheclark / isElementInViewport.js
Created May 4, 2013 02:00
JavaScript: Is element in viewport?
/*
No jQuery necessary.
Thanks to Dan's StackOverflow answer for this:
http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
*/
function isElementInViewport(el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
@davidtheclark
davidtheclark / dumb_to_smart_quotes.py
Created May 5, 2013 17:10
Convert dumb quotes to smart quotes in Python
def dumb_to_smart_quotes(string):
"""Takes a string and returns it with dumb quotes, single and double,
replaced by smart quotes. Accounts for the possibility of HTML tags
within the string."""
# Find dumb double quotes coming directly after letters or punctuation,
# and replace them with right double quotes.
string = re.sub(r'([a-zA-Z0-9.,?!;:\'\"])"', r'\1”', string)
# Find any remaining dumb double quotes and replace them with
# left double quotes.
@davidtheclark
davidtheclark / output.scss
Last active July 6, 2017 17:04
A template for grunt-webfont that outputs a SCSS "icon" mixin. Also, adds a rule to hide text within a `<span>` inside the designated icon element -- for text describing the icon. (You know: accessibility, SEO, etc.) Below, `output.scss` is some example output, `scss-mixin-icon-template.css` is the template.
@font-face {
font-family:"icon";
src:url("../fonts/icon.eot");
src:url("../fonts/icon.eot?#iefix") format("embedded-opentype"),
url("../fonts/icon.woff") format("woff"),
url("../fonts/icon.ttf") format("truetype"),
url("../fonts/icon.svg?#webfont") format("svg");
font-weight:normal;
font-style:normal;
}
@davidtheclark
davidtheclark / scss-extendable-icon-template.css
Created August 15, 2013 20:33
A template for grunt-webfont that utilizes the SCSS @extend functionality to limit code duplication without requiring two classes in the markup. Also, automatically hides the text of <b> tags within the icon element.
/* Generated by grunt-webfont */
<% if (fontfaceStyles) { %>@font-face {
font-family:"<%= fontBaseName %>";<% if (eot) { %>
src:<%= fontSrc1 %>;<% }%>
src:<%= fontSrc2 %>;
font-weight:normal;
font-style:normal;
}
<% } %>
@davidtheclark
davidtheclark / gist:6366838
Created August 28, 2013 14:47
grunt-webfont SCSS template outputting classes that utilize an @extend placeholder, and accompanying demo HTML template.
/* Generated by grunt-webfont */
<% if (fontfaceStyles) { %>@font-face {
font-family:"<%= fontBaseName %>";<% if (eot) { %>
src:<%= fontSrc1 %>;<% }%>
src:<%= fontSrc2 %>;
font-weight:normal;
font-style:normal;
}
<% } %>
var mblConnect = {
$cont: $('#connect'),
$site: $('#site'),
isOpen: false,
$overlay: $('<div id="mbl-overlay" class="mbl-overlay js-connect-btn" />'),
_getBtns: function () {
return $('.js-connect-btn');
},
@davidtheclark
davidtheclark / test-extends.scss
Created April 5, 2014 23:04
for comparing gzipping of Sass extends and mixins
@import "../bower_components/scut/dist/scut";
@for $i from 1 through 200 {
.test-#{$i} {
@extend %scut-hide-visually;
@extend %scut-image-replace;
@extend %scut-triangle;
@extend %scut-clearfix;
@extend %scut-fill;
@extend %scut-list-unstyled;
@davidtheclark
davidtheclark / SassMeister-input.scss
Created August 2, 2014 18:01
Generated by SassMeister.com.
// ----
// libsass (v2.0.0)
// ----
@mixin first {
/* first mixin was included */
body {
font-size: 100px;
}
}