Skip to content

Instantly share code, notes, and snippets.

View EWhite613's full-sized avatar

Eric White EWhite613

View GitHub Profile
@EWhite613
EWhite613 / components.my-component-help.js
Last active April 20, 2016 19:55
Computed Component
import Ember from 'ember'
export default Ember.Component.extend({
tagName: 'button',
classNames: ['navigation', 'user-menu'],
myService: Ember.inject.service('my-service'),
contexts: Ember.computed.oneWay('myService.contexts'),
actions: {
openHelp(){
console.log(this.get('contexts'))
@EWhite613
EWhite613 / slimerjs-launcher.js
Last active June 13, 2016 14:37
SlimerJS launcher for Testem
/* Testem usage
'launchers': {
'slimerjs': {
'command': 'slimerjs slimerjs-launcher.js <url>',
'protocol': 'browser'
}
}
*/
// Doesn't exit on Linux for some reason
'use strict'
@EWhite613
EWhite613 / svg.js
Last active August 26, 2016 14:52
svg.js conversion
[].forEach.call(document.querySelectorAll('use'), function (use) {
function replaceTargetWith( target, html ){
/// find our target
var i, tmp, elm, last = target;
/// create a temporary div or tr (to support tds)
tmp = document.createElement(html.indexOf('<td')!=-1?'tr':'div');
/// fill that div with our html, this generates our children
tmp.innerHTML = html;
/// step through the temporary div's children and insertBefore our target
i = tmp.childNodes.length;
@EWhite613
EWhite613 / convert.js
Last active June 29, 2016 20:05
Fix svgs for html2canvas WIP (use GET needs work)
Array.from(document.querySelectorAll('use')).forEach(function (use) {
var
svg = use.parentNode,
url = use.getAttribute('xlink:href').split('#'),
url_root = url[0],
url_hash = url[1],
xhr = new XMLHttpRequest()
if (!xhr.s) {
@EWhite613
EWhite613 / gist:4ed858e18da5b8a54461ba99b84acc60
Created July 12, 2016 15:38
Full slimerjs debug logs SEG Fault
/usr/local/lib/node_modules/slimerjs/lib/slimer/xulrunner/xulrunner
/usr/local/lib/node_modules/slimerjs/lib/slimer
--profile /tmp/slimerjs.V4xazCt0
System JS : WARNING resource://gre/modules/Preferences.jsm:378 - mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create
2016-07-12T15:37:04.139Z [DEBUG] Gecko version: 33.1.1
2016-07-12T15:37:04.139Z [DEBUG] script args: vendor/phantomjs-launcher.js http://localhost:7357/3064/tests/index.html?hidepassed
2016-07-12T15:37:04.139Z [DEBUG] Configuration: error-log-file=error.log
2016-07-12T15:37:04.140Z [DEBUG] Configuration: debug=true
2016-07-12T15:37:04.140Z [DEBUG] Configuration: Script=/localdisk/workspace/ember-frost-core/vendor/phantomjs-launcher.js
2016-07-12T15:37:04.140Z [DEBUG] Configuration: workingDirectory=/localdisk/workspace/ember-frost-core
@EWhite613
EWhite613 / index.js
Created August 2, 2016 15:00
Fix broccoli-lint-eslint
'use strict';
/* eslint global-require: 0, consistent-return: 0 */
var Filter = require('broccoli-persistent-filter');
var CLIEngine = require('eslint').CLIEngine;
var md5Hex = require('md5-hex');
var stringify = require('json-stable-stringify');
var path = require('path');
var escapeStringRegexp = require('escape-string-regexp');
@EWhite613
EWhite613 / broccoli-lint-eslint.js
Last active August 4, 2016 21:50
broccoli-lint-eslint mergeTree fix WIP
/* eslint global-require: 0, consistent-return: 0 */
const Filter = require('broccoli-persistent-filter');
const CLIEngine = require('eslint').CLIEngine;
const md5Hex = require('md5-hex');
const stringify = require('json-stable-stringify');
const path = require('path');
const chalk = require('chalk')
const escapeStringRegexp = require('escape-string-regexp');
const BUILD_DIR_REGEXP = new RegExp('(' + escapeStringRegexp(path.sep) + ')?build(' + escapeStringRegexp(path.sep) + ')?$');
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@EWhite613
EWhite613 / controllers.application.js
Created August 12, 2016 20:16
Date Object helper
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
date: new Date()
});
@EWhite613
EWhite613 / conversion.js
Created May 19, 2017 15:04
Convert SVG4Everybody (svg `use` tags) to inline
function convertSVG4Everbody () {
var items = Array.from(document.querySelectorAll('use'))
items.map(function (use) {
var svgParent = use.parentNode
var url = use.href.baseVal
var id = /#\S*/.exec(url)[0].replace('#', '')
console.log('url: ', url)
var xml = httpGetXML(url)
var symbol = xml.getElementById(id)
// Grab all of the original's attributes, and pass them to the replacement