Skip to content

Instantly share code, notes, and snippets.

View BolajiAyodeji's full-sized avatar
🥑
Working from home

Bolaji Ayodeji BolajiAyodeji

🥑
Working from home
View GitHub Profile
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.0.0/workbox-sw.js");
if (workbox) {
console.log("Yay! Workbox is loaded !");
workbox.precaching.precacheAndRoute([]);
/* cache images in the e.g others folder; edit to other folders you got
and config in the sw-config.js file
*/
workbox.routing.registerRoute(
const input = document.getElementById('lbsInput');
const output = document.getElementById('output');
output.style.visibility = 'hidden';
input.addEventListener('input', (e) => {
let lbs = e.target.value;
output.style.visibility = 'visible';
{
"name": "Weight Converter",
"short_name": "weight converter",
"icons": [
{
"src": "img/icons/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="description" content="Simple weight converter">
<title>Weight Converter</title>
@BolajiAyodeji
BolajiAyodeji / regexCheatSheet.js
Created April 16, 2019 19:40
A Regular Expressions Cheat Sheet
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
class TodoApp extends React.Component {
constructor(props) {
super(props);
this.state = { items: [], text: '' };
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
render() {
return (
import React from "react"
import ReactDOM from "react-dom"
function App() {
const date = new Date()
const hours = date.getHours()
let timeOfDay
if (hours < 12) {
timeOfDay = "morning"
<form action="https://formspree.io/[email protected]" method="POST">
<input type="hidden" name="_subject" value="Bolaji's Form">
<input type="hidden" name="_next" value="/thanks.html" >
<div class="form-group">
<label>Name:</label>
<input type="text" class="form-control" id="name" placeholder="Name">
<div class="invalid-feedback">
Name must be between 2 and 20 characters
</div>
</div>
<form action="/thanks.html" name="Bolaji's form" method="POST" data-netlify="true">
<div class="form-group">
<label>Name:</label>
<input type="text" class="form-control" id="name" placeholder="Name">
<div class="invalid-feedback">
Name must be between 2 and 20 characters
</div>
</div>
<div class="form-group">
<label>Email:</label>
const urlSlug = (postTitle) => {
let postUrl = postTitle.toLowerCase().split(' ');
let postSlug = postUrl.join('-');
return postSlug;
}
let postTitle = 'Handling Static Forms, The Client-side Way'
console.log(urlSlug(postTitle));