Skip to content

Instantly share code, notes, and snippets.

View trotzig's full-sized avatar

Henric Trotzig trotzig

View GitHub Profile
@trotzig
trotzig / happo-logo.html
Created April 9, 2024 13:02
Re-implementing the happo.io logo in HTML (with email-client safe properties)
<div
style="
width: 42px;
height: 42px;
box-sizing: border-box;
border-radius: 50%;
overflow: hidden;
background-color: white;
padding: 6px 0 5px 0;
"
@trotzig
trotzig / happo-ci-jenkins.sh
Created August 15, 2019 22:01
An example of a Happo CI script for Jenkins
#!/bin/bash
# Make the whole script fail on errors
set -euo pipefail
PREVIOUS_SHA=$(git merge-base origin/master "${CIRCLE_SHA1}")
export PREVIOUS_SHA
export CURRENT_SHA="$(git rev-parse ${1-HEAD})"
export CHANGE_URL="$GERRIT_CHANGE_URL"

Install happo and plugin:

yarn add --dev happo.io happo-plugin-storybook

.happo.js config

const { RemoteBrowserTarget } = require('happo.io');
const happoPluginStorybook = require('happo-plugin-storybook');
@trotzig
trotzig / Instructions-for-beta-testing-happo-plugin-storybook.md
Last active January 21, 2019 19:58
Instructions for using happo-plugin-storybook

First, install the latest happo packages:

yarn add --dev happo-plugin-storybook@latest happo.io@latest

Add the plugin to .happo.js:

const happoPluginStorybook = require('happo-plugin-storybook');
@trotzig
trotzig / .happo.js
Created January 8, 2019 10:20
Example of using happo-plugin-scrape with a wrapper element
const path = require('path');
const { RemoteBrowserTarget } = require('happo.io');
const happoScrapePlugin = require('happo-plugin-scrape');
function commonWrapper(html) {
return `
<div class="application-wrapper">
<div style="width:100%" class="od-homepage">${html}</div>
</div>
`;
const AWS = require('aws-sdk');
const {
S3_REGION: region,
S3_BUCKET_NAME: Bucket,
S3_ACCESS_KEY_ID: accessKeyId,
S3_SECRET_ACCESS_KEY: secretAccessKey,
} = process.env;
AWS.config.update({
region,
<html>
<style>
* {
box-sizing: border-box;
}
.nitem {
#!/bin/bash
browser=$1
if [ -z "$browser" ]; then
echo "Usage: ./deploy.sh <browser>"
exit 1
fi
set -euo pipefail
# Copy the right files
const octokit = require('@octokit/rest');
const jsonwebtoken = require('jsonwebtoken');
const PEM = `-----BEGIN RSA PRIVATE KEY-----
<REDACTED>
-----END RSA PRIVATE KEY-----`;
function generateJwtToken() {
// Sign with RSA SHA256
return jsonwebtoken.sign(
@trotzig
trotzig / makeRequest.js
Created January 26, 2018 12:52
JWT creation for happo.io
import request from 'request-promise-native';
import jwt from 'jsonwebtoken';
export default function makeRequest(requestAttributes, { apiKey, apiSecret }) {
const signed = jwt.sign({ key: apiKey }, apiSecret, { header: { kid: apiKey } });
return request(
Object.assign({
auth: {
bearer: signed,
},