Skip to content

Instantly share code, notes, and snippets.

View AndersDJohnson's full-sized avatar

Anders D. Johnson AndersDJohnson

View GitHub Profile
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@AndersDJohnson
AndersDJohnson / jquery-ie8-html-parse-bug.md
Last active June 5, 2019 13:36
jQuery IE8 HTML parse bug

Apparently in IE8 only, there are bugs with the jQuery HTML parser.

var $el = $('<span class="sub-features">');
// $el[0] == undefined

Only this works:

$('<span class="sub-features"></span>');
@AndersDJohnson
AndersDJohnson / css-font-smooth.css
Last active June 5, 2019 13:32
CSS Font Smoothing
/**
* http://blakepetersen.io/how-to-clean-up-chrome-and-safaris-webfont-rendering/
*/
.smooth-stroke {
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: .5px;
-webkit-text-stroke-color: rgba(0,0,0,0.5);
}
@AndersDJohnson
AndersDJohnson / constructors.js
Last active June 5, 2019 13:36
JS constructors example
/***
* This JavaScript example demonstrates constructors and prototypes by defining a product "class".
* Written for Require.js (http://requirejs.org/) and documented with JSDoc (http://usejsdoc.org/).
*/
define('Product', [], function () {
/**
* A product type.
* @typedef Product
@AndersDJohnson
AndersDJohnson / bootstrap-version-detect.js
Last active June 5, 2019 13:28
Bootstrap version detect
/**
* Hacks to detect Bootstrap version (2 vs. 3) from JavaScript.
* Does some detection of stringified functions - should be safe against most minification, but please test!
*
* Example:
* ```js
* bootstrapVersionDetect.isVersion('2', $);
* ```
*
* May not be necessary soon for Bootstrap 3+, @see https://github.com/twbs/bootstrap/pull/13578
@AndersDJohnson
AndersDJohnson / ConditionalSpec.groovy
Last active June 5, 2019 13:32
Geb conditional flow
class ConditionalSpec extends GebReportingSpec {
/**
* This should get us to SomePage, handling any interim pages.
*/
def getToSomePage () {
waitFor {
if (isAt(SomePage)) {
println "at some page"
return true
@AndersDJohnson
AndersDJohnson / jquery-until.js
Last active June 5, 2019 13:32
jquery-until: wait for selector match
var until = function (selector, time, callback) {
var $match = $(selector);
if ($match.length) {
return callback($match);
}
setTimeout(function () {
until(selector, time, callback);
}, time);
};
@AndersDJohnson
AndersDJohnson / input-height.less
Last active June 5, 2019 13:35
Normalize vertical centering of form items across browsers.
/**
* This will normalize vertical centering of input text across browsers.
*/
.mixin-input-height (@font-size, @height-scale: 2.5) {
@input-height: @font-size * @height-scale;
@input-padding-vertical: (@input-height - @font-size) / 2;
font-size: @font-size;
height: @input-height + 2; // webkit seems to have a weird 1px gap
// to vertically center input text in IE <= 8, but not stretch caret in modern browsers
var csv = require('csv');
csv()
.from.path(__dirname+'/export.csv', { delimiter: ',', escape: '"' })
.to.array( function(data){
var labels = data.shift();
var items = [];
data.forEach(function (row) {
var item = {};
row.forEach(function (value, index) {
@AndersDJohnson
AndersDJohnson / xml2js-as-promised.js
Last active June 5, 2019 13:32
xml2js-as-promised
var Q = require('q');
var xml2js = require('xml2js');
module.exports = function (input) {
var deferred = Q.defer();
var parser = new xml2js.Parser();
parser.parseString(input, function (err, stdout, stderr) {
if (err) {
return deferred.reject(err);
}