Skip to content

Instantly share code, notes, and snippets.

@sebastianbenz
sebastianbenz / sample.html
Created June 7, 2019 10:13
AMP Sample Template
<!---
- author: your-github-user-name
- formats
- websites
- ads
- email
- stories
--->
<!--
@sebastianbenz
sebastianbenz / FetchAmpComponents.js
Created August 30, 2018 15:13
Fetches a list of AMP components.
const fetch = require('node-fetch');
const REGEX_EXTENSION_DIR = /extensions\/(amp-[^\/]+)$/;
const GITHUB_AMPHTML_TREE_URL = 'https://api.github.com/repos/ampproject/amphtml/git/trees/master?recursive=1';
const fetchComponentList = async () => {
const response = await fetch(GITHUB_AMPHTML_TREE_URL);
const data = await response.json();
return data.tree.map((item) => item.path.match(REGEX_EXTENSION_DIR))
.filter((match) => match && !match[1].endsWith('impl'))
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"></script>
<link rel="canonical" href="https://ampbyexample.com/components/amp-sidebar/">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</
<!doctype html>
<html amp lang="en">
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<title>Hello, AMPs</title>
<link rel="canonical" href="http://example.ampproject.org/article-metadata.html" />
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"></script>
<!--
#### Introduction
AMP HTML files don't support the normal HTML `img` tag. With `amp-img` AMP
provides a powerful replacement.
-->
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
@sebastianbenz
sebastianbenz / gcm-high-prio.sh
Last active August 4, 2021 15:29
Send high priority GCM messages via curl (Android Doze mode & App Standby testing)
curl -X POST \
-H "Authorization: key= YOUR-API-KEY" \
-H "Content-Type: application/json" \
-d '{
"registration_ids": [
"YOUR-GCM-REGISTRATION-ID"
],
"data": {
"message": "Hello Message"
},
@sebastianbenz
sebastianbenz / Traditional.java
Last active August 29, 2015 13:57
Advanced static typing
TicTacToe ticTacToe = new TicTacToe();
ticTacToe.move(position);
if(!ticTacToe.isFinished()){
waitForNextMove(ticTacToe);
}else{
handleGameResult(ticTacToe);
}
@sebastianbenz
sebastianbenz / polymorphism.rb
Last active August 29, 2015 13:57
Programming without conditional statements.
class DeadCell
def to_s
' '
end
end
class AliveCell
@sebastianbenz
sebastianbenz / Demo.spec
Created January 13, 2014 21:31
Defining helper classes in your specs.
describe "Saying Hello"{
fact new Greeter("Sebastian").sayHello => "Hello Sebastian"
}
@Data class Greeter{
String name
def sayHello(){
"Hello " + name
}
}
package matchers
describe "Matchers"{
val personOfAgeFour = new Person("A", 4)
val personOfAgeFive = new Person("B", 5)
context "Hamcrest"{
fact "Example:"{