Skip to content

Instantly share code, notes, and snippets.

@einarlove
einarlove / load-env.js
Created March 18, 2016 14:58
load local .env files with app.json as manifest
const path = require('path')
const fs = require('fs')
import attempt from 'lodash/attempt'
const app = require('./app.json')
const readDotEnv = filePath => attempt(
fs.readFileSync(filePath, 'utf-8').split('\n').filter(Boolean)
)
@einarlove
einarlove / data-structure-documentation.md
Last active April 27, 2016 08:53
EarlyBird content data structure documentation
@einarlove
einarlove / normalized.js
Created June 8, 2016 00:15
normalized store with selectors for dummy requests
{
flightsById: {
'sk4011-osl-svg-2016-06-09': { … },
},
flightRequests: {
'sk4011-osl-svg-2016-06-09': {
startedAt: '2016-06-08T17:44:00Z',
completedAt: '2016-06-08T17:44:00Z',
error: null,
import React from 'react'
import { Link } from 'react-router'
import { cashay as cashayClient } from '../client'
import { connect } from 'react-redux'
const FlightDetail = ({ request }) => {
const { data, isComplete } = request
if (!isComplete) {
return <div>Loading</div>
@einarlove
einarlove / Future.js
Last active July 26, 2016 14:32
What if you could pass a function that return multiple styles react-fela?
import { connect } from 'react-fela'
import React from 'react'
const App = ({ styles }) => (
<div>
<h1 className={styles.heading}>Sorry</h1>
<h2 className={styles.ingress}>All your base are belong to us</h2>
<p className={styles.paragraph}>We know it's not nice, but you don't need it anyway.</p>
</div>
)
http://flights.tjenester.avinor.no/flights/departure/ham?fromDate=2016-09-18&toDate=2016-09-20
{
"lastUpdated": "2016-09-16T15:47:12.274Z",
"flightLegs": [
{
"id": "ew4192-ham-osl-20160919",
"flightIds": [
{
"flightId": "EW4192",
@einarlove
einarlove / server-features.md
Created October 21, 2016 13:18
Earlybird server features

Hva vi gjør idag på EarlyBird server

  • healthcheck / pink
  • application insights
  • versjonsjekk mellom client og server
  • sentry error tracking
  • redirect for /personvern-og-cookies -> avinor
  • proxy
    • bilder
  • login
  • sikkerhetskontroll køtid
@einarlove
einarlove / gist:62d97aefdd2fc0be9ab322bd21f29fc2
Created December 13, 2016 11:46
Hide chrome extensions and socket files in Network panel in Google Chrome
-scheme:chrome-extension -sockjs-node
import path from 'path'
import fs from 'fs'
export default root => {
const stories = []
const loopFiles = context => {
fs.readdirSync(context).forEach(name => {
const filepath = path.join(context, name)
if (fs.lstatSync(filepath).isDirectory()) {
@einarlove
einarlove / lightenDarkenColor.js
Created February 15, 2017 12:29
Takes a hex color and luminosity adjustment and outputs new color
/* eslint-disable no-bitwise */
export default (inputColor, amt) => {
let usePound = false
let color = inputColor
if (color[0] === '#') {
color = color.slice(1)
usePound = true
}