import { PRIMARY, PRIMARY_LIGHT, IRON_GREY } from '@styles/variables/colors' | |
import React, { useEffect, useRef, useState } from 'react' | |
import styled from 'styled-components' | |
const Slider = styled.div` | |
position: relative; | |
margin: 16px auto; | |
width: calc(100% - 12px); | |
height: 8px; | |
background: ${PRIMARY_LIGHT}; |
/*- | |
* Copyright (c) 2017 | |
* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
import { createCipheriv, createDecipheriv, randomBytes } from "crypto"; | |
const ENCRYPTION_KEY: string = process.env.ENCRYPTION_KEY || ""; // Must be 256 bits (32 characters) | |
const IV_LENGTH: number = 16; // For AES, this is always 16 | |
/** | |
* Will generate valid encryption keys for use | |
* Not used in the code below, but generate one and store it in ENV for your own purposes | |
*/ | |
export function keyGen() { |
Recently I noticed that Safari 10 for Mac/iOS had achieved 100% support for ES6. With that in mind, I began to look at the browser landscape and see how thorough the support in the other browsers. Also, how does that compare to Babel and its core-js
runtime. According to an ES6 compatability table, Chrome, Firefox, and IE Edge have all surpassed what the Babel transpiler can generate in conjunction with runtime polyfills. The Babel/core-js combination achieves 71% support for ES6, which is quite a bit lower than the latest browsers provide.
It made me ask the question, "Do we need to run the babel es2015 preset anymore?", at least if our target audience is using Chrome, Firefox, or Safari.
It's clear that, for now, we can't create a site or application that only serves ES6. That will exclude users of Internet Explorer and various older browsers running on older iOS and Android devices. For example, Safari on iOS 9 has pretty mediocre ES6 support.
// getComponent is a function that returns a promise for a component | |
// It will not be called until the first mount | |
function asyncComponent(getComponent) { | |
return class AsyncComponent extends React.Component { | |
static Component = null; | |
state = { Component: AsyncComponent.Component }; | |
componentWillMount() { | |
if (!this.state.Component) { | |
getComponent().then(Component => { |
Advantages compared to using symbols as enum values:
- Enum values are much more customizable. For example, one can have custom prototype and/or instance methods.
- Enum values get two custom properties:
name
provides direct access to the name of an enum value.ordinal
holds a number, the position of the enum value. Useful for some applications.
- One can use
instanceof
to test whether a value is an element of an enum. - One occasionally requested feature for enums is that enum values be numbers (e.g. for flags) or strings (e.g. to compare with values in HTTP headers). That can be achieved by making those values properties of enum values. For an example, see
enum Mode
, below.
Static properties of enums:
The usecase here is to migrate an Heroku Application to Heroku Europe, and minimise downtime.
The heroku documentation on this subject is quite complete.
It is recommanded to read it if you are planning a migration.
https://devcenter.heroku.com/articles/app-migration
In this guide, sourceapp is the original (source) app and targetapp is the migrated (target) app.
var db = mongoose.connect('mongodb://localhost:27017/DB'); | |
// In middleware | |
app.use(function (req, res, next) { | |
// action after response | |
var afterResponse = function() { | |
logger.info({req: req}, "End request"); | |
// any other clean ups |