Skip to content

Instantly share code, notes, and snippets.

View stephenasamoah's full-sized avatar

Stephen Asamoah stephenasamoah

View GitHub Profile
@stephenasamoah
stephenasamoah / index.html
Created March 7, 2017 15:37 — forked from sergejmueller/index.html
Embedded Google Analytics: Fix “Leverage Browser Caching” Warning on Nginx
<html>
<!-- ... -->
<!-- Embed analytics.js as local file -->
<script src="/analytics.js"></script>
</html>
@stephenasamoah
stephenasamoah / form-xhr.php
Created June 8, 2017 20:00
amp-form xhr submission
<?php
if (!empty($_POST)) {
header("access-control-allow-credentials:true");
header("access-control-allow-headers:Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token");
header("access-control-allow-methods:POST, GET, OPTIONS");
header("access-control-allow-origin:".$_SERVER['HTTP_ORIGIN']);
header("access-control-expose-headers:AMP-Access-Control-Allow-Source-Origin");
// I changed the protocol to HTTP since I was testing the site locally using BrowserSync, http://localhost:3000
<form method="post" action-xhr="/assets/scripts/form-xhr.php" target="_top" class="form__rsrv form__sidebar">
<h2 class="form__rsrv--hd">Book Now</h2>
<div class="grid">
<div class="form__rsrv--motor">
<!-- Date In -->
<div class="form__mod">
<label for="book__date--in-top" class="form__label--required book--label">Arrival Date</label>
<input type="date" value="2017-01-01" class="form--input book--text" id="book__date--in-top"
aria-required="true" required>
@stephenasamoah
stephenasamoah / amp-accordion-child-table-fix.html
Last active June 13, 2017 16:52
Fix for amp-accordion table child-element
// amp-accordion doesn't seem to play well with table elements. Table inside of accordion maxes out to only about 50-60% width.
// Creating a dummy <tr> with <td> equal to amount of rows in table seemed to fix it. The dummy <tr> needs to have "display:table"
// to be able to override ".i-amphtml-content" 's default value of "display: block!important".
// Of course, table will be adjusted to preferred percentage.
// To mask text values in <td>'s, color was set to <body> background-color to hide text and make it look empty
<!DOCTYPE html>
@stephenasamoah
stephenasamoah / critical-for-jekyll-site.js
Created July 6, 2017 06:27
Gulp critical css snippet
criticalOpts: {
base: paths.dest,
css: [paths.dest + 'css/styles.css'], // multiple stylesheets concatenated
minify: true,
}
// htmldir.in = '_site/**/*.html';
// gulp-concat combines all files from multiple pages into one
// nano purges redundant code and minifies.
@stephenasamoah
stephenasamoah / Auth.jsx
Created June 18, 2020 00:27 — forked from EduVencovsky/Auth.jsx
Private Routes with Auth using react-router and Context API
import React, { useState, useEffect } from 'react'
import PropTypes from 'prop-types'
import { checkIsAuthenticated, authSignUp, authLogin, authLogout } from '../../services/auth'
export const AuthContext = React.createContext({})
export default function Auth({ children }) {
const [isAuthenticated, setIsAuthenticated] = useState(false)
const [isLoading, setIsLoading] = useState(true)
@stephenasamoah
stephenasamoah / wsl-setup.md
Created June 18, 2020 00:59 — forked from imfing/wsl-setup.md
WSL + ZSH + Hyper Setup

My WSL Setup

A guide to setup your WSL with Hyper and zsh

Download & Install the WSL

  • Follow the very thorough instructions here

Get a prettier terminal

  • Download Hyper.js here - I went with the 'hyperblue' theme.

Haskell, Stack and Intellij IDEA IDE setup tutorial how to get started

Upon completion you will have a sane, productive Haskell environment adhering to best practices.

Basics

  • Haskell is a programming language.
  • Stack is tool for Haskell projects. (similar tools for other languages include Maven, Gradle, npm, RubyGems etc)
  • Intellij IDEA IDE is a popular IDE.

Install required libraries

sudo apt-get install libtinfo-dev libghc-zlib-dev libghc-zlib-bindings-dev

@stephenasamoah
stephenasamoah / string-utils.js
Created April 5, 2021 12:37 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();