const ListItems = [
{ id: 1, address: '/link-one', text: 'Link One' },
{ id: 2, address: '/link-two', text: 'Link Two' },
{ id: 3, address: '/link-three', text: 'Link Three' },
{ id: 4, address: '/link-four', text: 'Link Four' },
{ id: 5, address: '/link-five', text: 'Link Five' }
]
const l = console.log.bind(this)
const _a = atom({ list: [1,2,3,4], bool: false, key: 'value' })
_a.subscribe(() => l(_a.get())) // will log the state on every change
_a.get('key') // 'value'
const { key } = _a.get() // key === { key: 'value' }
const root1 = document.getElementById('root1') | |
const root2 = document.getElementById('root2') | |
const root3 = document.getElementById('root3') | |
const l = console.log.bind(this) | |
const api = { | |
path: 'https://jsonplaceholder.typicode.com', | |
getPostById(id) { | |
return m.request({ url: `${this.path}/posts/${id}` }) | |
}, |
const webpack = require('webpack'); | |
require('dotenv').config({ | |
path: process.env.NODE_ENV === 'production' ? '.env.production' : '.env' | |
}); | |
module.exports = { | |
webpack: config => { | |
const env = Object.keys(process.env).reduce((acc, curr) => { | |
acc[`process.env.${curr}`] = JSON.stringify(process.env[curr]); |
/** | |
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken | |
* It was requested to be introduced at as part of the jsonwebtoken library, | |
* since we feel it does not add too much value but it will add code to mantain | |
* we won't include it. | |
* | |
* I create this gist just to help those who want to auto-refresh JWTs. | |
*/ | |
const jwt = require('jsonwebtoken'); |
Based on info from http://peterdowns.com/posts/open-iterm-finder-service.html but with modified behavior and fixed to work with iTerm2 version 3 or later. It will not work with older versions of iTerm. The modified behavior is to open a new terminal window for each invocation instead of reusing an already open window. Update - The original author released a build script for the newer iTerm2 versions at https://github.com/peterldowns/iterm2-finder-tools that keeps the original behavior of reusing an open iTerm2 window.
- Run Automator, select a new Service
- Select Utilities -> Run AppleScript
- Service receives selected 'folders' in 'finder.app'
- Paste script:
Direct copy of pre-encoded file:
$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8
ffmpeg -i data/video.mp4 -vcodec h264 -b:v 1000k -acodec mp2 data/output.mp4 |
Whether your component relies on client-side features or you are using 3rd party components that are not designed for server-side rendering, sometimes you'll want to defer rendering until on the client. For our example, we'll be using react-chart-2 to load a Doughnut chart.
You'll need a next
project and to install chart.js
+ react-chartjs-2
.
$ npm install --save chart.js react-chartjs-2
// connect() is a function that injects Redux-related props into your component. | |
// You can inject data and callbacks that change that data by dispatching actions. | |
function connect(mapStateToProps, mapDispatchToProps) { | |
// It lets us inject component as the last step so people can use it as a decorator. | |
// Generally you don't need to worry about it. | |
return function (WrappedComponent) { | |
// It returns a component | |
return class extends React.Component { | |
render() { | |
return ( |