Skip to content

Instantly share code, notes, and snippets.

View gitumarkk's full-sized avatar

Mark Gituma gitumarkk

  • Toronto, Canada
View GitHub Profile
//...
export default function SelectFile () {
const dispatch = useDispatch();
const pickVideo = () => {
const options = {
title: 'Upload Video',
takePhotoButtonTitle: 'Record video',
chooseFromLibraryButtonTitle: 'Choose From Library',
mediaType: 'video',
python manage.py migrate
gunicorn kubernetes_django.wsgi:application --bind 0.0.0.0:8000 --log-level info --timeout 180 --workers 3
@gitumarkk
gitumarkk / django-react-k8s-pod.yaml
Last active August 21, 2020 19:35
Django React Kubernetes Pod
---
apiVersion: v1
kind: Pod
metadata:
name: django-react-k8s-pod
labels:
pod: django-react-k8s
spec:
containers:
- name: django
@gitumarkk
gitumarkk / build-and-deploy.py
Last active August 21, 2020 19:34
Django React Kubernetes config override
import argparse
import os
from pathlib import Path
def get_docker_image(tag, env):
return f'gcr.io/<PROJECT_ID>/django_react_k8s:{tag}'
def get_bucket(env):
return f'<BUCKET_PREFIX>-{env}'
@gitumarkk
gitumarkk / config-override.js
Last active August 20, 2020 16:07
Django React Kubernetes config override
const BundleTracker = require("webpack-bundle-tracker");
const paths = require("react-scripts/config/paths");
const WriteFilePlugin = require("write-file-webpack-plugin");
const {
override,
addWebpackPlugin,
} = require("customize-cra");
function appOverride(config) {
const bucket = `https://storage.googleapis.com/${process.env.REACT_GCLOUD_BUCKET}/`;
// feed.js
export const APP_NAME = 'APP_NAME';
// Action Constants
const GET_REQUEST = `${APP_NAME}/GET_REQUEST`;
const GET_SUCCESS = `${APP_NAME}/GET_SUCCESS`;
const GET_ERROR = `${APP_NAME}/GET_ERROR`;
const URL = '/api/v1/endpoint/';
// Action Creators
export const getRequest = () => ({ type: GET_REQUEST });
/*********** module/container.js ***********/
import React from 'react';
import { createStructuredSelector } from 'reselect';
import { connect } from 'react-redux';
// App
import ReduxApi from 'containers/redux/api';
const user = new ReduxApi('user', '/api/v1/user/');
const feed = new ReduxAPI('feed', '/api/v1/feed/');
/*********** redux/index.js ***********/
import { all } from 'redux-saga/effects';
import ReduxAPI from './api';
// creating objects using the ReduxAPI base class
const user = new ReduxAPI('user', '/api/v1/user/');
const feed = new ReduxAPI('feed', '/api/v1/feed/');
const comment = new ReduxAPI('comment', '/api/v1/comment/');
// exporting the reducers as a default object
class ReduxApi {
constructor(appName, relativePath) {
this.APP_NAME = appName;
this.URL = `{relativePath}`
this.GET_REQUEST = `${this.APP_NAME}/GET_REQUEST`;
this.GET_SUCCESS = `${this.APP_NAME}/GET_SUCCESS`;
this.GET_ERROR = `${this.APP_NAME}/GET_ERROR`;
// NEEDS TO BE BOUND TO CURRENT CONTEXT
/*********** redux/api.js ***********/
class ReduxApi {
constructor(appName, relativePath) {
this.APP_NAME = appName;
this.URL = `{relativePath}`
this.GET_REQUEST = `${this.APP_NAME}/GET_REQUEST`;
this.GET_SUCCESS = `${this.APP_NAME}/GET_SUCCESS`;
this.GET_ERROR = `${this.APP_NAME}/GET_ERROR`;