Skip to content

Instantly share code, notes, and snippets.

View stefany-newman's full-sized avatar

Stefany Newman stefany-newman

View GitHub Profile
<?php
// Task: Design a function that takes two array-parameters containing sorted lists and merges them into one array,
// in a way that results into a sorted array containing all elements of the original two lists.
$first_array = [1, 2];
$second_array = [4, 3, 11];
@stefany-newman
stefany-newman / today.js
Created October 20, 2017 14:50
Add class to a dd elements based on the day of the week
var now = new Date();
var all_days = [].slice.call(document.querySelectorAll('dd'));
var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
var today = days[ now.getDay() ];
all_days.forEach(function(node)
{
var text = node.dataset.open;
if(text != undefined)
{
if(node.dataset.open.indexOf(today) != -1){
@stefany-newman
stefany-newman / map.html
Created June 19, 2019 21:47
Embedding Google Maps with amp-iframe
<amp-iframe
width="1200"
height="500"
layout="intrinsic"
sandbox="allow-scripts allow-same-origin allow-popups"
src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d380559.8849917613!2d-88.01093622197548!3d41.82562576585843!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x880e2c3cd0f4cbed%3A0xafe0a6ad09c0c000!2sChicago%2C+IL!5e0!3m2!1sen!2sus!4v1560979429160!5m2!1sen!2sus" >
</amp-iframe>
@stefany-newman
stefany-newman / external_stylesheet.php
Created June 19, 2019 22:08
Use external stylesheets with AMP
<style amp-custom="">
<?php readfile(getcwd() ."/styles/css/styles.css"); ?>
</style>
@stefany-newman
stefany-newman / contact_process.php
Created June 21, 2019 22:05
AMP contact form validation and submission
<?php
/*
Function siteURL() courtesy of Chris McKee - https://gist.github.com/ChrisMcKee/1284052
Get sute URL with protocol (http or https)
*/
function siteURL()
{
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'
|| $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$domainName = $_SERVER['HTTP_HOST'];
<form
action-xhr="/scripts/contact_process.php"
verify-xhr="/scripts/contact_process.php"
method="post"
class="detailed_contact_form "
custom-validation-reporting="show-all-on-submit"
>
<fieldset class="user-valid valid">
<legend>
<span> Schedule an appointment</span>
@stefany-newman
stefany-newman / amp_print.html
Created June 25, 2019 18:33
AMP print button
<button on="tap:AMP.print()">Print Page</button>
@stefany-newman
stefany-newman / subscriber_process.php
Created June 26, 2019 15:54
Process subscription form submissions in AMP
<?php
/*
Function siteURL() courtesy of Chris McKee - https://gist.github.com/ChrisMcKee/1284052
Get sute URL with protocol (http or https)
*/
function siteURL()
{
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'
|| $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$domainName = $_SERVER['HTTP_HOST'];
<form
action-xhr="https://fabulousnewwebsite.com/scripts/subscriber_process.php"
verify-xhr="https://fabulousnewwebsite.com/scripts/subscriber_process.php"
method="post"
custom-validation-reporting="show-all-on-submit"
class="mb3"
>
<label class="center">
Email:
<input type="text"
@stefany-newman
stefany-newman / bookend.json
Created July 4, 2019 15:43
AMP story bookend
{
"bookendVersion": "v1.0",
"shareProviders": [
"facebook",
"twitter",
"email"
],
"components": [
{
"type": "heading",