Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save christiaanwesterbeek/277db6f04bd26d87d0f1b3c9a8552e1f to your computer and use it in GitHub Desktop.
Mijn FAQ
Q: En nu wil ik het naadje van de kous weten van Apollo in Express
A: https://www.robinwieruch.de/graphql-apollo-server-tutorial/
Q: Genereer een veilig token dat in een URL gebruikt kan worden
A: https://stackoverflow.com/questions/8855687/secure-random-token-in-node-js
```
const crypto = require('crypto')
const randomBytes = Util.promisify(crypto.randomBytes)
const plain = (await randomBytes(24)).toString('base64').replace(/\W/g, '')
```
Q: Ik wil debounced zoeken met react hooks.
A:
import React, { useState } from 'react';
import { useDebounce } from 'use-debounce';
const Search = () => {
const [searchTerm, setSearchTerm] = useState('');
const [debouncedSearchTerm] = useDebounce(searchTerm, 1000);
const handleChange = event => {
setSearchTerm(event.target.value);
}
return (
<div>
<TextField
label="Zoeken"
value={searchTerm}
onChange={handleChange}
/>
<div>searchTerm: {searchTerm}</div>
<div>debouncedSearchTerm: {debouncedSearchTerm}</div>
</div>
);
};
export default Search;
Q: Hoe kopieer ik een tabel van Postgres server a naar server b?
A:
```
pg_dump -h host_source -U user_source -d db_source -a -t "schema_name.table_name">~/table_dump
# Alles verwijderen boven COPY schema_name.table_name (...
psql -h host_target -U user_target -d db_target<~/table_dump
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment