Skip to content

Instantly share code, notes, and snippets.

View nelsonpecora's full-sized avatar

Nelson Pecora nelsonpecora

View GitHub Profile
@nelsonpecora
nelsonpecora / parent-selector.scss
Created June 29, 2017 20:41
Another idea for cross-component selectors
// sites/selectall/styleguide.css
$text-color: #111;
$one-column-text-color: #333;
$link-color: #111;
$sponsored-link-color: #1782a9;
$link-border-color: #fcd400;
$serif-stack: Georgia, serif;
$sans-serif-stack: Arial, sans-serif;
// sites/selectall/styleguide.css
$text-color: #111;
$one-column-text-color: #333;
$link-color: #111;
$sponsored-link-color: #1782a9;
$link-border-color: #fcd400;
/* -------------------------------------- */
@nelsonpecora
nelsonpecora / strict-variable-names.scss
Created June 28, 2017 21:40
Strictly-enforced variable names
/* component styles */
.myComponent-title {
color: $myComponent-title--color or red;
font-size: $myComponent-title--font-size or 24px;
font-weight: $myComponent-title--font-weight or bold;
}
.myComponent-body {
color: $myComponent-body--color or black;
font-size: $myComponent-body--font-size or 16px;
@nelsonpecora
nelsonpecora / composited-css.css
Last active June 28, 2017 21:51
Composited CSS Idea
/* component styles */
.myComponent-title {
color: red;
font-size: 24px;
font-weight: bold;
}
.myComponent-body {
color: black;
font-size: 16px;
[
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
sequences: true,
properties: true,
function recursivelyCheckReference(urls) {
const stream = rest.get(urls)
.map((data) => {
const childUrls = listComponentReferences(data); // returns an array of urls
stream.append(recursivelyCheckReference(childUrls));
return { result: 'success' }; // object I can filter on
}).errors((err, push) => {
push(null, { result: 'error', url: err.url }); // object I can filter on. I'm adding url to errors thrown from the rest service
});
// checking references shallowly is easy
rest.get(url)
.map(() => false)
// we don't care about data, but we want the resulting stream's length
// to be the number of urls we've checked
.errors((err, push) => {
push(null, url); // every url that errors out should be captured
});
// my files service returns a stream of schemas and data
// (from a folder of mixed schema- and data-containing files)
// each item in the stream is an object with a dynamic key
// (in reality it's based on the filename, but this is a simplified example)
const files = _([
{ schema1: { foo: 'bar' } },
{ data1: { baz: 'qux' } },
{ data2: { quux: 'quuux' } }
]);
npm install --save nymag-handlebars
var hbs = require('nymag-handlebars')(),
  template = hbs.compile('<h1>Hello {{ place }}!</h1>'),
  result = template({ place: 'World' });

// result: <h1>Hello World!</h1>
@nelsonpecora
nelsonpecora / handlebars_faq.md
Last active January 6, 2017 20:17
Nunjucks → Handlebars FAQ

Handlebars FAQs

Q: What do I do about {{ _ref or _self }}?

A: {{ default _ref _self }}


Q: I need a helper that doesn’t exist. What should I do?