The AVR series microcontrollers are a collection of cheap and versatile chips that are used in many applications ranging from hobbist projects to commercial infrastructure. One major problem for some hobbists is the lack of secure random number generation on the Arduino platform. The included pseudo-random number generator (PRNG) is very easy to defeat and is useless for any crypto-related uses. One recommendation from the Arduino Reference Manual is to use atmospheric noise from the chip's analog sensor pins as seed data[6].
Unfortunately this method is extremely weak and should not be used to emulate a true random number generator (TRNG). Existing methods such as using the internal timer drift or using a dedicated generator are either too slow, requires extensive external hardware or modifications to the microcontroller's internal mech
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Example extends React.Component< | |
Props, | |
State, | |
Snapshot | |
> { | |
static getDerivedStateFromProps( | |
nextProps: Props, | |
prevState: State | |
): $Shape<State> | null { | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// USING: | |
// import Messenger from './Messenger' | |
// <Messenger news={['your', 'array', 'with', 'strings', 'here']}/> | |
import React, { Component } from "react"; | |
export default class Messenger extends Component { | |
state = { | |
mainMessage: "", | |
codeletters: "&#*+%?£@§$", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="messenger"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
axios({ | |
url: 'http://localhost:5000/static/example.pdf', | |
method: 'GET', | |
responseType: 'blob', // important | |
}).then((response) => { | |
const url = window.URL.createObjectURL(new Blob([response.data])); | |
const link = document.createElement('a'); | |
link.href = url; | |
link.setAttribute('download', 'file.pdf'); | |
document.body.appendChild(link); |
Python docstrings can be written following several formats as the other posts showed. However the default Sphinx docstring format was not mentioned and is based on reStructuredText (reST). You can get some information about the main formats in that tuto.
Note that the reST is recommended by the PEP 287
There follows the main used formats for docstrings.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PREFIX = 'synaptic' | |
const NpmRegExp = /^@?[a-z0-9\-]*([a-z0-9\-])?$/ | |
export default function requireByKind ( kind, given ) { | |
// Avoid access to specific files by restricting the `given` | |
if ( given.match( NpmRegExp ) ) { | |
throw new Error( `only alphanumeric names are valid` ) | |
} |
- Users want to compose reducer tree across modules
- Idea of a single reducer function makes it difficult for the library to dynamically augment the shape of the state tree
- Turning control over to the library to build the root reducer limits the use of meta-reducers
- Feature modules may inadvertently collide with the state of the root module
- Library authors may want to leverage @ngrx/store in their projects and provide an easy way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloStore } from 'apollo-client'; | |
import { Store } from '@ngrx/store'; | |
import { skip } from 'rxjs/operator/skip'; | |
import { take } from 'rxjs/operator/take'; | |
export function toApolloStore(store: Store<any>): ApolloStore { | |
return { | |
subscribe(fn: () => void): () => void { | |
const futureStates$ = skip.call(store, 1); |