Skip to content

Instantly share code, notes, and snippets.

View avastamin's full-sized avatar

Ruhul Amin avastamin

View GitHub Profile
https://gist.github.com/avastamin/a254506a97374c921d9bd4e086ff7ef2
/**
* In this short assessment, the following code tries to implement the React Suspense API,
* but does so incorrectly. There are 3 core issues with how these components utilize Suspense and concurrent mode -- can you find them?
*
* In your submission, be sure to:
* 1) Clearly identify what the 3 core issues are, and how they violate the principles of React Suspense;
* 2) Write and submit the code to fix the core issues you have identified in a gist of your own
*
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
//https://groups.google.com/forum/#!topic/mongodb-user/AdlvRy1AC_I
//https://stackoverflow.com/questions/45293832/simple-questionnaire-app-design-in-mongodb
// https://stackoverflow.com/questions/19672260/mongodb-schema-for-dynamic-questions-and-answers
// https://talk.birmingham.io/t/questionnaire-database-schema-help/1464
//https://stackoverflow.com/questions/9127174/why-does-mongoose-have-both-schemas-and-models
const QuestionSchema = new Schema({
name: String,

Folder Structure

Motivations

  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
import React, { useState, useEffect } from "react";
import Button from "@material-ui/core/Button";
import { makeStyles } from "@material-ui/core";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from "@material-ui/core/DialogContent";
import DialogTitle from "@material-ui/core/DialogTitle";
import TextField from "@material-ui/core/TextField";
import CancelIcon from "@material-ui/icons/Cancel";
export const authenticateWithTwilio = () => (dispatch) => {
dispatch(fetchTwilioRequest());
return API.getTwilioToken()
.then((response) => {
dispatch(authenticateWithTwilioSuccess(response));
Client.create(response.token).then((chatClient) => {
twilioChat.chatClient = chatClient;
dispatch(initChat(chatClient));
chatClient.on('messageAdded', message => dispatch(sendNewMessageSuccess(message)));
});
@avastamin
avastamin / README.md
Created February 15, 2018 12:22 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@avastamin
avastamin / IndexedDB101.js
Created January 7, 2018 18:09 — forked from JamesMessinger/IndexedDB101.js
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});
@avastamin
avastamin / braking.md
Created December 11, 2017 08:50
Fahrschule
@avastamin
avastamin / pardot-form-handler-iframe.html
Created October 10, 2017 13:57 — forked from afischoff/pardot-form-handler-iframe.html
Example of using a hidden iframe to pass data to a Pardot form handler before continuing with normal form submission.
<html>
<head>
<title>Pardot Example Form Handler Submit</title>
<!-- Include jQuery -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- Post to Pardot function -->
<script type="text/javascript">
// set the pardot form handler url and form element id
/*
* Programming Quiz: Make An Iterable Object
*
* Turn the `james` object into an iterable object.
*
* Each call to iterator.next should log out an object with the following info:
* - key: the key from the `james` object
* - value: the value of the key from the `james` object
* - done: true or false if there are more keys/values
*