Skip to content

Instantly share code, notes, and snippets.

@neevai
neevai / background-storage.js
Created March 17, 2020 15:44
An Amplify.Storage class for Chrome extensions
/* global chrome */
const MEMORY_KEY_PREFIX = '@BackgroundStorage:';
let dataMemory = {};
export default class BackgroundStorage {
static syncPromise = null;
@neevai
neevai / ReactiveIframe.js
Created March 21, 2019 13:28
React iframe component that listens to messages from the embedded document
import React from 'react';
import PropTypes from 'prop-types';
export default class ReactiveIframe extends React.Component {
static propTypes = {
origin: PropTypes.string.isRequired,
src: PropTypes.string.isRequired,
onMessage: PropTypes.func.isRequired,
title: PropTypes.string,
frameBorder: PropTypes.number
@neevai
neevai / flask_admin_http_basic_auth.py
Created January 31, 2019 13:34
Apply HTTP basic auth just to the admin interface
# The docs say "Unfortunately, there is no easy way of applying HTTP Basic Auth just to your admin interface."
# But this is not true :)
# First:
# pip install flask-admin
# pip install flask-basicauth
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
from flask_admin.base import expose, AdminIndexView
from flask_basicauth import BasicAuth
@neevai
neevai / nginx.conf
Last active January 31, 2019 13:35
Nginx configuration server block for static frontend and websocket backend
# Nginx configuration server block for static frontend and websocket backend
# For example - React and Gunicorn or Angular and Rack
#
# Setup:
# sudo cp nginx.conf /etc/nginx/sites-available/mynewconfig
# sudo ln -s /etc/nginx/sites-available/mynewconfig /etc/nginx/sites-enabled
# sudo rm /etc/nginx/sites-enabled/default
# sudo service nginx restart
#