Skip to content

Instantly share code, notes, and snippets.

function getText(node) {
if (node.nodeType === 3) {
return node.data;
}
var txt = '';
if (node = node.firstChild) do {
txt += getText(node);
@mgrandrath
mgrandrath / normalized.html
Created July 6, 2012 07:16 — forked from scottkellum/normalized.html
pixel normalization
<!doctype html>
<html>
<head>
<!-- Encoding -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta>
@mgrandrath
mgrandrath / gist:3838530
Created October 5, 2012 07:20
escapeHTML (AMD)
define(function() {
var entityMap = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': '&quot;',
"'": '&#39;',
"/": '&#x2F;'
};
void function() {//closure
var global = this
, _initKeyboardEvent_type = (function( e ) {
try {
e.initKeyboardEvent(
"keyup" // in DOMString typeArg
, false // in boolean canBubbleArg
, false // in boolean cancelableArg
, global // in views::AbstractView viewArg
@mgrandrath
mgrandrath / pseudo-container.css
Last active December 15, 2015 00:59
Silent classes for pseudo elements as icon containers
.foo, .bar {
position: relative;
}
.foo:before, .bar:after {
position: absolute;
content: "";
display: block;
}
@mgrandrath
mgrandrath / ruby.el
Created April 4, 2013 13:58 — forked from fujin/ruby.el
(setq ruby-deep-indent-paren nil)
(defadvice ruby-indent-line (after unindent-closing-paren activate)
(let ((column (current-column))
indent offset)
(save-excursion
(back-to-indentation)
(let ((state (syntax-ppss)))
(setq offset (- column (current-column)))
(when (and (eq (char-after) ?\))
(not (zerop (car state))))
@mgrandrath
mgrandrath / style.css
Created August 20, 2013 20:52
CSS Transitions
.hidden {
display: none;
}
.visible,
.invisible.fade-in {
opacity: 1;
-webkit-transform: translateX(0);
}
#
# Jekyll Generator for SCSS
#
# (File paths in this description relative to jekyll project root directory)
# Place this file in ./_plugins
# Place .scss files in ./_scss
# Compiles .scss files in ./_scss to .css files in whatever directory you indicated in your config
# Config file placed in ./_sass/config.rb
require 'compass'
configurationField
.filter("valueText", function () {
return function (value) {
return value.getUserText();
}
})
.directive("configurationField", function () {
return {
configurationField
.filter("valueText", function () {
return function (value) {
return value.getUserText();
}
})
.directive("configurationField", function () {
return {
// ...