This file contains hidden or 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
#!/usr/bin/env bash | |
echo "Restoring database" | |
psql -U postgres -c "CREATE DATABASE ${DBNAME}" | |
pg_restore -v -d ${DBNAME} /tmp/${FILE} > /tmp/log | |
psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE ${DBNAME} TO postgres" | |
echo "Database restored successfully" |
This file contains hidden or 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 throttle = (callback, delay) => { | |
let throttleTimeout = null; | |
let storedEvent = null; | |
const throttledEventHandler = event => { | |
storedEvent = event; | |
const shouldHandleEvent = !throttleTimeout; | |
if (shouldHandleEvent) { |
This file contains hidden or 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 poll = ({ fn, validate, interval, maxAttempts }) => { | |
console.log('Start poll...'); | |
let attempts = 0; | |
const executePoll = async (resolve, reject) => { | |
console.log('- poll'); | |
const result = await fn(); | |
attempts++; | |
if (validate(result)) { |
This file contains hidden or 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 poll = async ({ fn, validate, interval, maxAttempts }) => { | |
let attempts = 0; | |
const executePoll = async (resolve, reject) => { | |
const result = await fn(); | |
attempts++; | |
if (validate(result)) { | |
return resolve(result); | |
} else if (maxAttempts && attempts === maxAttempts) { |
This file contains hidden or 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 express from 'express'; | |
import { rootHandler, helloHandler } from './handlers'; | |
const app = express(); | |
const port = process.env.PORT || '8000'; | |
app.get('/', rootHandler); | |
app.get('/hello/:name', helloHandler); | |
app.listen(port, err => { |
This file contains hidden or 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 { Request, Response } from 'express'; | |
interface HelloResponse { | |
hello: string; | |
} | |
type HelloBuilder = (name: string) => HelloResponse; | |
const helloBuilder: HelloBuilder = name => ({ hello: name }); |
This file contains hidden or 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
Show hidden characters
{ | |
"compilerOptions": { | |
"module": "commonjs", | |
"esModuleInterop": true, | |
"allowSyntheticDefaultImports": true, | |
"target": "es6", | |
"noImplicitAny": true, | |
"moduleResolution": "node", | |
"sourceMap": true, | |
"outDir": "dist", |
This file contains hidden or 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
{ | |
"compilerOptions": { | |
/* Basic Options */ | |
// "incremental": true, /* Enable incremental compilation */ | |
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ | |
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ | |
// "lib": [], /* Specify library files to be included in the compilation. */ | |
// "allowJs": true, /* Allow javascript files to be compiled. */ | |
// "checkJs": true, /* Report errors in .js files. */ | |
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ |
This file contains hidden or 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
// Pass in the callback that we want to throttle and the delay between throttled events | |
const throttle = (callback, delay) => { | |
// Create a closure around these variables. | |
// They will be shared among all events handled by the throttle. | |
let throttleTimeout = null; | |
let storedEvent = null; | |
// This is the function that will handle events and throttle callbacks when the throttle is active. | |
const throttledEventHandler = event => { | |
// Update the stored event every iteration |
This file contains hidden or 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 <PageComponentName> from './<PageComponentName>'; | |
export default <PageComponentName>; |