Skip to content

Instantly share code, notes, and snippets.

View gbozee's full-sized avatar
🎯
Focusing

Abiola gbozee

🎯
Focusing
View GitHub Profile
@gbozee
gbozee / scenario1.js
Last active February 22, 2018 20:06
Buggy Case
import React from "react";
import { render } from "react-dom";
import Hello from "./Hello";
const styles = {
fontFamily: "sans-serif",
textAlign: "center"
};
class ChildComponent extends React.Component {
High High on eagle's wings 3x
Lord take me higher on eagle's wings
We are going higher
We are moving upward way
Backward never forward ever
We are moving high
Verse 1
@gbozee
gbozee / currency_converter.py
Created January 20, 2018 15:02
Python Meetup Lesson Gist
#Twitter @Beee_sama
#Slack pythonnigeria.slack.com @B33s@m@
rates = [{
'country': ['USA'],
'currency': 'USD',
'rate': 360
},
{
'country': ['UK'],
@gbozee
gbozee / base.html
Created December 29, 2017 19:35
Django app that makes api call to the graphql service
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body {
@gbozee
gbozee / app.js
Created December 29, 2017 19:20
Server side implementation files with graphql support
// To use preact, we would have
/***
import { getComponent, cdn, afterScripts } from "./preact-server"; // should be the first line because of how module-alias works
***/
import { getComponent, cdn, afterScripts } from "./react-server";
const { graphqlExpress, graphiqlExpress } = require("apollo-server-express");
import Loadable from "react-loadable";
import express from "express";
import path from "path";
$ yarn build # Builds the frontend application

$ yarn build:server # Build the server application

$ yarn server # Starts the server application
const nodeExternals = require('webpack-node-externals');
const path = require('path');
const srcPath = path.resolve(__dirname, 'src'); //same directory that consist of all the source code. the server app resides here
const distPath = path.resolve(__dirname, 'build'); //same directory created by cra after building the frontend app
module.exports = {
context: srcPath,
entry: 'server.js', //name of server file.
output: {
path: distPath,
@gbozee
gbozee / a setup.md
Last active December 14, 2017 16:57
Preparing Server Code.
$ yarn add --dev babel-cli # to compile our node application 
$ yarn add --dev babel-plugin-dynamic-import-webpack # To ensure server webpack config understands the `import` provided by webpack
$ yarn add --dev babel-plugin-transform-object-rest-spread # ability to use the compile the spread operator in Node
$ yarn add --dev babel-preset-env # default preset for babel when compiling
$ yarn add --dev babel-preset-react # ensure that babel understands react from the server
$ yarn add --dev file-loader url-loader webpack-node-externals # webpack specific loaders to be used by the server.
$ yarn add module-alias # Since we are swapping out React for Preact in production, does the job of webpack resolve alias.
@gbozee
gbozee / App.js
Created December 14, 2017 16:30
Frontend code located in `src`
import React, { Component } from 'react';
import { Link } from "react-router-dom";
import styled, {css, keyframes, injectGlobal} from 'styled-components'
import logo from './logo.svg';
injectGlobal`
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
@gbozee
gbozee / a script.md
Last active December 14, 2017 16:20
extends Default Create react app webpack config
$ yarn add --dev dynamic-cdn-webpack-plugin # load react from a cdn when built in production mode
$ yarn add --dev module-to-cdn # required by dynamic-cdn-webpack-plugin
$ yarn add --dev react-app-rewire-preact # install preact-compat
$ yarn add --dev react-app-rewire-styled-components # ability to use babel plugin of styled-components
$ yarn add --dev preload-webpack-plugin # ability to prefetch all code splitted routes/components.