Skip to content

Instantly share code, notes, and snippets.

⚡️
JAMstack + a11y = 🔥

Bolaji Ayodeji BolajiAyodeji

⚡️
JAMstack + a11y = 🔥
Block or report user

Report or block BolajiAyodeji

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:5255bb1d2c81b7c63028b978a7a04768
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));
View netlify.html
<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>
View formspree.html
<form action="https://formspree.io/you@email.com" 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>
View greetings.js
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"
View todo.js
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 (
@BolajiAyodeji
BolajiAyodeji / regexCheatSheet.js
Created Apr 16, 2019
A Regular Expressions Cheat Sheet
View regexCheatSheet.js
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"
View wc-final-index.html
<!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>
View manifest.json
{
"name": "Weight Converter",
"short_name": "weight converter",
"icons": [
{
"src": "img/icons/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
View wc-final-app.js
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';
View sw.js
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(
You can’t perform that action at this time.