Skip to content

Instantly share code, notes, and snippets.

View sethbergman's full-sized avatar
🐋
Building Docker Images for Dell Technologies

Seth Bergman sethbergman

🐋
Building Docker Images for Dell Technologies
View GitHub Profile
@sethbergman
sethbergman / app.js
Created September 17, 2017 04:29
React router matching
// Server Side Rendering based on routes matched by React-router.
app.use((req, res) => {
match({
routes,
location: req.url
}, (err, redirectLocation, renderProps) => {
if (err) {
return res.status(500).end('Internal server error');
}
@sethbergman
sethbergman / using-eslint-with-prettier.md
Created September 7, 2017 19:34 — forked from yangshun/using-eslint-with-prettier.md
Comparison between tools to allow you to use ESLint and Prettier together.
prettier-eslint eslint-plugin-prettier eslint-config-prettier
What it is A JavaScript module exporting a single function. An ESLint plugin. An ESLint configuration.
What it does Runs the code (string) through prettier then eslint --fix. The output is also a string. Plugins usually contain implementations for additional rules that ESLint will check for. This plugin uses Prettier under the hood and will raise ESLint errors when your code differs from Prettier's expected output. This config turns off formatting-related rules that might conflict with Prettier, allowing you to use Prettier with other ESLint configs like eslint-config-airbnb.
How to use it Either calling the function in your code or via [prettier-eslint-cli](https://github.co
@sethbergman
sethbergman / app.html
Created August 5, 2017 18:31 — forked from jdanyow/app.html
AST Visualizer
<template>
<require from="./expression"></require>
<button class="button-outline button-small"
repeat.for="example of examples"
click.delegate="expressionString = example.expression">
${example.name}
</button>
<label class="expression-input">
@sethbergman
sethbergman / app.html
Created August 5, 2017 18:31 — forked from jdanyow/app.html
AST Visualizer
<template>
<require from="./expression"></require>
<button class="button-outline button-small"
repeat.for="example of examples"
click.delegate="expressionString = example.expression">
${example.name}
</button>
<label class="expression-input">
@sethbergman
sethbergman / app.html
Last active July 19, 2017 06:54 — forked from Vheissu/app.html
Checking for user provided slots
<template>
<require from="./modal"></require>
<modal>
<div slot="modalHeader">This is user provided header content.</div>
</modal>
</template>
@sethbergman
sethbergman / imageMacro.js
Created July 6, 2017 10:44
You want to display images without writing lots of code or repeating yourself. Create a basic macro to handle it.
// We’re passing the following variables to the macro:
// - The image object
// - Alt text
// - The transform
// - The declared width and height.
// This is what will be output in the tag. You may want it to be different than the actual image size. URL, if you want to // link the image Class You can easily add you own items to the macro, like title, onClick, whatever you like.
{% macro sizedImage(img, alt, transform, declaredWidth, declaredHeight, link, class) %}
@sethbergman
sethbergman / gulpfile.js
Created July 5, 2017 10:15 — forked from ktmud/gulpfile.js
An example gulpfile.js with bower components and live reload support
var BatchStream = require('batch-stream2')
var gulp = require('gulp')
var coffee = require('gulp-coffee')
var uglify = require('gulp-uglify')
var cssmin = require('gulp-minify-css')
var bower = require('gulp-bower-files')
var stylus = require('gulp-stylus')
var livereload = require('gulp-livereload')
var include = require('gulp-include')
var concat = require('gulp-concat')
@sethbergman
sethbergman / async-await.js
Last active July 3, 2017 20:05
await only works inside async functions
async function run () {
try {
const response = await fetch('/api/products')
const data = await response.json()
updateView(data)
} catch (err) {
console.log('Update failed', err)
}
}
@sethbergman
sethbergman / spotify.embed.css
Last active July 1, 2017 02:42
spotify.embed
.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
height: auto;
}
.embed-container iframe,
// server/app.js
const express = require('express');
const morgan = require('morgan');
const path = require('path');
const app = express();
// Setup logger
app.use(morgan(':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] :response-time ms'));