[6:34 PM] marekweb: I started using ES6 classes for my React components because ES6 is the new hotness and all that, but I'm realizing that I can't actually name any advantages, and I have to bind methods manually. So why use classes over React.createClass?
[6:34 PM] acemarke: a few reasons
[6:35 PM] acemarke: first, classes are an official part of the language
[6:35 PM] acemarke: second, that means that tooling understands the syntax
[6:35 PM] acemarke: third, createClass is eventually going to be deprecated
[6:36 PM] acemarke: there's various solutions to the method binding issue
[6:36 PM] acemarke: the suggested one is to use the "class properties" syntax, which isn't yet final, but I think may have recently hit stage 3
[6:37 PM] acemarke: ah... no, looks like it's still stage 2. Object spread hit stage 3, that's what I was thinking of
[6:37 PM] acemarke: that said, class properties are well supported in Babel, and used in tools like create-react-app
[
| 'use strict'; | |
| const crypto = require('crypto'); | |
| const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bytes (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', new Buffer(ENCRYPTION_KEY), iv); |
| import moment from 'moment'; | |
| const log = console.log; | |
| let date1 = moment().format(); | |
| let mom = moment(); | |
| // log(moment('2017-11-21', 'YYYY-MM-DD').toISOString()) | |
| // log(moment().format()) | |
| // log(typeof date1); | |
| // log(date1); | |
| // Object.keys( |
| #!/bin/bash | |
| set -e | |
| # Shell script to compute code coverage even after the Babel transforms have | |
| # been applied. | |
| # Clear previous coverage. | |
| rm -rf coverage | |
| # Generate test coverage based on however `npm test` performs the tests. |
My current editor of choice for all things related to Javascript and Node is VS Code, which I highly recommend. The other day I needed to hunt down a bug in one of my tests written in ES6, which at time of writing is not fully supported in Node. Shortly after, I found myself down the rabbit hole of debugging in VS Code and realized this isn't as straightforward as I thought initially. This short post summarizes the steps I took to make debugging ES6 in VS Code frictionless.
My first approach was a launch configuration in launch.json mimicking tape -r babel-register ./path/to/testfile.js with babel configured to create inline sourcemaps in my package.json. The debugging started but breakpoints and stepping through the code in VS Code were a complete mess. Apparently, ad-hoc transpilation via babel-require-hook and inline sourcemaps do not work in VS Code. The same result for
attaching (instead of launch) to `babel-node
| #!/usr/bin/env bash | |
| # | |
| # Usage: dev_signed_cert.sh HOSTNAME | |
| # | |
| # Creates a CA cert and then generates an SSL certificate signed by that CA for the | |
| # given hostname. | |
| # | |
| # After running this, add the generated dev_cert_ca.cert.pem to the trusted root | |
| # authorities in your browser / client system. | |
| # |
Steps to deploy a Node.js app to Digital Ocean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt
If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a
I will be using the root user, but would suggest creating a new user
| #### INFOS #### | |
| openapi: "3.0.0" | |
| info: | |
| version: <PROJET VERSION> | |
| title: <PROJET NAME> | |
| description: >- | |
| Multiline description allowed. | |
| <br/> | |
| <br/> | |
| Lines jumps using `<br/>` are also possibles and Markdown |
Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.
