Skip to content

Instantly share code, notes, and snippets.

View olayemii's full-sized avatar
🐼
Working from home

Olayemii Garuba olayemii

🐼
Working from home
View GitHub Profile
This file has been truncated, but you can view the full file.
{
"numTotalTestSuites": 911,
"numPassedTestSuites": 911,
"numFailedTestSuites": 0,
"numPendingTestSuites": 0,
"numTotalTests": 2245,
"numPassedTests": 2235,
"numFailedTests": 10,
"numPendingTests": 0,
"numTodoTests": 0,
@olayemii
olayemii / google_maps_polyline.dart
Created January 30, 2021 17:04
Adding polylines to Google Maps on flutter
import 'dart:async';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
@olayemii
olayemii / distance.dart
Last active June 8, 2023 23:18
A dart helper to calculate the distance between two geometric points
import 'dart:math';
double calculateDifference(double lat1, double lon1, double lat2, double lon2) {
double radius = 6371; // km
double changeInLat = toRad(lat2 - lat1);
double changeInLong = toRad(lon2 - lon1);
double lat1Rad = toRad(lat1);
double lat2Rad = toRad(lat2);
double formula = sin(changeInLat / 2) * sin(changeInLat / 2) +
@olayemii
olayemii / .eslintrc
Created May 23, 2020 02:10
EsLint Configuration for React
{
"env": {
"browser": true,
"es6": true
},
"extends": ["eslint:recommended", "react-app", "prettier"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
@olayemii
olayemii / useDebounce.js
Last active July 16, 2021 16:41
useDebounce - A hook to debounce a function
import { useEffect, useCallback } from "react";
let debounceTimeout;
const useDebounce = (delay = 1000) => {
const debounceRequest = useCallback(
debounceFunction => {
clearTimeout(debounceTimeout);
debounceTimeout = setTimeout(() => {
debounceFunction();
}, delay);
@olayemii
olayemii / code.js
Last active April 15, 2020 20:23
A simple helper function for getting deeply nested object property
const getObjectProperty = (obj, path, defaultValue="", returnUndefined=true) => {
const checkForDefaultValue = value =>
value !== undefined ? value : undefined;
if (path === undefined) {
return obj;
}
try {
const value = path.split('.').reduce((o, i) => o[i], obj);
if (value === undefined && returnUndefined) return value;