Skip to content

Instantly share code, notes, and snippets.

View kingisaac95's full-sized avatar

Kingdom Orjiewuru kingisaac95

View GitHub Profile
@kingisaac95
kingisaac95 / index.js
Last active September 19, 2017 13:12
DMS Schema v1
const { makeExecutableSchema } = require('graphql-tools');
const typeDefinitions = `
type Document {
id: ID!
title: String!
content: String!
}
type User {
@kingisaac95
kingisaac95 / index.js
Created September 19, 2017 13:07
DMS Server v1
const express = require('express');
const bodyParser = require('body-parser');
// handle graphql request and response based on schema
const { graphqlExpress } = require('apollo-server-express');
const schema = require('./schema');
let app = express();
@kingisaac95
kingisaac95 / resolvers.js
Last active September 19, 2017 15:40
DMS Resolver v1
const documents = [
{
id: 1,
title: 'document 1',
content: 'The first document'
},
{
id: 2,
title: 'document 2',
content: 'The second document'
@kingisaac95
kingisaac95 / RavePayment.jsx
Last active September 29, 2017 15:06
A simple script for rave-payment library that + a little button for triggering the modal.
import React, { Component } from 'react'
// import the library
import RavePaymentModal from 'react-ravepayment'
class App extends Component {
state = {
key: "FLWPUBK-XXXXXXXXXXXXXXXXXXXXXXXXXX-X", // RavePay PUBLIC KEY
email: "foo@example.com", // customer email
amount: "1000" // equals NGN 1000. Minimum amount allow of NGN500,
@kingisaac95
kingisaac95 / Workshop_v1.jsx
Created December 5, 2017 17:32
Fetch and render
import React, { Component } from 'react';
import request from 'axios';
import Name from './Name.jsx';
class WorkShop extends Component {
constructor(props) {
super(props);
this.state = {
user: {},
@kingisaac95
kingisaac95 / Name_v1.jsx
Created December 5, 2017 17:32
Receive and render
import React from 'react';
const Name = ({ data: { bio, avatar, handleClick } }) => {
return (
<div>
<button onClick={handleClick}>Click Me</button>
<h4>About: {bio}</h4>
<img src={avatar} alt="avatar"/>
</div>
);
import React, { Component } from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import Name from './Name.jsx';
import { fetchUserData } from '../../../actions/getUserActions';
class WorkShop extends Component {
constructor(props) {
super(props);
class DynamicForm extends React.Component {
constructor(props) {
super(props);
this.state = {
education: [
{ name: '', start: '', end: '' },
]
}
}
@kingisaac95
kingisaac95 / readFile.js
Last active November 18, 2021 16:41
File Reader to Base64
/*
* @params - event: upload file event
* @params - onComplete: callback provided by caller
*/
const uploadFile = ({ event, onComplete }) => {
event.preventDefault();
var base64File = null;
const file = event.target.files[0];
@kingisaac95
kingisaac95 / searchContact.js
Last active August 5, 2021 13:54
A simple algorithm to search through a contact list; where contact list is an array with first and last names spaced out.
const sampleData = ['tom harry', 'dike harry', 'girl guy', 'boo baa'];
/**
* use first/last name to create regex pattern
* if no last name return first name pattern
*/
const getSearchPattern = (terms, index) =>
new RegExp(".*" + (terms[index] ? terms[index] : terms[0]) + ".*");
const searchUsers = (searchTerm) => {