Skip to content

Instantly share code, notes, and snippets.

View OliverJAsh's full-sized avatar

Oliver Joseph Ash OliverJAsh

View GitHub Profile
@OliverJAsh
OliverJAsh / gist:bcc676e381a06dbb3be0
Created October 28, 2014 11:34
webpack experiment and comparison against jspm

webpack: http://webpack.github.io/ jspm: http://jspm.io/

Nice introduction presentation: http://peerigon.github.io/presentations/2014-07-09-MNUG-webpack/

The watch seems intelligent in that it might be tracing the dependency graph. In my test case it seems to, at least. AMD and CommonJS modules are supported out of the box. In my test I was unable to get es6-loader working (see commit in link below).

Unlike jspm, it's not a registry. Instead it resolves dependencies from node_modules (i.e. npm) by default (like browserify), although according to this tutorial it's trivial to configure which directories the module resolver should read from.

@OliverJAsh
OliverJAsh / TODO
Created July 25, 2014 12:16
Virtual DOM experiment for Scribe
Broken deps:
* vdom => global
* global => min-document
@OliverJAsh
OliverJAsh / inheritance.css
Created June 21, 2014 13:12
CSS tooling: implicit style dependencies

I see this quite often in CSS: something doesn't look right, so we apply some new styles on our class to make it look right.

Instead we need to review what the current styles are, and where they come from – another class (composition) or inheritance. If you’re changing the font-family style, for example, you should have a look to see what might be currently setting that property in the styles pane, and identify how it’s cascading to this element. It may be that you can remove it from a parent element, or you might need to override it with a class. Without reviewing the code is this way, you CSS codebase can easily become bloated with style overrides.

Chrome DevTools makes reviewing the cascade very easy with its styles pane. However, when you look at some CSS code in your IDE, it’s not at all explicit what styles will be inherited or applied through composition. This means we have to have strong discipline in documenting our CSS – where you’re unsetting or resetting a style that is inherited, you might le

@mixin font-size($percent, $min-font-size, $max-font-size) {
// Min
font-size: $min-font-size;
@include breakpoint($min-font-size/$percent * 100) {
font-size: #{$percent}vw;
}
@include breakpoint($max-font-size/$percent * 100) {
font-size: $max-font-size;
@OliverJAsh
OliverJAsh / SassMeister-input-HTML.html
Created May 9, 2014 16:11
Generated by SassMeister.com.
<div class="l-row l-desktop-row">
<div class="l-desktop-row__item flex-2">
<section class="island">
<h1>We build in pursuit of a cause that is greater than ourselves.</h1>
<div class="l-row l-tablet-row l-tablet-row--max-2">
<div class="l-tablet-row__item">
<section class="island">
<h1 class="h3">Empowering journalists</h1>
<p>We build products that make it easier for journalists to publish informative and delightful stories.</p>
<div class="l-row l-default-row l-default-row--max-2">
@OliverJAsh
OliverJAsh / foo.js
Created April 12, 2014 14:21
Uncompress a HTTP response when needed
var request = require('request');
var stream = require('stream');
var zlib = require('zlib');
var websiteRequest = request('http://oliverjash.me/', {
headers: {
'Accept-Encoding': 'gzip,deflate'
}
});
@OliverJAsh
OliverJAsh / Plumbing.js
Last active August 29, 2015 13:57
The Plumber equivalent of the Gruntfile from https://github.com/Mixd/frontend-framework
// https://github.com/plumberjs/plumber
var all = require('plumber-all');
var glob = require('plumber-glob');
var bower = require('plumber-bower');
var uglifyjs = require('plumber-uglifyjs')();
var concat = require('plumber-concat');
var filter = require('plumber-filter');
var mincss = require('plumber-mincss');
var rename = require('plumber-rename');
@OliverJAsh
OliverJAsh / foo.md
Last active August 29, 2015 13:57
`git stash pop` not merging

If you’re trying to pop a stash and Git won’t merge for you because you have changes in your index to the same file(s) (Git needs to use the index to do a merge at all), i.e.:

❯ gsp
error: Your local changes to the following files would be overwritten by merge:
	index.html
Please, commit your changes or stash them before you can merge.
Aborting
@OliverJAsh
OliverJAsh / foo.js
Last active December 27, 2015 21:29
Functional programming experiment
/**
* Goal: add 10 to each persons age using functions from Lodash and curry only.
*
* I have provided a custom version of curry, instead of using _.curry, as
* the one in Lodash sadly doesn't play nicely here.
*
* Transform:
* [ { name: 'Foo', age: 20 }, { name: 'Baz', age: 21 } ]
* into:
* [ { name: 'Foo', age: 30 }, { name: 'Baz', age: 31 } ]
@OliverJAsh
OliverJAsh / chrome-history-select-bulk.js
Last active December 25, 2015 14:28
A script to select multiple history entries (in Chrome) that match against a given string — handy for bulk deletions
// Go to chrome://history-frame and run the following script from the console:
var url = window.prompt('Enter a URL to match');
var entries = document.querySelectorAll('.entry');
Array.prototype.forEach.call(entries, function (entry) {
var test = new RegExp(url)
if (test.exec(entry.querySelector('.title a').attributes.getNamedItem('href').value)) {
entry.querySelector('input[type="checkbox"]').checked = true;
}
});