Skip to content

Instantly share code, notes, and snippets.

const {keys, create, assign} = Object;
function fakeClass(Constructor, prototype) {
const methods = keys(Constructor.prototype);
const overrides = keys(prototype);
methods.forEach(function (method) {
if (!overrides.includes(method)) {
throw new Error(`Method "${method}" missing in Overrides for class [${Constructor.name}]`);
}
});
@mgrandrath
mgrandrath / karma-clientjs.js
Last active November 27, 2015 20:28
Karma configuration for letscodejavascript.com
var karmaCommon = require("./karma-common.js");
module.exports = function(config) {
"use strict";
config.set(Object.assign({}, karmaCommon, {
port: 9876,
basePath: '../../',
@mgrandrath
mgrandrath / README.md
Created November 5, 2015 08:07 — forked from jxson/README.md
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@mgrandrath
mgrandrath / Jakefile.js
Last active August 29, 2015 14:14
Lint a list of files with Jake.js
"use strict";
var TOUCH_DIR_PREFIX = "generated/lint/";
var path = require("path");
var touchFiles = filesToLint().map(touchFileName);
var touchDirs = uniqify(touchFiles.map(path.dirname));
touchDirs.forEach(directory); // this is Jake's `directory` task
@mgrandrath
mgrandrath / gist:f9afff6adb4d64cb7fa7
Created December 7, 2014 11:40
Collect font information from all ElementNodes
function walk(f, node) {
f(node);
node = node.firstChild;
while (node) {
walk(f, node);
node = node.nextSibling;
}
}
function parseNode(node) {
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 {
#
# 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'
@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);
}
@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))))