By using ReturnType
we don't have to manually write type for Context
See also gist for SolidJS https://gist.github.com/JLarky/a46055f673a2cb021db1a34449e3be07
And original tweet https://twitter.com/JLarky/status/1554152932425117697
By using ReturnType
we don't have to manually write type for Context
See also gist for SolidJS https://gist.github.com/JLarky/a46055f673a2cb021db1a34449e3be07
And original tweet https://twitter.com/JLarky/status/1554152932425117697
import React, { Component } from 'react'; | |
import { render } from 'react-dom'; | |
import InputTrigger from 'react-input-trigger'; | |
class App extends Component { | |
constructor() { | |
this.state = { | |
top: null, | |
left: null, | |
showSuggestor: false, |
When hosting our web applications, we often have one public IP
address (i.e., an IP address visible to the outside world)
using which we want to host multiple web apps. For example, one
may wants to host three different web apps respectively for
example1.com
, example2.com
, and example1.com/images
on
the same machine using a single IP address.
How can we do that? Well, the good news is Internet browsers
#Download Elementary OS from here: | |
#https://elementary.io/ | |
#Clean-up System | |
sudo apt-get purge midori-granite -y | |
sudo apt-get purge yelp -y | |
sudo apt-get purge evince -y | |
sudo apt-get purge gnome-orca -y | |
sudo apt-get autoremove -y | |
sudo apt-get autoclean -y |
var crypto = require('crypto') | |
, rrange = 4294967296; | |
/** | |
* Return an integer, pseudo-random number in the range [0, 2^32). | |
*/ | |
var nextInt = function() { | |
return crypto.randomBytes(4).readUInt32BE(0); | |
}; |
First of all, please note that token expiration and revoking are two different things.
A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.
Quoted from JWT RFC:
/** | |
* Tweet sized English number to Persian converter and vice versa. | |
* You can find out old and obsolete version in here: https://gist.github.com/eAmin/786108 | |
* by Amin Akbari | |
* MIT License | |
*/ | |
/** | |
* Convert English numbers to Persian | |
* |
Not all random values are created equal - for security-related code, you need a specific kind of random value.
A summary of this article, if you don't want to read the entire thing:
Math.random()
. There are extremely few cases where Math.random()
is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.crypto.getRandomBytes
directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.uuid
, specifically the uuid.v4()
method. Avoid node-uuid
- it's not the same package, and doesn't produce reliably secure random values.random-number-csprng
.You should seriously consider reading the entire article, though - it's
function download(fileUrl, apiPath, callback) { | |
var url = require('url'), | |
http = require('http'), | |
p = url.parse(fileUrl), | |
timeout = 10000; | |
var file = fs.createWriteStream(apiPath); | |
var timeout_wrapper = function( req ) { | |
return function() { |