Skip to content

Instantly share code, notes, and snippets.

View ayoola-solomon's full-sized avatar
:octocat:
WIP 🚓

Solomon Ayoola ayoola-solomon

:octocat:
WIP 🚓
View GitHub Profile
@ayoola-solomon
ayoola-solomon / checkWebPSupport.js
Last active May 15, 2021 20:29
react hook to check webp support
// https://developers.google.com/speed/webp/faq#how_can_i_detect_browser_support_for_webp
// 'callback(feature, result)' will be passed back the detection result (in an asynchronous way!)
export const checkWebPSupport = callback => {
const kTestImages = {
lossy: 'UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA'
}
const img = new Image()
img.onload = () => {
const result = img.width > 0 && img.height > 0
{"lastUpload":"2019-05-03T15:32:31.178Z","extensionVersion":"v3.2.9"}
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export function withAppContext<
P extends { appContext?: AppContextInterface },
R = Omit<P, 'appContext'>
>(
Component: React.ComponentClass<P> | React.StatelessComponent<P>
): React.SFC<R> {
return function BoundComponent(props: R) {
return (
@ayoola-solomon
ayoola-solomon / braking.md
Last active August 13, 2018 19:45
Fahrschule
const monthlyRateColumn = ({ showDuration, monthlyRate, duration }) => ({
text: columnText('currency', monthlyRate),
subText: showDuration && (
<span>
{bankItemContent.rate.monthly}{' '}
<Text fontWeight={fontWeight.BOLD}>
{contentWithParams(bankItemContent.rate.duration, { duration })}
</Text>
</span>
),
@ayoola-solomon
ayoola-solomon / a.js
Created February 22, 2018 14:28
promise idea
export const fetchCache = (key) =>
new Promise(resolve => {
resolve(getCache(key)); // will return undefined is not available.
});
// in the action then you can do this
fetchCache(CLIENT_API.calculatedJson)
.then(data => {
if (data) {
return data;
import path from 'path';
import webpack from 'webpack';
import merge from 'lodash.merge';
const DEBUG = !process.argv.includes('--release');
const VERBOSE = process.argv.includes('--verbose');
const WATCH = global.WATCH === undefined ? false : global.WATCH;
const AUTOPREFIXER_BROWSERS = [
'Android 2.3',
'Android >= 4',
const array = [[1, 2, [3]] , 4];
const flatten = (array) => {
// reduce traverses the array and we return the result
return array.reduce((acc, b) => {
// if is an array we use recursion to perform the same operations over the array we found
// else we just concat the element to the accumulator
return acc.concat(Array.isArray(b) ? flatten(b) : b);
}, []); // we initialize the accumulator on an empty array to collect all the elements
}
@ayoola-solomon
ayoola-solomon / index.html
Created July 30, 2017 12:27
Date.prototype.strftime test with YUI created by Soulman - https://repl.it/Josn/12
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Date.prototype.strftime test with YUI</title>
</head>
<body class="yui-skin-sam">
<div id="yui-main">
<div id="testReport"></div>
@ayoola-solomon
ayoola-solomon / Smava SortUsers.js
Created June 27, 2017 17:21
Smava SortUsers created by Soulman - https://repl.it/JEGC/7
function usersComparator(userA, userB) {
if (userA.active !== userB.active) {
return userA.active - userB.active
}
if(userA.registrationDate !== userB.registrationDate) {
return userA.registrationDate - userB.registrationDate;
}
return userA.requestedAmount - userB.requestedAmount;