- Update OS
sudo apt-get update && sudo apt-get upgrade
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 |
'use strict'; | |
const crypto = require('crypto'); | |
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters) | |
const IV_LENGTH = 16; // For AES, this is always 16 | |
function encrypt(text) { | |
let iv = crypto.randomBytes(IV_LENGTH); | |
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv); |
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:
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.instanceof
to test whether a value is an element of an enum.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 |
/* | |
Initialize the variables | |
-------------------------- | |
private int jumpWidth = 0; | |
private boolean jumpStatus = false; | |
private int gravity = 2; | |
private int jumpPower = 5; | |
private boolean startJump = false; | |
*/ |