Skip to content

Instantly share code, notes, and snippets.

Avatar
🙏
These hands make digital projects finish.

Nick Dandakis nickdandakis

🙏
These hands make digital projects finish.
View GitHub Profile
@nickdandakis
nickdandakis / ModalPortal.jsx
Created Sep 17, 2020
A basic React Modal Portal
View ModalPortal.jsx
// Import dynamically without SSR, as this is expected to be rendered clientside only
// e.g. const ModalPortal = dynamic(() => import('~/shared/components/ModalPortal'), { ssr: false });
//
// Expects an empty div with id of `modal-portal-root` somewhere in the DOM
import React, { useRef, useEffect } from 'react';
import { createPortal } from 'react-dom';
function ModalPortal({ children }) {
const $modalPortalRoot = useRef();
@nickdandakis
nickdandakis / debounce.js
Last active Sep 15, 2020
Common utility functions and hooks when working in a React codebase
View debounce.js
export default function debounce (fn, delay) {
let timeoutID = null;
return function (...args) {
clearTimeout(timeoutID);
timeoutID = setTimeout(() => {
fn.call(this, ...args);
}, delay);
};
};
@nickdandakis
nickdandakis / ReCAPTCHA.jsx
Created Jun 2, 2019
A React component for Google's ReCAPTCHA
View ReCAPTCHA.jsx
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class ReCAPTCHA extends Component {
static propTypes = {
sitekey: PropTypes.string.isRequired,
onVerify: PropTypes.func,
};
static defaultProps = {
@nickdandakis
nickdandakis / MacOSWindowControls.jsx
Created Mar 16, 2018
Apple MacOS window controls
View MacOSWindowControls.jsx
import React, { Component } from 'react';
import classnames from 'classnames';
const ALT = 18;
class MacOSWindowControls extends Component {
state = {
altKeyDown: false,
blurred: false,
fullscreen: false,
@nickdandakis
nickdandakis / WindowsWindowControls.jsx
Created Mar 16, 2018
Microsoft Windows window controls
View WindowsWindowControls.jsx
import React, { Component } from 'react';
import _ from 'lodash';
import classnames from 'classnames';
import { remote } from 'electron';
class WindowsWindowControls extends Component {
state = {
fullscreen: false,
blur: false,
};
@nickdandakis
nickdandakis / package.json
Last active Apr 11, 2019
Next.js + AWS Elastic Beanstalk + AWS EC2 Container Service + Docker package.json
View package.json
{
"name": "this-web-scale",
"version": "0.0.1",
"scripts": {
"dev": "node server.js",
"build": "NODE_ENV=production next build",
"start": "NODE_ENV=production node server.js",
"dockerize": "npm run build:docker && npm run tag:docker && npm run push:docker && npm run tag-latest:docker && npm run push-latest:docker",
"deploy": "eb use this-web-scale-production && eb deploy --label v$npm_package_version --verbose",
"build:docker": "docker build -t $npm_package_config_docker_image:$npm_package_version -t $npm_package_config_docker_image:latest .",
@nickdandakis
nickdandakis / config.yml
Last active Nov 13, 2019
AWS Elastic Beanstalk configuration with Dockerrun.aws.json deployment artifact
View config.yml
branch-defaults:
develop:
environment: this-web-scale-production
deploy:
artifact: Dockerrun.aws.json
environment-defaults:
this-web-scale-production:
branch: null
repository: null
global:
@nickdandakis
nickdandakis / package.json
Created Oct 14, 2017
Next.js + AWS Elastic Beanstalk + AWS EC2 Container Service + Docker package.json
View package.json
{
"name": "this-web-scale",
"version": "x.x.x",
"scripts": {
"dev": "node server.js",
"build": "NODE_ENV=production next build",
"start": "NODE_ENV=production node server.js",
"dockerize": "npm run build:docker && npm run tag:docker && npm run push:docker && npm run tag-latest:docker && npm run push-latest:docker",
"deploy": "npm run deploy:staging",
"deploy:staging": "eb use token-staging && eb deploy --label v$npm_package_version --verbose",
@nickdandakis
nickdandakis / package.json
Created Oct 14, 2017
Next.js + Docker + AWS Elastic Beanstalk + AWS Elastic Container Service package.json
View package.json
{
"name": "this-web-scale",
"version": "x.x.x",
"scripts": {
"dev": "node server.js",
"build": "NODE_ENV=production next build",
"start": "NODE_ENV=production node server.js",
"dockerize": "npm run build:docker && npm run tag:docker && npm run push:docker && npm run tag-latest:docker && npm run push-latest:docker",
"deploy": "npm run deploy:staging",
"deploy:staging": "eb use token-staging && eb deploy --label v$npm_package_version --verbose",
@nickdandakis
nickdandakis / Dockerrun.aws.json
Last active Oct 16, 2017
Single Container Docker AWS Elastic Beanstalk deployment artifact
View Dockerrun.aws.json
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "bestest-aws-org.dkr.ecr.us-east-1.amazonaws.com/token/this-web-scale:latest",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "3000"
}