Skip to content

Instantly share code, notes, and snippets.

View heyolajyd's full-sized avatar
:octocat:
Coding

Olajide Michael Ade heyolajyd

:octocat:
Coding
View GitHub Profile
@heyolajyd
heyolajyd / simplePagination.js
Created May 23, 2020 01:48
Simple Pagination
import React, { useEffect, useState, useCallback } from 'react';
const USERS_URL = 'https://example.com/api/users';
const PAGE_SIZE = 10;
const calcPageCount = (count) => {
return Math.floor(count/PAGE_SIZE) + (count%PAGE_SIZE ? 1 : 0);
}
@heyolajyd
heyolajyd / arrayFunctions.js
Created June 20, 2019 17:47
[JS] Simple functions on javascript arrays
/*
* Given an array of objects in JavaScript.
* Each one contains a name (a string) and ranking (a number).
* Write two functions, one to return the objects ordered by ranking and another to return the average ranking.
*/
// Calculate the average ranking
const calcAverageRanking = arr => arr.reduce((total, { ranking }) => (total + ranking), 0)/ arr.length;
// Function to return objects ordered by ranking
@heyolajyd
heyolajyd / RegistrationForm.js
Last active October 9, 2016 16:18
Simple Custom TextInput and
import React, { PropTypes, Component } from 'react';
import { isEmpty } from 'underscore';
import { reduxForm } from 'redux-form';
import { bindActions, validateRegFields } from 'path to base';
import { regFields } from 'path to constants';
import TextInput from 'path to TextInput component';
import ProgressBar from 'path to ProgressBar component';
class RegisterForm extends Component {
constructor(props) {
@heyolajyd
heyolajyd / Readme.txt
Last active September 20, 2016 14:25
Simple function to find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
Set up a simple folder strucure thus:
```
SumNumbers
|-src/
| |-index.js
|-test/
| |-test.js
|-package.json
```
@heyolajyd
heyolajyd / Readme.txt
Last active May 20, 2016 00:42
Simple function to flatten an array of arbitrarily nested arrays of integers into a flat array of integers with tests in ES6
Set up a simple folder strucure thus:
```
FlattenList
|-src
| |-index.js
|-test
| |-test.js
|-package.json
```